Fix for Kiran: since the Variant Annotator will re-annotate on top of existing annotations it makes sense to remove old headers if they conflict with the definitions being added by VA.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3951 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
1539791a04
commit
07addf1187
|
|
@ -139,12 +139,19 @@ public abstract class VCFCompoundHeaderLine extends VCFHeaderLine implements VCF
|
||||||
return name.equals(other.name) &&
|
return name.equals(other.name) &&
|
||||||
count == other.count &&
|
count == other.count &&
|
||||||
description.equals(other.description) &&
|
description.equals(other.description) &&
|
||||||
type == other.type;
|
type == other.type &&
|
||||||
|
lineType == other.lineType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equalsExcludingDescription(VCFCompoundHeaderLine other) {
|
public boolean equalsExcludingDescription(VCFCompoundHeaderLine other) {
|
||||||
return count == other.count &&
|
return count == other.count &&
|
||||||
type == other.type &&
|
type == other.type &&
|
||||||
|
lineType == other.lineType &&
|
||||||
|
name.equals(other.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean sameLineTypeAndName(VCFCompoundHeaderLine other) {
|
||||||
|
return lineType == other.lineType &&
|
||||||
name.equals(other.name);
|
name.equals(other.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator;
|
||||||
|
|
||||||
import org.broad.tribble.vcf.VCFHeader;
|
import org.broad.tribble.vcf.VCFHeader;
|
||||||
import org.broad.tribble.vcf.VCFHeaderLine;
|
import org.broad.tribble.vcf.VCFHeaderLine;
|
||||||
|
import org.broad.tribble.vcf.VCFCompoundHeaderLine;
|
||||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||||
import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext;
|
import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext;
|
||||||
|
|
@ -134,10 +135,14 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
||||||
engine = new VariantAnnotatorEngine(getToolkit(), annotationGroupsToUse, annotationsToUse);
|
engine = new VariantAnnotatorEngine(getToolkit(), annotationGroupsToUse, annotationsToUse);
|
||||||
|
|
||||||
// setup the header fields
|
// setup the header fields
|
||||||
|
// note that if any of the definitions conflict with our new ones, then we want to overwrite the old ones
|
||||||
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
||||||
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit(), Arrays.asList("variant")));
|
|
||||||
hInfo.add(new VCFHeaderLine("source", "VariantAnnotator"));
|
|
||||||
hInfo.addAll(engine.getVCFAnnotationDescriptions());
|
hInfo.addAll(engine.getVCFAnnotationDescriptions());
|
||||||
|
hInfo.add(new VCFHeaderLine("source", "VariantAnnotator"));
|
||||||
|
for ( VCFHeaderLine line : VCFUtils.getHeaderFields(getToolkit(), Arrays.asList("variant")) ) {
|
||||||
|
if ( isUniqueHeaderLine(line, hInfo) )
|
||||||
|
hInfo.add(line);
|
||||||
|
}
|
||||||
|
|
||||||
vcfWriter = new VCFWriter(out);
|
vcfWriter = new VCFWriter(out);
|
||||||
VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
|
VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
|
||||||
|
|
@ -148,6 +153,18 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isUniqueHeaderLine(VCFHeaderLine line, Set<VCFHeaderLine> currentSet) {
|
||||||
|
if ( !(line instanceof VCFCompoundHeaderLine) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for ( VCFHeaderLine hLine : currentSet ) {
|
||||||
|
if ( hLine instanceof VCFCompoundHeaderLine && ((VCFCompoundHeaderLine)line).sameLineTypeAndName((VCFCompoundHeaderLine)hLine) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the number of loci processed to zero.
|
* Initialize the number of loci processed to zero.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,14 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
||||||
executeTest("test file doesn't have annotations, asking for annotations, #2", spec);
|
executeTest("test file doesn't have annotations, asking for annotations, #2", spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverwritingHeader() {
|
||||||
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
|
baseTestString() + " -G \"Standard\" -B variant,VCF," + validationDataLocation + "vcfexample4.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,001,292", 1,
|
||||||
|
Arrays.asList("87d124ddfee8537e2052c495777d2b3b"));
|
||||||
|
executeTest("test overwriting header", spec);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoReads() {
|
public void testNoReads() {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue