本文整理汇总了Java中htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder.setCreateMD5方法的典型用法代码示例。如果您正苦于以下问题:Java VariantContextWriterBuilder.setCreateMD5方法的具体用法?Java VariantContextWriterBuilder.setCreateMD5怎么用?Java VariantContextWriterBuilder.setCreateMD5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder
的用法示例。
在下文中一共展示了VariantContextWriterBuilder.setCreateMD5方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVCFWriter
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder; //导入方法依赖的package包/类
public static VariantContextWriter createVCFWriter(final File outFile,VCFHeader header) {
Utils.nonNull(outFile);
VariantContextWriterBuilder vcWriterBuilder = new VariantContextWriterBuilder().clearOptions()
.setOutputFile(outFile);
if (lenientVCFProcessing) {
vcWriterBuilder = vcWriterBuilder.setOption(Options.ALLOW_MISSING_FIELDS_IN_HEADER);
}
if (createOutputVariantIndex && null != header) {
vcWriterBuilder = vcWriterBuilder.setOption(Options.INDEX_ON_THE_FLY);
}
if (createOutputVariantMD5) {
vcWriterBuilder.setCreateMD5();
}
if (null != header) {
vcWriterBuilder = vcWriterBuilder.setReferenceDictionary(header.getSequenceDictionary());
}
return vcWriterBuilder.build();
}
示例2: createVariantContextWriter
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder; //导入方法依赖的package包/类
/**
* create a VariantContextWriter
* @param OUT output file or null to stdout
* @return
* @throws IOException
*/
public static VariantContextWriter createVariantContextWriter(final File OUT) throws IOException
{
if(OUT==null)
{
return createVariantContextWriterToStdout();
}
else
{
IOUtil.assertFileIsWritable(OUT);
final VariantContextWriterBuilder vcwb=new VariantContextWriterBuilder();
vcwb.setCreateMD5(false);
vcwb.setReferenceDictionary(null);
vcwb.clearOptions();
vcwb.setOutputFile(OUT);
return new VariantContextWriterDelayedFlush(vcwb.build());
}
}
示例3: createVCFWriter
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder; //导入方法依赖的package包/类
/**
* Creates a VariantContextWriter whose outputFile type is based on the extension of the output file name.
* The default options set by VariantContextWriter are cleared before applying ALLOW_MISSING_FIELDS_IN_HEADER (if
* <code>lenientProcessing</code> is set), followed by the set of options specified by any <code>options</code> args.
*
* @param outFile output File for this writer. May not be null.
* @param referenceDictionary required if on the fly indexing is set, otherwise can be null
* @param createMD5 true if an md5 file should be created
* @param options variable length list of additional Options to be set for this writer
* @returns VariantContextWriter must be closed by the caller
*/
public static VariantContextWriter createVCFWriter(
final File outFile,
final SAMSequenceDictionary referenceDictionary,
final boolean createMD5,
final Options... options)
{
Utils.nonNull(outFile);
VariantContextWriterBuilder vcWriterBuilder =
new VariantContextWriterBuilder().clearOptions().setOutputFile(outFile);
if (VariantContextWriterBuilder.OutputType.UNSPECIFIED == getVariantFileTypeFromExtension(outFile)) {
// the only way the user has to specify an output type is by file extension, and htsjdk
// throws if it can't map the file extension to a known vcf type, so fallback to a default
// of VCF
logger.warn(String.format(
"Can't determine output variant file format from output file extension \"%s\". Defaulting to VCF.",
FilenameUtils.getExtension(outFile.getPath())));
vcWriterBuilder = vcWriterBuilder.setOutputFileType(VariantContextWriterBuilder.OutputType.VCF);
}
if (createMD5) {
vcWriterBuilder.setCreateMD5();
}
if (null != referenceDictionary) {
vcWriterBuilder = vcWriterBuilder.setReferenceDictionary(referenceDictionary);
}
for (Options opt : options) {
vcWriterBuilder = vcWriterBuilder.setOption(opt);
}
return vcWriterBuilder.build();
}
示例4: open
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder; //导入方法依赖的package包/类
@Override
public void open(final ExecutionContext executionContext) throws ItemStreamException {
if(this.filenameFactory==null) throw new ItemStreamException("resource is not defined");
try {
final String filename = this.filenameFactory.apply(executionContext);
if(StringUtil.isBlank(filename)) throw new ItemStreamException("No output file defined.");
if(LOG.isInfoEnabled()) LOG.info("Opening "+filename+" for writing");
if(!Arrays.stream(IOUtil.VCF_EXTENSIONS).anyMatch(SUFF->filename.endsWith(SUFF)))
{
throw new ItemStreamException("Bad extension for a VCF file:" + filename);
}
final File vcfFile = new File(filename);
VCFHeader header= SpringBatchUtils.getVcfHeader(executionContext);
final VariantContextWriterBuilder vcwb = new VariantContextWriterBuilder();
vcwb.setOutputFile(vcfFile);
if(this.reference!=null)
{
final SAMSequenceDictionary dic=SAMSequenceDictionaryExtractor.extractDictionary(this.reference);
vcwb.setReferenceDictionary(dic);
if(header.getSequenceDictionary()==null) {
header = new VCFHeader(header);
header.setSequenceDictionary(dic);
}
}
else
{
vcwb.setReferenceDictionary(header.getSequenceDictionary());
}
vcwb.setCreateMD5(this.createMD5);
this.vcw = vcwb.build();
this.vcw.writeHeader(header);
}
catch(final Exception err)
{
priv_close();
throw new ItemStreamException(err);
}
}
示例5: createVariantContextWriterToOutputStream
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder; //导入方法依赖的package包/类
public static VariantContextWriter createVariantContextWriterToOutputStream(final OutputStream ostream)
{
final VariantContextWriterBuilder vcwb=new VariantContextWriterBuilder();
vcwb.setCreateMD5(false);
vcwb.setOutputStream(ostream);
vcwb.setReferenceDictionary(null);
vcwb.clearOptions();
return new VariantContextWriterDelayedFlush(vcwb.build());
}
示例6: writeHeader
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder; //导入方法依赖的package包/类
@Override
public void writeHeader(final VCFHeader header) {
if(this.delegate!=null) {
throw new IllegalStateException("WriteHeader called twice");
}
SAMSequenceDictionary dict=config.dict;
if(config.createIndex && dict==null) {
dict= header.getSequenceDictionary();
}
final VariantContextWriterBuilder builder = this.config.createVariantContextWriterBuilder();
builder.unsetOption(Options.INDEX_ON_THE_FLY);
if(dict!=null) {
builder.setReferenceDictionary(dict);
}
if(this.outputFileOrNull==null) {
builder.setCreateMD5(false);
if(this.config.outputbcf) {
builder.setOutputBCFStream(this._stdout);
}
else
{
builder.setOutputVCFStream(this._stdout);
}
}
else
{
builder.setCreateMD5(this.config.createMd5);
if(this.config.createIndex)
{
if(dict==null|| dict.isEmpty()) {
throw new JvarkitException.DictionaryMissing("Cannot index vcf when SamSequence dictionary missing");
}
builder.setOption(Options.INDEX_ON_THE_FLY);
}
builder.setOutputFile(this.outputFileOrNull);
}
this.delegate = builder.build();
this.delegate.writeHeader(header);
}