Example #1
0
def build_key_struct(args, handle):
    structure = collections.defaultdict(set)
    for readgroup in collect_readgroups(args, handle).itervalues():
        lb_key = readgroup["LB"]
        sm_key = readgroup["SM"]
        structure[sm_key].add(lb_key)

    return structure
Example #2
0
def build_key_struct(args, handle):
    structure = collections.defaultdict(set)
    for readgroup in collect_readgroups(args, handle).itervalues():
        lb_key = readgroup["LB"]
        sm_key = readgroup["SM"]
        structure[sm_key].add(lb_key)

    return structure
Example #3
0
def build_table(args, handle, counts):
    table = {}
    for (key, readgroup) in collect_readgroups(args, handle).iteritems():
        sample = readgroup["SM"]
        library = readgroup["LB"]

        for (reference, size) in collect_references(args, handle).iteritems():
            subtable_key = (args.target_name, sample, library, reference)
            subtable = create_or_get_subtable(table, subtable_key, size)

            statistics = counts.get(reference, {}).get(key, {})
            for (stat, value) in statistics.iteritems():
                subtable[stat] += value

    return table
Example #4
0
def build_table(args, handle, counts):
    table = {}
    for (key, readgroup) in collect_readgroups(args, handle).iteritems():
        sample = readgroup["SM"]
        library = readgroup["LB"]

        for (reference, size) in collect_references(args, handle).iteritems():
            subtable_key = (args.target_name, sample, library, reference)
            subtable = create_or_get_subtable(table, subtable_key, size)

            statistics = counts.get(reference, {}).get(key, {})
            for (stat, value) in statistics.iteritems():
                subtable[stat] += value

    return table
Example #5
0
def build_rg_to_smlbid_keys(args, handle):
    """Returns a dictionary which maps a readgroup ID to an index value,
    as well as a list containing a tuple (samples, library) corresponding
    to each index. Typically, this list will be shorter than the map of read-
    groups, as multiple read-groups will map to the same sample / library.
    """

    rg_to_lbsmid = {}
    lbsm_to_lbsmid = {}
    lbsmid_to_smlb = []
    for (key_rg, readgroup) in collect_readgroups(args, handle).iteritems():
        key_sm = readgroup["SM"]
        key_lb = readgroup["LB"]

        key_lbsm = (key_sm, key_lb)
        if key_lbsm not in lbsm_to_lbsmid:
            lbsm_to_lbsmid[key_lbsm] = len(lbsm_to_lbsmid)
            lbsmid_to_smlb.append(key_lbsm)

        rg_to_lbsmid[key_rg] = lbsm_to_lbsmid[key_lbsm]
    return rg_to_lbsmid, lbsmid_to_smlb
Example #6
0
def build_rg_to_smlbid_keys(args, handle):
    """Returns a dictionary which maps a readgroup ID to an index value,
    as well as a list containing a tuple (samples, library) corresponding
    to each index. Typically, this list will be shorter than the map of read-
    groups, as multiple read-groups will map to the same sample / library.
    """

    rg_to_lbsmid = {}
    lbsm_to_lbsmid = {}
    lbsmid_to_smlb = []
    for (key_rg, readgroup) in collect_readgroups(args, handle).iteritems():
        key_sm = readgroup["SM"]
        key_lb = readgroup["LB"]

        key_lbsm = (key_sm, key_lb)
        if key_lbsm not in lbsm_to_lbsmid:
            lbsm_to_lbsmid[key_lbsm] = len(lbsm_to_lbsmid)
            lbsmid_to_smlb.append(key_lbsm)

        rg_to_lbsmid[key_rg] = lbsm_to_lbsmid[key_lbsm]
    return rg_to_lbsmid, lbsmid_to_smlb
Example #7
0
def build_region_template(args, handle):
    template = {}
    for key in collect_readgroups(args, handle):
        template[key] = dict(READGROUP_TEMPLATE)
    return template
Example #8
0
def build_region_template(args, handle):
    template = {}
    for key in collect_readgroups(args, handle):
        template[key] = dict(READGROUP_TEMPLATE)
    return template