/** * Validate and build the <code>VariantContextWriter</code>. * * @return the <code>VariantContextWriter</code> as specified by previous method calls. * @throws RuntimeIOException if the writer is configured to write to a file, and the corresponding path does not exist. * @throws IllegalArgumentException if no output file or stream is specified. * @throws IllegalArgumentException if <code>Options.INDEX_ON_THE_FLY</code> is specified and no reference dictionary is provided. * @throws IllegalArgumentException if <code>Options.INDEX_ON_THE_FLY</code> is specified and a stream output is specified. */ public VariantContextWriter build() { return build(EMPTY_OPEN_OPTION_ARRAY); }
/** * Validate and build the <code>VariantContextWriter</code>. * * @return the <code>VariantContextWriter</code> as specified by previous method calls. * @throws RuntimeIOException if the writer is configured to write to a file, and the corresponding path does not exist. * @throws IllegalArgumentException if no output file or stream is specified. * @throws IllegalArgumentException if <code>Options.INDEX_ON_THE_FLY</code> is specified and no reference dictionary is provided. * @throws IllegalArgumentException if <code>Options.INDEX_ON_THE_FLY</code> is specified and a stream output is specified. */ public VariantContextWriter build() { return build(EMPTY_OPEN_OPTION_ARRAY); }
protected VariantContextWriter createVariantContextWriter(Configuration conf, OutputStream out) { return new VariantContextWriterBuilder().clearOptions() .setOutputStream(out).build(); }
protected VariantContextWriter createVariantContextWriter(Configuration conf, OutputStream out) { return new VariantContextWriterBuilder().clearOptions() .setOutputStream(out).build(); }
@Test public void testAsync() { final VariantContextWriterBuilder builder = new VariantContextWriterBuilder() .setReferenceDictionary(dictionary) .setOutputFile(vcf); VariantContextWriter writer = builder.build(); Assert.assertEquals(writer instanceof AsyncVariantContextWriter, Defaults.USE_ASYNC_IO_WRITE_FOR_TRIBBLE, "testAsync default"); writer = builder.setOption(Options.USE_ASYNC_IO).build(); Assert.assertTrue(writer instanceof AsyncVariantContextWriter, "testAsync option=set"); writer = builder.unsetOption(Options.USE_ASYNC_IO).build(); Assert.assertFalse(writer instanceof AsyncVariantContextWriter, "testAsync option=unset"); }
protected VariantContextWriter createVariantContextWriter(Configuration conf, OutputStream out) { return new VariantContextWriterBuilder().clearOptions() .setOption(Options.FORCE_BCF) .setOutputBCFStream(out).build(); }
protected VariantContextWriter createVariantContextWriter(Configuration conf, OutputStream out) { return new VariantContextWriterBuilder().clearOptions() .setOption(Options.FORCE_BCF) .setOutputBCFStream(out).build(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testUnsupportedDefaultIndexOnTheFlyForStreaming() { new VariantContextWriterBuilder() .setReferenceDictionary(dictionary) .setOutputStream(new ByteArrayOutputStream()) .build(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testInvalidImplicitFileType() { new VariantContextWriterBuilder() .setReferenceDictionary(dictionary) .setOutputFile("test.bam") .build(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testRefDictRequiredForVCFIndexOnTheFly() { new VariantContextWriterBuilder() .setOutputFile(vcf) .setOption(Options.INDEX_ON_THE_FLY) .build(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testRefDictRequiredForBCFIndexOnTheFly() { new VariantContextWriterBuilder() .setOutputFile(bcf) .setOption(Options.INDEX_ON_THE_FLY) .build(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testInvalidSetFileTypeForStream() { new VariantContextWriterBuilder() .setReferenceDictionary(dictionary) .setOutputStream(new ByteArrayOutputStream()) .setOutputFileType(VariantContextWriterBuilder.OutputType.VCF) .build(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testUnsupportedIndexOnTheFlyForStreaming() { new VariantContextWriterBuilder() .setReferenceDictionary(dictionary) .setOutputStream(new ByteArrayOutputStream()) .setOption(Options.INDEX_ON_THE_FLY) .build(); }
private void init( OutputStream output, VCFHeader header, boolean writeHeader) throws IOException { final StoppableOutputStream stopOut = new StoppableOutputStream(!writeHeader, output); writer = new VariantContextWriterBuilder().clearOptions() .setOutputStream(stopOut).build(); writer.writeHeader(header); stopOut.stopped = false; setInputHeader(header); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testSetInvalidFileType() { new VariantContextWriterBuilder() .setReferenceDictionary(dictionary) .setOutputFile("test.bam") .setOutputFileType(VariantContextWriterBuilder.OutputType.VCF_STREAM) .build(); }
@Test public void testStdOut() { final VariantContextWriter writer = new VariantContextWriterBuilder().setOutputFile("/dev/stdout").clearOptions().build(); OutputStream s = ((VCFWriter) writer).getOutputStream(); Assert.assertNotNull(((VCFWriter) writer).getOutputStream()); Assert.assertNotEquals(((VCFWriter) writer).getStreamName(), IndexingVariantContextWriter.DEFAULT_READER_NAME); }
private VariantContextWriter getWriter() { SAMSequenceDictionary seqDict = new SAMSequenceDictionary(); EnumSet<Options> options = VariantContextWriterBuilder.DEFAULT_OPTIONS; options.add(Options.ALLOW_MISSING_FIELDS_IN_HEADER); VariantContextWriterBuilder builder = new VariantContextWriterBuilder() .setReferenceDictionary(seqDict) .setOptions(options); VariantContextWriter writer = builder.setOutputFile(outFile).build(); return writer; }
@Override public VariantContextWriter makeWriter(final File file, final EnumSet<Options> baseOptions) { return new VariantContextWriterBuilder() .setOutputFile(file) .setReferenceDictionary(dictionary) .setOptions(baseOptions) .build(); }
@Override public VariantContextWriter makeWriter(final File file, final EnumSet<Options> baseOptions) { return new VariantContextWriterBuilder() .setOutputFile(file) .setReferenceDictionary(dictionary) .setOptions(baseOptions) .build(); }
private void innerWriteToFifo(String pathToFifo) { // Do not enable INDEX_OF_THE_FLY because that is not compatible with writing to a pipe. final VariantContextWriterBuilder builder = new VariantContextWriterBuilder() .clearOptions() .setReferenceDictionary(dictionary); Path vcfPath = Paths.get(pathToFifo); VariantContextWriter writer = builder.setOutputPath(vcfPath).build(); writer.writeHeader(new VCFHeader()); writer.close(); }