VariantEval can now see the EvaluationContext group objects, so they can decide if/when to print interesting sites. GenotypeConcordance has a hard-coded option to print FNs that is on the way to being generally useful. VCFWriter now uses the US locale for formatting floating point numbers; I believe this fixes a long-standing annoyance. Italian guys will check on this.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3864 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
77cace3aff
commit
33090629ea
|
|
@ -25,7 +25,10 @@
|
||||||
|
|
||||||
package org.broad.tribble.vcf;
|
package org.broad.tribble.vcf;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public final class VCFConstants {
|
public final class VCFConstants {
|
||||||
|
public static final Locale VCF_LOCALE = Locale.US;
|
||||||
|
|
||||||
// standard INFO/FORMAT field keys
|
// standard INFO/FORMAT field keys
|
||||||
public static final String ANCESTRAL_ALLELE_KEY = "AA";
|
public static final String ANCESTRAL_ALLELE_KEY = "AA";
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ import java.util.*;
|
||||||
|
|
||||||
@Analysis(name = "Genotype Concordance", description = "Determine the genotype concordance between the genotypes in difference tracks")
|
@Analysis(name = "Genotype Concordance", description = "Determine the genotype concordance between the genotypes in difference tracks")
|
||||||
public class GenotypeConcordance extends VariantEvaluator {
|
public class GenotypeConcordance extends VariantEvaluator {
|
||||||
|
private static final boolean PRINT_INTERESTING_SITES = false;
|
||||||
|
|
||||||
protected final static Logger logger = Logger.getLogger(GenotypeConcordance.class);
|
protected final static Logger logger = Logger.getLogger(GenotypeConcordance.class);
|
||||||
|
|
||||||
// a mapping from allele count to stats
|
// a mapping from allele count to stats
|
||||||
|
|
@ -58,6 +60,7 @@ public class GenotypeConcordance extends VariantEvaluator {
|
||||||
|
|
||||||
private static final int MAX_MISSED_VALIDATION_DATA = 100;
|
private static final int MAX_MISSED_VALIDATION_DATA = 100;
|
||||||
|
|
||||||
|
private VariantEvalWalker.EvaluationContext group = null;
|
||||||
|
|
||||||
static class FrequencyStats implements TableType {
|
static class FrequencyStats implements TableType {
|
||||||
class Stats {
|
class Stats {
|
||||||
|
|
@ -229,7 +232,9 @@ public class GenotypeConcordance extends VariantEvaluator {
|
||||||
|
|
||||||
private boolean warnedAboutValidationData = false;
|
private boolean warnedAboutValidationData = false;
|
||||||
|
|
||||||
public String update2(VariantContext eval, VariantContext validation, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public String update2(VariantContext eval, VariantContext validation, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context, VariantEvalWalker.EvaluationContext group) {
|
||||||
|
this.group = group;
|
||||||
|
|
||||||
String interesting = null;
|
String interesting = null;
|
||||||
|
|
||||||
// sanity check that we at least have either eval or validation data
|
// sanity check that we at least have either eval or validation data
|
||||||
|
|
@ -287,7 +292,6 @@ public class GenotypeConcordance extends VariantEvaluator {
|
||||||
truth = Genotype.Type.NO_CALL;
|
truth = Genotype.Type.NO_CALL;
|
||||||
} else {
|
} else {
|
||||||
truth = validation.getGenotype(sample).getType();
|
truth = validation.getGenotype(sample).getType();
|
||||||
// TODO -- capture "interesting" sites here, for example:
|
|
||||||
// interesting = "ConcordanceStatus=FP";
|
// interesting = "ConcordanceStatus=FP";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,6 +305,9 @@ public class GenotypeConcordance extends VariantEvaluator {
|
||||||
for (final String sample : validation.getSampleNames()) {
|
for (final String sample : validation.getSampleNames()) {
|
||||||
final Genotype.Type truth = validation.getGenotype(sample).getType();
|
final Genotype.Type truth = validation.getGenotype(sample).getType();
|
||||||
sampleStats.incrValue(sample, truth, called);
|
sampleStats.incrValue(sample, truth, called);
|
||||||
|
if ( (truth == Genotype.Type.HOM_VAR || truth == Genotype.Type.HET) && called == Genotype.Type.NO_CALL ) {
|
||||||
|
if ( PRINT_INTERESTING_SITES ) System.out.printf("%s: HM3 FN => %s%n", group, validation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
||||||
// --------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** private class holding all of the information about a single evaluation group (e.g., for eval ROD) */
|
/** private class holding all of the information about a single evaluation group (e.g., for eval ROD) */
|
||||||
private class EvaluationContext implements Comparable<EvaluationContext> {
|
public class EvaluationContext implements Comparable<EvaluationContext> {
|
||||||
// useful for typing
|
// useful for typing
|
||||||
public String evalTrackName, compTrackName, novelty, filtered;
|
public String evalTrackName, compTrackName, novelty, filtered;
|
||||||
public boolean enableInterestingSiteCaptures = false;
|
public boolean enableInterestingSiteCaptures = false;
|
||||||
|
|
@ -221,6 +221,8 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
||||||
return Utils.join(CONTEXT_SEPARATOR, Arrays.asList(evalTrackName, compTrackName, selectExp == null ? "all" : selectExp.name, filtered, novelty));
|
return Utils.join(CONTEXT_SEPARATOR, Arrays.asList(evalTrackName, compTrackName, selectExp == null ? "all" : selectExp.name, filtered, novelty));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() { return getDisplayName(); }
|
||||||
|
|
||||||
public int compareTo(EvaluationContext other) {
|
public int compareTo(EvaluationContext other) {
|
||||||
return this.getDisplayName().compareTo(other.getDisplayName());
|
return this.getDisplayName().compareTo(other.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
@ -495,7 +497,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
||||||
switch ( evaluation.getComparisonOrder() ) {
|
switch ( evaluation.getComparisonOrder() ) {
|
||||||
case 1:
|
case 1:
|
||||||
if ( evalWantsVC && vc != null ) {
|
if ( evalWantsVC && vc != null ) {
|
||||||
String interesting = evaluation.update1(vc, tracker, ref, context);
|
String interesting = evaluation.update1(vc, tracker, ref, context, group);
|
||||||
if ( interesting != null ) interestingReasons.add(interesting);
|
if ( interesting != null ) interestingReasons.add(interesting);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -506,7 +508,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
||||||
comp.hasNegLog10PError() &&
|
comp.hasNegLog10PError() &&
|
||||||
comp.getNegLog10PError() < (minCompQualScore / 10.0) )
|
comp.getNegLog10PError() < (minCompQualScore / 10.0) )
|
||||||
comp = null;
|
comp = null;
|
||||||
String interesting = evaluation.update2( evalWantsVC ? vc : null, comp, tracker, ref, context );
|
String interesting = evaluation.update2( evalWantsVC ? vc : null, comp, tracker, ref, context, group );
|
||||||
if ( interesting != null ) interestingReasons.add(interesting);
|
if ( interesting != null ) interestingReasons.add(interesting);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,20 @@ abstract class VariantEvaluator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String update1(VariantContext vc1, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context, VariantEvalWalker.EvaluationContext group) {
|
||||||
|
return update1(vc1, tracker, ref, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String update2(VariantContext vc1, VariantContext vc2, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public String update2(VariantContext vc1, VariantContext vc2, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String update2(VariantContext vc1, VariantContext vc2, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context, VariantEvalWalker.EvaluationContext group) {
|
||||||
|
return update2(vc1, vc2, tracker, ref, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* override this method for any finalization of calculations after the analysis is completed
|
* override this method for any finalization of calculations after the analysis is completed
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ public class VCFWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getQualValue(double qual) {
|
private String getQualValue(double qual) {
|
||||||
String s = String.format(VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, qual);
|
String s = String.format(VCFConstants.VCF_LOCALE, VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, qual);
|
||||||
if ( s.endsWith(VCFConstants.DOUBLE_PRECISION_INT_SUFFIX) )
|
if ( s.endsWith(VCFConstants.DOUBLE_PRECISION_INT_SUFFIX) )
|
||||||
s = s.substring(0, s.length() - VCFConstants.DOUBLE_PRECISION_INT_SUFFIX.length());
|
s = s.substring(0, s.length() - VCFConstants.DOUBLE_PRECISION_INT_SUFFIX.length());
|
||||||
return s;
|
return s;
|
||||||
|
|
@ -387,7 +387,7 @@ public class VCFWriter {
|
||||||
if ( val == null )
|
if ( val == null )
|
||||||
result = VCFConstants.MISSING_VALUE_v4;
|
result = VCFConstants.MISSING_VALUE_v4;
|
||||||
else if ( val instanceof Double )
|
else if ( val instanceof Double )
|
||||||
result = String.format(VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, (Double)val);
|
result = String.format(VCFConstants.VCF_LOCALE, VCFConstants.DOUBLE_PRECISION_FORMAT_STRING, (Double)val);
|
||||||
else if ( val instanceof Boolean )
|
else if ( val instanceof Boolean )
|
||||||
result = (Boolean)val ? "" : null; // empty string for true, null for false
|
result = (Boolean)val ? "" : null; // empty string for true, null for false
|
||||||
else if ( val instanceof List ) {
|
else if ( val instanceof List ) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue