本文整理汇总了Java中htsjdk.variant.variantcontext.Genotype.isCalled方法的典型用法代码示例。如果您正苦于以下问题:Java Genotype.isCalled方法的具体用法?Java Genotype.isCalled怎么用?Java Genotype.isCalled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.variant.variantcontext.Genotype
的用法示例。
在下文中一共展示了Genotype.isCalled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public void annotate(final RefMetaDataTracker tracker,
final AnnotatorCompatible walker,
final ReferenceContext ref,
final AlignmentContext stratifiedContext,
final VariantContext vc,
final Genotype g,
final GenotypeBuilder gb,
final PerReadAlleleLikelihoodMap alleleLikelihoodMap) {
if ( g == null || !g.isCalled() || ( stratifiedContext == null && alleleLikelihoodMap == null) )
return;
if (alleleLikelihoodMap != null && !alleleLikelihoodMap.isEmpty())
annotateWithLikelihoods(alleleLikelihoodMap, vc, gb);
else if ( stratifiedContext != null && (vc.isSNP()))
annotateWithPileup(stratifiedContext, vc, gb);
}
示例2: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public void annotate(final RefMetaDataTracker tracker,
final AnnotatorCompatible walker,
final ReferenceContext ref,
final AlignmentContext stratifiedContext,
final VariantContext vc,
final Genotype g,
final GenotypeBuilder gb,
final PerReadAlleleLikelihoodMap alleleLikelihoodMap){
if ( g == null || !g.isCalled() || stratifiedContext == null )
return;
int mq0 = 0;
final ReadBackedPileup pileup = stratifiedContext.getBasePileup();
for (PileupElement p : pileup ) {
if ( p.getMappingQual() == 0 )
mq0++;
}
gb.attribute(getKeyNames().get(0), mq0);
}
示例3: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public Map<String, Object> annotate(final VariantDataTracker tracker,
final ChromosomeInformationShare ref,
final Mpileup mpileup,
final VariantContext vc,
final Map<String, PerReadAlleleLikelihoodMap> stratifiedPerReadAlleleLikelihoodMap) {
if ( vc.isMonomorphicInSamples() || !vc.hasGenotypes() )
return null;
StringBuffer samples = new StringBuffer();
for ( Genotype genotype : vc.getGenotypesOrderedByName() ) {
if ( genotype.isCalled() && !genotype.isHomRef() ){
if ( samples.length() > 0 )
samples.append(",");
samples.append(genotype.getSampleName());
}
}
if ( samples.length() == 0 )
return null;
Map<String, Object> map = new HashMap<String, Object>();
map.put("Samples", samples.toString());
return map;
}
示例4: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public void annotate(final VariantDataTracker tracker,
final ChromosomeInformationShare ref,
final Pileup pileup,
final VariantContext vc,
final Genotype g,
final GenotypeBuilder gb,
final PerReadAlleleLikelihoodMap alleleLikelihoodMap){
if ( g == null || !g.isCalled() || pileup == null )
return;
int mq0 = 0;
for (PileupReadInfo p : pileup.getTotalPileup() ) {
if ( p.getMappingQuality() == 0 )
mq0++;
}
gb.attribute(getKeyNames().get(0), mq0);
}
示例5: 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;
}
示例6: containsCalls
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private boolean containsCalls(final HaplotypeCallerGenotypingEngine.CalledHaplotypes calledHaplotypes) {
final List<VariantContext> calls = calledHaplotypes.getCalls();
if (calls.isEmpty()) return false;
for (final VariantContext call : calls)
for (final Genotype genotype : call.getGenotypes())
if (genotype.isCalled())
return true;
return false;
}
示例7: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public void annotate(final RefMetaDataTracker tracker,
final AnnotatorCompatible walker,
final ReferenceContext ref,
final AlignmentContext stratifiedContext,
final VariantContext vc,
final Genotype g,
final GenotypeBuilder gb,
final PerReadAlleleLikelihoodMap alleleLikelihoodMap) {
if (g == null || !g.isCalled() || (stratifiedContext == null && alleleLikelihoodMap == null))
return;
if (alleleLikelihoodMap == null)
throw new IllegalStateException("DepthPerSampleHC can only be used with likelihood based annotations in the HaplotypeCaller");
// the depth for the HC is the sum of the informative alleles at this site. It's not perfect (as we cannot
// differentiate between reads that align over the event but aren't informative vs. those that aren't even
// close) but it's a pretty good proxy and it matches with the AD field (i.e., sum(AD) = DP).
int dp = 0;
if (alleleLikelihoodMap.isEmpty()) {
// there are no reads
} else {
final Set<Allele> alleles = new HashSet<>(vc.getAlleles());
// make sure that there's a meaningful relationship between the alleles in the perReadAlleleLikelihoodMap and our VariantContext
if (!alleleLikelihoodMap.getAllelesSet().containsAll(alleles))
throw new IllegalStateException("VC alleles " + alleles + " not a strict subset of per read allele map alleles " + alleleLikelihoodMap.getAllelesSet());
for (Map.Entry<GATKSAMRecord, Map<Allele, Double>> el : alleleLikelihoodMap.getLikelihoodReadMap().entrySet()) {
final MostLikelyAllele a = PerReadAlleleLikelihoodMap.getMostLikelyAllele(el.getValue(), alleles);
if (a.isInformative()) {
dp++;
}
}
gb.DP(dp);
}
}
示例8: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public void annotate(final VariantDataTracker tracker,
final ChromosomeInformationShare ref,
final Pileup pileup,
final VariantContext vc,
final Genotype g,
final GenotypeBuilder gb,
final PerReadAlleleLikelihoodMap alleleLikelihoodMap) {
if ( g == null || !g.isCalled() || ( pileup == null && alleleLikelihoodMap == null) )
return;
if (alleleLikelihoodMap != null && !alleleLikelihoodMap.isEmpty())
annotateWithLikelihoods(alleleLikelihoodMap, vc, gb);
else if ( pileup != null && (vc.isSNP()))
annotateWithPileup(pileup, vc, gb);
}
示例9: annotateSNP
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private Double annotateSNP(Pileup pileup, VariantContext vc, Genotype g) {
double ratio = -1;
if ( !vc.isSNP() )
return null;
if ( !vc.isBiallelic() )
return null;
if ( g == null || !g.isCalled() )
return null;
if (!g.isHet())
return null;
Collection<Allele> altAlleles = vc.getAlternateAlleles();
if ( altAlleles.size() == 0 )
return null;
final String bases = new String(pileup.getBases());
if ( bases.length() == 0 )
return null;
char refChr = vc.getReference().toString().charAt(0);
char altChr = vc.getAlternateAllele(0).toString().charAt(0);
int refCount = MathUtils.countOccurrences(refChr, bases);
int altCount = MathUtils.countOccurrences(altChr, bases);
// sanity check
if ( refCount + altCount == 0 )
return null;
ratio = ((double)refCount / (double)(refCount + altCount));
return ratio;
}
示例10: isAppropriateInput
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
private boolean isAppropriateInput(final PerReadAlleleLikelihoodMap map, final Genotype g) {
return ! (map == null || g == null || !g.isCalled());
}
示例11: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public void annotate(final RefMetaDataTracker tracker,
final AnnotatorCompatible walker,
final ReferenceContext ref,
final AlignmentContext stratifiedContext,
final VariantContext vc,
final Genotype g,
final GenotypeBuilder gb,
final PerReadAlleleLikelihoodMap alleleLikelihoodMap) {
// We need a heterozygous genotype and either a context or alleleLikelihoodMap
if (g == null || !g.isCalled() || !g.isHet() || (stratifiedContext == null && alleleLikelihoodMap == null))
return;
// Test for existence of <NON_REF> allele, and manually check isSNP()
// and isBiallelic() while ignoring the <NON_REF> allele
boolean biallelicSNP = vc.isSNP() && vc.isBiallelic();
if (vc.hasAllele(GVCF_NONREF)) {
// If we have the GVCF <NON_REF> allele, then the SNP is biallelic
// iff there are 3 alleles and both the reference and first alt
// allele are length 1.
biallelicSNP = vc.getAlleles().size() == 3 &&
vc.getReference().length() == 1 &&
vc.getAlternateAllele(0).length() == 1;
}
if (!biallelicSNP)
return;
Double ratio;
if (alleleLikelihoodMap != null && !alleleLikelihoodMap.isEmpty())
ratio = annotateWithLikelihoods(alleleLikelihoodMap, vc);
else if (stratifiedContext != null)
ratio = annotateWithPileup(stratifiedContext, vc);
else
return;
if (ratio == null)
return;
gb.attribute(getKeyNames().get(0), Double.valueOf(String.format("%.2f", ratio)));
}
示例12: isVar
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public boolean isVar(Genotype gt){
return gt.isCalled() && !gt.isHomRef();
}
示例13: isVar
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
public boolean isVar(Genotype gt){
return gt.isCalled() && !gt.isHomRef();
}
示例14: annotate
import htsjdk.variant.variantcontext.Genotype; //导入方法依赖的package包/类
@Override
public void annotate(RefMetaDataTracker tracker, ChromosomeInformationShare ref, VariantContext vc, Genotype g,
GenotypeBuilder gb) {
if ( g == null || !g.isCalled() )
return;
}
示例15: 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};
}