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


Java Genotype.getAllele方法代码示例

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


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

示例1: getVariationTypeForSimpleInDels

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
@NotNull private static VariationType getVariationTypeForSimpleInDels(VariantContext context,
        Genotype genotype) {
    Allele firstAllele = genotype.getAllele(0);
    Allele secondAllele = genotype.getAllele(1);
    VariationType type;
    if (firstAllele.isNonReference() && secondAllele.isNonReference()) {
        // if both are alt
        if (firstAllele.length() > context.getReference().length()
                && secondAllele.length() > context.getReference().length()) {
            type = VariationType.INS;
        } else if (firstAllele.length() < context.getReference().length() &&
                secondAllele.length() < context.getReference().length()) {
            type = VariationType.DEL;
        } else {
            type = VariationType.MIXED;
        }
    } else {
        // if both are ref
        type = VariationType.MIXED;
    }
    return type;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:23,代码来源:VcfFileReader.java

示例2: getVariationTypeForComplexInDels

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
@NotNull private static VariationType getVariationTypeForComplexInDels(Genotype genotype) {
    Allele firstAllele = genotype.getAllele(0);
    Allele secondAllele = genotype.getAllele(1);
    if (firstAllele.length() == secondAllele.length()) { // if it is a change
        return firstAllele.length() == 1 ? VariationType.SNV : VariationType.MNP;
    }
    VariationType type;
    if (firstAllele.isReference()) { // if it is an insertion/deletion
        type = genotype.getAlleles().get(0).length() > genotype.getAlleles().get(1).length() ?
                VariationType.DEL : VariationType.INS;
    } else if (secondAllele.isReference()) {
        type = genotype.getAlleles().get(1).length() > genotype.getAlleles().get(0).length() ?
                VariationType.DEL : VariationType.INS;
    } else {
        type = VariationType.MIXED;
    }
    return type;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:19,代码来源:VcfFileReader.java

示例3: getGenotypeCountsForRefVsAllAlts

import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
/**
 * Get the genotype counts for A/A, A/B, and B/B where A is the reference and B is any alternate allele
 * @param vc
 * @param genotypes may be subset to just founders if a pedigree file is provided
 * @return may be null, otherwise length-3 double[] representing homRef, het, and homVar counts
 */
public double[] getGenotypeCountsForRefVsAllAlts(final VariantContext vc, final GenotypesContext genotypes) {
    if (genotypes == null || !vc.isVariant())
        return null;

    final boolean doMultiallelicMapping = !vc.isBiallelic();

    int idxAA = 0, idxAB = 1, idxBB = 2;

    double refCount = 0;
    double hetCount = 0;
    double homCount = 0;

    sampleCount = 0;
    for (final Genotype g : genotypes) {
        if (g.isCalled() && g.hasLikelihoods() && g.getPloidy() == 2)  // only work for diploid samples
            sampleCount++;
        else
            continue;

        //Need to round the likelihoods to deal with small numerical deviations due to normalizing
        final double[] normalizedLikelihoodsUnrounded = GvcfMathUtils.normalizeFromLog10(g.getLikelihoods().getAsVector());
        double[] normalizedLikelihoods = new double[normalizedLikelihoodsUnrounded.length];
        if (returnRounded) {
            for (int i = 0; i < normalizedLikelihoodsUnrounded.length; i++) {
                normalizedLikelihoods[i] = Math.round(normalizedLikelihoodsUnrounded[i]);
            }
        } else {
            normalizedLikelihoods = normalizedLikelihoodsUnrounded;
        }

        if (doMultiallelicMapping) {
            if (g.isHetNonRef()) {
                //all likelihoods go to homCount
                homCount++;
                continue;
            }

            if (!g.isHomRef()) {
                //get alternate allele for each sample
                final Allele a1 = g.getAllele(0);
                final Allele a2 = g.getAllele(1);
                final int[] idxVector = vc.getGLIndecesOfAlternateAllele(a2.isNonReference() ? a2 : a1);
                idxAA = idxVector[0];
                idxAB = idxVector[1];
                idxBB = idxVector[2];
            }
        }

        refCount += normalizedLikelihoods[idxAA];
        hetCount += normalizedLikelihoods[idxAB];
        homCount += normalizedLikelihoods[idxBB];
    }
    return new double[]{refCount, hetCount, homCount};
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:61,代码来源:HeterozygosityUtils.java


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