/** * Should we also write a BCF file alongside our VCF file for testing * * TODO -- remove me when argument generateShadowBCF is removed * * @return */ public boolean alsoWriteBCFForTest() { return engine.getArguments().numberOfDataThreads == 1 && // only works single threaded ! isCompressed() && // for non-compressed outputs getOutputFile() != null && // that are going to disk engine.getArguments().generateShadowBCF; // and we actually want to do it }
public EnumSet<Options> getWriterOptions() { return getWriterOptions(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."); }
if ( allowCompressed && stub.isCompressed() ) stream = new BlockCompressedOutputStream(file); else final VariantContextWriterBuilder.OutputType fileOutputType = allowCompressed && stub.isCompressed() ? VariantContextWriterBuilder.OutputType.BLOCK_COMPRESSED_VCF : VariantContextWriterBuilder.OutputType.VCF; final EnumSet<Options> options = stub.getWriterOptions(indexOnTheFly); .setReferenceDictionary(stub.getMasterSequenceDictionary()) .setIndexCreator(stub.getIndexCreator()) .setOptions(options) .build(); if ( stub.alsoWriteBCFForTest() && ! ( options.contains(Options.FORCE_BCF) || file != null && (file.getName().endsWith(".bcf") || file.getName().endsWith(".bcf.gz")) ) ) { .setOutputFile(bcfFile) .setOutputFileType(VariantContextWriterBuilder.OutputType.BCF) .setReferenceDictionary(stub.getMasterSequenceDictionary()) .setOptions(options) .build();
/** * Gets a string representation of this object. * @return a string representation of this object. */ @Override public String toString() { return (getOutputFile() == null) ? "(Stream)" : getOutputFile().getAbsolutePath(); }
? new VariantContextWriterStub(engine, writerFile, argumentSources) : new VariantContextWriterStub(engine, defaultOutputStream, argumentSources); stub.setCompressed(isCompressed(writerFileName == null ? null: writerFileName.asString()));
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 redirect into a different file. * * Note that this function does not respect the isCompressed() request from the stub, in order * to ensure that tmp. files can be read back in by the Tribble system, and merged with the mergeInto function. * * @param stub Stub to use when synthesizing file / header info. * @param tempFile File into which to direct the output data. */ public VariantContextWriterStorage(VariantContextWriterStub stub, File tempFile) { //logger.debug("Creating temporary output file " + tempFile.getAbsolutePath() + " for VariantContext output."); this.file = tempFile; this.writer = vcfWriterToFile(stub, file, false, false); writer.writeHeader(stub.getVCFHeader()); }
@Override public Object createTypeDefault(ParsingEngine parsingEngine, ArgumentSource source, Type type) { if(source.isRequired() || !source.defaultsToStdout()) throw new ReviewedGATKException("BUG: tried to create type default for argument type descriptor that can't support a type default."); VariantContextWriterStub stub = new VariantContextWriterStub(engine, defaultOutputStream, argumentSources); engine.addOutput(stub); return stub; }
/** * Is writing to an output GVCF file? * * @return true if the VCF output file has a .g.vcf or .g.vcf.gz extension or if no output file */ private boolean isGVCF() { final File file = ((VariantContextWriterStub) vcfWriter).getOutputFile(); if ( file == null ){ return true; } else { final String fileName = file.getName(); return ( fileName.endsWith("." + GATKVCFUtils.GVCF_EXT) || fileName.endsWith("." + GATKVCFUtils.GVCF_GZ_EXT) ); } } }
public EnumSet<Options> getWriterOptions(boolean indexOnTheFly) { final List<Options> options = new ArrayList<>(); if ( doNotWriteGenotypes ) options.add(Options.DO_NOT_WRITE_GENOTYPES); if ( engine.lenientVCFProcessing() ) options.add(Options.ALLOW_MISSING_FIELDS_IN_HEADER); if ( indexOnTheFly) options.add(Options.INDEX_ON_THE_FLY); if ( writeFullFormatField ) options.add(Options.WRITE_FULL_FORMAT_FIELD); final File file = getOutputFile(); if ( forceBCF || (file != null && options.contains(Options.FORCE_BCF) || file != null && (file.getName().endsWith(".bcf") || file.getName().endsWith(".bcf.gz"))) ) options.add(Options.FORCE_BCF); return options.isEmpty() ? EnumSet.noneOf(Options.class) : EnumSet.copyOf(options); }
sitesOnlyVCF = ((VariantContextWriterStub)vcfWriter).getWriterOptions().contains(Options.DO_NOT_WRITE_GENOTYPES); if ( sitesOnlyVCF ) logger.info("Pre-stripping genotypes for performance"); } else