From f7ce18553e63cab7c7835a20360ecc4f6be2635f Mon Sep 17 00:00:00 2001 From: depristo Date: Wed, 20 Oct 2010 00:29:02 +0000 Subject: [PATCH] GenotypeConcordance now prints interesting sites more nicely. RMDTrackBuilder is now uses the root class FeatureSource not BasicFeatureSource. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4525 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/refdata/tracks/RMDTrack.java | 5 ++-- .../tracks/builders/RMDTrackBuilder.java | 26 +++++++++---------- .../varianteval/GenotypeConcordance.java | 8 +++--- .../sting/utils/text/XReadLines.java | 6 ++--- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrack.java b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrack.java index 6801842a5..7956e4469 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrack.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/RMDTrack.java @@ -27,7 +27,6 @@ import net.sf.samtools.SAMSequenceDictionary; import net.sf.samtools.util.CloseableIterator; import org.broad.tribble.FeatureCodec; import org.broad.tribble.FeatureSource; -import org.broad.tribble.source.BasicFeatureSource; import org.broadinstitute.sting.gatk.refdata.utils.FeatureToGATKFeatureIterator; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.utils.GenomeLoc; @@ -55,7 +54,7 @@ public class RMDTrack { private final File file; // the associated file we create the reader from // our feature reader - allows queries - private BasicFeatureSource reader; + private FeatureSource reader; // our sequence dictionary, which can be null private final SAMSequenceDictionary dictionary; @@ -102,7 +101,7 @@ public class RMDTrack { * @param dict the sam sequence dictionary * @param codec the feature codec we use to decode this type */ - public RMDTrack(Class type, String name, File file, BasicFeatureSource reader, SAMSequenceDictionary dict, FeatureCodec codec) { + public RMDTrack(Class type, String name, File file, FeatureSource reader, SAMSequenceDictionary dict, FeatureCodec codec) { this.type = type; this.recordType = codec.getFeatureType(); this.name = name; diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java index bee7f18a6..751e60cc0 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilder.java @@ -32,6 +32,7 @@ import org.broad.tribble.*; import org.broad.tribble.index.Index; import org.broad.tribble.index.IndexFactory; import org.broad.tribble.source.BasicFeatureSource; +import org.broad.tribble.source.CachingFeatureSource; import org.broad.tribble.util.LittleEndianOutputStream; import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack; import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrackCreationException; @@ -121,7 +122,7 @@ public class RMDTrackBuilder extends PluginManager { */ public RMDTrack createInstanceOfTrack(Class targetClass, String name, File inputFile) throws RMDTrackCreationException { // return a feature reader track - Pair pair = createFeatureReader(targetClass, name, inputFile); + Pair pair = createFeatureReader(targetClass, name, inputFile); if (pair == null) throw new UserException.CouldNotReadInputFile(inputFile, "Unable to make the feature reader for input file"); return new RMDTrack(targetClass, name, inputFile, pair.first, pair.second, createCodec(targetClass, name)); } @@ -132,7 +133,7 @@ public class RMDTrackBuilder extends PluginManager { * @param inputFile the input file, that corresponds to the feature type * @return a pair of */ - public Pair createFeatureReader(Class targetClass, File inputFile) { + public Pair createFeatureReader(Class targetClass, File inputFile) { return createFeatureReader(targetClass, "anonymous", inputFile); } @@ -143,8 +144,8 @@ public class RMDTrackBuilder extends PluginManager { * @param inputFile the input file to create the track from (of the codec type) * @return the FeatureReader instance */ - public Pair createFeatureReader(Class targetClass, String name, File inputFile) { - Pair pair; + public Pair createFeatureReader(Class targetClass, String name, File inputFile) { + Pair pair; if (inputFile.getAbsolutePath().endsWith(".gz")) pair = createBasicFeatureSourceNoAssumedIndex(targetClass, name, inputFile); else @@ -162,11 +163,11 @@ public class RMDTrackBuilder extends PluginManager { * @param inputFile the file to load * @return a feature reader implementation */ - private Pair createBasicFeatureSourceNoAssumedIndex(Class targetClass, String name, File inputFile) { + private Pair createBasicFeatureSourceNoAssumedIndex(Class targetClass, String name, File inputFile) { // we might not know the index type, try loading with the default reader constructor logger.info("Attempting to blindly load " + inputFile + " as a tabix indexed file"); try { - return new Pair(BasicFeatureSource.getFeatureSource(inputFile.getAbsolutePath(), createCodec(targetClass, name)),null); + return new Pair(BasicFeatureSource.getFeatureSource(inputFile.getAbsolutePath(), createCodec(targetClass, name)),null); } catch (TribbleException e) { throw new UserException(e.getMessage(), e); } @@ -192,8 +193,8 @@ public class RMDTrackBuilder extends PluginManager { * @param inputFile the tribble file to parse * @return the input file as a FeatureReader */ - private Pair getFeatureSource(Class targetClass, String name, File inputFile) { - Pair reader; + private Pair getFeatureSource(Class targetClass, String name, File inputFile) { + Pair reader; try { Index index = loadIndex(inputFile, createCodec(targetClass, name)); try { logger.info(String.format(" Index for %s has size in bytes %d", inputFile, Sizeof.getObjectGraphSize(index))); } @@ -207,11 +208,10 @@ public class RMDTrackBuilder extends PluginManager { setIndexSequenceDictionary(index,dict,indexFile,true); dictFromIndex = getSequenceDictionaryFromProperties(index); } - - reader = new Pair(new BasicFeatureSource(inputFile.getAbsolutePath(), - index, - createCodec(targetClass, name)), - dictFromIndex); + + FeatureSource source = new BasicFeatureSource(inputFile.getAbsolutePath(), index, createCodec(targetClass, name)); + //source = new CachingFeatureSource(source, 100, 100000); + reader = new Pair(source, dictFromIndex); } catch (TribbleException e) { throw new UserException(e.getMessage()); } catch (IOException e) { diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/GenotypeConcordance.java b/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/GenotypeConcordance.java index 02a576598..cd75dbafd 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/GenotypeConcordance.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/GenotypeConcordance.java @@ -312,10 +312,10 @@ public class GenotypeConcordance extends VariantEvaluator implements StandardEva } else { truth = validation.getGenotype(sample).getType(); // interesting = "ConcordanceStatus=FP"; - if (discordantInteresting && truth.ordinal() != called.ordinal()) - { - interesting = "ConcordanceStatus=" + truth.ordinal() + "/" + called.ordinal(); - } + if (discordantInteresting && truth.ordinal() != called.ordinal()) + { + interesting = "ConcordanceStatus=" + truth + "/" + called; + } } sampleStats.incrValue(sample, truth, called); diff --git a/java/src/org/broadinstitute/sting/utils/text/XReadLines.java b/java/src/org/broadinstitute/sting/utils/text/XReadLines.java index 4cf2ccf2f..064256388 100644 --- a/java/src/org/broadinstitute/sting/utils/text/XReadLines.java +++ b/java/src/org/broadinstitute/sting/utils/text/XReadLines.java @@ -84,9 +84,8 @@ public class XReadLines implements Iterator, Iterable { * Creates a new xReadLines object to read lines from an input stream * * @param inputStream - * @throws FileNotFoundException */ - public XReadLines(final InputStream inputStream, final boolean trimWhitespace) throws FileNotFoundException { + public XReadLines(final InputStream inputStream, final boolean trimWhitespace) { this(new BufferedReader(new InputStreamReader(inputStream)), trimWhitespace); } @@ -99,9 +98,8 @@ public class XReadLines implements Iterator, Iterable { * Creates a new xReadLines object to read lines from an bufferedReader * * @param reader - * @throws FileNotFoundException */ - public XReadLines(final BufferedReader reader, final boolean trimWhitespace) throws FileNotFoundException { + public XReadLines(final BufferedReader reader, final boolean trimWhitespace) { try { this.in = reader; nextline = readNextLine();