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

feat: added template.fixmate() (#83) #182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TimD1
Copy link
Contributor

@TimD1 TimD1 commented Sep 3, 2024

  • added fixmate() method
  • added set_mate_info_on_supplementary() helper function
  • moved builder._set_mate_info() to helper function set_mate_info()
  • moved test_template_iterator.py to test_template.py (contained more than just iterator)
  • added template_test_fixmate() tests

- added fixmate() method
- added set_mate_info_on_supplementary() helper function
- moved builder._set_mate_info() to helper function set_mate_info()
- moved test_template_iterator.py to test_template.py (contained more than just iterator)
- added template_test_fixmate() tests
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 95.16129% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.64%. Comparing base (d574e5a) to head (dff494d).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
fgpyo/sam/__init__.py 95.08% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #182      +/-   ##
==========================================
+ Coverage   89.21%   89.64%   +0.42%     
==========================================
  Files          18       18              
  Lines        2068     2086      +18     
  Branches      457      460       +3     
==========================================
+ Hits         1845     1870      +25     
+ Misses        146      141       -5     
+ Partials       77       75       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TimD1 TimD1 linked an issue Sep 3, 2024 that may be closed by this pull request
@TimD1 TimD1 changed the title feat: added template.fixmate() [issue #83] feat: added template.fixmate() (#83) Sep 3, 2024
Comment on lines +757 to +758
# Arbitrarily set proper pair if the we have an FR pair with isize <= 1000
if r1.is_reverse != r2.is_reverse and abs(r1.template_length) <= 1000:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue This will break many structural variant callers.

Is there a reason to overwrite the proper pair status reported by the aligner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what initially motivated this; I transferred this _set_mate_info() helper function out of fgpyo/sam/builder.py. Are you aware of a reason for it to be present there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msto what's the alternative? Invoking this function is tantamount to saying "I've changed some of the values on one or both of these reads, please make sure everything is in sync". I understand the concern around proper_pair - and it's true that this implementation made sense when it was in SamBuilder, and less so here...

But if someone has changed alignment values .. the value from the aligner is also questionable here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimD1 - @msto and I chatted and we think the right solution here is a little complicated. We suggest doing something like:

def set_mate_info(
  r1: AlignedSegment,
  r2: AlignedSegment,
  is_proper_pair: Callable[[AlignedSegment, AlignedSegment], bool] = lambda a, b: a.is_proper_pair and b.is_proper_pair
) -> Unit
    ...

I.e. the default is to leave it True if it's already set on R1 and R1, but set it to false if already false, or there is disagreement. Then a user (e.g. SamBuilder) can provide it's own lambda.

@fulcrumgenomics fulcrumgenomics deleted a comment from coderabbitai bot Oct 17, 2024
@fulcrumgenomics fulcrumgenomics deleted a comment from coderabbitai bot Oct 17, 2024
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.

Add a method on Template to fixmate information
3 participants