Provide flattened lane information with multiplexed barcodes separated.
490463
def _flatten_lane_details(runinfo):
    
    out = []
    for ldetail in runinfo["details"]:
        # handle controls
        if "project_name" not in ldetail and ldetail["description"] == "control":
            ldetail["project_name"] = "control"
        for i, barcode in enumerate(ldetail.get("multiplex", [{}])):
            cur = copy.deepcopy(ldetail)
            cur["name"] = "%s-%s" % (ldetail["name"], i + 1)
            cur["description"] = barcode.get("name", ldetail["description"])
            cur["bc_index"] = barcode.get("sequence", "")
            cur["project_name"] = clean_name(ldetail["project_name"])
            out.append(cur)
    return out
592195
def queue_ramp_dicts(ramp_dict_list, server_ip_and_port):
    """"""
    client = server.ClientForServer(server.BECServer, server_ip_and_port)
    for dct in ramp_dict_list:
        client.queue_ramp(dct)
    client.start({})
335163
def header(parent, identifier, datestamp, sets=None, deleted=False):
    """"""
    e_header = SubElement(parent, etree.QName(NS_OAIPMH, 'header'))
    if deleted:
        e_header.set('status', 'deleted')
    e_identifier = SubElement(e_header, etree.QName(NS_OAIPMH, 'identifier'))
    e_identifier.text = identifier
    e_datestamp = SubElement(e_header, etree.QName(NS_OAIPMH, 'datestamp'))
    e_datestamp.text = datetime_to_datestamp(datestamp)
    for spec in sets or []:
        e = SubElement(e_header, etree.QName(NS_OAIPMH, 'setSpec'))
        e.text = spec
    return e_header
51575
public static void writeRoutingLabel(byte[] destination, int si, int ssi, int sls, int dpc, int opc) {
        // see Q.704.14.2
        destination[0] = (byte) (((ssi & 0x0F) << 4) | (si & 0x0F));
        destination[1] = (byte) dpc;
        destination[2] = (byte) (((dpc >> 8) & 0x3F) | ((opc & 0x03) << 6));
        destination[3] = (byte) (opc >> 2);
        destination[4] = (byte) (((opc >> 10) & 0x0F) | ((sls & 0x0F) << 4));
        // sif[4] = (byte) (((opc>> 10) & 0x0F) | ((0 & 0x0F) << 4));
    }
793067
def split_path_info(self, path_info: str) -> Tuple[str, str]:
        
        return path_info[:self.matchlength], path_info[self.matchlength:]
1355848
def normalize(self, address, **kwargs):
        """"""
        # TODO: normalize well-known parts like "Street", "Road", etc.
        # TODO: consider using https://github.com/openvenues/pypostal
        addresses = super(AddressType, self).normalize(address, **kwargs)
        return addresses
795907
def _set_transmaps(self):
        """"""
        if self._std == 'ascii':
            self._lower_chars = string.ascii_lowercase
            self._upper_chars = string.ascii_uppercase

        elif self._std == 'rfc1459':
            self._lower_chars = (string.ascii_lowercase +
                                 ''.join(chr(i) for i in range(123, 127)))
            self._upper_chars = (string.ascii_uppercase +
                                 ''.join(chr(i) for i in range(91, 95)))

        elif self._std == 'rfc1459-strict':
            self._lower_chars = (string.ascii_lowercase +
                                 ''.join(chr(i) for i in range(123, 126)))
            self._upper_chars = (string.ascii_uppercase +
                                 ''.join(chr(i) for i in range(91, 94)))
1040430
def demultiplex_samples(fastq, out_dir, nedit, barcodes):
    ''' 
    '''
    annotations = detect_fastq_annotations(fastq)
    re_string = construct_transformed_regex(annotations)
    parser_re = re.compile(re_string)

    if barcodes:
        barcodes = set(barcode.strip() for barcode in barcodes)
    else:
        barcodes = set()

    if nedit == 0:
        filter_bc = partial(exact_sample_filter, barcodes=barcodes)
    else:
        barcodehash = MutationHash(barcodes, nedit)
        filter_bc = partial(correcting_sample_filter, barcodehash=barcodehash)

    sample_set = set()
    batch = collections.defaultdict(list)
    parsed = 0
    safe_makedir(out_dir)
    for read in read_fastq(fastq):
        parsed += 1
        read = filter_bc(read)
        if not read:
            continue
        match = parser_re.search(read).groupdict()
        sample = match['SB']
        sample_set.add(sample)
        batch[sample].append(read)
        # write in batches to avoid opening up file handles repeatedly
        if not parsed % 10000000:
            for sample, reads in batch.items():
                out_file = os.path.join(out_dir, sample + ".fq")
                with open(out_file, "a") as out_handle:
                    for read in reads:
                        fixed = filter_bc(read)
                        if fixed:
                            out_handle.write(fixed)
            batch = collections.defaultdict(list)

    for sample, reads in batch.items():
        out_file = os.path.join(out_dir, sample + ".fq")
        with open(out_file, "a") as out_handle:
            for read in reads:
                fixed = filter_bc(read)
                if fixed:
                    out_handle.write(read)
