From 3d93ea1a4b20ec1bba39bf4c6d8b913a7b27d0c4 Mon Sep 17 00:00:00 2001 From: agalitsyna Date: Fri, 4 Oct 2024 11:31:44 -0400 Subject: [PATCH] Return --readid-transform functionality broken after latest release. --- pairtools/lib/parse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pairtools/lib/parse.py b/pairtools/lib/parse.py index 681027c..bd8a576 100644 --- a/pairtools/lib/parse.py +++ b/pairtools/lib/parse.py @@ -94,9 +94,7 @@ def streaming_classify( ### Iterate over input pysam: instream = iter(instream) - for (readID, (sams1, sams2)) in read_alignment_block(instream, sort=True, group_by_side=True, return_readID=True): - if readID_transform is not None: - readID = eval(readID_transform) + for (readID, (sams1, sams2)) in read_alignment_block(instream, sort=True, group_by_side=True, return_readID=True, readID_transform=readID_transform): ### Parse if not parse2: # regular parser: @@ -224,13 +222,15 @@ def group_alignments_by_side(sams): return sams1, sams2 -def read_alignment_block(instream, sort=True, group_by_side=True, return_readID=True): +def read_alignment_block(instream, sort=True, group_by_side=True, return_readID=True, readID_transform=None): sams = [] prev_readID = None while True: sam_entry = next(instream, None) readID = sam_entry.query_name if sam_entry else None + if readID_transform is not None and readID is not None: + readID = eval(readID_transform) # Read is fully populated, then parse and write: if not (sam_entry) or ((readID != prev_readID) and prev_readID):