Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #381 from broadinstitute/mm_rev_picard_to_get_trib…

…ble_updates

Adaptations to accomodate Tribble API changes.
  • Loading branch information...
commit 6663d48ffe0a2e080f97d64b2e1cb169c120dc12 2 parents ee5de85 + c3a933c
@eitanbanks eitanbanks authored
Showing with 176 additions and 170 deletions.
  1. +4 −4 protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/HaplotypeCallerIntegrationTest.java
  2. +10 −5 protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsUnitTest.java
  3. +27 −33 protected/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ConcordanceMetricsUnitTest.java
  4. +8 −8 public/java/src/org/broadinstitute/sting/gatk/io/storage/VariantContextWriterStorage.java
  5. +6 −7 public/java/src/org/broadinstitute/sting/utils/codecs/beagle/BeagleCodec.java
  6. +8 −12 public/java/src/org/broadinstitute/sting/utils/codecs/hapmap/RawHapMapCodec.java
  7. +9 −1 public/java/src/org/broadinstitute/sting/utils/codecs/refseq/RefSeqCodec.java
  8. +7 −1 public/java/src/org/broadinstitute/sting/utils/codecs/sampileup/SAMPileupCodec.java
  9. +7 −1 public/java/src/org/broadinstitute/sting/utils/codecs/samread/SAMReadCodec.java
  10. +21 −22 public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java
  11. +25 −34 public/java/src/org/broadinstitute/sting/utils/variant/GATKVCFUtils.java
  12. +4 −2 public/java/test/org/broadinstitute/sting/BaseTest.java
  13. +4 −5 public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java
  14. +1 −1  public/java/test/org/broadinstitute/sting/gatk/refdata/utils/TestFeatureReader.java
  15. +6 −2 public/java/test/org/broadinstitute/sting/utils/activeregion/BandPassActivityProfileUnitTest.java
  16. +19 −20 public/java/test/org/broadinstitute/sting/utils/codecs/hapmap/HapMapUnitTest.java
  17. +2 −2 public/java/test/org/broadinstitute/sting/utils/variant/VariantContextBenchmark.java
  18. +2 −4 public/scala/src/org/broadinstitute/sting/queue/util/VCF_BAM_utilities.scala
  19. BIN  settings/repository/net.sf/{picard-1.96.1515.jar → picard-1.96.1525.jar}
  20. +1 −1  settings/repository/net.sf/{picard-1.96.1515.xml → picard-1.96.1525.xml}
  21. +0 −3  settings/repository/net.sf/sam-1.96.1515.xml
  22. BIN  settings/repository/net.sf/{sam-1.96.1515.jar → sam-1.96.1525.jar}
  23. +3 −0  settings/repository/net.sf/sam-1.96.1525.xml
  24. BIN  settings/repository/org.broad/{tribble-1.96.1515.jar → tribble-1.96.1526.jar}
  25. +1 −1  settings/repository/org.broad/{tribble-1.96.1515.xml → tribble-1.96.1526.xml}
  26. BIN  settings/repository/org.broadinstitute/{variant-1.96.1515.jar → variant-1.96.1525.jar}
  27. +1 −1  settings/repository/org.broadinstitute/{variant-1.96.1515.xml → variant-1.96.1525.xml}
