use of org.broadinstitute.hellbender.engine.TraversalParameters in project gatk by broadinstitute.
the class IntervalArgumentCollection method parseIntervals.
private void parseIntervals(final GenomeLocParser genomeLocParser) {
// return if no interval arguments at all
if (!intervalsSpecified()) {
throw new GATKException("Cannot call parseIntervals() without specifying either intervals to include or exclude.");
}
GenomeLocSortedSet includeSortedSet;
if (getIntervalStrings().isEmpty()) {
// the -L argument isn't specified, which means that -XL was, since we checked intervalsSpecified()
// therefore we set the include set to be the entire reference territory
includeSortedSet = GenomeLocSortedSet.createSetFromSequenceDictionary(genomeLocParser.getSequenceDictionary());
} else {
try {
includeSortedSet = IntervalUtils.loadIntervals(getIntervalStrings(), intervalSetRule, intervalMerging, intervalPadding, genomeLocParser);
} catch (UserException.EmptyIntersection e) {
throw new CommandLineException.BadArgumentValue("-L, --interval_set_rule", getIntervalStrings() + "," + intervalSetRule, "The specified intervals had an empty intersection");
}
}
final GenomeLocSortedSet excludeSortedSet = IntervalUtils.loadIntervals(excludeIntervalStrings, IntervalSetRule.UNION, intervalMerging, intervalExclusionPadding, genomeLocParser);
if (excludeSortedSet.contains(GenomeLoc.UNMAPPED)) {
throw new UserException("-XL unmapped is not currently supported");
}
GenomeLocSortedSet intervals;
// if no exclude arguments, can return the included set directly
if (excludeSortedSet.isEmpty()) {
intervals = includeSortedSet;
} else // otherwise there are exclude arguments => must merge include and exclude GenomeLocSortedSets
{
intervals = includeSortedSet.subtractRegions(excludeSortedSet);
if (intervals.isEmpty()) {
throw new CommandLineException.BadArgumentValue("-L,-XL", getIntervalStrings().toString() + ", " + excludeIntervalStrings.toString(), "The intervals specified for exclusion with -XL removed all territory specified by -L.");
}
// logging messages only printed when exclude (-XL) arguments are given
final long toPruneSize = includeSortedSet.coveredSize();
final long toExcludeSize = excludeSortedSet.coveredSize();
final long intervalSize = intervals.coveredSize();
logger.info(String.format("Initial include intervals span %d loci; exclude intervals span %d loci", toPruneSize, toExcludeSize));
logger.info(String.format("Excluding %d loci from original intervals (%.2f%% reduction)", toPruneSize - intervalSize, (toPruneSize - intervalSize) / (0.01 * toPruneSize)));
}
logger.info(String.format("Processing %d bp from intervals", intervals.coveredSize()));
// Separate out requests for unmapped records from the rest of the intervals.
boolean traverseUnmapped = false;
if (intervals.contains(GenomeLoc.UNMAPPED)) {
traverseUnmapped = true;
intervals.remove(GenomeLoc.UNMAPPED);
}
traversalParameters = new TraversalParameters(IntervalUtils.convertGenomeLocsToSimpleIntervals(intervals.toList()), traverseUnmapped);
}
use of org.broadinstitute.hellbender.engine.TraversalParameters in project gatk by broadinstitute.
the class IntervalArgumentCollectionTest method testUnmappedAndMappedInclusion.
@Test(dataProvider = "optionalOrNot")
public void testUnmappedAndMappedInclusion(IntervalArgumentCollection iac) {
iac.addToIntervalStrings("1:10-20");
iac.addToIntervalStrings("2:1-5");
iac.addToIntervalStrings("unmapped");
final TraversalParameters traversalParameters = iac.getTraversalParameters(hg19GenomeLocParser.getSequenceDictionary());
Assert.assertTrue(traversalParameters.traverseUnmappedReads());
Assert.assertEquals(traversalParameters.getIntervalsForTraversal().size(), 2);
Assert.assertEquals(traversalParameters.getIntervalsForTraversal().get(0), new SimpleInterval("1", 10, 20));
Assert.assertEquals(traversalParameters.getIntervalsForTraversal().get(1), new SimpleInterval("2", 1, 5));
}
use of org.broadinstitute.hellbender.engine.TraversalParameters in project gatk by broadinstitute.
the class IntervalArgumentCollectionTest method testMultipleUnmappedInclusion.
@Test(dataProvider = "optionalOrNot")
public void testMultipleUnmappedInclusion(IntervalArgumentCollection iac) {
iac.addToIntervalStrings("unmapped");
iac.addToIntervalStrings("1:10-20");
iac.addToIntervalStrings("unmapped");
iac.addToIntervalStrings("unmapped");
final TraversalParameters traversalParameters = iac.getTraversalParameters(hg19GenomeLocParser.getSequenceDictionary());
Assert.assertTrue(traversalParameters.traverseUnmappedReads());
Assert.assertEquals(traversalParameters.getIntervalsForTraversal().size(), 1);
Assert.assertEquals(traversalParameters.getIntervalsForTraversal().get(0), new SimpleInterval("1", 10, 20));
}
use of org.broadinstitute.hellbender.engine.TraversalParameters in project gatk by broadinstitute.
the class IntervalArgumentCollectionTest method testUnmappedAndMappedInclusionPlusMappedExclusion.
@Test(dataProvider = "optionalOrNot")
public void testUnmappedAndMappedInclusionPlusMappedExclusion(IntervalArgumentCollection iac) {
iac.addToIntervalStrings("1:10-20");
iac.addToIntervalStrings("2:1-5");
iac.addToIntervalStrings("unmapped");
iac.excludeIntervalStrings.addAll(Arrays.asList("1"));
final TraversalParameters traversalParameters = iac.getTraversalParameters(hg19GenomeLocParser.getSequenceDictionary());
Assert.assertTrue(traversalParameters.traverseUnmappedReads());
Assert.assertEquals(traversalParameters.getIntervalsForTraversal().size(), 1);
Assert.assertEquals(traversalParameters.getIntervalsForTraversal().get(0), new SimpleInterval("2", 1, 5));
}
use of org.broadinstitute.hellbender.engine.TraversalParameters in project gatk by broadinstitute.
the class IntervalArgumentCollectionTest method testUnmappedInclusion.
@Test(dataProvider = "optionalOrNot")
public void testUnmappedInclusion(IntervalArgumentCollection iac) {
iac.addToIntervalStrings("unmapped");
final TraversalParameters traversalParameters = iac.getTraversalParameters(hg19GenomeLocParser.getSequenceDictionary());
Assert.assertTrue(traversalParameters.traverseUnmappedReads());
Assert.assertTrue(traversalParameters.getIntervalsForTraversal().isEmpty());
}
Aggregations