Java Code Examples for htsjdk.samtools.util.IntervalList#getIntervals()
The following examples show how to use
htsjdk.samtools.util.IntervalList#getIntervals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RnaSeqMetricsCollector.java From picard with MIT License | 6 votes |
public static OverlapDetector<Interval> makeOverlapDetector(final File samFile, final SAMFileHeader header, final File ribosomalIntervalsFile, final Log log) { final OverlapDetector<Interval> ribosomalSequenceOverlapDetector = new OverlapDetector<Interval>(0, 0); if (ribosomalIntervalsFile != null) { final IntervalList ribosomalIntervals = IntervalList.fromFile(ribosomalIntervalsFile); if (ribosomalIntervals.size() == 0) { log.warn("The RIBOSOMAL_INTERVALS file, " + ribosomalIntervalsFile.getAbsolutePath() + " does not contain intervals"); } try { SequenceUtil.assertSequenceDictionariesEqual(header.getSequenceDictionary(), ribosomalIntervals.getHeader().getSequenceDictionary()); } catch (SequenceUtil.SequenceListsDifferException e) { throw new PicardException("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; }
Example 2
Source File: TagReadWithInterval.java From Drop-seq with MIT License | 5 votes |
/** * Each interval has a corresponding ReadDepthMetric. * @param loci * @return */ OverlapDetector<Interval> getOverlapDetector (final IntervalList loci) { OverlapDetector<Interval> od = new OverlapDetector<>(0, 0); for (Interval i: loci.getIntervals()) od.addLhs(i, i); return (od); }
Example 3
Source File: MaskReferenceSequence.java From Drop-seq with MIT License | 5 votes |
private Map<String, List<Interval>> getIntervalsForContig (final IntervalList iList) { Map<String,List<Interval>> result = new HashMap<>(); for (Interval i: iList.getIntervals()) { String contig = i.getContig(); List<Interval> r= result.get(contig); if (r==null) { r = new ArrayList<>(); result.put(contig, r); } r.add(i); } return result; }
Example 4
Source File: IntervalListScatter.java From picard with MIT License | 5 votes |
public ScatterState(final IntervalListScatterer scatterer, final IntervalList inputIntervals, final int scatterCount) { this.scatterCount = scatterCount; final IntervalList processedIntervals = scatterer.preprocessIntervalList(inputIntervals); this.idealSplitWeight = scatterer.deduceIdealSplitWeight(processedIntervals, scatterCount); this.intervalQueue = new ArrayDeque<>(processedIntervals.getIntervals()); this.scatterer = scatterer; this.header = processedIntervals.getHeader(); this.weightRemaining = scatterer.listWeight(processedIntervals); }
Example 5
Source File: FilterIntervalsIntegrationTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test(dataProvider = "dataAnnotationBasedFilters") public void testAnnotationBasedFilters(final File intervalsFile, final List<String> excludedIntervals, final File annotatedIntervalsFile, final double minimumGCContent, final double maximumGCContent, final double minimumMappability, final double maximumMappability, final double minimumSegmentalDuplicationContent, final double maximumSegmentalDuplicationContent, final List<Integer> expectedIndices) { final File outputFile = createTempFile("filter-intervals-test", ".interval_list"); final ArgumentsBuilder argsBuilder = new ArgumentsBuilder() .add(StandardArgumentDefinitions.INTERVALS_LONG_NAME, intervalsFile.getAbsolutePath()) .add(CopyNumberStandardArgument.ANNOTATED_INTERVALS_FILE_LONG_NAME, annotatedIntervalsFile.getAbsolutePath()) .add(FilterIntervals.MINIMUM_GC_CONTENT_LONG_NAME, Double.toString(minimumGCContent)) .add(FilterIntervals.MAXIMUM_GC_CONTENT_LONG_NAME, Double.toString(maximumGCContent)) .add(FilterIntervals.MINIMUM_MAPPABILITY_LONG_NAME, Double.toString(minimumMappability)) .add(FilterIntervals.MAXIMUM_MAPPABILITY_LONG_NAME, Double.toString(maximumMappability)) .add(FilterIntervals.MINIMUM_SEGMENTAL_DUPLICATION_CONTENT_LONG_NAME, Double.toString(minimumSegmentalDuplicationContent)) .add(FilterIntervals.MAXIMUM_SEGMENTAL_DUPLICATION_CONTENT_LONG_NAME, Double.toString(maximumSegmentalDuplicationContent)) .add(IntervalArgumentCollection.INTERVAL_MERGING_RULE_LONG_NAME, IntervalMergingRule.OVERLAPPING_ONLY.toString()) .addOutput(outputFile); excludedIntervals.forEach(i -> argsBuilder.add(IntervalArgumentCollection.EXCLUDE_INTERVALS_LONG_NAME, i)); runCommandLine(argsBuilder); final IntervalList result = IntervalList.fromFile(outputFile); final IntervalList all = IntervalList.fromFile(intervalsFile); final List<Interval> allIntervals = all.getIntervals(); final IntervalList expected = new IntervalList(all.getHeader().getSequenceDictionary()); expectedIndices.stream().map(allIntervals::get).map(Interval::new).forEach(expected::add); Assert.assertEquals(result, expected); Assert.assertNotSame(result, expected); }
Example 6
Source File: FilterIntervalsIntegrationTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test(dataProvider = "dataCountBasedFilters") public void testCountBasedFilters(final File intervalsFile, final List<File> countFiles, final int lowCountFilterCountThreshold, final double lowCountFilterPercentageOfSamples, final double extremeCountFilterMinimumPercentile, final double extremeCountFilterMaximumPercentile, final double extremeCountFilterPercentageOfSamples, final List<Integer> expectedIndices) { final File outputFile = createTempFile("filter-intervals-test", ".interval_list"); final ArgumentsBuilder argsBuilder = new ArgumentsBuilder() .add(StandardArgumentDefinitions.INTERVALS_LONG_NAME, intervalsFile.getAbsolutePath()) .add(FilterIntervals.LOW_COUNT_FILTER_COUNT_THRESHOLD_LONG_NAME, Integer.toString(lowCountFilterCountThreshold)) .add(FilterIntervals.LOW_COUNT_FILTER_PERCENTAGE_OF_SAMPLES_LONG_NAME, Double.toString(lowCountFilterPercentageOfSamples)) .add(FilterIntervals.EXTREME_COUNT_FILTER_MINIMUM_PERCENTILE_LONG_NAME, Double.toString(extremeCountFilterMinimumPercentile)) .add(FilterIntervals.EXTREME_COUNT_FILTER_MAXIMUM_PERCENTILE_LONG_NAME, Double.toString(extremeCountFilterMaximumPercentile)) .add(FilterIntervals.EXTREME_COUNT_FILTER_PERCENTAGE_OF_SAMPLES_LONG_NAME, Double.toString(extremeCountFilterPercentageOfSamples)) .add(IntervalArgumentCollection.INTERVAL_MERGING_RULE_LONG_NAME, IntervalMergingRule.OVERLAPPING_ONLY.toString()) .addOutput(outputFile); countFiles.forEach(argsBuilder::addInput); runCommandLine(argsBuilder); final IntervalList result = IntervalList.fromFile(outputFile); final IntervalList all = IntervalList.fromFile(intervalsFile); final List<Interval> allIntervals = all.getIntervals(); final IntervalList expected = new IntervalList(all.getHeader().getSequenceDictionary()); expectedIndices.stream().map(allIntervals::get).map(Interval::new).forEach(expected::add); Assert.assertEquals(result, expected); Assert.assertNotSame(result, expected); }
Example 7
Source File: FilterIntervalsIntegrationTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(dataProvider = "dataAllFilters") public void testAllFilters(final File intervalsFile, final List<String> excludedIntervals, final File annotatedIntervalsFile, final double minimumGCContent, final double maximumGCContent, final double minimumMappability, final double maximumMappability, final double minimumSegmentalDuplicationContent, final double maximumSegmentalDuplicationContent, final List<File> countFiles, final int lowCountFilterCountThreshold, final double lowCountFilterPercentageOfSamples, final double extremeCountFilterMinimumPercentile, final double extremeCountFilterMaximumPercentile, final double extremeCountFilterPercentageOfSamples, final List<Integer> expectedIndices) { final File outputFile = createTempFile("filter-intervals-test", ".interval_list"); final ArgumentsBuilder argsBuilder = new ArgumentsBuilder() .add(StandardArgumentDefinitions.INTERVALS_LONG_NAME, intervalsFile.getAbsolutePath()) .add(CopyNumberStandardArgument.ANNOTATED_INTERVALS_FILE_LONG_NAME, annotatedIntervalsFile.getAbsolutePath()) .add(FilterIntervals.MINIMUM_GC_CONTENT_LONG_NAME, Double.toString(minimumGCContent)) .add(FilterIntervals.MAXIMUM_GC_CONTENT_LONG_NAME, Double.toString(maximumGCContent)) .add(FilterIntervals.MINIMUM_MAPPABILITY_LONG_NAME, Double.toString(minimumMappability)) .add(FilterIntervals.MAXIMUM_MAPPABILITY_LONG_NAME, Double.toString(maximumMappability)) .add(FilterIntervals.MINIMUM_SEGMENTAL_DUPLICATION_CONTENT_LONG_NAME, Double.toString(minimumSegmentalDuplicationContent)) .add(FilterIntervals.MAXIMUM_SEGMENTAL_DUPLICATION_CONTENT_LONG_NAME, Double.toString(maximumSegmentalDuplicationContent)) .add(FilterIntervals.LOW_COUNT_FILTER_COUNT_THRESHOLD_LONG_NAME, Integer.toString(lowCountFilterCountThreshold)) .add(FilterIntervals.LOW_COUNT_FILTER_PERCENTAGE_OF_SAMPLES_LONG_NAME, Double.toString(lowCountFilterPercentageOfSamples)) .add(FilterIntervals.EXTREME_COUNT_FILTER_MINIMUM_PERCENTILE_LONG_NAME, Double.toString(extremeCountFilterMinimumPercentile)) .add(FilterIntervals.EXTREME_COUNT_FILTER_MAXIMUM_PERCENTILE_LONG_NAME, Double.toString(extremeCountFilterMaximumPercentile)) .add(FilterIntervals.EXTREME_COUNT_FILTER_PERCENTAGE_OF_SAMPLES_LONG_NAME, Double.toString(extremeCountFilterPercentageOfSamples)) .add(IntervalArgumentCollection.INTERVAL_MERGING_RULE_LONG_NAME, IntervalMergingRule.OVERLAPPING_ONLY.toString()) .addOutput(outputFile); excludedIntervals.forEach(i -> argsBuilder.add(IntervalArgumentCollection.EXCLUDE_INTERVALS_LONG_NAME, i)); countFiles.forEach(argsBuilder::addInput); runCommandLine(argsBuilder); final IntervalList result = IntervalList.fromFile(outputFile); final IntervalList all = IntervalList.fromFile(intervalsFile); final List<Interval> allIntervals = all.getIntervals(); final IntervalList expected = new IntervalList(all.getHeader().getSequenceDictionary()); expectedIndices.stream().map(allIntervals::get).map(Interval::new).forEach(expected::add); Assert.assertEquals(result, expected); Assert.assertNotSame(result, expected); }