-Don't annotate allele balance or on-off genotype if there's no genotype data

-If qscore is infinity (because of precision) make a best guess instead


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2076 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-11-18 22:01:32 +00:00
parent 90212c643b
commit f667bed7fc
3 changed files with 44 additions and 41 deletions

View File

@ -11,31 +11,32 @@ import java.util.ArrayList;
public class AlleleBalance implements VariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {
double ratio = -1;
if ( genotypes.size() > 0 ) {
Genotype g = genotypes.get(0);
if ( g instanceof ReadBacked && g instanceof PosteriorsBacked ) {
Pair<Double, Integer> weightedBalance = computeWeightedBalance(ref.getBase(), genotypes, pileup);
if ( weightedBalance.second == 0 )
return null;
ratio = weightedBalance.first;
} else {
// this test doesn't make sense for homs
Genotype genotype = VariantAnnotator.getFirstHetVariant(genotypes);
if ( genotype == null )
return null;
if ( genotypes.size() == 0 )
return null;
final String genotypeStr = genotype.getBases().toUpperCase();
if ( genotypeStr.length() != 2 )
return null;
double ratio;
Genotype g = genotypes.get(0);
if ( g instanceof ReadBacked && g instanceof PosteriorsBacked ) {
Pair<Double, Integer> weightedBalance = computeWeightedBalance(ref.getBase(), genotypes, pileup);
if ( weightedBalance.second == 0 )
return null;
ratio = weightedBalance.first;
} else {
// this test doesn't make sense for homs
Genotype genotype = VariantAnnotator.getFirstHetVariant(genotypes);
if ( genotype == null )
return null;
final String bases = pileup.getBasesAsString().toUpperCase();
if ( bases.length() == 0 )
return null;
final String genotypeStr = genotype.getBases().toUpperCase();
if ( genotypeStr.length() != 2 )
return null;
ratio = computeSingleBalance(ref.getBase(), genotypeStr, bases);
}
final String bases = pileup.getBasesAsString().toUpperCase();
if ( bases.length() == 0 )
return null;
ratio = computeSingleBalance(ref.getBase(), genotypeStr, bases);
}
return new Pair<String, String>("AlleleBalance", String.format("%.2f", ratio));

View File

@ -14,30 +14,30 @@ public class OnOffGenotype implements VariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {
double ratio = -1;
if ( genotypes.size() == 0 )
return null;
if ( genotypes.size() > 0 ) {
Genotype g = genotypes.get(0);
if ( g instanceof ReadBacked && g instanceof PosteriorsBacked) {
Pair<Double, Integer> weightedBalance = computeWeightedBalance(ref.getBase(), genotypes, pileup);
if ( weightedBalance.second == 0 )
return null;
ratio = weightedBalance.first;
} else {
Genotype genotype = VariantAnnotator.getFirstVariant(ref.getBase(), genotypes);
if ( genotype == null )
return null;
double ratio;
Genotype g = genotypes.get(0);
if ( g instanceof ReadBacked && g instanceof PosteriorsBacked) {
Pair<Double, Integer> weightedBalance = computeWeightedBalance(ref.getBase(), genotypes, pileup);
if ( weightedBalance.second == 0 )
return null;
ratio = weightedBalance.first;
} else {
Genotype genotype = VariantAnnotator.getFirstVariant(ref.getBase(), genotypes);
if ( genotype == null )
return null;
final String genotypeStr = genotype.getBases().toUpperCase();
if ( genotypeStr.length() != 2 )
return null;
final String genotypeStr = genotype.getBases().toUpperCase();
if ( genotypeStr.length() != 2 )
return null;
final String bases = pileup.getBasesAsString().toUpperCase();
if ( bases.length() == 0 )
return null;
final String bases = pileup.getBasesAsString().toUpperCase();
if ( bases.length() == 0 )
return null;
ratio = computeSingleBalance(genotypeStr, bases);
}
ratio = computeSingleBalance(genotypeStr, bases);
}
return new Pair<String, String>("OnOffGenotype", String.format("%.2f", ratio));

View File

@ -238,6 +238,8 @@ public abstract class JointEstimateGenotypeCalculationModel extends GenotypeCalc
}
double phredScaledConfidence = -10.0 * Math.log10(alleleFrequencyPosteriors[indexOfMax][0]);
if ( Double.isInfinite(phredScaledConfidence) )
phredScaledConfidence = -10.0 * log10PofDgivenAFi[indexOfMax][0];
int bestAFguess = Utils.findIndexOfMaxEntry(alleleFrequencyPosteriors[indexOfMax]);
// return a null call if we don't pass the confidence cutoff or the most likely allele frequency is zero