Search in sources :

Example 6 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class BandPassActivityProfile method processState.

/**
     * Band pass the probabilities in the ActivityProfile, producing a new profile that's band pass filtered
     * @return a new double[] that's the band-pass filtered version of this profile
     */
@Override
protected Collection<ActivityProfileState> processState(final ActivityProfileState justAddedState) {
    final Collection<ActivityProfileState> states = new ArrayList<>();
    for (final ActivityProfileState superState : super.processState(justAddedState)) {
        if (superState.isActiveProb() > 0.0) {
            for (int i = -filterSize; i <= filterSize; i++) {
                final SimpleInterval loc = getLocForOffset(justAddedState.getLoc(), i);
                if (loc != null) {
                    final double newProb = superState.isActiveProb() * gaussianKernel[i + filterSize];
                    states.add(new ActivityProfileState(loc, newProb));
                }
            }
        } else {
            states.add(justAddedState);
        }
    }
    return states;
}
Also used : ArrayList(java.util.ArrayList) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval)

Example 7 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class ActivityProfile method processState.

/**
     * Process justAddedState, returning a collection of derived states that actually be added to the stateList
     *
     * The purpose of this function is to transform justAddedStates, if needed, into a series of atomic states
     * that we actually want to track.  For example, if state is for soft clips, we transform that single
     * state into a list of states that surround the state up to the distance of the soft clip.
     *
     * Can be overridden by subclasses to transform states in any way
     *
     * There's no particular contract for the output states, except that they can never refer to states
     * beyond the current end of the stateList unless the explicitly include preceding states before
     * the reference.  So for example if the current state list is [1, 2, 3] this function could return
     * [1,2,3,4,5] but not [1,2,3,5].
     *
     * @param justAddedState the state our client provided to use to add to the list
     * @return a list of derived states that should actually be added to this profile's state list
     */
protected Collection<ActivityProfileState> processState(final ActivityProfileState justAddedState) {
    if (justAddedState.getResultState().equals(ActivityProfileState.Type.HIGH_QUALITY_SOFT_CLIPS)) {
        // special code to deal with the problem that high quality soft clipped bases aren't added to pileups
        final List<ActivityProfileState> states = new ArrayList<>();
        // add no more than the max prob propagation distance num HQ clips
        final int numHQClips = Math.min(justAddedState.getResultValue().intValue(), getMaxProbPropagationDistance());
        for (int i = -numHQClips; i <= numHQClips; i++) {
            final SimpleInterval loc = getLocForOffset(justAddedState.getLoc(), i);
            if (loc != null) {
                states.add(new ActivityProfileState(loc, justAddedState.isActiveProb()));
            }
        }
        return states;
    } else {
        return Collections.singletonList(justAddedState);
    }
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval)

Example 8 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class ReferenceAPISourceUnitTest method testReferenceSourceMultiPageQuery.

@Test(groups = "cloud")
public void testReferenceSourceMultiPageQuery() {
    final int mio = 1_000_000;
    final ReferenceBases bases1 = queryReferenceAPI(HS37D5_REF_ID, new SimpleInterval("1", 50000, 50000 + mio + 50));
    final ReferenceBases bases2 = queryReferenceAPI(HS37D5_REF_ID, new SimpleInterval("1", 50025, 50025 + mio + 50));
    Assert.assertNotNull(bases1);
    Assert.assertNotNull(bases1.getBases());
    Assert.assertNotNull(bases2);
    Assert.assertNotNull(bases2.getBases());
    // those SimpleIntervals include the end, hence +1
    Assert.assertEquals(bases1.getBases().length, mio + 50 + 1, "Wrong number of bases returned");
    Assert.assertEquals(bases2.getBases().length, mio + 50 + 1, "Wrong number of bases returned");
    // grab some bases around the seam
    ReferenceBases seam1 = bases1.getSubset(new SimpleInterval("1", 50000 + mio - 100, 50000 + mio + 50));
    ReferenceBases seam2 = bases2.getSubset(new SimpleInterval("1", 50000 + mio - 100, 50000 + mio + 50));
    Assert.assertEquals(seam1.getBases(), seam2.getBases(), "seam doesn't match (paging bug?)");
}
Also used : ReferenceBases(org.broadinstitute.hellbender.utils.reference.ReferenceBases) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 9 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class ReferenceAPISourceUnitTest method testReferenceSourceQuery.

@Test(groups = "cloud")
public void testReferenceSourceQuery() {
    final ReferenceBases bases = queryReferenceAPI(HS37D5_REF_ID, new SimpleInterval("1", 50000, 50009));
    Assert.assertNotNull(bases);
    Assert.assertNotNull(bases.getBases());
    Assert.assertEquals(bases.getBases().length, 10, "Wrong number of bases returned");
    Assert.assertEquals(new String(bases.getBases()), "TAAACAGGTT", "Wrong bases returned");
}
Also used : ReferenceBases(org.broadinstitute.hellbender.utils.reference.ReferenceBases) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 10 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class ReferenceAPISourceUnitTest method testDummy.

@Test(groups = "cloud")
public void testDummy() {
    String referenceName = HS37D5_REF_ID;
    final String expected = "AAACAGGTTA";
    // -1 because we're using closed intervals
    SimpleInterval interval = new SimpleInterval("1", 50001, 50001 + expected.length() - 1);
    Logger logger = LogManager.getLogger(ReferenceAPISourceUnitTest.class);
    GenomicsOptions options = PipelineOptionsFactory.create().as(GenomicsOptions.class);
    options.setApiKey(getGCPTestApiKey());
    options.setProject(getGCPTestProject());
    // We don't use GATKTestPipeline because we need specific options.
    final Pipeline p = TestPipeline.create(options);
    ReferenceAPISource refAPISource = makeReferenceAPISource(referenceName, p);
    ReferenceBases bases = refAPISource.getReferenceBases(p.getOptions(), interval);
    final String actual = new String(bases.getBases());
    Assert.assertEquals(actual, expected, "Wrong bases returned");
    p.run();
}
Also used : ReferenceBases(org.broadinstitute.hellbender.utils.reference.ReferenceBases) ReferenceAPISource(org.broadinstitute.hellbender.engine.datasources.ReferenceAPISource) GenomicsOptions(com.google.cloud.genomics.dataflow.utils.GenomicsOptions) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Logger(org.apache.logging.log4j.Logger) TestPipeline(com.google.cloud.dataflow.sdk.testing.TestPipeline) Pipeline(com.google.cloud.dataflow.sdk.Pipeline) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)545 Test (org.testng.annotations.Test)287 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)202 File (java.io.File)102 ArrayList (java.util.ArrayList)66 DataProvider (org.testng.annotations.DataProvider)64 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)60 Collectors (java.util.stream.Collectors)53 java.util (java.util)41 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)40 AllelicCount (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCount)40 UserException (org.broadinstitute.hellbender.exceptions.UserException)39 VariantContext (htsjdk.variant.variantcontext.VariantContext)36 IntStream (java.util.stream.IntStream)34 Target (org.broadinstitute.hellbender.tools.exome.Target)34 IOException (java.io.IOException)32 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)28 Assert (org.testng.Assert)27 Locatable (htsjdk.samtools.util.Locatable)26 List (java.util.List)26