View
8 ...org/broadinstitute/sting/gatk/walkers/haplotypecaller/HaplotypeCallerIntegrationTest.java
@@ -47,7 +47,7 @@
package org.broadinstitute.sting.gatk.walkers.haplotypecaller;
import net.sf.picard.reference.IndexedFastaSequenceFile;
-import org.broad.tribble.readers.AsciiLineReader;
+import org.broad.tribble.readers.LineIterator;
import org.broad.tribble.readers.PositionalBufferedStream;
import org.broadinstitute.sting.WalkerTest;
import org.broadinstitute.sting.utils.GenomeLoc;
@@ -190,9 +190,9 @@ public void HCTestDanglingTailMergingForDeletions() throws IOException {
// confirm that the call is the correct one
final VCFCodec codec = new VCFCodec();
final FileInputStream s = new FileInputStream(outputVCF);
- final AsciiLineReader lineReader = new AsciiLineReader(new PositionalBufferedStream(s));
- codec.readHeader(lineReader);
- final String line = lineReader.readLine();
+ final LineIterator lineIterator = codec.makeSourceFromStream(new PositionalBufferedStream(s));
+ codec.readHeader(lineIterator);
+ final String line = lineIterator.next();
Assert.assertFalse(line == null);
final VariantContext vc = codec.decode(line);
Assert.assertTrue(vc.isBiallelic());
View
15 ...java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsUnitTest.java
@@ -46,16 +46,20 @@
package org.broadinstitute.sting.gatk.walkers.variantutils;
-import org.broad.tribble.readers.AsciiLineReader;
import org.broad.tribble.readers.PositionalBufferedStream;
import org.broadinstitute.sting.utils.SampleUtils;
-import org.broadinstitute.variant.vcf.*;
+import org.broadinstitute.variant.vcf.VCFCodec;
+import org.broadinstitute.variant.vcf.VCFHeader;
+import org.broadinstitute.variant.vcf.VCFHeaderLine;
+import org.broadinstitute.variant.vcf.VCFUtils;
import org.testng.Assert;
-
import org.testng.annotations.Test;
import java.io.StringBufferInputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
/**
* test out pieces of the combine variants code
@@ -154,7 +158,8 @@
private VCFHeader createHeader(String headerStr) {
VCFCodec codec = new VCFCodec();
- VCFHeader head = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(headerStr))));
+ VCFHeader head = null;
+ head = (VCFHeader) codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(headerStr))));
return head;
}
View
60 ...a/test/org/broadinstitute/sting/gatk/walkers/variantutils/ConcordanceMetricsUnitTest.java
@@ -46,25 +46,20 @@
package org.broadinstitute.sting.gatk.walkers.variantutils;
+import net.sf.picard.reference.ReferenceSequenceFile;
+import org.broad.tribble.readers.PositionalBufferedStream;
import org.broadinstitute.sting.BaseTest;
-import org.broadinstitute.sting.utils.GenomeLocParser;
+import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.GenomeLoc;
+import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
-import org.broadinstitute.sting.utils.BaseUtils;
-import org.broadinstitute.variant.variantcontext.Allele;
-import org.broadinstitute.variant.variantcontext.Genotype;
-import org.broadinstitute.variant.variantcontext.GenotypeBuilder;
-import org.broadinstitute.variant.variantcontext.GenotypeType;
-import org.broadinstitute.variant.variantcontext.VariantContext;
-import org.broadinstitute.variant.variantcontext.VariantContextBuilder;
+import org.broadinstitute.variant.variantcontext.*;
import org.broadinstitute.variant.vcf.VCFCodec;
import org.broadinstitute.variant.vcf.VCFHeader;
-import org.testng.annotations.Test;
-import org.broad.tribble.readers.AsciiLineReader;
-import org.broad.tribble.readers.PositionalBufferedStream;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
import java.io.File;
import java.io.FileNotFoundException;
@@ -72,7 +67,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import net.sf.picard.reference.ReferenceSequenceFile;
public class ConcordanceMetricsUnitTest extends BaseTest {
@@ -139,8 +133,8 @@ public void testSimpleComparison() {
VariantContext eval = data.getFirst();
VariantContext truth = data.getSecond();
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
metrics.update(eval,truth);
Assert.assertEquals(eval.getGenotype("test1_sample2").getType().ordinal(), 2);
@@ -189,8 +183,8 @@ public void testMismatchingAlleleInAlleleSubset() {
VariantContext eval = data.getFirst();
VariantContext truth = data.getSecond();
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
metrics.update(eval,truth);
Assert.assertEquals(eval.getGenotype("test1_sample2").getType().ordinal(), 2);
@@ -209,8 +203,8 @@ public void testMismatchingAlleleInAlleleSubset() {
eval = data.getSecond();
truth = data.getFirst();
codec = new VCFCodec();
- evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
- compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
metrics = new ConcordanceMetrics(evalHeader,compHeader);
metrics.update(eval,truth);
Assert.assertEquals(eval.getGenotype("test1_sample2").getType().ordinal(), 2);
@@ -264,8 +258,8 @@ public void testComplex() {
VariantContext eval = data.getFirst();
VariantContext truth = data.getSecond();
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
metrics.update(eval,truth);
Assert.assertEquals(metrics.getGenotypeConcordance("test1_sample1").getnMismatchingAlt(),1);
@@ -317,8 +311,8 @@ public void testNoCalls() {
VariantContext eval = data.getFirst();
VariantContext truth = data.getSecond();
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
metrics.update(eval,truth);
Assert.assertEquals(metrics.getGenotypeConcordance("test1_sample2").getnMismatchingAlt(),0);
@@ -366,8 +360,8 @@ public void testMissing() {
VariantContext eval = data.getFirst();
VariantContext truth = data.getSecond();
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
metrics.update(eval,truth);
Assert.assertTrue(eval.getGenotype("test1_sample2").getType().equals(GenotypeType.UNAVAILABLE));
@@ -520,8 +514,8 @@ public void testMultiSite() {
List<Pair<VariantContext,VariantContext>> data = getData6();
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
for ( Pair<VariantContext,VariantContext> contextPair : data ) {
@@ -554,8 +548,8 @@ public void testNRD_testNRS_testMargins() {
VariantContext eval = data.getFirst();
VariantContext truth = data.getSecond();
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_1_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
int[][] table = metrics.getOverallGenotypeConcordance().getTable();
// set up the table
@@ -588,9 +582,9 @@ public void testNRD_testNRS_testMargins() {
@Test(enabled=true)
public void testRobustness() {
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_3_HEADER_1))));
- VCFHeader disjointCompHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_3_HEADER_2))));
- VCFHeader overlapCompHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_3_HEADER_3))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_3_HEADER_1))));
+ VCFHeader disjointCompHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_3_HEADER_2))));
+ VCFHeader overlapCompHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_3_HEADER_3))));
ConcordanceMetrics disjointMetrics = new ConcordanceMetrics(evalHeader,disjointCompHeader);
ConcordanceMetrics overlapMetrics = new ConcordanceMetrics(evalHeader,overlapCompHeader);
@@ -720,8 +714,8 @@ public void testRobustness() {
@Test(enabled = true)
public void testSites() {
VCFCodec codec = new VCFCodec();
- VCFHeader evalHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
- VCFHeader compHeader = (VCFHeader)codec.readHeader(new AsciiLineReader(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
+ VCFHeader evalHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
+ VCFHeader compHeader = (VCFHeader)codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(TEST_2_HEADER))));
ConcordanceMetrics metrics = new ConcordanceMetrics(evalHeader,compHeader);
List<Pair<VariantContext,VariantContext>> data = getData7();
View
16 public/java/src/org/broadinstitute/sting/gatk/io/storage/VariantContextWriterStorage.java
@@ -28,17 +28,18 @@
import net.sf.samtools.util.BlockCompressedOutputStream;
import org.apache.log4j.Logger;
import org.broad.tribble.AbstractFeatureReader;
+import org.broad.tribble.Feature;
import org.broad.tribble.FeatureCodec;
import org.broadinstitute.sting.gatk.io.stubs.VariantContextWriterStub;
import org.broadinstitute.sting.gatk.refdata.tracks.FeatureManager;
-import org.broadinstitute.variant.bcf2.BCF2Utils;
-import org.broadinstitute.variant.vcf.VCFHeader;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.exceptions.UserException;
+import org.broadinstitute.variant.bcf2.BCF2Utils;
import org.broadinstitute.variant.variantcontext.VariantContext;
import org.broadinstitute.variant.variantcontext.writer.Options;
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter;
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriterFactory;
+import org.broadinstitute.variant.vcf.VCFHeader;
import java.io.*;
import java.util.Arrays;
@@ -205,12 +206,11 @@ public void mergeInto(VariantContextWriterStorage target) {
if ( fd == null )
throw new UserException.LocalParallelizationProblem(file);
- final FeatureCodec<VariantContext> codec = fd.getCodec();
- final AbstractFeatureReader<VariantContext> source =
- AbstractFeatureReader.getFeatureReader(file.getAbsolutePath(), codec, false);
-
- for ( final VariantContext vc : source.iterator() ) {
- target.writer.add(vc);
+ final FeatureCodec codec = fd.getCodec();
+ final AbstractFeatureReader<Feature, ?> source = AbstractFeatureReader.getFeatureReader(file.getAbsolutePath(), codec, false);
+
+ for ( final Feature vc : source.iterator() ) {
+ target.writer.add((VariantContext) vc);
}
source.close();
View
13 public/java/src/org/broadinstitute/sting/utils/codecs/beagle/BeagleCodec.java
@@ -51,9 +51,8 @@
import org.broad.tribble.AsciiFeatureCodec;
-import org.broad.tribble.Feature;
import org.broad.tribble.exception.CodecLineParsingException;
-import org.broad.tribble.readers.LineReader;
+import org.broad.tribble.readers.LineIterator;
import org.broadinstitute.sting.gatk.refdata.ReferenceDependentFeatureCodec;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
@@ -131,8 +130,8 @@ public void setGenomeLocParser(GenomeLocParser genomeLocParser) {
this.genomeLocParser = genomeLocParser;
}
- public Object readHeader(LineReader reader)
- {
+ @Override
+ public Object readActualHeader(LineIterator reader) {
int[] lineCounter = new int[1];
try {
header = readHeader(reader, lineCounter);
@@ -181,14 +180,14 @@ else if (header[0].matches("marker")) {
return header;
}
- private static String[] readHeader(final LineReader source, int[] lineCounter) throws IOException {
+ private static String[] readHeader(final LineIterator source, int[] lineCounter) throws IOException {
String[] header = null;
int numLines = 0;
//find the 1st line that's non-empty and not a comment
- String line;
- while( (line = source.readLine()) != null ) {
+ while(source.hasNext()) {
+ final String line = source.next();
numLines++;
if ( line.trim().isEmpty() ) {
continue;
View
20 public/java/src/org/broadinstitute/sting/utils/codecs/hapmap/RawHapMapCodec.java
@@ -28,9 +28,7 @@
import org.broad.tribble.AsciiFeatureCodec;
import org.broad.tribble.FeatureCodecHeader;
import org.broad.tribble.annotation.Strand;
-import org.broad.tribble.readers.AsciiLineReader;
-import org.broad.tribble.readers.LineReader;
-import org.broad.tribble.readers.PositionalBufferedStream;
+import org.broad.tribble.readers.LineIterator;
import java.io.IOException;
import java.util.Arrays;
@@ -112,18 +110,16 @@ public RawHapMapFeature decode(String line) {
headerLine);
}
- public Object readHeader(LineReader reader) {
- try {
- headerLine = reader.readLine();
- } catch (IOException e) {
- throw new IllegalArgumentException("Unable to read a line from the line reader");
- }
+ @Override
+ public Object readActualHeader(final LineIterator lineIterator) {
+ this.headerLine = lineIterator.next();
return headerLine;
}
@Override
- public FeatureCodecHeader readHeader(final PositionalBufferedStream stream) throws IOException {
- final AsciiLineReader br = new AsciiLineReader(stream);
- return new FeatureCodecHeader(readHeader(br), br.getPosition());
+ public FeatureCodecHeader readHeader(final LineIterator lineIterator) throws IOException {
+ final String header = (String) readActualHeader(lineIterator);
+ // TODO: This approach may cause issues with files formatted with \r\n-style line-endings.
+ return new FeatureCodecHeader(header, header.length() + 1);
}
}
View
10 public/java/src/org/broadinstitute/sting/utils/codecs/refseq/RefSeqCodec.java
@@ -28,6 +28,7 @@
import org.broad.tribble.AsciiFeatureCodec;
import org.broad.tribble.Feature;
import org.broad.tribble.TribbleException;
+import org.broad.tribble.readers.LineIterator;
import org.broadinstitute.sting.gatk.refdata.ReferenceDependentFeatureCodec;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
@@ -93,7 +94,8 @@ public void setGenomeLocParser(GenomeLocParser genomeLocParser) {
}
@Override
- public Feature decodeLoc(String line) {
+ public Feature decodeLoc(final LineIterator lineIterator) {
+ final String line = lineIterator.next();
if (line.startsWith("#")) return null;
String fields[] = line.split("\t");
if (fields.length < 3) throw new TribbleException("RefSeq (decodeLoc) : Unable to parse line -> " + line + ", we expected at least 3 columns, we saw " + fields.length);
@@ -160,4 +162,10 @@ public RefSeqFeature decode(String line) {
feature.setExon_frames(exon_frames);
return feature;
}
+
+ @Override
+ public Object readActualHeader(LineIterator lineIterator) {
+ // No header for this format
+ return null;
+ }
}
View
8 public/java/src/org/broadinstitute/sting/utils/codecs/sampileup/SAMPileupCodec.java
@@ -26,8 +26,8 @@
package org.broadinstitute.sting.utils.codecs.sampileup;
import org.broad.tribble.AsciiFeatureCodec;
-import org.broad.tribble.Feature;
import org.broad.tribble.exception.CodecLineParsingException;
+import org.broad.tribble.readers.LineIterator;
import org.broad.tribble.util.ParsingUtils;
import java.util.ArrayList;
@@ -163,6 +163,12 @@ public SAMPileupFeature decode(String line) {
return feature;
}
+ @Override
+ public Object readActualHeader(LineIterator lineIterator) {
+ // No header for this format
+ return null;
+ }
+
private void parseIndels(String genotype,SAMPileupFeature feature) {
String [] obs = genotype.split("/"); // get observations, now need to tinker with them a bit
View
8 public/java/src/org/broadinstitute/sting/utils/codecs/samread/SAMReadCodec.java
@@ -29,8 +29,8 @@
import net.sf.samtools.TextCigarCodec;
import net.sf.samtools.util.StringUtil;
import org.broad.tribble.AsciiFeatureCodec;
-import org.broad.tribble.Feature;
import org.broad.tribble.exception.CodecLineParsingException;
+import org.broad.tribble.readers.LineIterator;
import org.broad.tribble.util.ParsingUtils;
/**
@@ -114,4 +114,10 @@ public SAMReadFeature decode(String line) {
bases,
qualities);
}
+
+ @Override
+ public Object readActualHeader(LineIterator lineIterator) {
+ // No header for this format
+ return null;
+ }
}
View
43 public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java
@@ -26,14 +26,14 @@
package org.broadinstitute.sting.utils.codecs.table;
import org.broad.tribble.AsciiFeatureCodec;
-import org.broad.tribble.readers.LineReader;
+import org.broad.tribble.readers.LineIterator;
import org.broadinstitute.sting.gatk.refdata.ReferenceDependentFeatureCodec;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.exceptions.UserException;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
/**
* Reads tab deliminated tabular text files
@@ -97,30 +97,29 @@ public TableFeature decode(String line) {
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);
+ return new TableFeature(genomeLocParser.parseGenomeLoc(split[0]),Arrays.asList(split), header);
}
@Override
- public Object readHeader(LineReader reader) {
- String line = "";
- try {
- boolean isFirst = true;
- while ((line = reader.readLine()) != null) {
- if ( isFirst && ! line.startsWith(headerDelimiter) && ! line.startsWith(commentDelimiter)) {
- throw new UserException.MalformedFile("TableCodec file does not have a header");
- }
- isFirst &= line.startsWith(commentDelimiter);
- 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);
- for (String s : spl) header.add(s);
- return header;
- } else if (!line.startsWith(commentDelimiter)) {
- break;
- }
+ public Object readActualHeader(final LineIterator reader) {
+ boolean isFirst = true;
+ while (reader.hasNext()) {
+ final String line = reader.peek(); // Peek to avoid reading non-header data
+ if ( isFirst && ! line.startsWith(headerDelimiter) && ! line.startsWith(commentDelimiter)) {
+ throw new UserException.MalformedFile("TableCodec file does not have a header");
+ }
+ isFirst &= line.startsWith(commentDelimiter);
+ if (line.startsWith(headerDelimiter)) {
+ reader.next(); // "Commit" the peek
+ if (header.size() > 0) throw new IllegalStateException("Input table file seems to have two header lines. The second is = " + line);
+ final String spl[] = line.split(delimiterRegex);
+ Collections.addAll(header, spl);
+ return header;
+ } else if (line.startsWith(commentDelimiter)) {
+ reader.next(); // "Commit" the peek
+ } else {
+ break;
}
- } catch (IOException e) {
- throw new UserException.MalformedFile("unable to parse header from TableCodec file",e);
}
return header;
}
View
59 public/java/src/org/broadinstitute/sting/utils/variant/GATKVCFUtils.java
@@ -28,6 +28,7 @@
import org.broad.tribble.Feature;
import org.broad.tribble.FeatureCodec;
import org.broad.tribble.FeatureCodecHeader;
+import org.broad.tribble.readers.LineIterator;
import org.broad.tribble.readers.PositionalBufferedStream;
import org.broadinstitute.sting.commandline.RodBinding;
import org.broadinstitute.sting.gatk.CommandLineGATK;
@@ -177,31 +178,26 @@ public static VCFHeader withUpdatedContigs(final VCFHeader header, final GenomeA
/**
* Utility class to read all of the VC records from a file
*
- * @param source
+ * @param file
* @param codec
* @return
* @throws IOException
*/
- public final static Pair<VCFHeader, VCIterable> readAllVCs( final File source, final FeatureCodec<VariantContext> codec ) throws IOException {
+ public final static <SOURCE> Pair<VCFHeader, VCIterable<SOURCE>> readAllVCs( final File file, final FeatureCodec<VariantContext, SOURCE> codec) throws IOException {
// read in the features
- PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(source));
- FeatureCodecHeader header = codec.readHeader(pbs);
- pbs.close();
-
- pbs = new PositionalBufferedStream(new FileInputStream(source));
- pbs.skip(header.getHeaderEnd());
-
+ SOURCE source = codec.makeSourceFromStream(new FileInputStream(file));
+ FeatureCodecHeader header = codec.readHeader(source);
final VCFHeader vcfHeader = (VCFHeader)header.getHeaderValue();
- return new Pair<VCFHeader, VCIterable>(vcfHeader, new VCIterable(pbs, codec, vcfHeader));
+ return new Pair<>(vcfHeader, new VCIterable<>(source, codec, vcfHeader));
}
- public static class VCIterable implements Iterable<VariantContext>, Iterator<VariantContext> {
- final PositionalBufferedStream pbs;
- final FeatureCodec<VariantContext> codec;
+ public static class VCIterable<SOURCE> implements Iterable<VariantContext>, Iterator<VariantContext> {
+ final SOURCE source;
+ final FeatureCodec<VariantContext, SOURCE> codec;
final VCFHeader header;
- private VCIterable(final PositionalBufferedStream pbs, final FeatureCodec<VariantContext> codec, final VCFHeader header) {
- this.pbs = pbs;
+ private VCIterable(final SOURCE source, final FeatureCodec<VariantContext, SOURCE> codec, final VCFHeader header) {
+ this.source = source;
this.codec = codec;
this.header = header;
}
@@ -213,17 +209,13 @@ private VCIterable(final PositionalBufferedStream pbs, final FeatureCodec<Varian
@Override
public boolean hasNext() {
- try {
- return ! pbs.isDone();
- } catch ( IOException e ) {
- throw new RuntimeException(e);
- }
+ return ! codec.isDone(source);
}
@Override
public VariantContext next() {
try {
- final VariantContext vc = codec.decode(pbs);
+ final VariantContext vc = codec.decode(source);
return vc == null ? null : vc.fullyDecode(header, false);
} catch ( IOException e ) {
throw new RuntimeException(e);
@@ -249,20 +241,19 @@ public void remove() {
final List<VariantContext> vcs = new ArrayList<VariantContext>();
final VCFCodec codec = new VCFCodec();
PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(source));
- FeatureCodecHeader header = codec.readHeader(pbs);
- pbs.close();
-
- pbs = new PositionalBufferedStream(new FileInputStream(source));
- pbs.skip(header.getHeaderEnd());
-
- final VCFHeader vcfHeader = (VCFHeader)header.getHeaderValue();
+ final LineIterator vcfSource = codec.makeSourceFromStream(pbs);
+ try {
+ final VCFHeader vcfHeader = (VCFHeader) codec.readActualHeader(vcfSource);
+
+ while (vcfSource.hasNext()) {
+ final VariantContext vc = codec.decode(vcfSource);
+ if ( vc != null )
+ vcs.add(vc);
+ }
- while ( ! pbs.isDone() ) {
- final VariantContext vc = codec.decode(pbs);
- if ( vc != null )
- vcs.add(vc);
+ return new Pair<VCFHeader, List<VariantContext>>(vcfHeader, vcs);
+ } finally {
+ codec.close(vcfSource);
}
-
- return new Pair<VCFHeader, List<VariantContext>>(vcfHeader, vcs);
}
}
View
6 public/java/test/org/broadinstitute/sting/BaseTest.java
@@ -30,6 +30,8 @@
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;
+import org.broad.tribble.readers.LineIterator;
+import org.broad.tribble.readers.PositionalBufferedStream;
import org.broadinstitute.sting.commandline.CommandLineUtils;
import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.crypt.CryptUtils;
@@ -450,8 +452,8 @@ public static void assertVCFHeadersAreEqual(final VCFHeader actual, final VCFHea
}
public static void assertVCFandBCFFilesAreTheSame(final File vcfFile, final File bcfFile) throws IOException {
- final Pair<VCFHeader, GATKVCFUtils.VCIterable> vcfData = GATKVCFUtils.readAllVCs(vcfFile, new VCFCodec());
- final Pair<VCFHeader, GATKVCFUtils.VCIterable> bcfData = GATKVCFUtils.readAllVCs(bcfFile, new BCF2Codec());
+ final Pair<VCFHeader, GATKVCFUtils.VCIterable<LineIterator>> vcfData = GATKVCFUtils.readAllVCs(vcfFile, new VCFCodec());
+ final Pair<VCFHeader, GATKVCFUtils.VCIterable<PositionalBufferedStream>> bcfData = GATKVCFUtils.readAllVCs(bcfFile, new BCF2Codec());
assertVCFHeadersAreEqual(bcfData.getFirst(), vcfData.getFirst());
assertVariantContextStreamsAreEqual(bcfData.getSecond(), vcfData.getSecond());
}
View
9 public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java
@@ -28,11 +28,9 @@
import net.sf.samtools.SAMFileReader;
import net.sf.samtools.SAMReadGroupRecord;
import net.sf.samtools.SAMRecord;
-import org.broad.tribble.readers.AsciiLineReader;
import org.broadinstitute.sting.WalkerTest;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Output;
-import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.filters.MappingQualityUnavailableFilter;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@@ -48,7 +46,6 @@
import org.broadinstitute.variant.vcf.VCFHeader;
import org.broadinstitute.variant.vcf.VCFHeaderLine;
import org.testng.Assert;
-import org.testng.TestException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -218,7 +215,8 @@ public void testGATKVersionInVCF() throws Exception {
1, Arrays.asList(""));
spec.disableShadowBCF();
final File vcf = executeTest("testGATKVersionInVCF", spec).first.get(0);
- final VCFHeader header = (VCFHeader)new VCFCodec().readHeader(new AsciiLineReader(new FileInputStream(vcf)));
+ final VCFCodec codec = new VCFCodec();
+ final VCFHeader header = (VCFHeader) codec.readActualHeader(codec.makeSourceFromStream(new FileInputStream(vcf)));
final VCFHeaderLine versionLine = header.getMetaDataLine(GATKVCFUtils.GATK_COMMAND_LINE_KEY);
Assert.assertNotNull(versionLine);
Assert.assertTrue(versionLine.toString().contains("SelectVariants"));
@@ -232,7 +230,8 @@ public void testMultipleGATKVersionsInVCF() throws Exception {
1, Arrays.asList(""));
spec.disableShadowBCF();
final File vcf = executeTest("testMultipleGATKVersionsInVCF", spec).first.get(0);
- final VCFHeader header = (VCFHeader)new VCFCodec().readHeader(new AsciiLineReader(new FileInputStream(vcf)));
+ final VCFCodec codec = new VCFCodec();
+ final VCFHeader header = (VCFHeader) codec.readActualHeader(codec.makeSourceFromStream(new FileInputStream(vcf)));
boolean foundHC = false;
boolean foundSV = false;
View
2  public/java/test/org/broadinstitute/sting/gatk/refdata/utils/TestFeatureReader.java
@@ -34,7 +34,7 @@
/**
* Feature reader with additional test utilities. The iterators can be checked to see if they are closed.
*/
-public class TestFeatureReader extends TribbleIndexedFeatureReader<Feature> {
+public class TestFeatureReader extends TribbleIndexedFeatureReader<Feature, Object> {
public TestFeatureReader(String featurePath, FeatureCodec codec) throws IOException {
super(featurePath, codec, true);
}
View
8 ...ava/test/org/broadinstitute/sting/utils/activeregion/BandPassActivityProfileUnitTest.java
@@ -31,6 +31,7 @@
import net.sf.picard.reference.ReferenceSequenceFile;
import org.apache.commons.lang.ArrayUtils;
+import org.broad.tribble.readers.LineIterator;
import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
@@ -48,7 +49,10 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
public class BandPassActivityProfileUnitTest extends BaseTest {
@@ -261,7 +265,7 @@ public void testVCFProfile(final String path, final String contig, final int sta
final File file = new File(path);
final VCFCodec codec = new VCFCodec();
- final Pair<VCFHeader, GATKVCFUtils.VCIterable> reader = GATKVCFUtils.readAllVCs(file, codec);
+ final Pair<VCFHeader, GATKVCFUtils.VCIterable<LineIterator>> reader = GATKVCFUtils.readAllVCs(file, codec);
final List<ActiveRegion> incRegions = new ArrayList<ActiveRegion>();
final BandPassActivityProfile incProfile = new BandPassActivityProfile(genomeLocParser, null);
View
39 public/java/test/org/broadinstitute/sting/utils/codecs/hapmap/HapMapUnitTest.java
@@ -26,7 +26,9 @@
package org.broadinstitute.sting.utils.codecs.hapmap;
import org.broad.tribble.annotation.Strand;
-import org.broad.tribble.readers.AsciiLineReader;
+import org.broad.tribble.readers.LineIterator;
+import org.broad.tribble.readers.LineIteratorImpl;
+import org.broad.tribble.readers.LineReaderUtil;
import org.broad.tribble.readers.PositionalBufferedStream;
import org.broadinstitute.sting.BaseTest;
import org.testng.Assert;
@@ -53,15 +55,13 @@
@Test
public void testReadHeader() {
RawHapMapCodec codec = new RawHapMapCodec();
- AsciiLineReader reader = getReader();
+ final LineIterator reader = getLineIterator();
try {
- String header = reader.readLine();
- reader.close();
- Assert.assertTrue(header.equals(codec.readHeader(getReader())));
- } catch (IOException e) {
- Assert.fail("Unable to read from file " + hapMapFile);
+ String header = reader.next();
+ Assert.assertTrue(header.equals(codec.readActualHeader(getLineIterator())));
+ } finally {
+ codec.close(reader);
}
- reader.close();
}
@Test
@@ -114,22 +114,20 @@ public void testKnownRecordConversion() {
public void testReadCorrectNumberOfRecords() {
// setup the record for reading our 500 line file (499 records, 1 header line)
RawHapMapCodec codec = new RawHapMapCodec();
- AsciiLineReader reader = getReader();
+ final LineIterator reader = getLineIterator();
- String line;
int count = 0;
try {
codec.readHeader(reader);
- line = reader.readLine();
- while (line != null) {
- codec.decode(line);
- line = reader.readLine();
+ while (reader.hasNext()) {
+ codec.decode(reader.next());
++count;
}
} catch (IOException e) {
Assert.fail("IOException " + e.getMessage());
+ } finally {
+ codec.close(reader);
}
- reader.close();
Assert.assertEquals(count,499);
}
@@ -137,25 +135,26 @@ public void testReadCorrectNumberOfRecords() {
public void testGetSampleNames() {
// setup the record for reading our 500 line file (499 records, 1 header line)
RawHapMapCodec codec = new RawHapMapCodec();
- AsciiLineReader reader = getReader();
+ final LineIterator reader = getLineIterator();
String line;
try {
codec.readHeader(reader);
- line = reader.readLine();
+ line = reader.next();
RawHapMapFeature feature = (RawHapMapFeature) codec.decode(line);
Assert.assertEquals(feature.getSampleIDs().length,87);
} catch (IOException e) {
Assert.fail("IOException " + e.getMessage());
+ } finally {
+ codec.close(reader);
}
- reader.close();
}
- public AsciiLineReader getReader() {
+ public LineIterator getLineIterator() {
try {
- return new AsciiLineReader(new PositionalBufferedStream(new FileInputStream(hapMapFile)));
+ return new LineIteratorImpl(LineReaderUtil.fromBufferedStream(new PositionalBufferedStream(new FileInputStream(hapMapFile))));
} catch (FileNotFoundException e) {
Assert.fail("Unable to open hapmap file : " + hapMapFile);
}
View
4 public/java/test/org/broadinstitute/sting/utils/variant/VariantContextBenchmark.java
@@ -105,7 +105,7 @@
public void run(T vc);
}
- private <T extends Feature> void runBenchmark(FeatureCodec<T> codec, FunctionToBenchmark<T> func) {
+ private <T extends Feature> void runBenchmark(FeatureCodec codec, FunctionToBenchmark<T> func) {
// TODO -- update for new Tribble interface
// try {
// InputStream is = new ByteArrayInputStream(INPUT_STRING.getBytes());
@@ -129,7 +129,7 @@
public void timeV14(int rep) {
for ( int i = 0; i < rep; i++ ) {
FunctionToBenchmark<VariantContext> func = getV14FunctionToBenchmark();
- FeatureCodec<VariantContext> codec = new VCFCodec();
+ final VCFCodec codec = new VCFCodec();
runBenchmark(codec, func);
}
}
View
6 public/scala/src/org/broadinstitute/sting/queue/util/VCF_BAM_utilities.scala
@@ -31,14 +31,12 @@ import scala.io.Source._
import net.sf.samtools.SAMFileReader
import org.broadinstitute.variant.vcf.{VCFHeader, VCFCodec}
import scala.collection.JavaConversions._
-import org.broad.tribble.{FeatureCodec, AbstractFeatureReader}
-import org.broadinstitute.variant.variantcontext.VariantContext
+import org.broad.tribble.AbstractFeatureReader
object VCF_BAM_utilities {
def getSamplesFromVCF(vcfFile: File): List[String] = {
- val codec: FeatureCodec[VariantContext] = new VCFCodec().asInstanceOf[FeatureCodec[VariantContext]]
- AbstractFeatureReader.getFeatureReader(vcfFile.getPath, codec).getHeader.asInstanceOf[VCFHeader].getGenotypeSamples.toList
+ AbstractFeatureReader.getFeatureReader(vcfFile.getPath, new VCFCodec()).getHeader.asInstanceOf[VCFHeader].getGenotypeSamples.toList
}
def getSamplesInBAM(bam: File): List[String] = {
View
BIN  ...gs/repository/net.sf/picard-1.96.1515.jar → ...gs/repository/net.sf/picard-1.96.1525.jar
Binary file not shown
View
2  ...gs/repository/net.sf/picard-1.96.1515.xml → ...gs/repository/net.sf/picard-1.96.1525.xml
@@ -1,3 +1,3 @@
<ivy-module version="1.0">
- <info organisation="net.sf" module="picard" revision="1.96.1515" status="release" />
+ <info organisation="net.sf" module="picard" revision="1.96.1525" status="release" />
</ivy-module>
View
3  settings/repository/net.sf/sam-1.96.1515.xml
@@ -1,3 +0,0 @@
-<ivy-module version="1.0">
- <info organisation="net.sf" module="sam" revision="1.96.1515" status="release" />
-</ivy-module>
View
BIN  settings/repository/net.sf/sam-1.96.1515.jar → settings/repository/net.sf/sam-1.96.1525.jar 100644 → 100755
Binary file not shown
View
3  settings/repository/net.sf/sam-1.96.1525.xml
@@ -0,0 +1,3 @@
+<ivy-module version="1.0">
+ <info organisation="net.sf" module="sam" revision="1.96.1525" status="release" />
+</ivy-module>
View
BIN  ...epository/org.broad/tribble-1.96.1515.jar → ...epository/org.broad/tribble-1.96.1526.jar
Binary file not shown
View
2  ...epository/org.broad/tribble-1.96.1515.xml → ...epository/org.broad/tribble-1.96.1526.xml
@@ -1,3 +1,3 @@
<ivy-module version="1.0">
- <info organisation="org.broad" module="tribble" revision="1.96.1515" status="integration" />
+ <info organisation="org.broad" module="tribble" revision="1.96.1526" status="integration" />
</ivy-module>
View
BIN  .../org.broadinstitute/variant-1.96.1515.jar → .../org.broadinstitute/variant-1.96.1525.jar
Binary file not shown
View
2  .../org.broadinstitute/variant-1.96.1515.xml → .../org.broadinstitute/variant-1.96.1525.xml
@@ -1,3 +1,3 @@
<ivy-module version="1.0">
- <info organisation="org.broadinstitute" module="variant" revision="1.96.1515" status="integration" />
+ <info organisation="org.broadinstitute" module="variant" revision="1.96.1525" status="integration" />
</ivy-module>
Please sign in to comment.
Something went wrong with that request. Please try again.