当前位置: 首页>>代码示例>>Java>>正文


Java VariantContextWriter.writeHeader方法代码示例

本文整理汇总了Java中htsjdk.variant.variantcontext.writer.VariantContextWriter.writeHeader方法的典型用法代码示例。如果您正苦于以下问题:Java VariantContextWriter.writeHeader方法的具体用法?Java VariantContextWriter.writeHeader怎么用?Java VariantContextWriter.writeHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htsjdk.variant.variantcontext.writer.VariantContextWriter的用法示例。


在下文中一共展示了VariantContextWriter.writeHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processVariants

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
private static void processVariants(@NotNull final String filePath, @NotNull final Slicer highConfidenceSlicer,
        @NotNull final String outputVcf, @NotNull final String sampleName, @NotNull final String tumorBam) throws HartwigException {
    final VCFFileReader vcfReader = new VCFFileReader(new File(filePath), false);
    final VCFHeader outputHeader = generateOutputHeader(vcfReader.getFileHeader(), sampleName);
    final VariantContextWriter writer = new VariantContextWriterBuilder().setOutputFile(outputVcf)
            .setReferenceDictionary(outputHeader.getSequenceDictionary())
            .build();
    writer.writeHeader(outputHeader);
    final MNVValidator validator = ImmutableMNVValidator.of(tumorBam);
    Pair<PotentialMNVRegion, Optional<PotentialMNVRegion>> outputPair = ImmutablePair.of(PotentialMNVRegion.empty(), Optional.empty());

    final VariantContextFilter filter = new StrelkaPostProcess(highConfidenceSlicer);
    for (final VariantContext variantContext : vcfReader) {
        if (filter.test(variantContext)) {
            final VariantContext simplifiedVariant = StrelkaPostProcess.simplifyVariant(variantContext, sampleName);
            final PotentialMNVRegion potentialMNV = outputPair.getLeft();
            outputPair = MNVDetector.fitsMNVRegion(potentialMNV, simplifiedVariant);
            outputPair.getRight().ifPresent(mnvRegion -> validator.mergeVariants(mnvRegion).forEach(writer::add));
        }
    }
    validator.mergeVariants(outputPair.getLeft()).forEach(writer::add);
    writer.close();
    vcfReader.close();
    LOGGER.info("Written output variants to " + outputVcf);
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:26,代码来源:StrelkaPostProcessApplication.java

示例2: processVariants

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
private static void processVariants(@NotNull final String filePath, @NotNull final String outputVcf, @NotNull final String tumorBam) {
    final VCFFileReader vcfReader = new VCFFileReader(new File(filePath), false);
    final VariantContextWriter vcfWriter = new VariantContextWriterBuilder().setOutputFile(outputVcf)
            .setReferenceDictionary(vcfReader.getFileHeader().getSequenceDictionary())
            .build();
    vcfWriter.writeHeader(vcfReader.getFileHeader());
    final MNVValidator validator = ImmutableMNVValidator.of(tumorBam);
    Pair<PotentialMNVRegion, Optional<PotentialMNVRegion>> outputPair = ImmutablePair.of(PotentialMNVRegion.empty(), Optional.empty());
    for (final VariantContext variant : vcfReader) {
        final PotentialMNVRegion potentialMNV = outputPair.getLeft();
        outputPair = MNVDetector.fitsMNVRegion(potentialMNV, variant);
        outputPair.getRight().ifPresent(mnvRegion -> validator.mergeVariants(mnvRegion).forEach(vcfWriter::add));
    }
    validator.mergeVariants(outputPair.getLeft()).forEach(vcfWriter::add);
    vcfWriter.close();
    vcfReader.close();
    LOGGER.info("Written output variants to " + outputVcf);
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:19,代码来源:MNVValidatorApplication.java

示例3: vcfHeaderToStrings

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
public static List<String> vcfHeaderToStrings(VCFHeader header) {

	    File fakeVCFFile;
	    List<String> str= new ArrayList<String>();
	    try {
	    	fakeVCFFile = Utils.createTempFile(".vcfheader", ".vcf");
		    fakeVCFFile.deleteOnExit();
			final VariantContextWriter writer = new VariantContextWriterBuilder()
		            .setOutputFile(fakeVCFFile)
		            .setReferenceDictionary(header.getSequenceDictionary())
		            .setOptions(EnumSet.of(Options.ALLOW_MISSING_FIELDS_IN_HEADER, Options.WRITE_FULL_FORMAT_FIELD))
		            .build();
		    writer.writeHeader(header);
		    writer.close();
		    BufferedReader br= new BufferedReader(new FileReader(fakeVCFFile));
		    String line= br.readLine();
		    while(line != null){
		    	str.add(line);
		    	line= br.readLine();
		    }
		    br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:27,代码来源:Utils.java

示例4: encodeAll

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
public Map<String, Object> encodeAll(OutputStream outputStream, Iterator<? extends VCFVariant> features) throws IOException {

    SAMSequenceDictionary seqDict = new SAMSequenceDictionary();
    EnumSet<Options> options = VariantContextWriterFactory.DEFAULT_OPTIONS;
    options.add(Options.ALLOW_MISSING_FIELDS_IN_HEADER);
    options.remove(Options.INDEX_ON_THE_FLY);
    VariantContextWriter writer = VariantContextWriterFactory.create(outputStream, seqDict, options);

    writer.writeHeader(this.header);

    while(features.hasNext()){
        writer.add(features.next().getVariantContext());
    }

    return null;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:18,代码来源:VCFEncoder.java

示例5: composeVariantContextAndWrite

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
/**
 * For each segment in genotypingSegments, compose the variant context and write to outputWriter
 *
 * @param genotypingSegments a list of genotyping segments
 * @param outputWriter a VCF writer
 * @param variantPrefix a prefix for composing variant IDs
 * @param commandLine (optional) command line used to generated the data
 */
private void composeVariantContextAndWrite(@Nonnull final List<GenotypingSegment> genotypingSegments,
                                           @Nonnull final VariantContextWriter outputWriter,
                                           @Nonnull final String variantPrefix,
                                           @Nullable final String commandLine) {
    outputWriter.writeHeader(composeHeader(commandLine));
    int counter = 0;
    int prevReportedDonePercentage = -1;
    for (final GenotypingSegment segment : genotypingSegments) {
        final int donePercentage = (int)(100 * counter / (double)genotypingSegments.size());
        if (donePercentage % 10 == 0 && prevReportedDonePercentage != donePercentage) {
            logger.info(String.format("%d%% done...", donePercentage));
            prevReportedDonePercentage = donePercentage;
        }
        final VariantContext variant = composeVariantContext(segment, variantPrefix);
        counter++;
        outputWriter.add(variant);
    }
    logger.info("100% done.");
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:28,代码来源:HMMPostProcessor.java

示例6: writeHeader

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
public void writeHeader(final VariantContextWriter vcfWriter, final SAMSequenceDictionary sequenceDictionary,
                        final Set<VCFHeaderLine>  defaultToolHeaderLines) {
    final Set<VCFHeaderLine> headerInfo = new HashSet<>();

    // all annotation fields from VariantAnnotatorEngine
    headerInfo.addAll(annotationEngine.getVCFAnnotationDescriptions());
    headerInfo.addAll(defaultToolHeaderLines);

    // all callers need to add these standard FORMAT field header lines
    VCFStandardHeaderLines.addStandardFormatLines(headerInfo, true,
            VCFConstants.GENOTYPE_KEY,
            VCFConstants.GENOTYPE_ALLELE_DEPTHS,
            VCFConstants.GENOTYPE_QUALITY_KEY,
            VCFConstants.DEPTH_KEY,
            VCFConstants.GENOTYPE_PL_KEY);

    headerInfo.addAll(getM2HeaderLines());
    headerInfo.addAll(getSampleHeaderLines());

    final VCFHeader vcfHeader = new VCFHeader(headerInfo, samplesList.asListOfSamples());
    vcfHeader.setSequenceDictionary(sequenceDictionary);
    vcfWriter.writeHeader(vcfHeader);
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:24,代码来源:Mutect2Engine.java

示例7: getVariantContextWriter

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
/** Gets the variant context writer if the output VCF is to be written, otherwise empty. */
private Optional<VariantContextWriter> getVariantContextWriter(final VCFFileReader truthReader, final VCFFileReader callReader) {
    if (OUTPUT_VCF) {
        final File outputVcfFile = new File(OUTPUT + OUTPUT_VCF_FILE_EXTENSION);
        final VariantContextWriterBuilder builder = new VariantContextWriterBuilder()
                .setOutputFile(outputVcfFile)
                .setReferenceDictionary(callReader.getFileHeader().getSequenceDictionary())
                .setOption(Options.ALLOW_MISSING_FIELDS_IN_HEADER)
                .setOption(Options.INDEX_ON_THE_FLY);
        final VariantContextWriter writer = builder.build();

        // create the output header
        final List<String> sampleNames = Arrays.asList(OUTPUT_VCF_CALL_SAMPLE_NAME, OUTPUT_VCF_TRUTH_SAMPLE_NAME);
        final Set<VCFHeaderLine> headerLines = new HashSet<>();
        headerLines.addAll(callReader.getFileHeader().getMetaDataInInputOrder());
        headerLines.addAll(truthReader.getFileHeader().getMetaDataInInputOrder());
        headerLines.add(CONTINGENCY_STATE_HEADER_LINE);
        writer.writeHeader(new VCFHeader(headerLines, sampleNames));
        return Optional.of(writer);
    }
    else {
        return Optional.empty();
    }
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:GenotypeConcordance.java

示例8: createTemporaryIndexedVcfFromInput

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
/**
 * This method makes a copy of the input VCF and creates an index file for it in the same location.
 * This is done so that we don't need to store the index file in the same repo
 * The copy of the input is done so that it and its index are in the same directory which is typically required.
 *
 * @param vcfFile the vcf file to index
 * @return File a vcf file (index file is created in same path).
 */
public static File createTemporaryIndexedVcfFromInput(final File vcfFile, final String tempFilePrefix) throws IOException {
    final String extension;

    if (vcfFile.getAbsolutePath().endsWith(".vcf")) extension = ".vcf";
    else if (vcfFile.getAbsolutePath().endsWith(".vcf.gz")) extension = ".vcf.gz";
    else
        throw new IllegalArgumentException("couldn't find a .vcf or .vcf.gz ending for input file " + vcfFile.getAbsolutePath());

    File output = createTemporaryIndexedVcfFile(tempFilePrefix, extension);

    final VCFFileReader in = new VCFFileReader(vcfFile, false);
    final VCFHeader header = in.getFileHeader();

    final VariantContextWriter out = new VariantContextWriterBuilder().
            setReferenceDictionary(header.getSequenceDictionary()).
            setOptions(EnumSet.of(Options.INDEX_ON_THE_FLY)).
            setOutputFile(output).build();
    out.writeHeader(header);
    for (final VariantContext ctx : in) {
        out.add(ctx);
    }
    out.close();
    in.close();
    return output;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:34,代码来源:VcfTestUtils.java

示例9: getVCFWriter

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
private VariantContextWriter getVCFWriter() {
    final SortedSet<String> samples = getSamplesForVariants();

    final VCFHeader inputVCFHeader = new VCFHeader(getHeaderForVariants().getMetaDataInInputOrder(), samples);

    final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputVCFHeader.getMetaDataInInputOrder());
    headerLines.addAll(getDefaultToolVCFHeaderLines());

    headerLines.addAll(annotationEngine.getVCFAnnotationDescriptions());

    // add headers for annotations added by this tool
    headerLines.add(VCFStandardHeaderLines.getInfoLine(VCFConstants.DEPTH_KEY));   // needed for gVCFs without DP tags
    if ( dbsnp.dbsnp != null  ) {
        VCFStandardHeaderLines.addStandardInfoLines(headerLines, true, VCFConstants.DBSNP_KEY);
    }

    VariantContextWriter writer = createVCFWriter(outputFile);

    final Set<String> sampleNameSet = new IndexedSampleList(samples).asSetOfSamples();
    final VCFHeader vcfHeader = new VCFHeader(headerLines, new TreeSet<>(sampleNameSet));
    writer.writeHeader(vcfHeader);

    return writer;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:25,代码来源:CombineGVCFs.java

示例10: writeHeader

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
public void writeHeader(final VariantContextWriter vcfWriter, final SAMSequenceDictionary sequenceDictionary,
                        final Set<VCFHeaderLine>  defaultToolHeaderLines) {
    final Set<VCFHeaderLine> headerInfo = new HashSet<>();
    headerInfo.add(new VCFHeaderLine(Mutect2FilteringEngine.FILTERING_STATUS_VCF_KEY, "Warning: unfiltered Mutect 2 calls.  Please run " + FilterMutectCalls.class.getSimpleName() + " to remove false positives."));

    // all annotation fields from VariantAnnotatorEngine
    headerInfo.addAll(annotationEngine.getVCFAnnotationDescriptions(false));
    headerInfo.addAll(defaultToolHeaderLines);

    // all callers need to add these standard FORMAT field header lines
    VCFStandardHeaderLines.addStandardFormatLines(headerInfo, true,
            VCFConstants.GENOTYPE_KEY,
            VCFConstants.GENOTYPE_ALLELE_DEPTHS,
            VCFConstants.GENOTYPE_QUALITY_KEY,
            VCFConstants.DEPTH_KEY,
            VCFConstants.GENOTYPE_PL_KEY);

    headerInfo.addAll(getM2HeaderLines());
    headerInfo.addAll(getSampleHeaderLines());

    final VCFHeader vcfHeader = new VCFHeader(headerInfo, samplesList.asListOfSamples());
    vcfHeader.setSequenceDictionary(sequenceDictionary);
    vcfWriter.writeHeader(vcfHeader);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:25,代码来源:Mutect2Engine.java

示例11: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(
		final String inputName,
		final VcfIterator iter,
		final VariantContextWriter delegate
		) {	
	final VariantContextWriter out = this.component.open(delegate);
	final SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(iter.getHeader()).logger(LOG);
	out.writeHeader(iter.getHeader());
	while(iter.hasNext())
		{
		out.add(progress.watch(iter.next()));
		}
	out.close();
	progress.finish();
	return 0;
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:18,代码来源:VcfTrap.java

示例12: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(
	final String inputName,
	final VcfIterator in,
	final VariantContextWriter delegate)
	{
	final VariantContextWriter  out = this.component.open(delegate);
	final SAMSequenceDictionaryProgress progess=new SAMSequenceDictionaryProgress(in.getHeader()).logger(LOG);
	out.writeHeader(in.getHeader());
	while(in.hasNext())
		{
		out.add(progess.watch(in.next()));
		}
	progess.finish();
	out.close();
	return 0;
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:18,代码来源:VcfBurdenFisherV.java

示例13: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(
	final String inputName,
	final VcfIterator in,
	final VariantContextWriter delegate
	) 
    {
	final VariantContextWriter out = this.component.open(delegate);
	
	out.writeHeader(in.getHeader());
	final SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(in.getHeader()).logger(LOG);
	while(in.hasNext())
		{
		out.add(progress.watch(in.next()));
		}
	progress.finish();
	return 0;
    }
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:19,代码来源:VcfSetSequenceDictionary.java

示例14: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(
	final String inputName,
	final VcfIterator in,
	final VariantContextWriter delegate)
	{
	final VariantContextWriter  out = this.component.open(delegate);
	final SAMSequenceDictionaryProgress progess=new SAMSequenceDictionaryProgress(in.getHeader()).logger(LOG);
	out.writeHeader(in.getHeader());
	while(in.hasNext() &&  !out.checkError())
		{
		out.add(progess.watch(in.next()));
		}
	progess.finish();
	out.close();
	return 0;
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:18,代码来源:VcfMoveFiltersToInfo.java

示例15: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(final String inputName, final VcfIterator r, final VariantContextWriter delegate) {
	final VariantContextWriter w = this.component.open(delegate);
	w.writeHeader(r.getHeader());
	final SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(r.getHeader()).logger(LOG);
	while(r.hasNext())
		{
		w.add(progress.watch(r.next()));
		
		// JVM crash sometimes ? suspect there is a memory leak ?
		if(progress.getCount()%1000L==0)
			{
			System.gc();
			}
		}
	progress.finish();
	w.close();
	return 0;
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:20,代码来源:VCFBigWig.java


注:本文中的htsjdk.variant.variantcontext.writer.VariantContextWriter.writeHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。