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;
}
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);
}
}
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?)");
}
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");
}
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();
}
Aggregations