Exemplo n.º 1
0
def read_table(table, filename):
    with open(filename) as table_file:
        for record in parse_padded_table(table_file):
            key = (record["Name"], record["Sample"], record["Library"],
                   record["Contig"])
            if "*" in key:
                continue

            subtable = get_in(table, key, {"Size": int(record["Size"])})
            assert int(subtable["Size"]) == int(record["Size"])

            for field in ("Hits", "SE", "PE_1", "PE_2", "Collapsed", "M", "I",
                          "D"):
                subtable[field] = subtable.get(field, 0) + int(
                    record.get(field, 0))
            set_in(table, key, subtable)
Exemplo n.º 2
0
def _read_max_depths(filename, prefix, sample):
    if filename in _DEPTHS_CACHE:
        return _DEPTHS_CACHE[filename]

    max_depth = None
    try:
        with open(filename) as handle:
            for row in parse_padded_table(handle):
                if row["Name"] == sample and row["Sample"] == "*" and row["Library"] == "*" and row["Contig"] == "*":
                    max_depth = row["MaxDepth"]
                    break
            else:
                raise MakefileError("Could not find MaxDepth in " "depth-histogram: %r" % (filename,))

    except (OSError, IOError), error:
        raise MakefileError("Error reading depth-histogram (%s): %s" % (filename, error))
Exemplo n.º 3
0
def read_table(table, filename):
    with open(filename) as table_file:
        for record in parse_padded_table(table_file):
            key = (record["Name"], record["Sample"], record["Library"], record["Contig"])
            if "*" in key:
                continue

            subtable = get_in(table, key)
            if subtable is None:
                subtable = dict(READGROUP_TEMPLATE)
                subtable["Size"] = int(record["Size"])
                set_in(table, key, subtable)

            assert int(subtable["Size"]) == int(record["Size"])
            for key in READGROUP_TEMPLATE:
                if key != "Size":
                    subtable[key] += int(record.get(key, 0))
Exemplo n.º 4
0
def read_table(table, filename):
    with open(filename) as table_file:
        for record in parse_padded_table(table_file):
            key = (record["Name"], record["Sample"], record["Library"],
                   record["Contig"])
            if "*" in key:
                continue

            subtable = get_in(table, key)
            if subtable is None:
                subtable = dict(READGROUP_TEMPLATE)
                subtable["Size"] = int(record["Size"])
                set_in(table, key, subtable)

            assert int(subtable["Size"]) == int(record["Size"])
            for key in READGROUP_TEMPLATE:
                if key != "Size":
                    subtable[key] += int(record.get(key, 0))
Exemplo n.º 5
0
def _read_max_depths(filename, prefix, sample):
    if filename in _DEPTHS_CACHE:
        return _DEPTHS_CACHE[filename]

    max_depth = None
    try:
        with open(filename) as handle:
            for row in parse_padded_table(handle):
                if row["Name"] == sample and \
                        row["Sample"] == "*" and \
                        row["Library"] == "*" and \
                        row["Contig"] == "*":
                    max_depth = row["MaxDepth"]
                    break
            else:
                raise MakefileError("Could not find MaxDepth in "
                                    "depth-histogram: %r" % (filename, ))

    except (OSError, IOError), error:
        raise MakefileError("Error reading depth-histogram (%s): %s" %
                            (filename, error))
Exemplo n.º 6
0
def _parse_padded_table(*args, **kwargs):
    return list(parse_padded_table(*args, **kwargs))
Exemplo n.º 7
0
def _parse_padded_table(*args, **kwargs):
    return list(parse_padded_table(*args, **kwargs))