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

the long awaited FastaAlternateReferenceMaker #5549

Merged
merged 3 commits into from
Jan 29, 2019

Conversation

lbergelson
Copy link
Member

  • new walker type ReferenceWalker
  • changes to close behavior in FastaWriter and adding additional buffering
  • new walkers:
    CountBasesInReference
    FastaReferenceMaker
    FastaAlternateReferenceMaker

@codecov-io
Copy link

codecov-io commented Dec 21, 2018

Codecov Report

Merging #5549 into master will decrease coverage by 0.072%.
The diff coverage is 92.824%.

@@              Coverage Diff               @@
##             master     #5549       +/-   ##
==============================================
- Coverage     87.09%   87.018%   -0.072%     
- Complexity    31524     31706      +182     
==============================================
  Files          1930      1943       +13     
  Lines        145231    146064      +833     
  Branches      16095     16137       +42     
==============================================
+ Hits         126482    127102      +620     
- Misses        12900     13077      +177     
- Partials       5849      5885       +36
Impacted Files Coverage Δ Complexity Δ
...institute/hellbender/utils/help/HelpConstants.java 4.167% <ø> (ø) 1 <0> (ø) ⬇️
...roadinstitute/hellbender/utils/SimpleInterval.java 93.182% <ø> (ø) 48 <0> (ø) ⬇️
...dinstitute/hellbender/engine/ReferenceContext.java 83.908% <ø> (ø) 39 <0> (ø) ⬇️
...lbender/utils/iterators/IntervalLocusIterator.java 92.593% <ø> (ø) 11 <0> (ø) ⬇️
...org/broadinstitute/hellbender/utils/BaseUtils.java 87.903% <100%> (+1.178%) 56 <10> (+10) ⬆️
...lbender/tools/examples/ExampleReferenceWalker.java 100% <100%> (ø) 7 <7> (?)
...rs/fasta/CountBasesInReferenceIntegrationTest.java 100% <100%> (ø) 3 <3> (?)
...llbender/utils/reference/FastaReferenceWriter.java 92.466% <100%> (+0.052%) 51 <0> (ø) ⬇️
...xamples/ExampleReferenceWalkerIntegrationTest.java 100% <100%> (ø) 3 <3> (?)
...lkers/variantutils/ReblockGVCFIntegrationTest.java 97.826% <100%> (ø) 8 <0> (ø) ⬇️
... and 147 more

@droazen droazen self-requested a review January 3, 2019 19:19
@droazen droazen self-assigned this Jan 3, 2019
@lbergelson lbergelson force-pushed the lb_fasta_alternative_reference branch from 4ec7a34 to f98fa90 Compare January 3, 2019 19:38
* new walker type ReferenceWalker
* changes to close behavior in FastaWriter and adding additional buffering
* new walkers:
     CountBasesInReference
     FastaReferenceMaker
     FastaAlternateReferenceMaker
@lbergelson lbergelson force-pushed the lb_fasta_alternative_reference branch from f98fa90 to 4e60787 Compare January 9, 2019 18:46
Copy link
Collaborator

@droazen droazen left a comment

Choose a reason for hiding this comment

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

Minor comments only -- back to @lbergelson. Merge once these are addressed.

import org.broadinstitute.hellbender.utils.iterators.IntervalLocusIterator;

/**
* A reference walker is a tool which process each position in a given reference.
Copy link
Collaborator

Choose a reason for hiding this comment

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

process -> processes

Copy link
Collaborator

Choose a reason for hiding this comment

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

each position -> each base that overlaps a set of intervals? (ie., describe the traversal more precisely here)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

* A reference walker is a tool which process each position in a given reference.
*
* ReferenceWalker authors must implement the apply() method to process each position, and may optionally implement
* {@link #onTraversalStart()} and/or {@link #onTraversalSuccess()}. See the {@link ExampleReferenceWalker} walker for an example.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mention getReferenceWindow() here as an additional method that tool authors might want to override.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


/**
* Determine the window to use when creating the ReferenceContext in apply. This determines which reference bases are
* see at each position, as well as which reads / features are considered to overlap the reference site.
Copy link
Collaborator

Choose a reason for hiding this comment

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

see -> seen

Copy link
Member Author

Choose a reason for hiding this comment

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

done

final CountingReadFilter readFilter = makeReadFilter();

for(SimpleInterval locus : getIntervalIterator()){
SimpleInterval referenceWindow = getReferenceWindow(locus);
Copy link
Collaborator

Choose a reason for hiding this comment

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

locus and referenceWindow should both be final

Copy link
Member Author

Choose a reason for hiding this comment

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

huh, I wonder why intellij didn't remind me of that.

@@ -0,0 +1,78 @@
package org.broadinstitute.hellbender.tools.examples;

import com.netflix.servo.util.VisibleForTesting;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wrong VisibleForTesting annotation...

Copy link
Member Author

Choose a reason for hiding this comment

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

changed to com.hulu.util.VisibleForTesting

public class CountBasesInReferenceIntegrationTest extends CommandLineProgramTest {

@Test
public void testExampleReferenceWalker(){
Copy link
Collaborator

Choose a reason for hiding this comment

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

testExampleReferenceWalker() -> testCountBasesInReferenceWithInterval()

}

@Test
public void testExampleReferenceWalkerFull(){
Copy link
Collaborator

Choose a reason for hiding this comment

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

testExampleReferenceWalkerFull() -> testCountBasesInReferenceFull()

Assert.assertEquals(BaseUtils.basesToIUPAC((byte)'A', (byte)'T'), 'W', "testing A/T=W");
Assert.assertEquals(BaseUtils.basesToIUPAC((byte)'T', (byte)'A'), 'W', "testing T/A=W");
Assert.assertEquals(BaseUtils.basesToIUPAC((byte) 'G', (byte) 'T'), 'K', "testing G/T=K");
Assert.assertEquals(BaseUtils.basesToIUPAC((byte) 'T', (byte) 'G'), 'K', "testing T/G=K");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test doesn't cover all the possibilities -- could you add the missing cases? (should be pretty easy)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

import java.util.Arrays;
import java.util.Map;

public class FastaTestUtils {
Copy link
Collaborator

Choose a reason for hiding this comment

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

final (and make the default constructor private)


public class FastaTestUtils {

public static void assertOutput(final Path path, final boolean mustHaveIndex, final boolean mustHaveDictionary,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add docs for these methods (and give assertOutput() a more descriptive name)

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved most of these back to the unit test they originally came from. I had intended to use them in my tests but they ended up being to brittle to adapt. I documented what was left.

@droazen droazen assigned lbergelson and unassigned droazen Jan 29, 2019
@droazen droazen merged commit 64e2d3a into master Jan 29, 2019
@droazen droazen deleted the lb_fasta_alternative_reference branch January 29, 2019 22:08
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.

3 participants