Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AlignedSegment is_mapped/mate_is_mapped/is_forward/mate_is_forward properties #1088

Merged
merged 2 commits into from
Mar 16, 2022

Conversation

jmarshall
Copy link
Member

These are opposites of the existing is_unmapped/mate_is_unmapped/is_reverse/mate_is_reverse properties. The existing properties match the sense of the underlying flag bits; these proposed additions allow more natural conditions to be written in some cases:

if not aln.is_unmapped:
    print('stilted way to say if mapped')

if aln.is_mapped:
    print('more natural')

if aln.is_forward:
    print('handle the forward case first')
else:
    print('then the reverse case')

Inspired by a minor grizzle by Nick Loman.

This enables rewriting `if not aln.is_unmapped: ...` in a more
straightforward way as `if aln.is_mapped: ...`.

Inspired by this Nick Loman / John Marshall twitter thread from 2019:
<https://twitter.com/pathogenomenick/status/1104006763559505920>
This allows a similar improvement on `if not aln.is_reverse: ...`.
(Also fix .mate_is_reverse doc string.)
@AndreasHeger
Copy link
Contributor

Thanks, it is nice to be nice :=)

@AndreasHeger AndreasHeger merged commit bd42f1c into pysam-developers:master Mar 16, 2022
@jmarshall
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants