From cba436fa2f080e968974787d802d32ec9df69c02 Mon Sep 17 00:00:00 2001 From: aaron Date: Wed, 5 Jan 2011 21:20:26 +0000 Subject: [PATCH] small fix for the table codec; if you see a header line, you know you've finished parsing the header. Also also some changes to return the ref ordered data pool test to using MappedStreamSegment instead of EntireStream git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4942 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/refdata/features/table/TableCodec.java | 5 ++--- .../ReferenceOrderedDataPoolUnitTest.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/features/table/TableCodec.java b/java/src/org/broadinstitute/sting/gatk/refdata/features/table/TableCodec.java index a930e825f..95d1da5b7 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/features/table/TableCodec.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/features/table/TableCodec.java @@ -13,7 +13,7 @@ import java.io.IOException; import java.util.*; /** - * implementation of a simple table (tab or comma delimited format) input files... more improvements to come + * implementation of a simple table (tab or comma delimited format) input files */ public class TableCodec implements ReferenceDependentFeatureCodec { private String delimiterRegex = "\\s+"; @@ -48,8 +48,6 @@ public class TableCodec implements ReferenceDependentFeatureCodec { String[] split = line.split(delimiterRegex); if (split.length < 1) throw new IllegalArgumentException("TableCodec line = " + line + " doesn't appear to be a valid table format"); - - return new TableFeature(genomeLocParser.parseGenomeLoc(split[0]),Arrays.asList(split),header); } @@ -67,6 +65,7 @@ public class TableCodec implements ReferenceDependentFeatureCodec { 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); for (String s : spl) header.add(s); + return header; } else if (!line.startsWith(commentDelimiter)) { break; } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java index c720cf4a3..f50734884 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java @@ -51,6 +51,10 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { private GenomeLoc testSite2; private GenomeLoc testSite3; + private GenomeLoc testInterval1; // an interval matching testSite1 -> testSite2 for queries + private GenomeLoc testInterval2; // an interval matching testSite2 -> testSite3 for queries + + @BeforeClass public void init() throws FileNotFoundException { seq = new CachingIndexedFastaSequenceFile(new File(hg18Reference)); @@ -59,6 +63,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { testSite1 = genomeLocParser.createGenomeLoc("chrM",10); testSite2 = genomeLocParser.createGenomeLoc("chrM",20); testSite3 = genomeLocParser.createGenomeLoc("chrM",30); + testInterval1 = genomeLocParser.createGenomeLoc("chrM",10,20); + testInterval2 = genomeLocParser.createGenomeLoc("chrM",20,30); } @BeforeMethod @@ -92,10 +98,10 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { @Test public void testCreateMultipleIterators() { ReferenceOrderedQueryDataPool iteratorPool = new ReferenceOrderedQueryDataPool(triplet,builder,seq.getSequenceDictionary(),genomeLocParser); - LocationAwareSeekableRODIterator iterator1 = iteratorPool.iterator( new EntireStream() ); + LocationAwareSeekableRODIterator iterator1 = iteratorPool.iterator( new MappedStreamSegment(testInterval1) ); // Create a new iterator at position 2. - LocationAwareSeekableRODIterator iterator2 = iteratorPool.iterator( new EntireStream() ); + LocationAwareSeekableRODIterator iterator2 = iteratorPool.iterator( new MappedStreamSegment(testInterval2) ); Assert.assertEquals(iteratorPool.numIterators(), 2, "Number of iterators in the pool is incorrect"); Assert.assertEquals(iteratorPool.numAvailableIterators(), 0, "Number of available iterators in the pool is incorrect");