diff --git a/fgpyo/sam/__init__.py b/fgpyo/sam/__init__.py index 6df78d4..9948da6 100644 --- a/fgpyo/sam/__init__.py +++ b/fgpyo/sam/__init__.py @@ -1467,10 +1467,10 @@ def many_pysam_from_rec(cls, rec: AlignedSegment) -> Iterator[AlignedSegment]: for hit in cls.many_from_rec(rec): # TODO: When the original record has hard clips we must set the bases and quals to "*". # It would be smarter to pad/clip the sequence to be compatible with new cigar... - if "H" in rec.cigarstring: + if "H" in rec.cigarstring or rec.query_sequence == NO_QUERY_BASES: query_sequence = NO_QUERY_BASES query_qualities = None - elif rec.query_sequence != NO_QUERY_BASES and rec.is_forward and not hit.is_forward: + elif rec.is_forward and not hit.is_forward: query_sequence = reverse_complement(rec.query_sequence) query_qualities = rec.query_qualities[::-1] else: