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


Java GenotypeBuilder.GQ属性代码示例

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


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

示例1: blockToVCF

/**
 * Convert a HomRefBlock into a VariantContext
 *
 * @param block the block to convert
 * @return a VariantContext representing the gVCF encoding for this block.
 * It will return {@code null} if input {@code block} is {@code null}, indicating that there
 * is no variant-context to be output into the VCF.
 */
private VariantContext blockToVCF(final HomRefBlock block) {
    if ( block == null ) return null;

    final VariantContextBuilder vcb = new VariantContextBuilder(block.getStartingVC());
    vcb.attributes(new HashMap<String, Object>(2)); // clear the attributes
    vcb.stop(block.getStop());
    vcb.attribute(VCFConstants.END_KEY, block.getStop());

    // create the single Genotype with GQ and DP annotations
    final GenotypeBuilder gb = new GenotypeBuilder(sampleName, GATKVariantContextUtils.homozygousAlleleList(block.getRef(),block.getPloidy()));
    gb.noAD().noPL().noAttributes(); // clear all attributes
    gb.GQ(block.getMedianGQ());
    gb.DP(block.getMedianDP());
    gb.attribute(MIN_DP_FORMAT_FIELD, block.getMinDP());
    gb.PL(block.getMinPLs());

    // This annotation is no longer standard
    //gb.attribute(MIN_GQ_FORMAT_FIELD, block.getMinGQ());

    return vcb.genotypes(gb.make()).make();
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:29,代码来源:GVCFWriter.java

示例2: subsetToRefOnly

/**
 * Subset the samples in VC to reference only information with ref call alleles
 *
 * Preserves DP if present
 *
 * @param vc the variant context to subset down to
 * @param ploidy ploidy to use if a genotype doesn't have any alleles
 * @return a GenotypesContext
 */
public static GenotypesContext subsetToRefOnly(final VariantContext vc, final int ploidy) {
    if ( vc == null ) throw new IllegalArgumentException("vc cannot be null");
    if ( ploidy < 1 ) throw new IllegalArgumentException("ploidy must be >= 1 but got " + ploidy);

    // the genotypes with PLs
    final GenotypesContext oldGTs = vc.getGenotypes();

    // optimization: if no input genotypes, just exit
    if (oldGTs.isEmpty()) return oldGTs;

    // the new genotypes to create
    final GenotypesContext newGTs = GenotypesContext.create(oldGTs.size());

    final Allele ref = vc.getReference();
    final List<Allele> diploidRefAlleles = Arrays.asList(ref, ref);

    // create the new genotypes
    for ( final Genotype g : vc.getGenotypes() ) {
        final int gPloidy = g.getPloidy() == 0 ? ploidy : g.getPloidy();
        final List<Allele> refAlleles = gPloidy == 2 ? diploidRefAlleles : Collections.nCopies(gPloidy, ref);
        final GenotypeBuilder gb = new GenotypeBuilder(g.getSampleName(), refAlleles);
        if ( g.hasDP() ) gb.DP(g.getDP());
        if ( g.hasGQ() ) gb.GQ(g.getGQ());
        newGTs.add(gb.make());
    }

    return newGTs;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:37,代码来源:GATKVariantContextUtils.java

示例3: subsetToRefOnly

/**
 * Subset the samples in VC to reference only information with ref call
 * alleles
 *
 * Preserves DP if present
 *
 * @param vc
 *            the variant context to subset down to
 * @param ploidy
 *            ploidy to use if a genotype doesn't have any alleles
 * @return a GenotypesContext
 */
public static GenotypesContext subsetToRefOnly(final VariantContext vc, final int ploidy) {
	if (vc == null)
		throw new IllegalArgumentException("vc cannot be null");
	if (ploidy < 1)
		throw new IllegalArgumentException("ploidy must be >= 1 but got " + ploidy);

	// the genotypes with PLs
	final GenotypesContext oldGTs = vc.getGenotypes();

	// optimization: if no input genotypes, just exit
	if (oldGTs.isEmpty())
		return oldGTs;

	// the new genotypes to create
	final GenotypesContext newGTs = GenotypesContext.create(oldGTs.size());

	final Allele ref = vc.getReference();
	final List<Allele> diploidRefAlleles = Arrays.asList(ref, ref);

	// create the new genotypes
	for (final Genotype g : vc.getGenotypes()) {
		final int gPloidy = g.getPloidy() == 0 ? ploidy : g.getPloidy();
		final List<Allele> refAlleles = Collections.nCopies(gPloidy, vc.getReference());
		final GenotypeBuilder gb = new GenotypeBuilder(g.getSampleName(), refAlleles);
		if (g.hasDP())
			gb.DP(g.getDP());
		if (g.hasGQ())
			gb.GQ(g.getGQ());
		newGTs.add(gb.make());
	}

	return newGTs;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:45,代码来源:GaeaGvcfVariantContextUtils.java

示例4: setGenotypeQualityFromPLs

/**
 * Instead of using the GQ value, it re-calculates the quality from the PL so that it does not need
 * to be bounded by an artificial maximum such as the standard GQ = 99.
 * @param builder where to set the genotypes.
 * @param genotype the PL source genotype.
 *
 * @throws IllegalArgumentException if {@code genotype} is {@code null}
 */
public static void setGenotypeQualityFromPLs(final GenotypeBuilder builder, final Genotype genotype) {
    final double gq = calculateGenotypeQualityFromPLs(genotype);
    if (Double.isNaN(gq)) {
        builder.noGQ();
    } else {
        builder.GQ((int) Math.floor(gq));
    }
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:16,代码来源:GATKProtectedVariantContextUtils.java

示例5: createHomRefGenotype

private Genotype createHomRefGenotype(String sampleName) {
    final GenotypeBuilder gb = new GenotypeBuilder(sampleName, Collections.nCopies(getPloidy(), getRef()));
    gb.noAD().noPL().noAttributes(); // clear all attributes

    final int[] minPLs = getMinPLs();
    gb.PL(minPLs);
    gb.GQ(GATKVariantContextUtils.calculateGQFromPLs(minPLs));
    gb.DP(getMedianDP());
    gb.attribute(GATKVCFConstants.MIN_DP_FORMAT_KEY, getMinDP());

    return gb.make();
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:12,代码来源:HomRefBlock.java

示例6: makeGenotypes

private List<Genotype> makeGenotypes(
	 final VariantContext ctx,
	 final List<String> sample_names,
	 final Allele theAllele,
	 final Allele replaceWith
	 )
		{
	final List<Genotype> genotypes=new ArrayList<>(sample_names.size());
	
	for(final String sampleName: sample_names)
		{							
		final Genotype g= ctx.getGenotype(sampleName);
		
		if( !disableHomVarAlt &&
			g.isCalled() && 
			!g.getAlleles().stream().
			filter(A->!(A.isNoCall() || A.isReference() || A.equals(theAllele) || A.equals(replaceWith))).
			collect(Collectors.toSet()).
			isEmpty() // only contains the 'other alleles'
			)
			{
			genotypes.add(GenotypeBuilder.createMissing(sampleName, g.getPloidy()));
			continue;
			}
		
		
		final GenotypeBuilder gb =new GenotypeBuilder(
				g.getSampleName(),
					g.getAlleles().stream().
					map(A->(A.isNoCall() || A.isReference() || A.equals(theAllele)?A:replaceWith)).
					collect(Collectors.toList())
				);
		if(g.hasDP()) gb.DP(g.getDP());
		if(g.hasGQ()) gb.GQ(g.getGQ());
		if(g.isFiltered()) gb.filter(g.getFilters());

		genotypes.add(gb.make());
		}
return genotypes;
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:40,代码来源:VcfMultiToOneAllele.java

示例7: entryToObject

@Override
public Genotype entryToObject(TupleInput in)
	{
	GenotypeBuilder gb=new GenotypeBuilder(in.readString());
	if(in.readBoolean()) gb.DP(in.readInt());
	if(in.readBoolean()) gb.AD(arrayOfIntToEntry(in));
	if(in.readBoolean()) gb.GQ(in.readInt());
	if(in.readBoolean()) gb.PL(arrayOfIntToEntry(in));
	
	/* ALLELES ======================================== */
	int n=in.readInt();
	List<Allele> alleles=new ArrayList<Allele>(n);
	for(int i=0;i< n;++i)
		{
		alleles.add(this.alleleBinding.entryToObject(in));
		}
	gb.alleles(alleles);
	/* ATTRIBUTES ===================================== */
	n=in.readInt();
	for(int i=0;i< n;++i)
		{
		String key=in.readString();
		gb.attribute(key, super.readAttribute(in));
		}
	 
	return gb.make();
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:27,代码来源:GenotypeBinding.java


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