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


Java VariantContextWriter.add方法代码示例

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


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

示例1: writeOutRecalibrationTable

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
public void writeOutRecalibrationTable( final VariantContextWriter recalWriter ) {
    // we need to sort in coordinate order in order to produce a valid VCF
    Collections.sort( data, new Comparator<VariantDatum>() {
        public int compare(VariantDatum vd1, VariantDatum vd2) {
            return vd1.loc.compareTo(vd2.loc);
        }} );

    // create dummy alleles to be used
    final List<Allele> alleles = new ArrayList<Allele>(2);
    alleles.add(Allele.create("N", true));
    alleles.add(Allele.create("<VQSR>", false));

    // to be used for the important INFO tags
    final HashMap<String, Object> attributes = new HashMap<String, Object>(3);

    for( final VariantDatum datum : data ) {
        attributes.put(VCFConstants.END_KEY, datum.loc.getStop());
        attributes.put(VCFQualityControl.VQS_LOD_KEY, String.format("%.4f", datum.lod));
        attributes.put(VCFQualityControl.CULPRIT_KEY, (datum.worstAnnotation != -1 ? annotationKeys.get(datum.worstAnnotation) : "NULL"));

        VariantContextBuilder builder = new VariantContextBuilder("VQSR", datum.loc.getContig(), datum.loc.getStart(), datum.loc.getStop(), alleles).attributes(attributes);
        recalWriter.add(builder.make());
    }
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:25,代码来源:VariantDataManager.java

示例2: writeOutRecalibrationTable

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
public void writeOutRecalibrationTable(final VariantContextWriter recalWriter,
		final SAMSequenceDictionary seqDictionary) {
	// we need to sort in coordinate order in order to produce a valid VCF
	Collections.sort(data, VariantDatum.getComparator(seqDictionary));

	// create dummy alleles to be used
	List<Allele> alleles = Arrays.asList(Allele.create("N", true), Allele.create("<VQSR>", false));

	for (final VariantDatum datum : data) {
		if (VRAC.useASannotations)
			alleles = Arrays.asList(datum.referenceAllele, datum.alternateAllele); 
		VariantContextBuilder builder = new VariantContextBuilder("VQSR", datum.loc.getContig(),
				datum.loc.getStart(), datum.loc.getStop(), alleles);
		builder.attribute(VCFConstants.END_KEY, datum.loc.getStop());
		builder.attribute(GaeaVCFConstants.VQS_LOD_KEY, String.format("%.4f", datum.lod));
		builder.attribute(GaeaVCFConstants.CULPRIT_KEY,
				(datum.worstAnnotation != -1 ? annotationKeys.get(datum.worstAnnotation) : "NULL"));

		if (datum.atTrainingSite)
			builder.attribute(GaeaVCFConstants.POSITIVE_LABEL_KEY, true);
		if (datum.atAntiTrainingSite)
			builder.attribute(GaeaVCFConstants.NEGATIVE_LABEL_KEY, true);

		recalWriter.add(builder.make());
	}
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:27,代码来源:VariantDataManager.java

示例3: 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

示例4: 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

示例5: 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

示例6: writeOutRecalibrationTable

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
public void writeOutRecalibrationTable(final VariantContextWriter recalWriter, final SAMSequenceDictionary seqDictionary) {
    // we need to sort in coordinate order in order to produce a valid VCF
    Collections.sort( data, VariantDatum.getComparator(seqDictionary) );

    // create dummy alleles to be used
    List<Allele> alleles = Arrays.asList(Allele.create("N", true), Allele.create("<VQSR>", false));

    for( final VariantDatum datum : data ) {
        if (VRAC.useASannotations)
            alleles = Arrays.asList(datum.referenceAllele, datum.alternateAllele); //use the alleles to distinguish between multiallelics in AS mode
        VariantContextBuilder builder = new VariantContextBuilder("VQSR", datum.loc.getContig(), datum.loc.getStart(), datum.loc.getEnd(), alleles);
        builder.attribute(VCFConstants.END_KEY, datum.loc.getEnd());
        builder.attribute(GATKVCFConstants.VQS_LOD_KEY, String.format("%.4f", datum.lod));
        builder.attribute(GATKVCFConstants.CULPRIT_KEY, (datum.worstAnnotation != -1 ? annotationKeys.get(datum.worstAnnotation) : "NULL"));

        if ( datum.atTrainingSite ) builder.attribute(GATKVCFConstants.POSITIVE_LABEL_KEY, true);
        if ( datum.atAntiTrainingSite ) builder.attribute(GATKVCFConstants.NEGATIVE_LABEL_KEY, true);

        recalWriter.add(builder.make());
    }
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:22,代码来源:VariantDataManager.java

示例7: writeVariant

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
private void writeVariant(VariantContextWriter writer, GenomeVariant genomeVar) {
	String nameInFasta = mapContigToFasta(genomeVar.getChrName());
	List<Allele> alleles = new ArrayList<Allele>();
	int shift = 0;
	if (genomeVar.getRef().isEmpty() || genomeVar.getAlt().isEmpty()) {
		shift = -1;
		String left = fasta.getSubsequenceAt(nameInFasta, genomeVar.getPos(), genomeVar.getPos())
				.getBaseString();
		alleles.add(Allele.create(left + genomeVar.getRef(), true));
		alleles.add(Allele.create(left + genomeVar.getAlt(), false));
	} else {
		alleles.add(Allele.create(genomeVar.getRef(), true));
		alleles.add(Allele.create(genomeVar.getAlt(), false));
	}

	VariantContextBuilder builder = new VariantContextBuilder();
	builder.chr(genomeVar.getChrName()).start(genomeVar.getPos() + shift + 1)
			.computeEndFromAlleles(alleles, genomeVar.getPos() + shift + 1).alleles(alleles);

	writer.add(builder.make());
}
 
开发者ID:charite,项目名称:jannovar,代码行数:22,代码来源:ProjectTranscriptToChromosome.java

示例8: 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

示例9: doVcfToVcf

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

示例10: 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

示例11: doVcfToVcf

import htsjdk.variant.variantcontext.writer.VariantContextWriter; //导入方法依赖的package包/类
@Override
protected int doVcfToVcf(
		final String inputName,final VcfIterator vcfIterator,
		final VariantContextWriter delegate) {
		final VcfIterator in = VCFUtils.createAssertSortedVcfIterator(vcfIterator, VCFUtils.createTidPosComparator(vcfIterator.getHeader().getSequenceDictionary()));
		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()));
			}
		out.close();
		progess.finish();
		CloserUtil.close(in);
		return 0;
		}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:19,代码来源:VcfBurdenFilterExac.java

示例12: 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,代码来源:VcfGnomad.java

示例13: 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,代码来源:VcfEigen01.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);
	
	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

示例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.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。