Java Code Examples for htsjdk.samtools.util.IOUtil#assertFilesEqual()
The following examples show how to use
htsjdk.samtools.util.IOUtil#assertFilesEqual() .
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: VcfToAdpcTest.java From picard with MIT License | 6 votes |
@Test(dataProvider = "vcfToAdpcBinCombinations") public void testVcfToAdpc(final List<File> vcfs, final File expectedAdpcBinFile, final File expectedSamplesFile, final File expectedNumMarkersFile) throws IOException { final File output = File.createTempFile("testIlluminaAdpcFileWriter.", ".adpc.bin"); output.deleteOnExit(); final File samplesFile = File.createTempFile("testIlluminaAdpcFileWriter.", ".samples.txt"); samplesFile.deleteOnExit(); final File numMarkersFile = File.createTempFile("testIlluminaAdpcFileWriter.", ".num_markers.txt"); samplesFile.deleteOnExit(); final VcfToAdpc vcfToAdpc = new VcfToAdpc(); vcfToAdpc.VCF = vcfs; vcfToAdpc.OUTPUT = output; vcfToAdpc.SAMPLES_FILE = samplesFile; vcfToAdpc.NUM_MARKERS_FILE = numMarkersFile; Assert.assertEquals(vcfToAdpc.instanceMain(new String[0]), 0); IOUtil.assertFilesEqual(expectedAdpcBinFile, output); IOUtil.assertFilesEqual(expectedSamplesFile, samplesFile); IOUtil.assertFilesEqual(expectedNumMarkersFile, numMarkersFile); }
Example 2
Source File: IlluminaBasecallsToFastqTest.java From picard with MIT License | 6 votes |
@Test public void testNonBarcoded() throws Exception { final String suffix = ".1.fastq"; final File outputFastq1 = File.createTempFile("nonBarcoded.", suffix); outputFastq1.deleteOnExit(); final String outputPrefix = outputFastq1.getAbsolutePath().substring(0, outputFastq1.getAbsolutePath().length() - suffix.length()); final File outputFastq2 = new File(outputPrefix + ".2.fastq"); outputFastq2.deleteOnExit(); final int lane = 1; runPicardCommandLine(new String[]{ "BASECALLS_DIR=" + BASECALLS_DIR, "LANE=" + lane, "READ_STRUCTURE=25T8B25T", "OUTPUT_PREFIX=" + outputPrefix, "RUN_BARCODE=HiMom", "MACHINE_NAME=machine1", "FLOWCELL_BARCODE=abcdeACXX", "MAX_READS_IN_RAM_PER_TILE=100" //force spill to disk to test encode/decode }); IOUtil.assertFilesEqual(outputFastq1, new File(TEST_DATA_DIR, "nonBarcoded.1.fastq")); IOUtil.assertFilesEqual(outputFastq2, new File(TEST_DATA_DIR, "nonBarcoded.2.fastq")); }
Example 3
Source File: IlluminaAdpcFileWriterTest.java From picard with MIT License | 6 votes |
@Test public void testWriteIlluminaAdpcFile() throws Exception { final File output = File.createTempFile("testIlluminaAdpcFileWriter.", ".adpc.bin"); output.deleteOnExit(); try (final IlluminaAdpcFileWriter adpcFileWriter = new IlluminaAdpcFileWriter(output)) { final List<IlluminaAdpcFileWriter.Record> adpcRecordList = new ArrayList<>(); adpcRecordList.add(new IlluminaAdpcFileWriter.Record(11352, 405, 1.444f, 0.088f, 0.705f, IlluminaGenotype.AA)); adpcRecordList.add(new IlluminaAdpcFileWriter.Record(458, 2743, 0.043f, 0.852f, 0.818f, IlluminaGenotype.BB)); adpcRecordList.add(new IlluminaAdpcFileWriter.Record(7548, 303, 1.072f, 0.076f, 0.0f, IlluminaGenotype.NN)); adpcRecordList.add(new IlluminaAdpcFileWriter.Record(7414, 2158, 0.805f, 0.597f, 0.881f, IlluminaGenotype.AB)); adpcRecordList.add(new IlluminaAdpcFileWriter.Record(222, 215, 0.0f, 0.0f, 0.91f, IlluminaGenotype.NN)); adpcRecordList.add(new IlluminaAdpcFileWriter.Record(232, 246, null, null, 0.926f, IlluminaGenotype.NN)); adpcFileWriter.write(adpcRecordList); } IOUtil.assertFilesEqual(TEST_EXPECTED_ADPC_BIN_FILE, output); }
Example 4
Source File: IlluminaLaneMetricsCollectorTest.java From picard with MIT License | 6 votes |
@Test(dataProvider = "testLaneMetrics") public void testWriteLaneMetrics(final String testRun) throws Exception { for (final boolean useReadStructure : Arrays.asList(true, false)) { final CollectIlluminaLaneMetrics clp = new CollectIlluminaLaneMetrics(); clp.OUTPUT_DIRECTORY = IOUtil.createTempDir("illuminaLaneMetricsCollectorTest", null); clp.RUN_DIRECTORY = new File(TEST_DIRECTORY, testRun); clp.OUTPUT_PREFIX = "test"; if (useReadStructure) clp.READ_STRUCTURE = new ReadStructure("101T8B101T"); clp.doWork(); final File laneMetricsFile = buildOutputFile(clp.OUTPUT_DIRECTORY, clp.OUTPUT_PREFIX, IlluminaLaneMetrics.getExtension()); final File canonicalOutputFile = buildOutputFile(TEST_DIRECTORY, testRun, IlluminaLaneMetrics.getExtension()); IOUtil.assertFilesEqual(canonicalOutputFile, laneMetricsFile); IOUtil.deleteDirectoryTree(clp.OUTPUT_DIRECTORY); } }
Example 5
Source File: IlluminaLaneMetricsCollectorTest.java From picard with MIT License | 6 votes |
@Test(dataProvider = "testCollectIlluminaLaneMetrics") public void testCollectIlluminaLaneMetrics(final String testRun, final ReadStructure readStructure, final boolean isNovaSeq) throws Exception { for (final boolean useReadStructure : Arrays.asList(true, false)) { final File runDirectory = new File(TILE_RUN_DIRECTORY, testRun); final CollectIlluminaLaneMetrics clp = new CollectIlluminaLaneMetrics(); clp.OUTPUT_DIRECTORY = IOUtil.createTempDir("illuminaLaneMetricsCollectorTest", null); clp.RUN_DIRECTORY = runDirectory; clp.OUTPUT_PREFIX = "test"; clp.IS_NOVASEQ = isNovaSeq; if (useReadStructure) clp.READ_STRUCTURE = readStructure; clp.doWork(); final File phasingMetricsFile = buildOutputFile(clp.OUTPUT_DIRECTORY, clp.OUTPUT_PREFIX, IlluminaPhasingMetrics.getExtension()); final File canonicalPhasingFile = buildOutputFile(runDirectory, testRun, IlluminaPhasingMetrics.getExtension()); IOUtil.assertFilesEqual(canonicalPhasingFile, phasingMetricsFile); final File laneMetricsFile = buildOutputFile(clp.OUTPUT_DIRECTORY, clp.OUTPUT_PREFIX, IlluminaLaneMetrics.getExtension()); final File canonicalLaneFile = buildOutputFile(runDirectory, testRun, IlluminaLaneMetrics.getExtension()); IOUtil.assertFilesEqual(canonicalLaneFile, laneMetricsFile); IOUtil.deleteDirectoryTree(clp.OUTPUT_DIRECTORY); } }
Example 6
Source File: IlluminaLaneMetricsCollectorTest.java From picard with MIT License | 6 votes |
/** Ensures that an exception is thrown when we encounter a tile without phasing/pre-phasing metrics. */ @Test(expectedExceptions = PicardException.class) public void testMissingPhasingValuesStrict() { final ReadStructure readStructure = new ReadStructure("151T8B8B151T"); for (final boolean useReadStructure : Arrays.asList(true, false)) { final File runDirectory = TEST_MISSING_PHASING_DIRECTORY; final CollectIlluminaLaneMetrics clp = new CollectIlluminaLaneMetrics(); clp.OUTPUT_DIRECTORY = IOUtil.createTempDir("illuminaLaneMetricsCollectorTest", null); clp.RUN_DIRECTORY = runDirectory; clp.OUTPUT_PREFIX = "test"; clp.VALIDATION_STRINGENCY = ValidationStringency.STRICT; if (useReadStructure) clp.READ_STRUCTURE = readStructure; clp.doWork(); final File phasingMetricsFile = buildOutputFile(clp.OUTPUT_DIRECTORY, clp.OUTPUT_PREFIX, IlluminaPhasingMetrics.getExtension()); final File canonicalPhasingFile = buildOutputFile(runDirectory, runDirectory.getName(), IlluminaPhasingMetrics.getExtension()); IOUtil.assertFilesEqual(canonicalPhasingFile, phasingMetricsFile); final File laneMetricsFile = buildOutputFile(clp.OUTPUT_DIRECTORY, clp.OUTPUT_PREFIX, IlluminaLaneMetrics.getExtension()); final File canonicalLaneFile = buildOutputFile(runDirectory, runDirectory.getName(), IlluminaLaneMetrics.getExtension()); IOUtil.assertFilesEqual(canonicalLaneFile, laneMetricsFile); IOUtil.deleteDirectoryTree(clp.OUTPUT_DIRECTORY); } }
Example 7
Source File: IlluminaLaneMetricsCollectorTest.java From picard with MIT License | 6 votes |
/** Silently continue if we encounter a tile without phasing/pre-phasing metrics. */ @Test public void testMissingPhasingValuesSilent() throws IOException { final ReadStructure readStructure = new ReadStructure("151T8B8B151T"); for (final boolean useReadStructure : Arrays.asList(true, false)) { final File runDirectory = TEST_MISSING_PHASING_DIRECTORY; final CollectIlluminaLaneMetrics clp = new CollectIlluminaLaneMetrics(); clp.OUTPUT_DIRECTORY = IOUtil.createTempDir("illuminaLaneMetricsCollectorTest", null); clp.RUN_DIRECTORY = runDirectory; clp.OUTPUT_PREFIX = "test"; clp.VALIDATION_STRINGENCY = ValidationStringency.SILENT; if (useReadStructure) clp.READ_STRUCTURE = readStructure; clp.doWork(); final File phasingMetricsFile = buildOutputFile(clp.OUTPUT_DIRECTORY, clp.OUTPUT_PREFIX, IlluminaPhasingMetrics.getExtension()); final File canonicalPhasingFile = buildOutputFile(runDirectory, runDirectory.getName(), IlluminaPhasingMetrics.getExtension()); IOUtil.assertFilesEqual(canonicalPhasingFile, phasingMetricsFile); final File laneMetricsFile = buildOutputFile(clp.OUTPUT_DIRECTORY, clp.OUTPUT_PREFIX, IlluminaLaneMetrics.getExtension()); final File canonicalLaneFile = buildOutputFile(runDirectory, runDirectory.getName(), IlluminaLaneMetrics.getExtension()); IOUtil.assertFilesEqual(canonicalLaneFile, laneMetricsFile); IOUtil.deleteDirectoryTree(clp.OUTPUT_DIRECTORY); } }
Example 8
Source File: MergeBamAlignmentTest.java From picard with MIT License | 6 votes |
@Test(dataProvider = "UnmappedReadStrategies") public void testContaminationDetection(final AbstractAlignmentMerger.UnmappingReadStrategy strategy, final String basename) throws IOException { final File unmappedSam = new File(TEST_DATA_DIR, "contam.unmapped.sam"); final File alignedSam = new File(TEST_DATA_DIR, "contam.aligned.sam"); final File expectedSam = new File(TEST_DATA_DIR, basename); final File refFasta = new File(TEST_DATA_DIR, "cliptest.fasta"); final File mergedSam = File.createTempFile("merged", ".sam"); mergedSam.deleteOnExit(); doMergeAlignment(unmappedSam, Collections.singletonList(alignedSam), null, null, null, null, false, true, false, 1, "0", "1.0", "align!", "myAligner", true, refFasta, mergedSam, null, null, null, null, true, SAMFileHeader.SortOrder.coordinate, strategy); if (strategy == null || strategy.isKeepValid()) { assertSamValid(mergedSam); } IOUtil.assertFilesEqual(expectedSam, mergedSam); }
Example 9
Source File: MergeBamAlignmentTest.java From picard with MIT License | 6 votes |
@Test public void testMergeHeaderMappedAndReference() throws IOException { final File unmappedSam = new File(TEST_DATA_DIR, "specialHeader.unmapped.sam"); final File alignedSam = new File(TEST_DATA_DIR, "specialHeader.aligned.sam"); final File expectedSam = new File(TEST_DATA_DIR, "specialHeader.expected.sam"); final File refFasta = new File(TEST_DATA_DIR, "specialHeader.fasta"); final File mergedSam = File.createTempFile("merged", ".sam"); mergedSam.deleteOnExit(); doMergeAlignment(unmappedSam, Collections.singletonList(alignedSam), null, null, null, null, false, true, false, 1, "0", "1.0", "align!", "myAligner", true, refFasta, mergedSam, null, null, null, null, true, null); assertSamValid(mergedSam); IOUtil.assertFilesEqual(expectedSam, mergedSam); }
Example 10
Source File: CreateHadoopBamSplittingIndexIntegrationTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test(dataProvider = "indexable") public void testCreateSplittingIndex(final File bam) throws IOException { final File splittingIndex = getTempIndexFile(); splittingIndex.delete(); Assert.assertFalse(splittingIndex.exists()); final ArgumentsBuilder args = getInputAndOutputArgs(bam, splittingIndex) .addRaw("--"+ CreateHadoopBamSplittingIndex.SPLITTING_INDEX_GRANULARITY_LONG_NAME).addRaw("1"); this.runCommandLine(args); assertIndexIsNotEmpty(splittingIndex); //checked in index created with // ./gatk CreateHadoopBamSplittingIndex --input <filename> --splitting-index-granularity 1 final File expectedSplittingIndex = new File(bam.toPath() + FileExtensions.SBI); IOUtil.assertFilesEqual(splittingIndex, expectedSplittingIndex); }
Example 11
Source File: MergeBamAlignmentTest.java From picard with MIT License | 6 votes |
@Test(dataProvider = "brokenAlignedFiles", expectedExceptions = IllegalArgumentException.class) public void testHeaderFromMappedBreaks(final String filename) throws IOException { final File unmappedSam = new File(TEST_DATA_DIR, "specialHeader.unmapped.sam"); final File alignedSam = new File(TEST_DATA_DIR, filename); final File expectedSam = new File(TEST_DATA_DIR, "specialHeader.expected.sam"); final File refFasta = new File(TEST_DATA_DIR, "specialHeader.fasta"); final File mergedSam = File.createTempFile("merged", ".sam"); mergedSam.deleteOnExit(); doMergeAlignment(unmappedSam, Collections.singletonList(alignedSam), null, null, null, null, false, true, false, 1, "0", "1.0", "align!", "myAligner", true, refFasta, mergedSam, null, null, null, null, true, null); assertSamValid(mergedSam); IOUtil.assertFilesEqual(expectedSam, mergedSam); }
Example 12
Source File: CreateHadoopBamSplittingIndexIntegrationTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testBothPathsProduceSameIndex() throws IOException { final File splittingIndexOnly = getTempIndexFile(); final ArgumentsBuilder splittingIndexOnlyArgs = getInputAndOutputArgs(SORTED_BAM, splittingIndexOnly); this.runCommandLine(splittingIndexOnlyArgs); assertIndexIsNotEmpty(splittingIndexOnly); final File splittingIndexWithBai = getTempIndexFile(); final ArgumentsBuilder splittingAndBaiArgs = getInputAndOutputArgs(SORTED_BAM, splittingIndexWithBai) .addRaw("--"+ CreateHadoopBamSplittingIndex.CREATE_BAI_LONG_NAME); this.runCommandLine(splittingAndBaiArgs); assertIndexIsNotEmpty(splittingIndexWithBai); IOUtil.assertFilesEqual(splittingIndexOnly, splittingIndexWithBai); }
Example 13
Source File: BucketUtilsUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test(groups={"bucket"}) public void testCopyAndDeleteGCS() throws IOException { final String src = publicTestDir + "empty.vcf"; File dest = createTempFile("copy-empty", ".vcf"); final String intermediate = BucketUtils.randomRemotePath(getGCPTestStaging(), "test-copy-empty", ".vcf"); Assert.assertTrue(BucketUtils.isGcsUrl(intermediate), "!BucketUtils.isCloudStorageUrl(intermediate)"); BucketUtils.copyFile(src, intermediate); BucketUtils.copyFile(intermediate, dest.getPath()); IOUtil.assertFilesEqual(new File(src), dest); Assert.assertTrue(BucketUtils.fileExists(intermediate)); BucketUtils.deleteFile(intermediate); Assert.assertFalse(BucketUtils.fileExists(intermediate)); }
Example 14
Source File: BucketUtilsUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testCopyLocal() throws IOException { final String src = publicTestDir+"empty.vcf"; File dest = createTempFile("copy-empty",".vcf"); BucketUtils.copyFile(src, dest.getPath()); IOUtil.assertFilesEqual(new File(src), dest); }
Example 15
Source File: BedToIntervalListTest.java From picard with MIT License | 5 votes |
private void doTest(final String inputBed, final String header) throws IOException, SAMException { final File outputFile = File.createTempFile("bed_to_interval_list_test.", ".interval_list"); outputFile.deleteOnExit(); final BedToIntervalList program = new BedToIntervalList(); final File inputBedFile = new File(TEST_DATA_DIR, inputBed); program.INPUT = inputBedFile; program.SEQUENCE_DICTIONARY = new File(TEST_DATA_DIR, header); program.OUTPUT = outputFile; program.UNIQUE = true; program.doWork(); // Assert they are equal IOUtil.assertFilesEqual(new File(inputBedFile.getAbsolutePath() + ".interval_list"), outputFile); }
Example 16
Source File: UpdateVcfSequenceDictionaryTest.java From picard with MIT License | 5 votes |
@Test public void testCaptureStdout() throws IOException { final File outputFile = File.createTempFile("UpdateVcfSequenceDictionaryTest.output.", ".vcf"); outputFile.deleteOnExit(); String[] command = { "/bin/bash", "-c", "java -Dpicard.useLegacyParser=false -classpath " + classPath + "picard.cmdline.PicardCommandLine " + "UpdateVcfSequenceDictionary " + "-I " + INPUT_FILE.getAbsolutePath() + " " + "-O /dev/stdout " + "-SD " + SAM_SEQUENCE_DICTIONARY_VCF.getAbsolutePath() }; try { ProcessBuilder processBuilder = new ProcessBuilder(command); processBuilder.inheritIO(); processBuilder.redirectOutput(outputFile); Process process = processBuilder.start(); Assert.assertEquals(process.waitFor(), 0); IOUtil.assertFilesEqual(SAM_SEQUENCE_DICTIONARY_VCF, outputFile); // A little extra checking. Assert.assertEquals(SAMSequenceDictionaryExtractor.extractDictionary(INPUT_FILE.toPath()).size(), 84); Assert.assertEquals(SAMSequenceDictionaryExtractor.extractDictionary(SAM_SEQUENCE_DICTIONARY_VCF.toPath()).size(), 82); Assert.assertEquals(SAMSequenceDictionaryExtractor.extractDictionary(outputFile.toPath()).size(), 82); } catch (Exception e) { Assert.fail("Failure executing UpdateVcfSequenceDictionary", e); } }
Example 17
Source File: MergeBamAlignmentTest.java From picard with MIT License | 5 votes |
@Test public void testMergeHeaderMappedAndReferenceWithUnmappedAsNamedStream() throws IOException, InterruptedException, NoSuchFieldException, IllegalAccessException { final File unmappedSam = new File(TEST_DATA_DIR, "specialHeader.unmapped.sam"); final File alignedSam = new File(TEST_DATA_DIR, "specialHeader.aligned.sam"); final File expectedSam = new File(TEST_DATA_DIR, "specialHeader.expected.sam"); final File refFasta = new File(TEST_DATA_DIR, "specialHeader.fasta"); final File mergedSam = File.createTempFile("merged", ".sam"); mergedSam.deleteOnExit(); FileInputStream stream = new FileInputStream(unmappedSam); // Ugliness required to read from a stream given as a string on the commandline. // Since the actual fd number is private inside FileDescriptor, need reflection // in order to pull it out. final Field fdField = FileDescriptor.class.getDeclaredField("fd"); fdField.setAccessible(true); final File inputStream = new File("/dev/fd/" + fdField.getInt(stream.getFD())); doMergeAlignment(inputStream, Collections.singletonList(alignedSam), null, null, null, null, false, true, false, 1, "0", "1.0", "align!", "myAligner", true, refFasta, mergedSam, null, null, null, null, true, null); assertSamValid(mergedSam); IOUtil.assertFilesEqual(expectedSam, mergedSam); }
Example 18
Source File: MergeBamAlignmentTest.java From picard with MIT License | 5 votes |
@Test public void testMergeHeaderMappedAndReferenceWithAlignedAsNamedStream() throws IOException, InterruptedException, NoSuchFieldException, IllegalAccessException { final File unmappedSam = new File(TEST_DATA_DIR, "specialHeader.unmapped.sam"); final File alignedSam = new File(TEST_DATA_DIR, "specialHeader.aligned.sam"); final File expectedSam = new File(TEST_DATA_DIR, "specialHeader.expected.sam"); final File refFasta = new File(TEST_DATA_DIR, "specialHeader.fasta"); final File mergedSam = File.createTempFile("merged", ".sam"); mergedSam.deleteOnExit(); FileInputStream stream = new FileInputStream(alignedSam); // Ugliness required to read from a stream given as a string on the commandline. // Since the actual fd number is private inside FileDescriptor, need reflection // in order to pull it out. final Field fdField = FileDescriptor.class.getDeclaredField("fd"); fdField.setAccessible(true); final File inputStream = new File("/dev/fd/" + fdField.getInt(stream.getFD())); doMergeAlignment(unmappedSam, Collections.singletonList(inputStream), null, null, null, null, false, true, false, 1, "0", "1.0", "align!", "myAligner", true, refFasta, mergedSam, null, null, null, null, true, null); assertSamValid(mergedSam); IOUtil.assertFilesEqual(expectedSam, mergedSam); }
Example 19
Source File: IlluminaBasecallsToFastqTest.java From picard with MIT License | 5 votes |
@Test public void testMultiplexWithIlluminaReadNameHeaders() throws Exception { final File outputDir = File.createTempFile("testMultiplexRH.", ".dir"); try { outputDir.delete(); outputDir.mkdir(); outputDir.deleteOnExit(); final String filePrefix = "testMultiplexRH"; final File outputPrefix = new File(outputDir, filePrefix); runPicardCommandLine(new String[]{ "BASECALLS_DIR=" + BASECALLS_DIR, "LANE=" + 1, "RUN_BARCODE=HiMom", "READ_STRUCTURE=" + "25T8B25T", "OUTPUT_PREFIX=" + outputPrefix.getAbsolutePath(), "MACHINE_NAME=machine1", "FLOWCELL_BARCODE=abcdeACXX", "READ_NAME_FORMAT=" + IlluminaBasecallsToFastq.ReadNameFormat.ILLUMINA, "MAX_READS_IN_RAM_PER_TILE=100" //force spill to disk to test encode/decode }); final String[] filenames = new String[]{ filePrefix + ".1.fastq", filePrefix + ".barcode_1.fastq" }; for (final String filename : filenames) { IOUtil.assertFilesEqual(new File(outputDir, filename), new File(TEST_DATA_DIR, filename)); } } finally { IOUtil.recursiveDelete(outputDir.toPath()); } }
Example 20
Source File: UpdateVcfSequenceDictionaryTest.java From picard with MIT License | 4 votes |
@Test(dataProvider = "OutputFiles") public void testUpdateVcfSequenceDictionary(final String outputFileName) throws IOException, NoSuchFieldException, IllegalAccessException { File outputFile = new File(outputFileName); outputFile.deleteOnExit(); final UpdateVcfSequenceDictionary updateVcfSequenceDictionary = new UpdateVcfSequenceDictionary(); updateVcfSequenceDictionary.INPUT = INPUT_FILE; updateVcfSequenceDictionary.SEQUENCE_DICTIONARY = SAM_SEQUENCE_DICTIONARY_VCF; if (outputFileName.equals(STD_OUT_NAME)) { final FileOutputStream stream = new FileOutputStream(STD_OUT_FILE); // Ugliness required to write to a stream given as a string on the commandline. // Since the actual fd number is private inside FileDescriptor, needs reflection // in order to pull it out. final Field fdField = FileDescriptor.class.getDeclaredField("fd"); fdField.setAccessible(true); updateVcfSequenceDictionary.OUTPUT = new File("/dev/fd/" + fdField.getInt(stream.getFD())); } else { updateVcfSequenceDictionary.OUTPUT = outputFile; } Assert.assertEquals(updateVcfSequenceDictionary.instanceMain(new String[0]), 0); if (outputFileName.equals(STD_OUT_NAME)) { outputFile = STD_OUT_FILE; } else if (outputFileName.endsWith(IOUtil.COMPRESSED_VCF_FILE_EXTENSION)) { // Output is a gzipped vcf, unzip it File unzippedOutputFile = new File(OUTPUT_DATA_PATH + ".out.vcf"); unzippedOutputFile.deleteOnExit(); unzipFile(outputFile, unzippedOutputFile); outputFile = unzippedOutputFile; } IOUtil.assertFilesEqual(SAM_SEQUENCE_DICTIONARY_VCF, outputFile); // A little extra checking. Assert.assertEquals(SAMSequenceDictionaryExtractor.extractDictionary(INPUT_FILE.toPath()).size(), 84); Assert.assertEquals(SAMSequenceDictionaryExtractor.extractDictionary(SAM_SEQUENCE_DICTIONARY_VCF.toPath()).size(), 82); Assert.assertEquals(SAMSequenceDictionaryExtractor.extractDictionary(outputFile.toPath()).size(), 82); }