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


Java Genotype.getSampleName方法代码示例

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


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

示例1: subsetGenotypeAllelesWithLikelihoods

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * From a given genotype, subset the PLs and SACs
 * @param g                                 genotype to subset
 * @param allelesToUse                      alleles to subset
 * @param vc                                variant context with alleles and genotypes
 * @param ploidy                            number of chromosomes
 * @param assignGenotypes                   true: assign hard genotypes, false: leave as no-call
 * @param newLikelihoods                    the PL values
 * @return genotype with the subsetted PLsL and SACs
 */
private Genotype subsetGenotypeAllelesWithLikelihoods(final Genotype g, final List<Allele> allelesToUse, final VariantContext vc, int ploidy,
                                                      final boolean assignGenotypes, final double[] newLikelihoods) {

    final GenotypeBuilder gb = new GenotypeBuilder(g);
    final String sampleName = g.getSampleName();

    // add likelihoods
    gb.PL(newLikelihoods);

    // get and add subsetted SACs
    final int[] newSACs = subsetSACAlleles(g, allelesToUse, vc);
    if (newSACs != null)
        gb.attribute(GaeaVCFConstants.STRAND_COUNT_BY_SAMPLE_KEY, newSACs);
    if (assignGenotypes)
        assignGenotype(gb, vc, sampleName, newLikelihoods, allelesToUse, ploidy);
    else
        gb.alleles(GaeaGvcfVariantContextUtils.noCallAlleles(ploidy));

    return gb.make();
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:31,代码来源:GeneralPloidyExactAFCalculator.java

示例2: subsetToRefOnly

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * 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,代码行数:38,代码来源:GATKVariantContextUtils.java

示例3: 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.
 *
 * @param mergedGenotypes   the genotypes context to add to
 * @param VC                the Variant Context for the sample
 * @param remappedAlleles   the list of remapped alleles for the sample
 * @param targetAlleles     the list of target alleles
 */
private static void mergeRefConfidenceGenotypes(final GenotypesContext mergedGenotypes,
                                                final VariantContext VC,
                                                final List<Allele> remappedAlleles,
                                                final List<Allele> targetAlleles) {
    final int maximumPloidy = VC.getMaxPloidy(GATKVariantContextUtils.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());
    final int[] indexesOfRelevantAlleles = getIndexesOfRelevantAlleles(remappedAlleles, targetAlleles, VC.getStart());

    for ( final Genotype g : VC.getGenotypes() ) {
        final String name = g.getSampleName();
        if ( mergedGenotypes.containsSample(name) )
            continue;
        final int ploidy = g.getPloidy();
        final GenotypeBuilder genotypeBuilder = new GenotypeBuilder(g).alleles(GATKVariantContextUtils.noCallAlleles(g.getPloidy()));
        if (g.hasPL()) {
            // lazy initialization of the genotype index map by ploidy.
            final int[] genotypeIndexMapByPloidy = genotypeIndexMapsByPloidy[ploidy] == null
                    ? GenotypeLikelihoodCalculators.getInstance(ploidy, maximumAlleleCount).genotypeIndexMap(indexesOfRelevantAlleles)
                    : genotypeIndexMapsByPloidy[ploidy];
            final int[] PLs = generatePL(g, genotypeIndexMapByPloidy);
            final int[] AD = g.hasAD() ? generateAD(g.getAD(), indexesOfRelevantAlleles) : null;
            genotypeBuilder.PL(PLs).AD(AD).noGQ();
        }
        mergedGenotypes.add(genotypeBuilder.make());
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:39,代码来源:ReferenceConfidenceVariantContextMerger.java

示例4: subsetToRefOnly

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * 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,代码行数:46,代码来源:GaeaGvcfVariantContextUtils.java

示例5: subsetAlleles

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
@Override
@Requires("vc != null && allelesToUse != null")
public GenotypesContext subsetAlleles(VariantContext vc, int defaultPloidy, List<Allele> allelesToUse, boolean assignGenotypes) {
    // the genotypes with PLs
    final GenotypesContext oldGTs = vc.getGenotypes();

    // samples
    final List<String> sampleIndices = oldGTs.getSampleNamesOrderedByName();

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

    // 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;


    // create the new genotypes
    for ( int k = 0; k < oldGTs.size(); k++ ) {
        final Genotype g = oldGTs.get(sampleIndices.get(k));
        final int declaredPloidy = g.getPloidy();
        final int ploidy = declaredPloidy <= 0 ? defaultPloidy : declaredPloidy;
        if ( !g.hasLikelihoods() ) {
            newGTs.add(GenotypeBuilder.create(g.getSampleName(),GaeaGvcfVariantContextUtils.noCallAlleles(ploidy)));
            continue;
        }

        // create the new likelihoods array from the alleles we are allowed to use
        final double[] originalLikelihoods = g.getLikelihoods().getAsVector();
        double[] newLikelihoods;

        // Optimization: if # of new alt alleles = 0 (pure ref call), keep original likelihoods so we skip normalization
        // and subsetting
        if ( numOriginalAltAlleles == numNewAltAlleles || numNewAltAlleles == 0) {
            newLikelihoods = originalLikelihoods;
        } else {
            newLikelihoods = GeneralPloidyGenotypeLikelihoods.subsetToAlleles(originalLikelihoods, ploidy, vc.getAlleles(), allelesToUse);

            // might need to re-normalize
            newLikelihoods = GvcfMathUtils.normalizeFromLog10(newLikelihoods, false, true);
        }

        // if there is no mass on the (new) likelihoods, then just no-call the sample
        if ( GvcfMathUtils.sum(newLikelihoods) > GaeaGvcfVariantContextUtils.SUM_GL_THRESH_NOCALL ) {
            newGTs.add(GenotypeBuilder.create(g.getSampleName(), GaeaGvcfVariantContextUtils.noCallAlleles(ploidy)));
        } else {
            final GenotypeBuilder gb = new GenotypeBuilder(g);
            final String sampleName = g.getSampleName();

            if ( numNewAltAlleles == 0 )
                gb.noPL();
            else
                gb.PL(newLikelihoods);

            // if we weren't asked to assign a genotype, then just no-call the sample
            if ( !assignGenotypes || GvcfMathUtils.sum(newLikelihoods) > GaeaGvcfVariantContextUtils.SUM_GL_THRESH_NOCALL )
                gb.alleles(GaeaGvcfVariantContextUtils.noCallAlleles(ploidy));
            else
                assignGenotype(gb, vc, sampleName, newLikelihoods, allelesToUse, ploidy);
            newGTs.add(gb.make());
        }
    }

    return GaeaGvcfVariantContextUtils.fixADFromSubsettedAlleles(newGTs, vc, allelesToUse);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:66,代码来源:IndependentAllelesExactAFCalculator.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.getSampleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。