Skip to content

Commit bb8342f

Browse files
committed
fix gene-barcode pairs counting
1 parent 23fdceb commit bb8342f

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

src/barcode_calling/umi_filtering.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ def add_stats_for_read(self, read_infos):
360360
if unique and spliced:
361361
self.stats["Uniquely assigned and spliced and barcoded"] += 1
362362

363-
if assigned and barcoded:
364-
self.unique_gene_barcode.add((read_infos[0].gene_id, read_infos[0].barcode))
365-
366363
def process(self, assignment_file, output_prefix, transcript_type_dict):
367364
outf = open(output_prefix + ".reads_ids.tsv", "w")
368365
allinfo_outf = open(output_prefix + ".allinfo", "w")
@@ -462,7 +459,6 @@ def process(self, assignment_file, output_prefix, transcript_type_dict):
462459
for k in sorted(self.stats.keys()):
463460
count_hist_file.write("%s\t%d\n" % (k, self.stats[k]))
464461

465-
466462
@staticmethod
467463
def load_barcodes_simple(barcode_file):
468464
barcode_dict = {}
@@ -620,39 +616,6 @@ def process_from_raw_assignments(self, saves_prefix, chr_ids, args, output_prefi
620616

621617
return allinfo_outf, stats_output
622618

623-
def count_stats(self, assignment_file, output_prefix):
624-
read_info_storage = defaultdict(list)
625-
626-
self.unique_gene_barcode = set()
627-
for l in open(assignment_file):
628-
if l.startswith("#"): continue
629-
v = l.strip().split("\t")
630-
read_id = v[0]
631-
gene_id = v[4]
632-
assignment_type = v[5]
633-
exon_blocks_str = v[7]
634-
exon_blocks = list(map(lambda x: tuple(map(int, x.split('-'))), exon_blocks_str.split(',')))
635-
if read_id in self.barcode_dict:
636-
barcode, umi = self.barcode_dict[read_id]
637-
else:
638-
barcode, umi = None, None
639-
matching_events = v[6]
640-
read_info_storage[read_id].append(ShortReadAssignmentInfo(gene_id, exon_blocks, assignment_type,
641-
matching_events, barcode))
642-
643-
self.count_stats_for_storage(read_info_storage)
644-
logger.info("Unique gene-barcodes pairs %d" % len(self.unique_gene_barcode))
645-
for k in sorted(self.stats.keys()):
646-
logger.info("%s: %d" % (k, self.stats[k]))
647-
648-
stats_output = output_prefix + ".stats.tsv"
649-
logger.info("Stats are written to written to %s" % stats_output)
650-
with open(stats_output, "w") as count_hist_file:
651-
count_hist_file.write("Unique gene-barcodes pairs %d\n" % len(self.unique_gene_barcode))
652-
653-
for k in sorted(self.stats.keys()):
654-
count_hist_file.write("%s\t%d\n" % (k, self.stats[k]))
655-
656619

657620
def filter_bam(in_file_name, out_file_name, read_set):
658621
inf = pysam.AlignmentFile(in_file_name, "rb")

0 commit comments

Comments
 (0)