/** * @return AMPLICON_INTERVALS */ @Override protected IntervalList getProbeIntervals() { return IntervalList.fromFile(AMPLICON_INTERVALS); }
@Override protected IntervalList getIntervalListInternal(final File intervalList, final boolean includeFiltered) { return IntervalList.fromFile(intervalList); } };
@Override protected IntervalList getIntervalListInternal(final File intervalList, final boolean includeFiltered) { return IntervalList.fromFile(intervalList); } };
/** * @return AMPLICON_INTERVALS */ @Override protected IntervalList getProbeIntervals() { return IntervalList.fromFile(AMPLICON_INTERVALS); }
/** * Calls {@link #fromFile(java.io.File)} on the provided files, and returns their {@link #union(java.util.Collection)}. */ public static IntervalList fromFiles(final Collection<File> intervalListFiles) { final Collection<IntervalList> intervalLists = new ArrayList<>(); for (final File file : intervalListFiles) { intervalLists.add(IntervalList.fromFile(file)); } return IntervalList.union(intervalLists); }
private Testcase(final File file, final int scatterWidth, final IntervalListScatterMode mode, final List<IntervalList> expectedScatter) { this.source = IntervalList.fromFile(file); this.file = file; this.expectedScatter = expectedScatter; this.scatterWidth = scatterWidth; this.mode = mode; } }
/** * Calls {@link #fromFile(java.io.File)} on the provided files, and returns their {@link #union(java.util.Collection)}. */ public static IntervalList fromFiles(final Collection<File> intervalListFiles) { final Collection<IntervalList> intervalLists = new ArrayList<IntervalList>(); for (final File file : intervalListFiles) { intervalLists.add(IntervalList.fromFile(file)); } return IntervalList.union(intervalLists); }
/** * Calls {@link #fromFile(java.io.File)} on the provided files, and returns their {@link #union(java.util.Collection)}. */ public static IntervalList fromFiles(final Collection<File> intervalListFiles) { final Collection<IntervalList> intervalLists = new ArrayList<>(); for (final File file : intervalListFiles) { intervalLists.add(IntervalList.fromFile(file)); } return IntervalList.union(intervalLists); }
private List<Interval> getIntervalList (final File intervalFile) throws IOException { IOUtil.assertFileIsReadable(intervalFile); return IntervalList.fromFile(intervalFile).getIntervals(); }
private List<Interval> getIntervalList (final File intervalFile) throws IOException { IOUtil.assertFileIsReadable(intervalFile); return IntervalList.fromFile(intervalFile).getIntervals(); }
static OverlapDetector<Interval> getOverlapDetectorFromIntervalListFile(File intervalList, int lhsBuffer, int rhsBuffer) { if (intervalList == null) { return null; } List<Interval> intervals = IntervalList.fromFile(intervalList).uniqued().getIntervals(); OverlapDetector<Interval> detector = new OverlapDetector<>(lhsBuffer, rhsBuffer); detector.addAll(intervals, intervals); return detector; }
static OverlapDetector<Interval> getOverlapDetectorFromIntervalListFile(File intervalList, int lhsBuffer, int rhsBuffer) { if (intervalList == null) { return null; } List<Interval> intervals = IntervalList.fromFile(intervalList).uniqued().getIntervals(); OverlapDetector<Interval> detector = new OverlapDetector<>(lhsBuffer, rhsBuffer); detector.addAll(intervals, intervals); return detector; }
/** * Creates {@link htsjdk.samtools.util.AbstractLocusIterator} implementation according to {@link this#USE_FAST_ALGORITHM} value. * * @param in inner {@link htsjdk.samtools.SamReader} * @return if {@link this#USE_FAST_ALGORITHM} is enabled, returns {@link htsjdk.samtools.util.EdgeReadIterator} implementation, * otherwise default algorithm is used and {@link htsjdk.samtools.util.SamLocusIterator} is returned. */ protected AbstractLocusIterator getLocusIterator(final SamReader in) { if (USE_FAST_ALGORITHM) { return (INTERVALS != null) ? new EdgeReadIterator(in, IntervalList.fromFile(INTERVALS)) : new EdgeReadIterator(in); } SamLocusIterator iterator = (INTERVALS != null) ? new SamLocusIterator(in, IntervalList.fromFile(INTERVALS)) : new SamLocusIterator(in); iterator.setMaxReadsToAccumulatePerLocus(LOCUS_ACCUMULATION_CAP); iterator.setEmitUncoveredLoci(true); iterator.setQualityScoreCutoff(0); return iterator; }
private IntervalList tester(IntervalListTools.Action action, boolean invert) throws IOException { final File ilOut = File.createTempFile("IntervalListTools", "interval_list"); ilOut.deleteOnExit(); final List<String> args = new ArrayList<>(); args.add("ACTION=" + action.toString()); args.add("INPUT=" + scatterable); if (action.takesSecondInput) { args.add("SECOND_INPUT=" + secondInput); } else { args.add("INPUT=" + secondInput); } if (invert) { args.add("INVERT=true"); } args.add("OUTPUT=" + ilOut); Assert.assertEquals(runPicardCommandLine(args), 0); return IntervalList.fromFile(ilOut); }
/** * Creates {@link htsjdk.samtools.util.AbstractLocusIterator} implementation according to {@link this#USE_FAST_ALGORITHM} value. * * @param in inner {@link htsjdk.samtools.SamReader} * @return if {@link this#USE_FAST_ALGORITHM} is enabled, returns {@link htsjdk.samtools.util.EdgeReadIterator} implementation, * otherwise default algorithm is used and {@link htsjdk.samtools.util.SamLocusIterator} is returned. */ protected AbstractLocusIterator getLocusIterator(final SamReader in) { if (USE_FAST_ALGORITHM) { return (INTERVALS != null) ? new EdgeReadIterator(in, IntervalList.fromFile(INTERVALS)) : new EdgeReadIterator(in); } SamLocusIterator iterator = (INTERVALS != null) ? new SamLocusIterator(in, IntervalList.fromFile(INTERVALS)) : new SamLocusIterator(in); iterator.setMaxReadsToAccumulatePerLocus(LOCUS_ACCUMULATION_CAP); iterator.setEmitUncoveredLoci(true); iterator.setQualityScoreCutoff(0); return iterator; }
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; }
@DataProvider public Object[][] actionAndTotalBasesWithInvertData() { final long totalBasesInDict = IntervalList.fromFile(secondInput).getHeader().getSequenceDictionary().getReferenceLength(); final int totalContigsInDict = IntervalList.fromFile(secondInput).getHeader().getSequenceDictionary().size(); return new Object[][]{ {IntervalListTools.Action.CONCAT, totalBasesInDict - 201, 2 + totalContigsInDict}, {IntervalListTools.Action.UNION, totalBasesInDict - 201, 2 + totalContigsInDict}, {IntervalListTools.Action.INTERSECT, totalBasesInDict - 140, 2 + totalContigsInDict}, {IntervalListTools.Action.SUBTRACT, totalBasesInDict - 60, 2 + totalContigsInDict}, {IntervalListTools.Action.SYMDIFF, totalBasesInDict - 61, 3 + totalContigsInDict}, {IntervalListTools.Action.OVERLAPS, totalBasesInDict - 150, 2 + totalContigsInDict}, }; }
/** Gets the intervals over which we will calculate metrics. */ protected IntervalList getIntervalsToExamine() { final IntervalList intervals; if (INTERVALS != null) { IOUtil.assertFileIsReadable(INTERVALS); intervals = IntervalList.fromFile(INTERVALS); } else { intervals = new IntervalList(this.header); for (final SAMSequenceRecord rec : this.header.getSequenceDictionary().getSequences()) { final Interval interval = new Interval(rec.getSequenceName(), 1, rec.getSequenceLength()); intervals.add(interval); } } return intervals; }
@Test public void testIntervalListFrom() throws IOException { final String testPath = TEST_DIR.resolve("IntervalListFromVCFTestComp.interval_list").toString(); final IntervalList fromFileList = IntervalList.fromFile(new File(testPath)); final IntervalList fromPathList = IntervalList.fromPath(IOUtil.getPath(testPath)); fromFileList.getHeader().getSequenceDictionary().assertSameDictionary(fromPathList.getHeader().getSequenceDictionary()); Assert.assertEquals(CollectionUtil.makeCollection(fromFileList.iterator()), CollectionUtil.makeCollection(fromPathList.iterator())); }
/** Gets the intervals over which we will calculate metrics. */ protected IntervalList getIntervalsToExamine() { final IntervalList intervals; if (INTERVALS != null) { IOUtil.assertFileIsReadable(INTERVALS); intervals = IntervalList.fromFile(INTERVALS); } else { intervals = new IntervalList(this.header); for (final SAMSequenceRecord rec : this.header.getSequenceDictionary().getSequences()) { final Interval interval = new Interval(rec.getSequenceName(), 1, rec.getSequenceLength()); intervals.add(interval); } } return intervals; }