From 091229e4dbf99666668ce8214f360e6138994fdb Mon Sep 17 00:00:00 2001 From: Christopher Hartl Date: Wed, 9 Nov 2011 11:03:29 -0500 Subject: [PATCH] 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. --- .../sting/gatk/walkers/annotator/MVLikelihoodRatio.java | 8 ++++---- .../sting/utils/codecs/table/TableCodec.java | 6 ++++++ .../sting/utils/codecs/table/TableFeature.java | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java index e0a2329f8..8da64608f 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java @@ -33,7 +33,7 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment public Map annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map 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 toRet = new HashMap(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)); diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java index 1919ccbf0..fac926587 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java @@ -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); diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java index a85849f0b..4b5c51bd4 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java @@ -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);