441729
def detour_info(self):
        
        resource_list = self.traffic_incident()
        detour_info = namedtuple('detour_info', 'detour_info')
        if len(resource_list) == 1 and resource_list[0] is None:
            return None
        else:
            try:
                return [detour_info(resource['detour'])
                        for resource in resource_list]
            except (KeyError, TypeError):
                try:
                    return [detour_info(resource['detourInfo'])
                            for resource in resource_list]
                except KeyError:
                    return None
990368
def split_addrs(addrs):
    '''
    '''
    splitted = {}
    for addr in addrs:
        host, port, _ = _addr_key(addr)
        if host not in splitted:
            splitted[host] = {}
        if port not in splitted[host]:
            splitted[host][port] = []
        splitted[host][port].append(addr)
    return splitted
85218
def _get_dstk_intersections(self, address, dstk_address):
        
        # Normalize both addresses
        normalized_address = self._normalize(address)
        normalized_dstk_address = self._normalize(dstk_address)
        address_uniques = set(normalized_address) - set(normalized_dstk_address)
        dstk_address_uniques = set(normalized_dstk_address) - set(normalized_address)
        if self.logger: self.logger.debug("Address Uniques {0}".format(address_uniques))
        if self.logger: self.logger.debug("DSTK Address Uniques {0}".format(dstk_address_uniques))
        return (len(address_uniques), len(dstk_address_uniques))
1288664
void handleBikeRelated(IntsRef edgeFlags, ReaderWay way, boolean partOfCycleRelation) {
        String surfaceTag = way.getTag("surface");
        String highway = way.getTag("highway");
        String trackType = way.getTag("tracktype");

        // Populate unpavedBit
        if ("track".equals(highway) && (trackType == null || !"grade1".equals(trackType))
                || "path".equals(highway) && surfaceTag == null
                || unpavedSurfaceTags.contains(surfaceTag)) {
            unpavedEncoder.setBool(false, edgeFlags, true);
        }

        WayType wayType;
        if (roadValues.contains(highway))
            wayType = WayType.ROAD;
        else
            wayType = WayType.OTHER_SMALL_WAY;

        boolean isPushingSection = isPushingSection(way);
        if (isPushingSection && !partOfCycleRelation || "steps".equals(highway))
            wayType = WayType.PUSHING_SECTION;

        if (way.hasTag("bicycle", intendedValues)) {
            if (isPushingSection && !way.hasTag("bicycle", "designated"))
                wayType = WayType.OTHER_SMALL_WAY;
            else if (wayType == WayType.OTHER_SMALL_WAY || wayType == WayType.PUSHING_SECTION)
                wayType = WayType.CYCLEWAY;
        } else if ("cycleway".equals(highway))
            wayType = WayType.CYCLEWAY;

        wayTypeEncoder.setInt(false, edgeFlags, wayType.getValue());
    }
403329
def make_data():
    """"""
    I,d = multidict({1:80, 2:270, 3:250, 4:160, 5:180})            # demand
    J,M,f = multidict({1:[500,1000], 2:[500,1000], 3:[500,1000]}) # capacity, fixed costs
    c = {(1,1):4,  (1,2):6,  (1,3):9,    # transportation costs
         (2,1):5,  (2,2):4,  (2,3):7,
         (3,1):6,  (3,2):3,  (3,3):4,
         (4,1):8,  (4,2):5,  (4,3):3,
         (5,1):10, (5,2):8,  (5,3):4,
         }
    return I,J,d,M,f,c
893734
def add_lane(lane, override = false)
      lanes[lane.platform] ||= {}

      if !override && lanes[lane.platform][lane.name]
        UI.user_error!("Lane '#{lane.name}' was defined multiple times!")
      end

      lanes[lane.platform][lane.name] = lane
    end
1197363
private Shape decodeMarkBorder(int width, int height) {
        int left = (width - 3) / 2 - 5;
        int top  = (height - 2) / 2 - 5;

        path.reset();
        path.moveTo(left + 1, top + 0);
        path.lineTo(left + 3, top + 0);
        path.pointAt(left + 4, top + 1);
        path.pointAt(left + 5, top + 2);
        path.pointAt(left + 6, top + 1);
        path.moveTo(left + 7, top + 0);
        path.lineTo(left + 9, top + 0);
        path.pointAt(left + 10, top + 1);
        path.pointAt(left + 9, top + 2);
        path.pointAt(left + 8, top + 3);
        path.moveTo(left + 7, top + 4);
        path.lineTo(left + 7, top + 5);
        path.pointAt(left + 8, top + 6);
        path.pointAt(left + 9, top + 7);
        path.pointAt(left + 10, top + 8);
        path.moveTo(left + 9, top + 9);
        path.lineTo(left + 7, top + 9);
        path.pointAt(left + 6, top + 8);
        path.pointAt(left + 5, top + 7);
        path.pointAt(left + 4, top + 8);
        path.moveTo(left + 3, top + 9);
        path.lineTo(left + 1, top + 9);
        path.pointAt(left + 0, top + 8);
        path.pointAt(left + 1, top + 7);
        path.pointAt(left + 2, top + 6);
        path.moveTo(left + 3, top + 5);
        path.lineTo(left + 3, top + 4);
        path.pointAt(left + 2, top + 3);
        path.pointAt(left + 1, top + 2);
        path.pointAt(left + 0, top + 1);

        return path;
    }
