diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java index 08ea295c3..b9c4feba0 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java @@ -4,6 +4,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.genotype.*; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.List; import java.util.Map; @@ -61,5 +62,5 @@ public class AlleleBalance extends StandardVariantAnnotation { public String getKeyName() { return "AB"; } - public String getDescription() { return "AB,1,Float,\"Allele Balance for hets (ref/(ref+alt))\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("AB", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Allele Balance for hets (ref/(ref+alt))"); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java index 2bd10b410..35c696b2b 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java @@ -4,6 +4,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.utils.genotype.Variation; import org.broadinstitute.sting.utils.genotype.vcf.VCFRecord; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.Map; @@ -19,5 +20,5 @@ public class DepthOfCoverage extends StandardVariantAnnotation { public String getKeyName() { return VCFRecord.DEPTH_KEY; } - public String getDescription() { return getKeyName() + ",1,Integer,\"Total Depth (including MQ0 reads)\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Total Depth (including MQ0 reads)"); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java index 12695d852..7f9130c93 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java @@ -4,6 +4,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.genotype.Variation; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.Map; @@ -21,7 +22,7 @@ public class HomopolymerRun extends StandardVariantAnnotation { public String getKeyName() { return "HRun"; } - public String getDescription() { return "HRun,1,Integer,\"Largest Contiguous Homopolymer Run of Variant Allele In Either Direction\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("HRun", 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Largest Contiguous Homopolymer Run of Variant Allele In Either Direction"); } public boolean useZeroQualityReads() { return false; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MismatchRate.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MismatchRate.java index 9869f443b..f6e99e3a8 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MismatchRate.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MismatchRate.java @@ -4,6 +4,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.utils.pileup.*; import org.broadinstitute.sting.utils.genotype.Variation; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.utils.*; import java.util.Map; @@ -30,5 +31,5 @@ public class MismatchRate implements VariantAnnotation { public String getKeyName() { return "MR"; } - public String getDescription() { return "MR,1,Float,\"Mismatch Rate of Reads Spanning This Position\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("MR", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Mismatch Rate of Reads Spanning This Position"); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java index f5f8f8621..90db8d8ee 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java @@ -7,6 +7,7 @@ import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.genotype.Variation; import org.broadinstitute.sting.utils.genotype.vcf.VCFRecord; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.Map; import java.util.ArrayList; @@ -31,5 +32,5 @@ public class RMSMappingQuality extends StandardVariantAnnotation { public String getKeyName() { return VCFRecord.RMS_MAPPING_QUALITY_KEY; } - public String getDescription() { return getKeyName() + ",1,Float,\"RMS Mapping Quality\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Float, "RMS Mapping Quality"); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java index 702cf1e67..d9894e7af 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java @@ -6,6 +6,7 @@ import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.genotype.*; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.List; import java.util.ArrayList; @@ -67,7 +68,7 @@ public class RankSumTest implements VariantAnnotation { public String getKeyName() { return "RankSum"; } - public String getDescription() { return "RankSum,1,Float,\"Phred-scaled p-value From Wilcoxon Rank Sum Test of Het Vs. Ref Base Qualities\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("RankSum", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Phred-scaled p-value From Wilcoxon Rank Sum Test of Het Vs. Ref Base Qualities"); } private void fillQualsFromPileup(char ref, char alt, ReadBackedPileup pileup, List refQuals, List altQuals) { for ( PileupElement p : pileup ) { diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java index a07c08e9c..4cf84fce9 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SecondBaseSkew.java @@ -5,6 +5,7 @@ import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.genotype.Variation; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; @@ -26,7 +27,7 @@ public class SecondBaseSkew implements VariantAnnotation { public String getKeyName() { return KEY_NAME; } - public String getDescription() { return KEY_NAME + ",1,Float,\"Chi-square Secondary Base Skew\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(KEY_NAME, 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Chi-square Secondary Base Skew"); } public String annotate(ReferenceContext ref, Map stratifiedContexts, Variation variation) { if ( !variation.isBiallelic() || !variation.isSNP() ) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java index 0ed37421a..d9a91b637 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java @@ -4,6 +4,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.genotype.Variation; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.Map; @@ -23,5 +24,5 @@ public class SpanningDeletions extends StandardVariantAnnotation { public String getKeyName() { return "Dels"; } - public String getDescription() { return "Dels,1,Float,\"Fraction of Reads Containing Spanning Deletions\""; } + public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine("Dels", 1, VCFInfoHeaderLine.INFO_TYPE.Float, "Fraction of Reads Containing Spanning Deletions"); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotation.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotation.java index 86c2c9702..d81109db8 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotation.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotation.java @@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.utils.genotype.Variation; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.Map; @@ -16,6 +17,6 @@ public interface VariantAnnotation { public String getKeyName(); // return the description used for the VCF INFO meta field - public String getDescription(); + public VCFInfoHeaderLine getDescription(); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index bc28c1148..7a741bc6e 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -116,10 +116,10 @@ public class VariantAnnotator extends RodWalker { } // setup the header fields - Set hInfo = new HashSet(); + Set hInfo = new HashSet(); hInfo.addAll(VCFUtils.getHeaderFields(getToolkit())); - hInfo.add("source=VariantAnnotator"); - hInfo.add("annotatorReference=" + getToolkit().getArguments().referenceFile.getName()); + hInfo.add(new VCFHeaderLine("source", "VariantAnnotator")); + hInfo.add(new VCFHeaderLine("annotatorReference", getToolkit().getArguments().referenceFile.getName())); hInfo.addAll(getVCFAnnotationDescriptions(requestedAnnotations)); vcfHeader = new VCFHeader(hInfo, samples); @@ -175,35 +175,35 @@ public class VariantAnnotator extends RodWalker { } // option #1: don't specify annotations to be used: standard annotations are used by default - public static Set getVCFAnnotationDescriptions() { + public static Set getVCFAnnotationDescriptions() { if ( standardAnnotations == null ) determineAllAnnotations(); - TreeSet descriptions = new TreeSet(); + TreeSet descriptions = new TreeSet(); for ( VariantAnnotation annotation : standardAnnotations.values() ) - descriptions.add("INFO=" + annotation.getDescription()); + descriptions.add(annotation.getDescription()); return descriptions; } // option #2: specify that all possible annotations be used - public static Set getAllVCFAnnotationDescriptions() { + public static Set getAllVCFAnnotationDescriptions() { if ( standardAnnotations == null ) determineAllAnnotations(); - TreeSet descriptions = new TreeSet(); + TreeSet descriptions = new TreeSet(); for ( VariantAnnotation annotation : allAnnotations.values() ) - descriptions.add("INFO=" + annotation.getDescription()); + descriptions.add(annotation.getDescription()); return descriptions; } // option #3: specify the exact annotations to be used - public static Set getVCFAnnotationDescriptions(Collection annotations) { + public static Set getVCFAnnotationDescriptions(Collection annotations) { - TreeSet descriptions = new TreeSet(); + TreeSet descriptions = new TreeSet(); for ( VariantAnnotation annotation : annotations ) - descriptions.add("INFO=" + annotation.getDescription()); + descriptions.add(annotation.getDescription()); return descriptions; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceWalker.java index 2b4f478fc..907522088 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/CallsetConcordanceWalker.java @@ -103,21 +103,21 @@ public class CallsetConcordanceWalker extends RodWalker { } // set up the header fields - Set hInfo = new HashSet(); + Set hInfo = new HashSet(); hInfo.addAll(VCFUtils.getHeaderFields(getToolkit())); - hInfo.add("source=CallsetConcordance"); - hInfo.add("note=\"This file represents a concordance test of various call sets - NOT the output from a multi-sample caller\""); + hInfo.add(new VCFHeaderLine("source", "CallsetConcordance")); + hInfo.add(new VCFHeaderLine("note", "\"This file represents a concordance test of various call sets - NOT the output from a multi-sample caller\"")); hInfo.addAll(getVCFAnnotationDescriptions(requestedTypes)); VCFHeader header = new VCFHeader(hInfo, samples); vcfWriter = new VCFWriter(header, OUTPUT); } - public static Set getVCFAnnotationDescriptions(Collection types) { + public static Set getVCFAnnotationDescriptions(Collection types) { - TreeSet descriptions = new TreeSet(); + TreeSet descriptions = new TreeSet(); for ( ConcordanceType type : types ) - descriptions.add("INFO=" + type.getInfoDescription()); + descriptions.add(type.getInfoDescription()); return descriptions; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/ConcordanceType.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/ConcordanceType.java index f28408948..daae3cb64 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/ConcordanceType.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/ConcordanceType.java @@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.concordance; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.Map; import java.util.Set; @@ -11,5 +12,5 @@ public interface ConcordanceType { public void initialize(Map args, Set samples); public String computeConcordance(Map samplesToRecords, ReferenceContext ref); public String getInfoName(); - public String getInfoDescription(); + public VCFInfoHeaderLine getInfoDescription(); } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java index f45c15b6b..788f8fbc9 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java @@ -5,6 +5,7 @@ import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.genotype.Variation; import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.*; @@ -102,5 +103,5 @@ public class IndelSubsets implements ConcordanceType { } public String getInfoName() { return "IndelSubsets"; } - public String getInfoDescription() { return getInfoName() + ",1,String,\"Indel-related subsets\""; } + public VCFInfoHeaderLine getInfoDescription() { return new VCFInfoHeaderLine(getInfoName(), 1, VCFInfoHeaderLine.INFO_TYPE.String, "Indel-related subsets"); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/NWayVenn.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/NWayVenn.java index 7db2cb5d3..c77619207 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/NWayVenn.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/NWayVenn.java @@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.concordance; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.*; import java.util.Map.Entry; @@ -39,5 +40,5 @@ public class NWayVenn implements ConcordanceType { } public String getInfoName() { return "NwayVenn"; } - public String getInfoDescription() { return getInfoName() + ",1,String,\"N-way Venn split\""; } + public VCFInfoHeaderLine getInfoDescription() { return new VCFInfoHeaderLine(getInfoName(), 1, VCFInfoHeaderLine.INFO_TYPE.String, "N-way Venn split"); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SNPGenotypeConcordance.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SNPGenotypeConcordance.java index 4f3db620b..d4311c485 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SNPGenotypeConcordance.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SNPGenotypeConcordance.java @@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.walkers.concordance; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import java.util.*; @@ -111,5 +112,5 @@ public class SNPGenotypeConcordance implements ConcordanceType { } public String getInfoName() { return "SnpConcordance"; } - public String getInfoDescription() { return getInfoName() + ",1,String,\"SNP concordance test\""; } + public VCFInfoHeaderLine getInfoDescription() { return new VCFInfoHeaderLine(getInfoName(), 1, VCFInfoHeaderLine.INFO_TYPE.String, "SNP concordance test"); } } \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java index 642aba236..a659712bb 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java @@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.walkers.concordance; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.utils.genotype.Variation; import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.utils.StingException; import java.util.*; @@ -59,5 +60,5 @@ public class SimpleVenn implements ConcordanceType { } public String getInfoName() { return "Venn"; } - public String getInfoDescription() { return getInfoName() + ",1,String,\"2-way Venn split\""; } + public VCFInfoHeaderLine getInfoDescription() { return new VCFInfoHeaderLine(getInfoName(), 1, VCFInfoHeaderLine.INFO_TYPE.String, "2-way Venn split"); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java index 183298e47..8b4f7598a 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java @@ -47,18 +47,19 @@ public class VariantFiltrationWalker extends RodWalker { private void initializeVcfWriter(RodVCF rod) { // setup the header fields - Set hInfo = new HashSet(); + Set hInfo = new HashSet(); hInfo.addAll(VCFUtils.getHeaderFields(getToolkit())); - hInfo.add("source=" + "VariantFiltration"); - hInfo.add("reference=" + getToolkit().getArguments().referenceFile.getName()); + hInfo.add(new VCFHeaderLine("source", "VariantFiltration")); + hInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName())); + if ( clusterWindow > 0 ) - hInfo.add("FILTER=" + CLUSTERED_SNP_FILTER_NAME + ",\"SNPs found in clusters\""); + hInfo.add(new VCFFilterHeaderLine(CLUSTERED_SNP_FILTER_NAME, "SNPs found in clusters")); if ( filterExpression != null ) - hInfo.add("FILTER=" + FILTER_NAME + ",\"" + FILTER_STRING + "\""); + hInfo.add(new VCFFilterHeaderLine(FILTER_NAME, FILTER_STRING)); List dataSources = getToolkit().getRodDataSources(); for ( ReferenceOrderedDataSource source : dataSources ) { if ( source.getReferenceOrderedData().getName().equals("mask") ) { - hInfo.add("FILTER=" + MASK_NAME + ",\"Overlaps a user-input mask\""); + hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Overlaps a user-input mask")); break; } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index a75925618..617e6b7b8 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -37,6 +37,8 @@ import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.cmdLine.*; import org.broadinstitute.sting.utils.genotype.*; import org.broadinstitute.sting.utils.genotype.vcf.VCFGenotypeRecord; +import org.broadinstitute.sting.utils.genotype.vcf.VCFHeaderLine; +import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine; import net.sf.samtools.SAMReadGroupRecord; @@ -139,7 +141,7 @@ public class UnifiedGenotyper extends LocusWalker headerInfo = getHeaderInfo(); + Set headerInfo = getHeaderInfo(); // create the output writer stream if ( VARIANTS_FILE != null ) @@ -154,16 +156,16 @@ public class UnifiedGenotyper extends LocusWalker getHeaderInfo() { - Set headerInfo = new HashSet(); + private Set getHeaderInfo() { + Set headerInfo = new HashSet(); // this is only applicable to VCF if ( UAC.VAR_FORMAT != GenotypeWriterFactory.GENOTYPE_FORMAT.VCF ) return headerInfo; // first, the basic info - headerInfo.add("source=UnifiedGenotyper"); - headerInfo.add("reference=" + getToolkit().getArguments().referenceFile.getName()); + headerInfo.add(new VCFHeaderLine("source", "UnifiedGenotyper")); + headerInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName())); // annotation (INFO) fields from VariantAnnotator if ( UAC.ALL_ANNOTATIONS ) @@ -172,10 +174,10 @@ public class UnifiedGenotyper extends LocusWalker commandLineArgs = CommandLineUtils.getApproximateCommandLineArguments(Collections.singleton(UAC)); for ( Map.Entry commandLineArg : commandLineArgs.entrySet() ) - headerInfo.add(String.format("UG_%s=%s", commandLineArg.getKey(), commandLineArg.getValue())); + headerInfo.add(new VCFHeaderLine(String.format("UG_%s", commandLineArg.getKey()), commandLineArg.getValue())); return headerInfo; } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/variantstovcf/VariantsToVCF.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/variantstovcf/VariantsToVCF.java index bc2323720..59ced192b 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/variantstovcf/VariantsToVCF.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/variantstovcf/VariantsToVCF.java @@ -59,9 +59,9 @@ public class VariantsToVCF extends RefWalker { //Calendar cal = Calendar.getInstance(); //metaData.put("fileDate", String.format("%d%02d%02d", cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH))); - Set metaData = new HashSet(); - metaData.add("source=VariantsToVCF"); - metaData.add("reference=" + args.referenceFile.getAbsolutePath()); + Set metaData = new HashSet(); + metaData.add(new VCFHeaderLine("source", "VariantsToVCF")); + metaData.add(new VCFHeaderLine("reference", args.referenceFile.getAbsolutePath())); Set additionalColumns = new HashSet(); additionalColumns.add("FORMAT"); diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/vcftools/VCFSubsetWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/vcftools/VCFSubsetWalker.java index 8cc8e403f..eb90f2a70 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/vcftools/VCFSubsetWalker.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/vcftools/VCFSubsetWalker.java @@ -33,9 +33,9 @@ public class VCFSubsetWalker extends RefWalker, VCFWriter> public void initializeWriter() { - Set metaData = new HashSet(); - metaData.add("source=VariantsToVCF"); - metaData.add("reference=" + this.getToolkit().getArguments().referenceFile.getAbsolutePath()); + Set metaData = new HashSet(); + metaData.add(new VCFHeaderLine("source", "VariantsToVCF")); + metaData.add(new VCFHeaderLine("reference", this.getToolkit().getArguments().referenceFile.getAbsolutePath())); Set additionalColumns = new HashSet(); additionalColumns.add("FORMAT"); diff --git a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriterFactory.java b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriterFactory.java index 6f447044b..548aa404f 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriterFactory.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriterFactory.java @@ -38,7 +38,7 @@ public class GenotypeWriterFactory { SAMFileHeader header, File destination, Set sampleNames, - Set headerInfo) { + Set headerInfo) { switch (format) { case GLF: return new GLFWriter(header.toString(), destination); @@ -57,7 +57,7 @@ public class GenotypeWriterFactory { SAMFileHeader header, PrintStream destination, Set sampleNames, - Set headerInfo) { + Set headerInfo) { switch (format) { case GELI: return new GeliTextWriter(destination); diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFFilterHeaderLine.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFFilterHeaderLine.java new file mode 100755 index 000000000..dc393c0ee --- /dev/null +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFFilterHeaderLine.java @@ -0,0 +1,40 @@ +package org.broadinstitute.sting.utils.genotype.vcf; + + +/** + * @author ebanks + *

+ * Class VCFFilterHeaderLine + *

+ * A class representing a key=value entry for FILTER fields in the VCF header + */ +public class VCFFilterHeaderLine extends VCFHeaderLine { + + private String mName; + private String mDescription; + + + /** + * create a VCF filter header line + * + * @param name the name for this header line + * @param description the description for this header line + */ + public VCFFilterHeaderLine(String name, String description) { + super("FILTER", ""); + mName = name; + mDescription = description; + } + + protected String makeStringRep() { + return String.format("FILTER=%s,\"%s\"", mName, mDescription); + } + + public boolean equals(Object o) { + if ( !(o instanceof VCFFilterHeaderLine) ) + return false; + VCFFilterHeaderLine other = (VCFFilterHeaderLine)o; + return mName.equals(other.mName) && + mDescription.equals(other.mDescription); + } +} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFFormatHeaderLine.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFFormatHeaderLine.java new file mode 100755 index 000000000..27db9a77c --- /dev/null +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFFormatHeaderLine.java @@ -0,0 +1,53 @@ +package org.broadinstitute.sting.utils.genotype.vcf; + + +/** + * @author ebanks + *

+ * Class VCFFormatHeaderLine + *

+ * A class representing a key=value entry for genotype FORMAT fields in the VCF header + */ +public class VCFFormatHeaderLine extends VCFHeaderLine { + + // the info field types + public enum INFO_TYPE { + Integer, Float, String + } + + private String mName; + private int mCount; + private String mDescription; + private INFO_TYPE mType; + + + /** + * create a VCF format header line + * + * @param name the name for this header line + * @param count the count for this header line + * @param type the type for this header line + * @param description the description for this header line + */ + public VCFFormatHeaderLine(String name, int count, INFO_TYPE type, String description) { + super("FORMAT", ""); + mName = name; + mCount = count; + mType = type; + mDescription = description; + } + + protected String makeStringRep() { + return String.format("FORMAT=%s,%d,%s,\"%s\"", mName, mCount, mType.toString(), mDescription); + } + + public boolean equals(Object o) { + if ( !(o instanceof VCFFormatHeaderLine) ) + return false; + VCFFormatHeaderLine other = (VCFFormatHeaderLine)o; + return mName.equals(other.mName) && + mCount == other.mCount && + mDescription.equals(other.mDescription) && + mType == other.mType; + } +} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeRecord.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeRecord.java index c374ec179..447f52951 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeRecord.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeRecord.java @@ -262,12 +262,12 @@ public class VCFGenotypeRecord implements Genotype, SampleBacked { return result; } - public static Set getSupportedHeaderStrings() { - Set result = new HashSet(); - result.add("FORMAT=" + GENOTYPE_KEY + ",1,String,\"Genotype\""); - result.add("FORMAT=" + GENOTYPE_QUALITY_KEY + ",1,Integer,\"Genotype Quality\""); - result.add("FORMAT=" + DEPTH_KEY + ",1,Integer,\"Read Depth (without MQ0 reads)\""); - //result.add("FORMAT=" + HAPLOTYPE_QUALITY_KEY + ",1,Integer,\"Haplotype Quality\""); + public static Set getSupportedHeaderStrings() { + Set result = new HashSet(); + result.add(new VCFFormatHeaderLine(GENOTYPE_KEY, 1, VCFFormatHeaderLine.INFO_TYPE.String, "Genotype")); + result.add(new VCFFormatHeaderLine(GENOTYPE_QUALITY_KEY, 1, VCFFormatHeaderLine.INFO_TYPE.Integer, "Genotype Quality")); + result.add(new VCFFormatHeaderLine(DEPTH_KEY, 1, VCFFormatHeaderLine.INFO_TYPE.Integer, "Read Depth (without MQ0 reads)")); + //result.add(new VCFFormatHeaderLine(HAPLOTYPE_QUALITY_KEY, 1, VCFFormatHeaderLine.INFO_TYPE.Integer, "Haplotype Quality")); return result; } } diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java index c5dd924e4..84caedfdf 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java @@ -25,7 +25,7 @@ public class VCFGenotypeWriterAdapter implements GenotypeWriter { protected static Logger logger = Logger.getLogger(VCFGenotypeWriterAdapter.class); - public VCFGenotypeWriterAdapter(File writeTo, Set sampleNames, Set headerInfo) { + public VCFGenotypeWriterAdapter(File writeTo, Set sampleNames, Set headerInfo) { mSampleNames.addAll(sampleNames); initializeHeader(headerInfo); @@ -34,7 +34,7 @@ public class VCFGenotypeWriterAdapter implements GenotypeWriter { mWriter = new VCFWriter(mHeader, writeTo); } - public VCFGenotypeWriterAdapter(OutputStream writeTo, Set sampleNames, Set headerInfo) { + public VCFGenotypeWriterAdapter(OutputStream writeTo, Set sampleNames, Set headerInfo) { mSampleNames.addAll(sampleNames); initializeHeader(headerInfo); @@ -48,11 +48,11 @@ public class VCFGenotypeWriterAdapter implements GenotypeWriter { * * @param optionalHeaderInfo the optional header fields */ - private void initializeHeader(Set optionalHeaderInfo) { - Set hInfo = new TreeSet(); + private void initializeHeader(Set optionalHeaderInfo) { + Set hInfo = new TreeSet(); // setup the header fields - hInfo.add(VCFHeader.FULL_FORMAT_LINE); + hInfo.add(new VCFHeaderLine(VCFHeader.FILE_FORMAT_KEY, VCFHeader.VCF_VERSION)); hInfo.addAll(optionalHeaderInfo); // setup the sample names diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFHeader.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFHeader.java index 4a8af1604..6fb2b7a8b 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFHeader.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFHeader.java @@ -8,12 +8,12 @@ import java.util.*; *

* Class VCFHeader *

- * A descriptions should go here. Blame aaron if it's missing. + * A class representing the VCF header */ public class VCFHeader { - public static final String FILE_FORMAT_KEY = "fileformat="; - public static final String OLD_FILE_FORMAT_KEY = "format="; // from version 3.2 + public static final String FILE_FORMAT_KEY = "fileformat"; + public static final String OLD_FILE_FORMAT_KEY = "format"; // from version 3.2 /** the current vcf version we support. */ @@ -22,7 +22,6 @@ public class VCFHeader { public static final double VCF_VERSION_NUMBER = 3.3; public static final String VCF_VERSION = VCF_VERSION_HEADER + VCF_VERSION_NUMBER; - public static final String FULL_FORMAT_LINE = FILE_FORMAT_KEY + VCF_VERSION; // the manditory header fields public enum HEADER_FIELDS { @@ -30,7 +29,7 @@ public class VCFHeader { } // the associated meta data - private final Set mMetaData; + private final Set mMetaData; // the list of auxillary tags private final Set mGenotypeSampleNames = new LinkedHashSet(); @@ -50,8 +49,8 @@ public class VCFHeader { * * @param metaData the meta data associated with this header */ - public VCFHeader(Set metaData) { - mMetaData = new TreeSet(metaData); + public VCFHeader(Set metaData) { + mMetaData = new TreeSet(metaData); checkVCFVersion(); } @@ -61,8 +60,8 @@ public class VCFHeader { * @param metaData the meta data associated with this header * @param genotypeSampleNames the genotype format field, and the sample names */ - public VCFHeader(Set metaData, Set genotypeSampleNames) { - mMetaData = new TreeSet(metaData); + public VCFHeader(Set metaData, Set genotypeSampleNames) { + mMetaData = new TreeSet(metaData); for (String col : genotypeSampleNames) { if (!col.equals("FORMAT")) mGenotypeSampleNames.add(col); @@ -77,19 +76,15 @@ public class VCFHeader { */ public void checkVCFVersion() { String version = null; - for ( String field : mMetaData ) { - if ( field.startsWith(FILE_FORMAT_KEY) ) { - version = field.substring(FILE_FORMAT_KEY.length()); - break; - } - else if ( field.startsWith(OLD_FILE_FORMAT_KEY) ) { - version = field.substring(OLD_FILE_FORMAT_KEY.length()); + for ( VCFHeaderLine line : mMetaData ) { + if ( line.getKey().equals(FILE_FORMAT_KEY) || line.getKey().equals(OLD_FILE_FORMAT_KEY) ) { + version = line.getValue(); break; } } if ( version == null ) - mMetaData.add(FULL_FORMAT_LINE); + mMetaData.add(new VCFHeaderLine(FILE_FORMAT_KEY, VCF_VERSION)); else if ( !isSupportedVersion(version) ) throw new RuntimeException("VCF version " + version + " is not yet supported; only version " + VCF_VERSION + " and earlier can be used"); @@ -124,7 +119,7 @@ public class VCFHeader { * * @return a set of the meta data */ - public Set getMetaData() { + public Set getMetaData() { return mMetaData; } diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderLine.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderLine.java new file mode 100755 index 000000000..b89c9d80b --- /dev/null +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderLine.java @@ -0,0 +1,86 @@ +package org.broadinstitute.sting.utils.genotype.vcf; + + +/** + * @author ebanks + *

+ * Class VCFHeaderLine + *

+ * A class representing a key=value entry in the VCF header + */ +public class VCFHeaderLine implements Comparable { + + private String stringRep = null; + private String mKey = null; + private String mValue = null; + + + /** + * create a VCF header line + * + * @param key the key for this header line + * @param value the value for this header line + */ + public VCFHeaderLine(String key, String value) { + mKey = key; + mValue = value; + } + + /** + * Get the key + * + * @return the key + */ + public String getKey() { + return mKey; + } + + /** + * Set the key + * + * @param key the key for this header line + */ + public void setKey(String key) { + mKey = key; + stringRep = null; + } + + /** + * Get the value + * + * @return the value + */ + public String getValue() { + return mValue; + } + + /** + * Set the value + * + * @param value the value for this header line + */ + public void setValue(String value) { + mValue = value; + stringRep = null; + } + + public String toString() { + if ( stringRep == null ) + stringRep = makeStringRep(); + return stringRep; + } + + protected String makeStringRep() { + return mKey + "=" + mValue; + } + + public boolean equals(Object o) { + if ( !(o instanceof VCFHeaderLine) ) + return false; + return mKey.equals(((VCFHeaderLine)o).getKey()) && mValue.equals(((VCFHeaderLine)o).getValue()); + } + + public int compareTo(Object other) { + return toString().compareTo(other.toString()); + } +} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFInfoHeaderLine.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFInfoHeaderLine.java new file mode 100755 index 000000000..1c5d063a2 --- /dev/null +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFInfoHeaderLine.java @@ -0,0 +1,53 @@ +package org.broadinstitute.sting.utils.genotype.vcf; + + +/** + * @author ebanks + *

+ * Class VCFInfoHeaderLine + *

+ * A class representing a key=value entry for INFO fields in the VCF header + */ +public class VCFInfoHeaderLine extends VCFHeaderLine { + + // the info field types + public enum INFO_TYPE { + Integer, Float, String + } + + private String mName; + private int mCount; + private String mDescription; + private INFO_TYPE mType; + + + /** + * create a VCF info header line + * + * @param name the name for this header line + * @param count the count for this header line + * @param type the type for this header line + * @param description the description for this header line + */ + public VCFInfoHeaderLine(String name, int count, INFO_TYPE type, String description) { + super("INFO", ""); + mName = name; + mCount = count; + mType = type; + mDescription = description; + } + + protected String makeStringRep() { + return String.format("INFO=%s,%d,%s,\"%s\"", mName, mCount, mType.toString(), mDescription); + } + + public boolean equals(Object o) { + if ( !(o instanceof VCFInfoHeaderLine) ) + return false; + VCFInfoHeaderLine other = (VCFInfoHeaderLine)o; + return mName.equals(other.mName) && + mCount == other.mCount && + mDescription.equals(other.mDescription) && + mType == other.mType; + } +} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFReader.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFReader.java index 63395707a..81d697765 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFReader.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFReader.java @@ -146,7 +146,7 @@ public class VCFReader implements Iterator, Iterable { * @return a VCF Header created from the list of stinrgs */ protected VCFHeader createHeader(List headerStrings) { - Set metaData = new TreeSet(); + Set metaData = new TreeSet(); Set auxTags = new LinkedHashSet(); // iterate over all the passed in strings for ( String str : headerStrings ) { @@ -169,7 +169,9 @@ public class VCFReader implements Iterator, Iterable { arrayIndex++; } } else { - metaData.add(str.substring(2)); + int equals = str.indexOf("="); + if ( equals != -1 ) + metaData.add(new VCFHeaderLine(str.substring(2, equals), str.substring(equals+1))); } } diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java index 9aa619100..a382305bd 100755 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java @@ -27,10 +27,10 @@ public class VCFUtils { * * @return a set of all fields */ - public static Set getHeaderFields(GenomeAnalysisEngine toolkit) { + public static Set getHeaderFields(GenomeAnalysisEngine toolkit) { // keep a map of sample name to occurrences encountered - TreeSet fields = new TreeSet(); + TreeSet fields = new TreeSet(); // iterate to get all of the sample names List dataSources = toolkit.getRodDataSources(); diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFWriter.java index c133d5619..c8ca43f18 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFWriter.java @@ -50,24 +50,22 @@ public class VCFWriter { new OutputStreamWriter(location)); try { // the fileformat field needs to be written first - TreeSet allMetaData = new TreeSet(header.getMetaData()); - for ( String metadata : allMetaData ) { - if ( metadata.startsWith(VCFHeader.FILE_FORMAT_KEY) ) { - mWriter.write(VCFHeader.METADATA_INDICATOR + metadata + "\n"); - break; + TreeSet nonFormatMetaData = new TreeSet(); + for ( VCFHeaderLine line : header.getMetaData() ) { + if ( line.getKey().equals(VCFHeader.FILE_FORMAT_KEY) ) { + mWriter.write(VCFHeader.METADATA_INDICATOR + line.toString() + "\n"); } - else if ( metadata.startsWith(VCFHeader.OLD_FILE_FORMAT_KEY) ) { - mWriter.write(VCFHeader.METADATA_INDICATOR + VCFHeader.FILE_FORMAT_KEY + metadata.substring(VCFHeader.OLD_FILE_FORMAT_KEY.length()) + "\n"); - break; + else if ( line.getKey().equals(VCFHeader.OLD_FILE_FORMAT_KEY) ) { + mWriter.write(VCFHeader.METADATA_INDICATOR + VCFHeader.FILE_FORMAT_KEY + line.toString().substring(VCFHeader.OLD_FILE_FORMAT_KEY.length()) + "\n"); + } else { + nonFormatMetaData.add(line); } } // write the rest of the header meta-data out - for ( String metadata : header.getMetaData() ) { - if ( !metadata.startsWith(VCFHeader.FILE_FORMAT_KEY) && !metadata.startsWith(VCFHeader.OLD_FILE_FORMAT_KEY) ) - mWriter.write(VCFHeader.METADATA_INDICATOR + metadata + "\n"); - } - + for ( VCFHeaderLine line : nonFormatMetaData ) + mWriter.write(VCFHeader.METADATA_INDICATOR + line + "\n"); + // write out the column line StringBuilder b = new StringBuilder(); b.append(VCFHeader.HEADER_INDICATOR); diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderTest.java index ecf2c3a8e..872f40c84 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderTest.java @@ -17,8 +17,7 @@ import java.util.*; */ public class VCFHeaderTest extends BaseTest { - private Set headerFields = new LinkedHashSet(); - private Set metaData = new HashSet(); + private Set metaData = new HashSet(); private Set additionalColumns = new HashSet(); /** @@ -26,8 +25,8 @@ public class VCFHeaderTest extends BaseTest { */ @Test public void testHeaderConstructor() { - metaData.add(VCFHeader.FULL_FORMAT_LINE); // required - metaData.add("two=2"); + metaData.add(new VCFHeaderLine(VCFHeader.FILE_FORMAT_KEY, VCFHeader.VCF_VERSION)); + metaData.add(new VCFHeaderLine("two", "2")); additionalColumns.add("extra1"); additionalColumns.add("extra2"); // this should create a header that is valid diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java index 1e9c8f608..3d166c727 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java @@ -24,17 +24,16 @@ public class VCFReaderTest extends BaseTest { private static final File complexFile = new File("/humgen/gsa-scr1/GATK_Data/Validation_Data/complexExample.vcf"); private static final File headerNoRecordsFile = new File("/humgen/gsa-scr1/GATK_Data/Validation_Data/headerNoRecords.vcf"); - private static IndexedFastaSequenceFile seq; - @BeforeClass - public static void beforeTests() { - try { - seq = new IndexedFastaSequenceFile(new File("/broad/1KG/reference/human_b36_both.fasta")); - } catch (FileNotFoundException e) { - throw new StingException("unable to load the sequence dictionary"); - } - GenomeLocParser.setupRefContigOrdering(seq); - } + @BeforeClass + public static void beforeTests() { + try { + IndexedFastaSequenceFile seq = new IndexedFastaSequenceFile(new File("/broad/1KG/reference/human_b36_both.fasta")); + GenomeLocParser.setupRefContigOrdering(seq); + } catch (FileNotFoundException e) { + throw new StingException("unable to load the sequence dictionary"); + } + } @Test public void testVCFInput() { @@ -330,7 +329,6 @@ public class VCFReaderTest extends BaseTest { public void testHeaderNoRecords() { VCFReader reader = new VCFReader(headerNoRecordsFile); Assert.assertTrue(reader.getHeader().getMetaData() != null); - Iterator iter = reader.iterator(); Assert.assertTrue(!reader.iterator().hasNext()); } diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFRecordTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFRecordTest.java index 537506413..4198c1149 100755 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFRecordTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFRecordTest.java @@ -22,21 +22,20 @@ import java.io.FileNotFoundException; */ public class VCFRecordTest extends BaseTest { - private static IndexedFastaSequenceFile seq; - @BeforeClass public static void beforeTests() { try { - seq = new IndexedFastaSequenceFile(new File(seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta")); + IndexedFastaSequenceFile seq = new IndexedFastaSequenceFile(new File(seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta")); + GenomeLocParser.setupRefContigOrdering(seq); } catch (FileNotFoundException e) { throw new StingException("unable to load the sequence dictionary"); } - GenomeLocParser.setupRefContigOrdering(seq); } /** * create a fake VCF record * + * @param infoFields the info fields * @return a VCFRecord */ private static VCFRecord makeFakeVCFRecord(Map infoFields) { @@ -140,9 +139,9 @@ public class VCFRecordTest extends BaseTest { * @return a fake VCF header */ public static VCFHeader createFakeHeader() { - Set metaData = new HashSet(); - metaData.add(VCFHeader.FULL_FORMAT_LINE); // required - metaData.add("two=2"); + Set metaData = new HashSet(); + metaData.add(new VCFHeaderLine(VCFHeader.FILE_FORMAT_KEY, VCFHeader.VCF_VERSION)); + metaData.add(new VCFHeaderLine("two", "2")); Set additionalColumns = new HashSet(); additionalColumns.add("FORMAT"); additionalColumns.add("sample1"); @@ -158,8 +157,6 @@ public class VCFRecordTest extends BaseTest { Map infoFields = new HashMap(); infoFields.put("DP", "50"); VCFRecord rec = makeFakeVCFRecord(infoFields); - Map metaData = new HashMap(); - List additionalColumns = new ArrayList(); String rep = rec.toStringEncoding(createFakeHeader()); Assert.assertTrue(stringRep.equals(rep)); rec.addInfoField("AB", "CD"); diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterTest.java index 61b6da2c1..38f2dfc3d 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterTest.java @@ -21,21 +21,18 @@ import java.util.*; * This class tests out the ability of the VCF writer to correctly write VCF files */ public class VCFWriterTest extends BaseTest { - private Set headerFields = new LinkedHashSet(); - private Set metaData = new HashSet(); + private Set metaData = new HashSet(); private Set additionalColumns = new HashSet(); private File fakeVCFFile = new File("FAKEVCFFILEFORTESTING.vcf"); - private static IndexedFastaSequenceFile seq; - @BeforeClass public static void beforeTests() { try { - seq = new IndexedFastaSequenceFile(new File(seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta")); + IndexedFastaSequenceFile seq = new IndexedFastaSequenceFile(new File(seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta")); + GenomeLocParser.setupRefContigOrdering(seq); } catch (FileNotFoundException e) { throw new StingException("unable to load the sequence dictionary"); } - GenomeLocParser.setupRefContigOrdering(seq); } /** test, using the writer and reader, that we can output and input a VCF file without problems */ @@ -50,21 +47,23 @@ public class VCFWriterTest extends BaseTest { int counter = 0; // validate what we're reading in validateHeader(reader.getHeader()); - for(VCFRecord rec :reader) { + for (VCFRecord rec : reader) { counter++; } - Assert.assertEquals(2,counter); + Assert.assertEquals(2,counter); reader.close(); fakeVCFFile.delete(); } /** * create a fake header of known quantity + * @param metaData the header lines + * @param additionalColumns the additional column names * @return a fake VCF header */ - public static VCFHeader createFakeHeader(Set metaData, Set additionalColumns) { - metaData.add(VCFHeader.FULL_FORMAT_LINE); // required - metaData.add("two=2"); + public static VCFHeader createFakeHeader(Set metaData, Set additionalColumns) { + metaData.add(new VCFHeaderLine(VCFHeader.FILE_FORMAT_KEY, VCFHeader.VCF_VERSION)); + metaData.add(new VCFHeaderLine("two", "2")); additionalColumns.add("FORMAT"); additionalColumns.add("extra1"); additionalColumns.add("extra2");