Skip to content

Commit

Permalink
do not forget some of the unassigned reads
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewprzh committed May 7, 2024
1 parent 16b164b commit 877c35f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/graph_based_model_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def process(self, read_assignment_storage):
self.forward_counts()

# FIXME: remove asserts below
if self.transcript_model_storage and len(set([x.read_id for x in read_assignment_storage])) != len(self.read_assignment_counts):
if len(set([x.read_id for x in read_assignment_storage])) != len(self.read_assignment_counts):
logger.warning("Some reads were not assigned %d %d" % (len(set([x.read_id for x in read_assignment_storage])), len(self.read_assignment_counts)))
# FIXME: remove asserts below
if any(value < 0 for value in self.read_assignment_counts.values()):
Expand Down Expand Up @@ -706,6 +706,9 @@ def transcript_from_reference(self, isoform_id):
# assign reads back to constructed isoforms
def assign_reads_to_models(self, read_assignments):
if not self.transcript_model_storage:
for assignment in read_assignments:
read_id = assignment.read_id
self.read_assignment_counts[read_id] = 0
logger.debug("No transcripts were assigned")
return

Expand All @@ -721,7 +724,7 @@ def assign_reads_to_models(self, read_assignments):
continue

read_exons = assignment.corrected_exons
#logger.debug("# Checking read %s: %s" % (assignment.read_id, str(read_exons)))
# logger.debug("# Checking read %s: %s" % (assignment.read_id, str(read_exons)))
model_combined_profile = profile_constructor.construct_profiles(read_exons, assignment.polya_info, [])
model_assignment = assigner.assign_to_isoform(assignment.read_id, model_combined_profile)
model_assignment.read_group = assignment.read_group
Expand Down
3 changes: 2 additions & 1 deletion src/transcript_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def dump_read_assignments(self, transcript_model_constructor):
# write read_id -> transcript_id map
if not self.output_r2t:
return
for model_id, read_assignments in transcript_model_constructor.transcript_read_ids.items():
for model_id in transcript_model_constructor.transcript_read_ids.keys():
read_assignments = transcript_model_constructor.transcript_read_ids[model_id]
for a in read_assignments:
self.out_r2t.write("%s\t%s\n" % (a.read_id, model_id))
for read_id in transcript_model_constructor.read_assignment_counts.keys():
Expand Down

0 comments on commit 877c35f

Please sign in to comment.