1251803
def append_lane(lane)
      lane.compact! # remove nil values

      new_lines = "\n\n"
      if self.is_swift_fastfile
        new_lines = "" unless self.fastfile_content.include?("lane() {") # the first lane we don't want new lines
        self.fastfile_content.gsub!("[[LANES]]", "#{new_lines}\t#{lane.join("\n\t")}[[LANES]]")
      else
        new_lines = "" unless self.fastfile_content.include?("lane :") # the first lane we don't want new lines
        self.fastfile_content.gsub!("[[LANES]]", "#{new_lines}  #{lane.join("\n  ")}[[LANES]]")
      end
    end
321247
def get_optics(self):
        """"""
        optics_table = junos_views.junos_intf_optics_table(self.device)
        optics_table.get()
        optics_items = optics_table.items()

        # optics_items has no lane information, so we need to re-format data
        # inserting lane 0 for all optics. Note it contains all optics 10G/40G/100G
        # but the information for 40G/100G is incorrect at this point
        # Example: intf_optic item is now: ('xe-0/0/0', [ optical_values ])
        optics_items_with_lane = []
        for intf_optic_item in optics_items:
            temp_list = list(intf_optic_item)
            temp_list.insert(1, "0")
            new_intf_optic_item = tuple(temp_list)
            optics_items_with_lane.append(new_intf_optic_item)

        # Now optics_items_with_lane has all optics with lane 0 included
        # Example: ('xe-0/0/0', u'0', [ optical_values ])

        # Get optical information for 40G/100G optics
        optics_table40G = junos_views.junos_intf_40Goptics_table(self.device)
        optics_table40G.get()
        optics_40Gitems = optics_table40G.items()

        # Re-format data as before inserting lane value
        new_optics_40Gitems = []
        for item in optics_40Gitems:
            lane = item[0]
            iface = item[1].pop(0)
            new_optics_40Gitems.append((iface[1], py23_compat.text_type(lane), item[1]))

        # New_optics_40Gitems contains 40G/100G optics only:
        # ('et-0/0/49', u'0', [ optical_values ]),
        # ('et-0/0/49', u'1', [ optical_values ]),
        # ('et-0/0/49', u'2', [ optical_values ])

        # Remove 40G/100G optics entries with wrong information returned
        # from junos_intf_optics_table()
        iface_40G = [item[0] for item in new_optics_40Gitems]
        for intf_optic_item in optics_items_with_lane:
            iface_name = intf_optic_item[0]
            if iface_name not in iface_40G:
                new_optics_40Gitems.append(intf_optic_item)

        # New_optics_40Gitems contains all optics 10G/40G/100G with the lane
        optics_detail = {}
        for intf_optic_item in new_optics_40Gitems:
            lane = intf_optic_item[1]
            interface_name = py23_compat.text_type(intf_optic_item[0])
            optics = dict(intf_optic_item[2])
            if interface_name not in optics_detail:
                optics_detail[interface_name] = {}
                optics_detail[interface_name]["physical_channels"] = {}
                optics_detail[interface_name]["physical_channels"]["channel"] = []

            INVALID_LIGHT_LEVEL = [None, C.OPTICS_NULL_LEVEL, C.OPTICS_NULL_LEVEL_SPC]

            # Defaulting avg, min, max values to 0.0 since device does not
            # return these values
            intf_optics = {
                "index": int(lane),
                "state": {
                    "input_power": {
                        "instant": (
                            float(optics["input_power"])
                            if optics["input_power"] not in INVALID_LIGHT_LEVEL
                            else 0.0
                        ),
                        "avg": 0.0,
                        "max": 0.0,
                        "min": 0.0,
                    },
                    "output_power": {
                        "instant": (
                            float(optics["output_power"])
                            if optics["output_power"] not in INVALID_LIGHT_LEVEL
                            else 0.0
                        ),
                        "avg": 0.0,
                        "max": 0.0,
                        "min": 0.0,
                    },
                    "laser_bias_current": {
                        "instant": (
                            float(optics["laser_bias_current"])
                            if optics["laser_bias_current"] not in INVALID_LIGHT_LEVEL
                            else 0.0
                        ),
                        "avg": 0.0,
                        "max": 0.0,
                        "min": 0.0,
                    },
                },
            }
            optics_detail[interface_name]["physical_channels"]["channel"].append(
                intf_optics
            )

        return optics_detail