use of htsjdk.samtools.util.Interval in project gatk by broadinstitute.
the class HetPulldownCalculatorUnitTest method inputGetTumorHetPulldown15.
@DataProvider(name = "inputGetTumorHetPulldownMin15")
public Object[][] inputGetTumorHetPulldown15() {
final Pulldown tumorHetPulldown = new Pulldown(normalHeader);
tumorHetPulldown.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8));
tumorHetPulldown.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9));
final IntervalList normalHetIntervals = new IntervalList(tumorHeader);
normalHetIntervals.add(new Interval("1", 14630, 14630));
normalHetIntervals.add(new Interval("2", 14689, 14689));
return new Object[][] { { normalHetIntervals, tumorHetPulldown } };
}
use of htsjdk.samtools.util.Interval in project gatk-protected by broadinstitute.
the class HetPulldownCalculatorUnitTest method inputGetPileupBaseCount.
@DataProvider(name = "inputGetPileupBaseCount")
public Object[][] inputGetPileupBaseCount() throws IOException {
try (final SamReader bamReader = SamReaderFactory.makeDefault().open(NORMAL_BAM_FILE)) {
final IntervalList intervals = new IntervalList(bamReader.getFileHeader());
intervals.add(new Interval("1", 100, 100));
intervals.add(new Interval("1", 11000, 11000));
intervals.add(new Interval("1", 14000, 14000));
intervals.add(new Interval("1", 14630, 14630));
final SamLocusIterator locusIterator = new SamLocusIterator(bamReader, intervals);
final Nucleotide.Counter baseCounts1 = makeBaseCounts(0, 0, 0, 0);
final Nucleotide.Counter baseCounts2 = makeBaseCounts(0, 9, 0, 0);
final Nucleotide.Counter baseCounts3 = makeBaseCounts(12, 0, 0, 0);
final Nucleotide.Counter baseCounts4 = makeBaseCounts(0, 0, 8, 9);
if (!locusIterator.hasNext()) {
throw new SAMException("Can't get locus to start iteration. Check that " + NORMAL_BAM_FILE.toString() + " contains 1:0-16000.");
}
final SamLocusIterator.LocusInfo locus1 = locusIterator.next();
final SamLocusIterator.LocusInfo locus2 = locusIterator.next();
final SamLocusIterator.LocusInfo locus3 = locusIterator.next();
final SamLocusIterator.LocusInfo locus4 = locusIterator.next();
locusIterator.close();
return new Object[][] { { locus1, baseCounts1 }, { locus2, baseCounts2 }, { locus3, baseCounts3 }, { locus4, baseCounts4 } };
}
}
use of htsjdk.samtools.util.Interval in project gatk-protected by broadinstitute.
the class HetPulldownCalculatorUnitTest method inputGetTumorHetPulldown.
@DataProvider(name = "inputGetTumorHetPulldown")
public Object[][] inputGetTumorHetPulldown() {
final Pulldown tumorHetPulldown = new Pulldown(normalHeader);
tumorHetPulldown.add(new AllelicCount(new SimpleInterval("1", 11522, 11522), 7, 4));
tumorHetPulldown.add(new AllelicCount(new SimpleInterval("1", 12098, 12098), 8, 6));
tumorHetPulldown.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8));
tumorHetPulldown.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9));
tumorHetPulldown.add(new AllelicCount(new SimpleInterval("2", 14982, 14982), 6, 5));
final IntervalList normalHetIntervals = new IntervalList(tumorHeader);
normalHetIntervals.add(new Interval("1", 11522, 11522));
normalHetIntervals.add(new Interval("1", 12098, 12098));
normalHetIntervals.add(new Interval("1", 14630, 14630));
normalHetIntervals.add(new Interval("2", 14689, 14689));
normalHetIntervals.add(new Interval("2", 14982, 14982));
return new Object[][] { { normalHetIntervals, tumorHetPulldown } };
}
use of htsjdk.samtools.util.Interval in project gatk by broadinstitute.
the class RnaSeqMetricsCollector method makeOverlapDetector.
public static OverlapDetector<Interval> makeOverlapDetector(final File samFile, final SAMFileHeader header, final File ribosomalIntervalsFile) {
OverlapDetector<Interval> ribosomalSequenceOverlapDetector = new OverlapDetector<>(0, 0);
if (ribosomalIntervalsFile != null) {
final IntervalList ribosomalIntervals = IntervalList.fromFile(ribosomalIntervalsFile);
try {
SequenceUtil.assertSequenceDictionariesEqual(header.getSequenceDictionary(), ribosomalIntervals.getHeader().getSequenceDictionary());
} catch (SequenceUtil.SequenceListsDifferException e) {
throw new UserException("Sequence dictionaries differ in " + samFile.getAbsolutePath() + " and " + ribosomalIntervalsFile.getAbsolutePath(), e);
}
final IntervalList uniquedRibosomalIntervals = ribosomalIntervals.uniqued();
final List<Interval> intervals = uniquedRibosomalIntervals.getIntervals();
ribosomalSequenceOverlapDetector.addAll(intervals, intervals);
}
return ribosomalSequenceOverlapDetector;
}
use of htsjdk.samtools.util.Interval in project gatk by broadinstitute.
the class IntervalListScatterer method scatter.
public List<IntervalList> scatter(final IntervalList sourceIntervalList, final int scatterCount, final boolean isUniqued) {
Utils.validateArg(scatterCount >= 1, "scatterCount < 1");
final IntervalList uniquedList = isUniqued ? sourceIntervalList : sourceIntervalList.uniqued();
final long idealSplitLength = deduceIdealSplitLength(uniquedList, scatterCount);
final List<IntervalList> accumulatedIntervalLists = new ArrayList<>();
IntervalList runningIntervalList = new IntervalList(uniquedList.getHeader());
final ArrayDeque<Interval> intervalQueue = new ArrayDeque<>(uniquedList.getIntervals());
while (!intervalQueue.isEmpty() && accumulatedIntervalLists.size() < scatterCount - 1) {
final Interval interval = intervalQueue.pollFirst();
final long projectedSize = runningIntervalList.getBaseCount() + interval.length();
if (projectedSize <= idealSplitLength) {
runningIntervalList.add(interval);
} else {
switch(mode) {
case INTERVAL_SUBDIVISION:
final int amountToConsume = (int) (idealSplitLength - runningIntervalList.getBaseCount());
final Interval left = new Interval(interval.getContig(), interval.getStart(), interval.getStart() + amountToConsume - 1, interval.isNegativeStrand(), interval.getName());
final Interval right = new Interval(interval.getContig(), interval.getStart() + amountToConsume, interval.getEnd(), interval.isNegativeStrand(), interval.getName());
runningIntervalList.add(left);
// Push back the excess back onto our queue for reconsideration.
intervalQueue.addFirst(right);
break;
case BALANCING_WITHOUT_INTERVAL_SUBDIVISION:
if (runningIntervalList.getIntervals().isEmpty()) {
runningIntervalList.add(interval);
} else {
// Push this interval into the next scatter; re-inject it into the queue, then advance the scatter.
intervalQueue.addFirst(interval);
accumulatedIntervalLists.add(runningIntervalList.uniqued());
runningIntervalList = new IntervalList(uniquedList.getHeader());
}
break;
}
}
if (runningIntervalList.getBaseCount() >= idealSplitLength) {
accumulatedIntervalLists.add(runningIntervalList.uniqued());
runningIntervalList = new IntervalList(uniquedList.getHeader());
}
}
// Flush the remaining intervals into the last split.
while (!intervalQueue.isEmpty()) {
runningIntervalList.add(intervalQueue.pollFirst());
}
if (!runningIntervalList.getIntervals().isEmpty()) {
accumulatedIntervalLists.add(runningIntervalList.uniqued());
}
return accumulatedIntervalLists;
}
Aggregations