/** * Gets a string representation of this object. * @return a string representation of this object. */ @Override public String toString() { return (getOutputFile() == null) ? "(Stream)" : getOutputFile().getAbsolutePath(); }
/** * 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); }
/** * 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 }
/** * 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."); }