Exemple #1
0
def write_summary(umi_well, out_file):
    """write summary about edit distance among same read position"""
    with file_transaction(out_file) as tx_out_file:
        with gzip.open(tx_out_file, 'wb') as out_handle:
            for read in umi_well:
                umi_list = Counter(umi_well[read].umi)
                ma = calculate_matrix_distance(umi_list.keys())
                for pair in ma:
                    max_umi, min_umi = pair[1], pair[0]
                    if umi_list[pair[0]] > umi_list[pair[1]]:
                        max_umi, min_umi = pair[0], pair[1]
                    out_handle.write("%s\n" % (" ".join(map(str, [read[0], read[1],
                                               umi_list[max_umi], umi_list[min_umi],
                                               ma[pair]]))))
Exemple #2
0
def write_extensive_summary(well_umi_gen, out_file):
    with file_transaction(out_file) as tx_out_file:
        with gzip.open(tx_out_file, 'wb') as out_handle:
            well_umi_gen_str = [[("\t%s\t%s\t" % (gen_well[0], gen_well[1])).join(map(str, umi)) for umi in well_umi_gen[gen_well].items()] for gen_well in well_umi_gen]
            out_handle.write("\n".join(["\n".join(item) for item in well_umi_gen_str]))
            out_handle.write("\n")