Functions getAsMap and getNegLog10GQ now handle missing genotype case.
This commit is contained in:
parent
19ad5b635a
commit
893787de53
|
|
@ -101,9 +101,12 @@ public class GenotypeLikelihoods {
|
|||
}
|
||||
|
||||
//Return genotype likelihoods as an EnumMap with Genotypes as keys and likelihoods as values
|
||||
//Returns null in case of missing likelihoods
|
||||
public EnumMap<Genotype.Type,Double> getAsMap(boolean normalizeFromLog10){
|
||||
//Make sure that the log10likelihoods are set
|
||||
double[] likelihoods = normalizeFromLog10 ? MathUtils.normalizeFromLog10(getAsVector()) : getAsVector();
|
||||
if(likelihoods == null)
|
||||
return null;
|
||||
EnumMap<Genotype.Type,Double> likelihoodsMap = new EnumMap<Genotype.Type, Double>(Genotype.Type.class);
|
||||
likelihoodsMap.put(Genotype.Type.HOM_REF,likelihoods[Genotype.Type.HOM_REF.ordinal()-1]);
|
||||
likelihoodsMap.put(Genotype.Type.HET,likelihoods[Genotype.Type.HET.ordinal()-1]);
|
||||
|
|
@ -112,10 +115,13 @@ public class GenotypeLikelihoods {
|
|||
}
|
||||
|
||||
//Return the neg log10 Genotype Quality (GQ) for the given genotype
|
||||
//Returns Double.NEGATIVE_INFINITY in case of missing genotype
|
||||
public double getNegLog10GQ(Genotype.Type genotype){
|
||||
|
||||
double qual = Double.NEGATIVE_INFINITY;
|
||||
EnumMap<Genotype.Type,Double> likelihoods = getAsMap(false);
|
||||
if(likelihoods == null)
|
||||
return qual;
|
||||
for(Map.Entry<Genotype.Type,Double> likelihood : likelihoods.entrySet()){
|
||||
if(likelihood.getKey() == genotype)
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Reference in New Issue