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


Java Genotype.getAlleles方法代码示例

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


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

示例1: mergeGenotypes

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private static void mergeGenotypes(GenotypesContext mergedGenotypes, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniquifySamples) {
    //TODO: should we add a check for cases when the genotypeMergeOption is REQUIRE_UNIQUE
    for ( final Genotype g : oneVC.getGenotypes() ) {
        final String name = mergedSampleName(oneVC.getSource(), g.getSampleName(), uniquifySamples);
        if ( ! mergedGenotypes.containsSample(name) ) {
            // only add if the name is new
            Genotype newG = g;

            if ( uniquifySamples || alleleMapping.needsRemapping() ) {
                final List<Allele> alleles = alleleMapping.needsRemapping() ? alleleMapping.remap(g.getAlleles()) : g.getAlleles();
                newG = new GenotypeBuilder(g).name(name).alleles(alleles).make();
            }

            mergedGenotypes.add(newG);
        }
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:18,代码来源:GATKVariantContextUtils.java

示例2: incrementChromosomeCountsInfo

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * Increment the number of called alternate and reference plus alternate
 * alleles for a genotype
 *
 * @param calledAltAlleles
 *            number of called alternate alleles for all genotypes
 * @param calledAlleles
 *            number of called alleles for all genotypes
 * @param genotype
 *            genotype
 * @return incremented called alleles
 * @throws IllegalArgumentException
 *             if calledAltAlleles or genotype are null
 */
public static int incrementChromosomeCountsInfo(final Map<Allele, Integer> calledAltAlleles,
		final int calledAlleles, final Genotype genotype) {
	if (calledAltAlleles == null)
		throw new IllegalArgumentException("Called alternate alleles can not be null");
	if (genotype == null)
		throw new IllegalArgumentException("Genotype can not be null");

	int incrementedCalledAlleles = calledAlleles;
	if (genotype.isCalled()) {
		for (final Allele allele : genotype.getAlleles()) {
			incrementedCalledAlleles++;
			if (allele.isNonReference()) {
				calledAltAlleles.put(allele, calledAltAlleles.get(allele) + 1);
			}
		}
	}

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

示例3: calculateMLEAlleleFrequencies

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private ArrayList<Double> calculateMLEAlleleFrequencies(List<Integer> alleleCountsofMLE,
		GenotypesContext genotypes) {
	int AN = 0;
	for (final Genotype g : genotypes)
		for (final Allele a : g.getAlleles())
			if (!a.isNoCall())
				AN++;

	final ArrayList<Double> MLEfrequencies = new ArrayList<>(alleleCountsofMLE.size());
	// the MLEAC is allowed to be larger than the AN (e.g. in the case of
	// all PLs being 0, the GT is ./. but the exact model may arbitrarily
	// choose an AC>1)
	for (final int AC : alleleCountsofMLE)
		MLEfrequencies.add(Math.min(1.0, (double) AC / (double) AN));
	return MLEfrequencies;
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:17,代码来源:UnifiedGenotypingEngine.java

示例4: genotypeAsAlleleIndexes

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/** Get the sample genotype in the same format as it appears on the VCF file.
    * I.e. allele indexes separated by '/' or '|' (if phased). E.g. 0/0, 0/1 etc 
    */
private String genotypeAsAlleleIndexes(VariantContext ctx, String sample) {
	Genotype gt = ctx.getGenotype(sample);
	char sep= gt.isPhased() ? '|' : '/';
	List<String> all= new ArrayList<String>();
	for(Allele a : gt.getAlleles()){
		if(a.isNoCall()){
			all.add(".");
		}
		else {
			int i= ctx.getAlleleIndex(a);
			all.add(Integer.toString(i));
		}
	}
	return '"' + Joiner.on(sep).join(all) + '"';
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:19,代码来源:GenotypeMatrix.java

示例5: makeCombinedAltAllelesVariantContext

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private VariantContext makeCombinedAltAllelesVariantContext(final VariantContext vc) {
    final int nAltAlleles = vc.getNAlleles() - 1;

    if ( nAltAlleles == 1 )
        return vc;
    else {
        final VariantContextBuilder vcb = new VariantContextBuilder(vc);
        final Allele reference = vcb.getAlleles().get(0);
        vcb.alleles(Arrays.asList(reference, GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE));
        final int genotypeCount = GenotypeLikelihoodCalculators.genotypeCount(2, vc.getNAlleles());
        final double[] hetLikelihoods = new double[vc.getNAlleles() - 1];
        final double[] homAltLikelihoods = new double[genotypeCount - hetLikelihoods.length - 1];
        final double[] newLikelihoods = new double[3];
        final List<Genotype> newGenotypes = new ArrayList<>(vc.getNSamples());
        for (final Genotype oldGenotype : vc.getGenotypes()) {
            final GenotypeBuilder gb = new GenotypeBuilder(oldGenotype);
            final List<Allele> oldAlleles = oldGenotype.getAlleles();
            if (oldAlleles != null) {
                final List<Allele> newAlleles = new ArrayList<>(oldAlleles.size());
                for (int i = 0; i < oldAlleles.size(); i++) {
                    final Allele oldAllele = oldAlleles.get(i);
                    if (oldAllele.isReference())
                        newAlleles.add(reference);
                    else if (oldAllele.isNoCall())
                        newAlleles.add(Allele.NO_CALL);
                    else
                        newAlleles.add(GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE);
                }
                gb.alleles(newAlleles);
            }
            if (combineAltAlleleLikelihoods(oldGenotype, genotypeCount, newLikelihoods, hetLikelihoods, homAltLikelihoods))
                gb.PL(newLikelihoods);
            newGenotypes.add(gb.make());
        }
        return vcb.genotypes(newGenotypes).make();
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:38,代码来源:IndependentAllelesDiploidExactAFCalculator.java

示例6: calculateMLEAlleleFrequencies

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private ArrayList<Double> calculateMLEAlleleFrequencies(List<Integer> alleleCountsofMLE, GenotypesContext genotypes) {
    int AN = 0;
    for (final Genotype g : genotypes)
        for (final Allele a : g.getAlleles())
            if (!a.isNoCall()) AN++;

    final ArrayList<Double> MLEfrequencies = new ArrayList<Double>(alleleCountsofMLE.size());
    // the MLEAC is allowed to be larger than the AN (e.g. in the case of all PLs being 0, the GT is ./. but the exact model may arbitrarily choose an AC>1)
    for (final int AC : alleleCountsofMLE )
        MLEfrequencies.add(Math.min(1.0, (double)AC / (double)AN));
    return MLEfrequencies;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:13,代码来源:GenotypingEngine.java

示例7: getTrueAlleles

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
protected VariantContext getTrueAlleles(final RefMetaDataTracker tracker,
                                        final ReferenceContext ref,
                                        Map<String,AlignmentContext> contexts) {
    // Get reference base from VCF or Reference
    if (UAC.referenceSampleName == null)
        return null;

    AlignmentContext context = contexts.get(UAC.referenceSampleName);
    ArrayList<Allele> trueReferenceAlleles = new ArrayList<Allele>();

    VariantContext referenceSampleVC;

    if (tracker != null && context != null)
        referenceSampleVC = tracker.getFirstValue(UAC.referenceSampleRod, context.getLocation());
    else
        return null;

    if (referenceSampleVC == null) {
        trueReferenceAlleles.add(Allele.create(ref.getBase(),true));
        return new VariantContextBuilder("pc",ref.getLocus().getContig(), ref.getLocus().getStart(), ref.getLocus().getStop(),trueReferenceAlleles).make();

    }
    else {
        Genotype referenceGenotype = referenceSampleVC.getGenotype(UAC.referenceSampleName);
        List<Allele> referenceAlleles = referenceGenotype.getAlleles();

        return new VariantContextBuilder("pc",referenceSampleVC.getChr(), referenceSampleVC.getStart(), referenceSampleVC.getEnd(),
                referenceSampleVC.getAlleles())
                .genotypes(new GenotypeBuilder(UAC.referenceSampleName, referenceAlleles).GQ(referenceGenotype.getGQ()).make())
                .make();
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:33,代码来源:GeneralPloidyGenotypeLikelihoodsCalculationModel.java

示例8: basicStatics

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private boolean[] basicStatics(Genotype gt, IntArray array, Allele Ref,GenotypeType type) {
	boolean[] conf = new boolean[4];
	Arrays.fill(conf, false);

	List<Allele> alts = gt.getAlleles();
	if(type == GenotypeType.NO_CALL || type == GenotypeType.HOM_REF)
		return conf;
	boolean isBiallelic = determinePolymorphicType(Ref, alts, conf);
	if(!isBiallelic)
		return new boolean[]{false,false,false,false};
	
	array.incr(VariantEnum.VARIANTS);
	if (conf[0])
		array.incr(VariantEnum.SNPS);
	if (conf[1])
		array.incr(VariantEnum.MNPS);
	if (conf[2]) {
		array.incr(VariantEnum.INSERTIONS);
	}
	if (conf[3]) {
		array.incr(VariantEnum.DELETIONS);
	}

	if (conf[2] || conf[3])
		array.incr(VariantEnum.INDELS);

	if (conf[0] && isBiallelic && isTransition(alts.get(0),alts.get(1))) {
		array.incr(VariantEnum.TRANSITIONS);
	} else if (conf[0] && isBiallelic)
		array.incr(VariantEnum.TRANSVERSIONS);

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

示例9: makeCombinedAltAllelesVariantContext

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private VariantContext makeCombinedAltAllelesVariantContext(final VariantContext vc) {
    final int nAltAlleles = vc.getNAlleles() - 1;

    if ( nAltAlleles == 1 )
        return vc;
    else {
        final VariantContextBuilder vcb = new VariantContextBuilder(vc);
        final Allele reference = vcb.getAlleles().get(0);
        vcb.alleles(Arrays.asList(reference, GaeaVCFConstants.NON_REF_SYMBOLIC_ALLELE));
        final int genotypeCount = GenotypeLikelihoodCalculators.genotypeCount(2, vc.getNAlleles());
        final double[] hetLikelihoods = new double[vc.getNAlleles() - 1];
        final double[] homAltLikelihoods = new double[genotypeCount - hetLikelihoods.length - 1];
        final double[] newLikelihoods = new double[3];
        final List<Genotype> newGenotypes = new ArrayList<>(vc.getNSamples());
        for (final Genotype oldGenotype : vc.getGenotypes()) {
            final GenotypeBuilder gb = new GenotypeBuilder(oldGenotype);
            final List<Allele> oldAlleles = oldGenotype.getAlleles();
            if (oldAlleles != null) {
                final List<Allele> newAlleles = new ArrayList<>(oldAlleles.size());
                for (int i = 0; i < oldAlleles.size(); i++) {
                    final Allele oldAllele = oldAlleles.get(i);
                    if (oldAllele.isReference())
                        newAlleles.add(reference);
                    else if (oldAllele.isNoCall())
                        newAlleles.add(Allele.NO_CALL);
                    else
                        newAlleles.add(GaeaVCFConstants.NON_REF_SYMBOLIC_ALLELE);
                }
                gb.alleles(newAlleles);
            }
            if (oldGenotype.isNonInformative())
                gb.PL(BIALLELIC_NON_INFORMATIVE_PLS);
            else if (combineAltAlleleLikelihoods(oldGenotype, genotypeCount, newLikelihoods, hetLikelihoods, homAltLikelihoods))
                gb.PL(newLikelihoods);
            newGenotypes.add(gb.make());
        }
        return vcb.genotypes(newGenotypes).make();
    }
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:40,代码来源:IndependentAllelesDiploidExactAFCalculator.java


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