private static boolean outputIsStdout(final Object out) { if ( out == null ) { return false; } else if ( out instanceof SAMFileWriterStub ) { return ((SAMFileWriterStub)out).getOutputStream() != System.out; } else if ( out instanceof VariantContextWriterStub ) { return ((VariantContextWriterStub)out).getOutputStream() == System.out; } else if ( out instanceof OutputStreamStub ) { return ((OutputStreamStub)out).getOutputStream() == System.out; } return false; }
/** * Constructs an object which will write directly into the output file provided by the stub. * Intentionally delaying the writing of the header -- this should be filled in by the walker. * * Respecs the isCompressed() request in stub, so if isCompressed() is true then this * will create a storage output that dumps output to a BlockCompressedOutputStream. * * @param stub Stub to use when constructing the output file. */ public VariantContextWriterStorage(VariantContextWriterStub stub) { if ( stub.getOutputFile() != null ) { this.file = stub.getOutputFile(); writer = vcfWriterToFile(stub,stub.getOutputFile(),true,true); } else if ( stub.getOutputStream() != null ) { this.file = null; this.stream = stub.getOutputStream(); writer = new VariantContextWriterBuilder() .setOutputVCFStream(stream) .setReferenceDictionary(stub.getMasterSequenceDictionary()) .setOptions(stub.getWriterOptions(false)) .build(); } else throw new ReviewedGATKException("Unable to create target to which to write; storage was provided with neither a file nor a stream."); }