Permalink
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...
2 parents ee5de85 + c3a933c commit 6663d48ffe0a2e080f97d64b2e1cb169c120dc12 @eitanbanks eitanbanks committed Aug 20, 2013
Showing with 176 additions and 170 deletions.
  1. +4 −4 ...va/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 ...cted/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}
@@ -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());
@@ -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;
}
@@ -46,33 +46,27 @@
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;
import java.io.StringBufferInputStream;
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();
@@ -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();
@@ -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;
@@ -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);
}
}
Oops, something went wrong.

0 comments on commit 6663d48

Please sign in to comment.