} else { try { samSequenceDictionary.assertSameDictionary(dict); } catch (final AssertionError e) { throw new IllegalArgumentException(e);
} else { try { samSequenceDictionary.assertSameDictionary(dict); } catch (final AssertionError e) { throw new IllegalArgumentException(e);
/** * Reads Interprets intervals from the input INTERVALS, if there's a file with that name, it opens the file, otherwise * it tries to parse it, checks that their dictionaries all agree with the input SequenceDictionary and returns the * intersection of all the lists. * * @param sequenceDictionary a {@link SAMSequenceDictionary} to parse the intervals against. * @return the intersection of the interval lists pointed to by the input parameter INTERVALS */ private IntervalList getIntervals(final SAMSequenceDictionary sequenceDictionary) { IntervalList regionOfInterest = null; for (final File intervalListFile : INTERVALS) { if (!intervalListFile.exists()) { throw new IllegalArgumentException("Input file " + intervalListFile + " doesn't seem to exist. "); } log.info("Reading IntervalList ", intervalListFile, "."); final IntervalList temp = IntervalList.fromFile(intervalListFile); sequenceDictionary.assertSameDictionary(temp.getHeader().getSequenceDictionary()); if (regionOfInterest == null) { regionOfInterest = temp; } else { log.info("Intersecting interval_list: ", intervalListFile, "."); regionOfInterest = IntervalList.intersection(regionOfInterest, temp); } } return regionOfInterest; }
/** * Reads Interprets intervals from the input INTERVALS, if there's a file with that name, it opens the file, otherwise * it tries to parse it, checks that their dictionaries all agree with the input SequenceDictionary and returns the * intersection of all the lists. * * @param sequenceDictionary a {@link SAMSequenceDictionary} to parse the intervals against. * @return the intersection of the interval lists pointed to by the input parameter INTERVALS */ private IntervalList getIntervals(final SAMSequenceDictionary sequenceDictionary) { IntervalList regionOfInterest = null; for (final File intervalListFile : INTERVALS) { if (!intervalListFile.exists()) { throw new IllegalArgumentException("Input file " + intervalListFile + " doesn't seem to exist. "); } log.info("Reading IntervalList ", intervalListFile, "."); final IntervalList temp = IntervalList.fromFile(intervalListFile); sequenceDictionary.assertSameDictionary(temp.getHeader().getSequenceDictionary()); if (regionOfInterest == null) { regionOfInterest = temp; } else { log.info("Intersecting interval_list: ", intervalListFile, "."); regionOfInterest = IntervalList.intersection(regionOfInterest, temp); } } return regionOfInterest; }
@Test(dataProvider = "testVCFHeaderDictionaryMergingData") public void testVCFHeaderDictionaryMerging(final String vcfFileName) { final VCFHeader headerOne = new VCFFileReader(new File(variantTestDataRoot + vcfFileName), false).getFileHeader(); final VCFHeader headerTwo = new VCFHeader(headerOne); // deep copy final List<String> sampleList = new ArrayList<String>(); sampleList.addAll(headerOne.getSampleNamesInOrder()); // Check that the two dictionaries start out the same headerOne.getSequenceDictionary().assertSameDictionary(headerTwo.getSequenceDictionary()); // Run the merge command final VCFHeader mergedHeader = new VCFHeader(VCFUtils.smartMergeHeaders(Arrays.asList(headerOne, headerTwo), false), sampleList); // Check that the mergedHeader's sequence dictionary matches the first two mergedHeader.getSequenceDictionary().assertSameDictionary(headerOne.getSequenceDictionary()); }
final VCFFileReader in = new VCFFileReader(f, false); try { dict.assertSameDictionary(in.getFileHeader().getSequenceDictionary()); } catch (final AssertionError e) { log.error("File #1: " + inputFiles.get(0));
final VCFFileReader in = new VCFFileReader(f, false); try { dict.assertSameDictionary(in.getFileHeader().getSequenceDictionary()); } catch (final AssertionError e) { log.error("File #1: " + inputFiles.get(0));
@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())); }
@Test(dataProvider = "VCFCompData") public void testFromVCF(final Path vcf, final Path compInterval, final boolean invertVCF) { final IntervalList compList = IntervalList.fromPath(compInterval); final IntervalList list = invertVCF ? IntervalList.invert(VCFFileReader.toIntervalList(vcf)) : VCFFileReader.toIntervalList(vcf); compList.getHeader().getSequenceDictionary().assertSameDictionary(list.getHeader().getSequenceDictionary()); final Collection<Interval> intervals = CollectionUtil.makeCollection(list.iterator()); final Collection<Interval> compIntervals = CollectionUtil.makeCollection(compList.iterator()); //assert that the intervals correspond Assert.assertEquals(intervals, compIntervals); final List<String> intervalNames = new LinkedList<>(); final List<String> compIntervalNames = new LinkedList<>(); for (final Interval interval : intervals) { intervalNames.add(interval.getName()); } for (final Interval interval : compIntervals) { compIntervalNames.add(interval.getName()); } //assert that the names match Assert.assertEquals(intervalNames, compIntervalNames); }
@Test(dataProvider = "VCFCompData") public void testFromVCFWithPath(final Path vcf, final Path compInterval, final boolean invertVCF) { final IntervalList compList = IntervalList.fromPath(compInterval); final IntervalList list = invertVCF ? IntervalList.invert(VCFFileReader.toIntervalList(vcf)) : VCFFileReader.toIntervalList(vcf); compList.getHeader().getSequenceDictionary().assertSameDictionary(list.getHeader().getSequenceDictionary()); final Collection<Interval> intervals = CollectionUtil.makeCollection(list.iterator()); final Collection<Interval> compIntervals = CollectionUtil.makeCollection(compList.iterator()); //assert that the intervals correspond Assert.assertEquals(intervals, compIntervals); final List<String> intervalNames = new LinkedList<>(); final List<String> compIntervalNames = new LinkedList<>(); for (final Interval interval : intervals) { intervalNames.add(interval.getName()); } for (final Interval interval : compIntervals) { compIntervalNames.add(interval.getName()); } //assert that the names match Assert.assertEquals(intervalNames, compIntervalNames); }
sequenceDictionary.assertSameDictionary(sam.getFileHeader().getSequenceDictionary());
sequenceDictionary.assertSameDictionary(sam.getFileHeader().getSequenceDictionary());