From b6ce6ed3f8a9017217652c09d25394ca88d2b353 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 26 Oct 2011 15:42:53 -0400 Subject: [PATCH] Go around the ROD system for now so that we can just call decodeLoc() for efficiency. Noted that we should go through the ROD system once it gets cleaned up. This means that currently gzipped files are not supported with -L. --- .../sting/commandline/IntervalBinding.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/commandline/IntervalBinding.java b/public/java/src/org/broadinstitute/sting/commandline/IntervalBinding.java index 7fcf50e9e..e515227a6 100644 --- a/public/java/src/org/broadinstitute/sting/commandline/IntervalBinding.java +++ b/public/java/src/org/broadinstitute/sting/commandline/IntervalBinding.java @@ -27,14 +27,19 @@ package org.broadinstitute.sting.commandline; import com.google.java.contract.Requires; import net.sf.samtools.util.CloseableIterator; import org.broad.tribble.Feature; +import org.broad.tribble.FeatureCodec; +import org.broad.tribble.readers.AsciiLineReader; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.gatk.refdata.tracks.FeatureManager; import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrackBuilder; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.utils.GenomeLoc; +import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.interval.IntervalUtils; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.util.*; /** @@ -74,15 +79,25 @@ public final class IntervalBinding { if ( featureIntervals != null ) { intervals = new ArrayList(); - RMDTrackBuilder builder = new RMDTrackBuilder(toolkit.getReferenceDataSource().getReference().getSequenceDictionary(), - toolkit.getGenomeLocParser(), - toolkit.getArguments().unsafe); - FeatureManager.FeatureDescriptor descriptor = new FeatureManager().getByName(featureIntervals.getTribbleType()); - CloseableIterator iterator = builder.createInstanceOfTrack(descriptor.getCodecClass(), new File(featureIntervals.getSource())).getIterator(); - while ( iterator.hasNext() ) { - intervals.add(iterator.next().getLocation()); + //RMDTrackBuilder builder = new RMDTrackBuilder(toolkit.getReferenceDataSource().getReference().getSequenceDictionary(), + // toolkit.getGenomeLocParser(), + // toolkit.getArguments().unsafe); + + // TODO -- after ROD system cleanup, go through the ROD system so that we can handle things like gzipped files + + FeatureCodec codec = new FeatureManager().getByName(featureIntervals.getTribbleType()).getCodec(); + try { + FileInputStream fis = new FileInputStream(new File(featureIntervals.getSource())); + AsciiLineReader lineReader = new AsciiLineReader(fis); + codec.readHeader(lineReader); + String line = lineReader.readLine(); + while ( line != null ) { + intervals.add(toolkit.getGenomeLocParser().createGenomeLoc(codec.decodeLoc(line))); + line = lineReader.readLine(); + } + } catch (IOException e) { + throw new UserException("Problem reading the interval file " + featureIntervals.getSource() + "; " + e.getMessage()); } - iterator.close(); } else { intervals = IntervalUtils.parseIntervalArguments(toolkit.getGenomeLocParser(), stringIntervals);