Skip to content

Commit

Permalink
Merge pull request #20 from chuan-wang/dev
Browse files Browse the repository at this point in the history
Fix wrong logic for collecting unassigned indexes
  • Loading branch information
ssjunnebo authored Oct 16, 2024
2 parents fd54a12 + 340de28 commit aad13f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
4 changes: 4 additions & 0 deletions VERSIONLOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# TACA Version Log

## 20241016.1

Fix wrong logic for collecting unassigned indexes

## 20241011.1

Fix issue with 0 lane number; Add percentage of unassigned in total unassigned per lane
Expand Down
39 changes: 13 additions & 26 deletions taca/element/Element_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,25 +1040,11 @@ def aggregate_stats_unassigned(
# Order: from longer to shorter indexes
sub_demux_with_shorter_index_lens = sub_demux_list[1:]
for sub_demux in sub_demux_with_shorter_index_lens:
unassigned_csv = os.path.join(
self.run_dir,
f"Demultiplexing_{sub_demux}",
"UnassignedSequences.csv",
)
if os.path.exists(unassigned_csv):
with open(unassigned_csv) as unassigned_file:
reader = csv.DictReader(unassigned_file)
unassigned_indexes = [row for row in reader]
else:
logger.warning(
f"No {os.path.basename(unassigned_csv)} file found for sub-demultiplexing {sub_demux}."
)
continue
# Filter by lane
unassigned_indexes = [
unassigned_index
for unassigned_index in unassigned_indexes
if unassigned_index["Lane"] == lane
sub_demux_assigned_indexes = [
sub_demux_assigned_index
for sub_demux_assigned_index in aggregated_assigned_indexes_filtered_sorted
if sub_demux_assigned_index["sub_demux_count"] == sub_demux
and sub_demux_assigned_index["Lane"] == lane
]
# Remove overlapped indexes from the list of max_unassigned_indexes
idx1_overlapped_len = min(
Expand All @@ -1085,11 +1071,11 @@ def aggregate_stats_unassigned(
if demux_lens_pair[0] == sub_demux_with_max_index_lens
][0][1],
)
for unassigned_index in unassigned_indexes:
idx1_overlapped_seq = unassigned_index["I1"][
for sub_demux_assigned_index in sub_demux_assigned_indexes:
idx1_overlapped_seq = sub_demux_assigned_index["I1"][
:idx1_overlapped_len
]
idx2_overlapped_seq = unassigned_index["I2"][
idx2_overlapped_seq = sub_demux_assigned_index["I2"][
:idx2_overlapped_len
]
# Remove the overlapped record from the max_unassigned_indexes list
Expand Down Expand Up @@ -1174,10 +1160,11 @@ def aggregate_stats_unassigned(
)

# Write to a new UnassignedSequences.csv file under demux_dir
aggregated_unassigned_csv = os.path.join(
self.run_dir, self.demux_dir, "UnassignedSequences.csv"
)
self.write_to_csv(aggregated_unassigned_indexes, aggregated_unassigned_csv)
if aggregated_unassigned_indexes:
aggregated_unassigned_csv = os.path.join(
self.run_dir, self.demux_dir, "UnassignedSequences.csv"
)
self.write_to_csv(aggregated_unassigned_indexes, aggregated_unassigned_csv)

# Aggregate demux results
def aggregate_demux_results(self, demux_results_dirs):
Expand Down

0 comments on commit aad13f6

Please sign in to comment.