fgpyo
fgpyo copied to clipboard
Add function(s) to set the 5' most alignment on a read as primary
This has come up in multiple client contexts and would be very helpful to have.
I think there are two functions that would be helpful:
def set_primary_alignments(template: Template) -> Template:
"""
Identify the 5' most alignment on each read, and set it as primary.
The formerly primary alignment will be marked as supplmementary and added
to the respective list of supplementary alignments (`r*_supplementals`).
"""
def is_5p_most_alignment(rec: AlignedSegment) -> bool:
"""
Determine whether the alignment is the 5' most on its read.
Check the record for supplementary alignments in its `SA` tag.
If none exist, the record is 5' most by default.
Otherwise, check the list of supplementary alignments, and identify if any are situated 5' to the current alignment.
"""
(the first could potentially include an argument to set the primary alignment on R1, R2, or both)