MVLikelihoodRatio now checks if the family string is provided before attempting to instantiate. Also check that variant contexts have both genotypes and genotype likelihoods.

Table codec now yells at users for not providing a HEADER with the table - parsing tables without a header line was causing the first line of the file to be eaten.
Table feature now has a toString method.

These are minor bug fixes.
This commit is contained in:
Christopher Hartl 2011-11-09 11:03:29 -05:00
parent b0e6afec48
commit 091229e4db
3 changed files with 16 additions and 4 deletions

View File

@ -33,7 +33,7 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( mendelianViolation == null ) {
if ( walker instanceof VariantAnnotator ) {
if ( walker instanceof VariantAnnotator && ((VariantAnnotator) walker).familyStr != null) {
mendelianViolation = new MendelianViolation(((VariantAnnotator)walker).familyStr, ((VariantAnnotator)walker).minGenotypeQualityP );
}
else {
@ -42,9 +42,9 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment
}
Map<String,Object> toRet = new HashMap<String,Object>(1);
boolean hasAppropriateGenotypes = vc.hasGenotype(mendelianViolation.getSampleChild()) &&
vc.hasGenotype(mendelianViolation.getSampleDad()) &&
vc.hasGenotype(mendelianViolation.getSampleMom());
boolean hasAppropriateGenotypes = vc.hasGenotype(mendelianViolation.getSampleChild()) && vc.getGenotype(mendelianViolation.getSampleChild()).hasLikelihoods() &&
vc.hasGenotype(mendelianViolation.getSampleDad()) && vc.getGenotype(mendelianViolation.getSampleDad()).hasLikelihoods() &&
vc.hasGenotype(mendelianViolation.getSampleMom()) && vc.getGenotype(mendelianViolation.getSampleMom()).hasLikelihoods();
if ( hasAppropriateGenotypes )
toRet.put("MVLR",mendelianViolation.violationLikelihoodRatio(vc));

View File

@ -86,7 +86,13 @@ public class TableCodec implements ReferenceDependentFeatureCodec {
public Object readHeader(LineReader reader) {
String line = "";
try {
boolean isFirst = true;
while ((line = reader.readLine()) != null) {
System.out.println(line);
if ( isFirst && ! line.startsWith(headerDelimiter) ) {
throw new UserException.MalformedFile("TableCodec file does not have a header");
}
isFirst &= false;
if (line.startsWith(headerDelimiter)) {
if (header.size() > 0) throw new IllegalStateException("Input table file seems to have two header lines. The second is = " + line);
String spl[] = line.split(delimiterRegex);

View File

@ -1,7 +1,9 @@
package org.broadinstitute.sting.utils.codecs.table;
import org.broad.tribble.Feature;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.Utils;
import java.util.List;
@ -44,6 +46,10 @@ public class TableFeature implements Feature {
return values.get(columnPosition);
}
public String toString() {
return String.format("%s\t%s",position.toString(), Utils.join("\t",values));
}
public String get(String columnName) {
int position = keys.indexOf(columnName);
if (position < 0) throw new IllegalArgumentException("We don't have a column named " + columnName);