diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotator.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotator.java index 914c356c7..b0c340eb0 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotator.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotator.java @@ -43,7 +43,6 @@ import java.util.Map.Entry; import org.broad.tribble.vcf.VCFHeader; import org.broad.tribble.vcf.VCFHeaderLine; -import org.broad.tribble.vcf.VCFRecord; import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; @@ -74,7 +73,7 @@ import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter; //@Allows(value={DataSource.READS, DataSource.REFERENCE}) //@Reference(window=@Window(start=-50,stop=50)) @By(DataSource.REFERENCE) -public class GenomicAnnotator extends RodWalker, LinkedList> implements TreeReducible> { +public class GenomicAnnotator extends RodWalker, LinkedList> implements TreeReducible> { @Argument(fullName="vcfOutput", shortName="vcf", doc="VCF file to which all variants should be written with annotations", required=true) protected File VCF_OUT; @@ -239,7 +238,7 @@ public class GenomicAnnotator extends RodWalker, LinkedLis hInfo.add(new VCFHeaderLine("annotatorReference", getToolkit().getArguments().referenceFile.getName())); hInfo.addAll(engine.getVCFAnnotationDescriptions()); - vcfWriter = new VCFWriter(VCF_OUT); + vcfWriter = new VCFWriter(VCF_OUT, true); VCFHeader vcfHeader = new VCFHeader(hInfo, samples); vcfWriter.writeHeader(vcfHeader); } @@ -249,7 +248,7 @@ public class GenomicAnnotator extends RodWalker, LinkedLis * * @return 0 */ - public LinkedList reduceInit() { return new LinkedList(); } + public LinkedList reduceInit() { return new LinkedList(); } /** @@ -267,8 +266,8 @@ public class GenomicAnnotator extends RodWalker, LinkedLis * @param context the context for the given locus * @return 1 if the locus was successfully processed, 0 if otherwise */ - public LinkedList map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { - LinkedList result = new LinkedList(); + public LinkedList map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { + LinkedList result = new LinkedList(); if ( tracker == null ) return result; @@ -299,12 +298,12 @@ public class GenomicAnnotator extends RodWalker, LinkedLis if(multiThreadedMode) { //keep results in memory, only writing them in onTraversalDone(..) after they have been merged via treeReduce(..) for(VariantContext annotatedVC : annotatedVCs ) { - result.add(VariantContextAdaptors.toVCF(annotatedVC, ref.getBase())); + result.add(annotatedVC); } } else { //write results to disk immediately for(VariantContext annotatedVC : annotatedVCs ) { - vcfWriter.addRecord(VariantContextAdaptors.toVCF(annotatedVC, ref.getBase())); + vcfWriter.add(annotatedVC, new byte[]{ref.getBase()}); } } @@ -320,7 +319,7 @@ public class GenomicAnnotator extends RodWalker, LinkedLis * @param sum accumulator for the reduce. * @return the new number of loci processed. */ - public LinkedList reduce(LinkedList value, LinkedList sum) { + public LinkedList reduce(LinkedList value, LinkedList sum) { sum.addAll(value); return sum; } @@ -330,7 +329,7 @@ public class GenomicAnnotator extends RodWalker, LinkedLis /** * Merge lists. */ - public LinkedList treeReduce(LinkedList lhs, LinkedList rhs) { + public LinkedList treeReduce(LinkedList lhs, LinkedList rhs) { lhs.addAll(rhs); return lhs; } @@ -341,13 +340,13 @@ public class GenomicAnnotator extends RodWalker, LinkedLis /** * Tell the user the number of loci processed and close out the new variants file. * - * @param result the number of loci seen. + * @param totalOutputRecords all VCs seen. */ - public void onTraversalDone(LinkedList totalOutputVCFRecords) { + public void onTraversalDone(LinkedList totalOutputRecords) { if(multiThreadedMode) { //finally write results to disk - for(VCFRecord vcfRecord : totalOutputVCFRecords ) { - vcfWriter.addRecord(vcfRecord); + for(VariantContext vc : totalOutputRecords ) { + vcfWriter.add(vc, vc.getReference().getBases()); } } diff --git a/java/test/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotatorIntegrationTest.java b/java/test/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotatorIntegrationTest.java index 3ef58601d..1339acc79 100755 --- a/java/test/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotatorIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotatorIntegrationTest.java @@ -26,7 +26,7 @@ public class GenomicAnnotatorIntegrationTest extends WalkerTest { */ - String[] md5WithDashSArg = {"a1bd36fc69a3cdd3a08d951730b1d7be"}; + String[] md5WithDashSArg = {"53c5d83d0d024482e0e69f9087df0a13"}; WalkerTestSpec specWithSArg = new WalkerTestSpec( "-T GenomicAnnotator -R " + oneKGLocation + "reference/human_b36_both.fasta " + "-B variant,vcf,/humgen/gsa-hpprojects/GATK/data/Annotations/examples/CEU_hapmap_nogt_23_subset.vcf " +