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


Java Genotype.hasExtendedAttribute方法代码示例

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


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

示例1: getNumOfReads

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public int getNumOfReads(final VariantContext vc) {
	// don't use the full depth because we don't calculate MQ for reference
	// blocks
	int numOfReads = 0;
	if (vc.hasAttribute(VCFConstants.DEPTH_KEY)) {
		numOfReads += Integer.parseInt(vc.getAttributeAsString(VCFConstants.DEPTH_KEY, "-1"));
		if (vc.hasGenotypes()) {
			for (Genotype gt : vc.getGenotypes()) {
				if (gt.isHomRef()) {
					// site-level DP contribution will come from MIN_DP for
					// gVCF-called reference variants or DP for BP
					// resolution
					if (gt.hasExtendedAttribute("MIN_DP"))
						numOfReads -= Integer.parseInt(gt.getExtendedAttribute("MIN_DP").toString());
					else if (gt.hasDP())
						numOfReads -= gt.getDP();
				}

			}
		}
		return numOfReads;
	}
	return -1;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:25,代码来源:RMSAnnotation.java

示例2: getSACs

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * Get the genotype SACs
 *
 * @param g
 *            the genotype
 * @return an arrays of SACs
 * @throws ReviewedGATKException
 *             if the type of the SACs is unexpected
 */
private static int[] getSACs(final Genotype g) {

	if (g == null)
		throw new IllegalArgumentException("the Genotype cannot be null");
	if (!g.hasExtendedAttribute(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY))
		throw new IllegalArgumentException("Genotype must have SAC");

	if (g.getExtendedAttributes().get(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY).getClass()
			.equals(String.class)) {
		final String SACsString = (String) g.getExtendedAttributes()
				.get(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY);
		ArrayList<String> stringSACs = Utils.split(SACsString, ",");
		final int[] intSACs = new int[stringSACs.size()];
		int i = 0;
		for (String sac : stringSACs)
			intSACs[i++] = Integer.parseInt(sac);

		return intSACs;
	} else if (g.getExtendedAttributes().get(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY).getClass()
			.equals(int[].class))
		return (int[]) g.getExtendedAttributes().get(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY);
	else
		throw new UserException("Unexpected SAC type");
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:34,代码来源:GaeaGvcfVariantContextUtils.java

示例3: subsetSACAlleles

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * From a given genotype, extract a given subset of alleles and return the new SACs
 * @param g                             genotype to subset
 * @param allelesToUse                  alleles to subset
 * @param vc                            variant context with alleles and genotypes
 * @return                              the subsetted SACs
 */
private int[] subsetSACAlleles(final Genotype g, final List<Allele> allelesToUse, final VariantContext vc){

    if ( !g.hasExtendedAttribute(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY) )
        return null;

    // we need to determine which of the alternate alleles (and hence the likelihoods) to use and carry forward
    final int numOriginalAltAlleles = vc.getAlternateAlleles().size();
    final int numNewAltAlleles = allelesToUse.size() - 1;
    final List<Integer> sacIndexesToUse = numOriginalAltAlleles == numNewAltAlleles ? null : GaeaGvcfVariantContextUtils.determineSACIndexesToUse(vc, allelesToUse);

    return GaeaGvcfVariantContextUtils.makeNewSACs(g, sacIndexesToUse);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:20,代码来源:GeneralPloidyExactAFCalculator.java

示例4: cleanupGenotypeAnnotations

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * Cleans up genotype-level annotations that need to be updated.
 * 1. move MIN_DP to DP if present
 * 2. propagate DP to AD if not present
 * 3. remove SB if present
 * 4. change the PGT value from "0|1" to "1|1" for homozygous variant genotypes
 *
 * @param VC            the VariantContext with the Genotypes to fix
 * @param createRefGTs  if true we will also create proper hom ref genotypes since we assume the site is monomorphic
 * @return a new set of Genotypes
 */
private List<Genotype> cleanupGenotypeAnnotations(final VariantContext VC, final boolean createRefGTs) {
    final GenotypesContext oldGTs = VC.getGenotypes();
    final List<Genotype> recoveredGs = new ArrayList<>(oldGTs.size());
    for ( final Genotype oldGT : oldGTs ) {
        final Map<String, Object> attrs = new HashMap<>(oldGT.getExtendedAttributes());

        final GenotypeBuilder builder = new GenotypeBuilder(oldGT);
        int depth = oldGT.hasDP() ? oldGT.getDP() : 0;

        // move the MIN_DP to DP
        if ( oldGT.hasExtendedAttribute("MIN_DP") ) {
            depth = Integer.parseInt((String)oldGT.getAnyAttribute("MIN_DP"));
            builder.DP(depth);
            attrs.remove("MIN_DP");
        }

        // remove SB
        attrs.remove("SB");

        // update PGT for hom vars
        if ( oldGT.isHomVar() && oldGT.hasExtendedAttribute(HaplotypeCaller.HAPLOTYPE_CALLER_PHASING_GT_KEY) ) {
            attrs.put(HaplotypeCaller.HAPLOTYPE_CALLER_PHASING_GT_KEY, "1|1");
        }

        // create AD if it's not there
        if ( !oldGT.hasAD() && VC.isVariant() ) {
            final int[] AD = new int[VC.getNAlleles()];
            AD[0] = depth;
            builder.AD(AD);
        }

        if ( createRefGTs ) {
            final int ploidy = oldGT.getPloidy();
            final List<Allele> refAlleles = Collections.nCopies(ploidy,VC.getReference());

            //keep 0 depth samples as no-call
            if (depth > 0) {
                builder.alleles(refAlleles);
            }

            // also, the PLs are technically no longer usable
            builder.noPL();
        }

        recoveredGs.add(builder.noAttributes().attributes(attrs).make());
    }
    return recoveredGs;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:60,代码来源:GenotypeGVCFs.java

示例5: cleanupGenotypeAnnotations

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private List<Genotype> cleanupGenotypeAnnotations(final VariantContext VC, final boolean createRefGTs) {
	final GenotypesContext oldGTs = VC.getGenotypes();
	final List<Genotype> recoveredGs = new ArrayList<>(oldGTs.size());
	for (final Genotype oldGT : oldGTs) {
		final Map<String, Object> attrs = new HashMap<>(oldGT.getExtendedAttributes());

		final GenotypeBuilder builder = new GenotypeBuilder(oldGT);
		int depth = oldGT.hasDP() ? oldGT.getDP() : 0;

		// move the MIN_DP to DP
		if (oldGT.hasExtendedAttribute(GaeaVCFConstants.MIN_DP_FORMAT_KEY)) {
			depth = Integer.parseInt((String) oldGT.getAnyAttribute(GaeaVCFConstants.MIN_DP_FORMAT_KEY));
			builder.DP(depth);
			attrs.remove(GaeaVCFConstants.MIN_DP_FORMAT_KEY);
		}

		// move the GQ to RGQ
		if (createRefGTs && oldGT.hasGQ()) {
			builder.noGQ();
			attrs.put(GaeaVCFConstants.REFERENCE_GENOTYPE_QUALITY, oldGT.getGQ());
		}

		// remove SB
		attrs.remove(GaeaVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY);

		// update PGT for hom vars
		if (oldGT.isHomVar() && oldGT.hasExtendedAttribute(GaeaVCFConstants.HAPLOTYPE_CALLER_PHASING_GT_KEY)) {
			attrs.put(GaeaVCFConstants.HAPLOTYPE_CALLER_PHASING_GT_KEY, "1|1");
		}

		// create AD if it's not there
		if (!oldGT.hasAD() && VC.isVariant()) {
			final int[] AD = new int[VC.getNAlleles()];
			AD[0] = depth;
			builder.AD(AD);
		}

		if (createRefGTs) {
			final int ploidy = oldGT.getPloidy();
			final List<Allele> refAlleles = Collections.nCopies(ploidy, VC.getReference());

			// keep 0 depth samples and 0 GQ samples as no-call
			if (depth > 0 && oldGT.hasGQ() && oldGT.getGQ() > 0) {
				builder.alleles(refAlleles);
			}

			// also, the PLs are technically no longer usable
			builder.noPL();
		}

		recoveredGs.add(builder.noAttributes().attributes(attrs).make());
	}
	return recoveredGs;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:55,代码来源:JointCallingEngine.java

示例6: mergeRefConfidenceGenotypes

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * Merge into the context a new genotype represented by the given
 * VariantContext for the provided list of target alleles. This method
 * assumes that none of the alleles in the VC overlaps with any of the
 * alleles in the set.
 */
private static void mergeRefConfidenceGenotypes(final GenotypesContext mergedGenotypes, final VariantContext vc,
		final List<Allele> remappedAlleles, final List<Allele> targetAlleles, final boolean samplesAreUniquified,
		final boolean shouldComputePLs) {
	final int maximumPloidy = vc.getMaxPloidy(GaeaGvcfVariantContextUtils.DEFAULT_PLOIDY);
	// the map is different depending on the ploidy, so in order to keep
	// this method flexible (mixed ploidies)
	// we need to get a map done (lazily inside the loop) for each ploidy,
	// up to the maximum possible.
	final int[][] genotypeIndexMapsByPloidy = new int[maximumPloidy + 1][];
	final int maximumAlleleCount = Math.max(remappedAlleles.size(), targetAlleles.size());

	for (final Genotype g : vc.getGenotypes()) {
		final String name;
		if (samplesAreUniquified)
			name = g.getSampleName() + "." + vc.getSource();
		else
			name = g.getSampleName();
		final int ploidy = g.getPloidy();
		final GenotypeBuilder genotypeBuilder = new GenotypeBuilder(g)
				.alleles(GaeaGvcfVariantContextUtils.noCallAlleles(g.getPloidy())).noPL();
		genotypeBuilder.name(name);

		final boolean doPLs = shouldComputePLs && g.hasPL();
		final boolean hasAD = g.hasAD();
		final boolean hasSAC = g.hasExtendedAttribute(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY);
		if (doPLs || hasSAC || hasAD) {
			final int[] perSampleIndexesOfRelevantAlleles = getIndexesOfRelevantAlleles(remappedAlleles,
					targetAlleles, vc.getStart(), g);
			if (doPLs) {
				// lazy initialization of the genotype index map by ploidy.

				final int[] genotypeIndexMapByPloidy = genotypeIndexMapsByPloidy[ploidy] == null
						? GenotypeLikelihoodCalculators.getInstance(ploidy, maximumAlleleCount).genotypeIndexMap(
								perSampleIndexesOfRelevantAlleles)
						: genotypeIndexMapsByPloidy[ploidy];
				final int[] PLs = generatePL(g, genotypeIndexMapByPloidy);
				genotypeBuilder.PL(PLs);
			}
			if (hasAD) {
				genotypeBuilder.AD(generateAD(g.getAD(), perSampleIndexesOfRelevantAlleles));
			}
			if (hasSAC) {
				final List<Integer> sacIndexesToUse = adaptToSACIndexes(perSampleIndexesOfRelevantAlleles);
				final int[] SACs = GaeaGvcfVariantContextUtils.makeNewSACs(g, sacIndexesToUse);
				genotypeBuilder.attribute(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY, SACs);
			}
		}
		mergedGenotypes.add(genotypeBuilder.make());
	}
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:57,代码来源:ReferenceConfidenceVariantContextMerger.java


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