From e206a48477a55afe05a6b033b428acedb771cd02 Mon Sep 17 00:00:00 2001 From: bbimber Date: Wed, 5 Jul 2023 18:23:20 -0700 Subject: [PATCH] Ensure MultiSourceAnnotator removes pre-existing annotations prior to transfer (#260) --- .../discvrseq/walkers/MultiSourceAnnotator.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/discvrseq/walkers/MultiSourceAnnotator.java b/src/main/java/com/github/discvrseq/walkers/MultiSourceAnnotator.java index c8376c1e..458a2dcf 100644 --- a/src/main/java/com/github/discvrseq/walkers/MultiSourceAnnotator.java +++ b/src/main/java/com/github/discvrseq/walkers/MultiSourceAnnotator.java @@ -390,7 +390,8 @@ public class MultiSourceAnnotator extends VariantWalker { "OMIMMUS", "LiftedContig", "LiftedStart", - "LiftedStop" + "LiftedStop", + "ReverseComplementedAlleles" ); private long clinvar = 0L; @@ -403,6 +404,8 @@ public class MultiSourceAnnotator extends VariantWalker { private final Impact IMPACT_ANNOTATION = new Impact(); + private final List allAnnotationKeys = new ArrayList<>(); + private final Collection ALLOWABLE_FILTERS = Arrays.asList("ReverseComplementedIndel", "NoTarget", "MismatchedRefAllele", "IndelStraddlesMultipleIntevals"); @Override @@ -412,6 +415,7 @@ public void onTraversalStart() { VCFHeader header = new VCFHeader(getHeaderForVariants()); IMPACT_ANNOTATION.getDescriptions().forEach(header::addMetaDataLine); + IMPACT_ANNOTATION.getDescriptions().stream().map(VCFInfoHeaderLine.class::cast).map(VCFInfoHeaderLine::getID).forEach(allAnnotationKeys::add); if (clinvarVariants != null) { VCFHeader clinvarHeader = (VCFHeader) getHeaderForFeatures(clinvarVariants); @@ -421,6 +425,7 @@ public void onTraversalStart() { throw new GATKException("Clinvar missing expected header line: " + id); } header.addMetaDataLine(line); + allAnnotationKeys.add(id); } List allKeys = new ArrayList<>(clinvarHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList()); @@ -439,6 +444,7 @@ public void onTraversalStart() { continue; } header.addMetaDataLine(line); + allAnnotationKeys.add(id); } List allKeys = new ArrayList<>(cassandraHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList()); @@ -457,6 +463,7 @@ public void onTraversalStart() { continue; } header.addMetaDataLine(line); + allAnnotationKeys.add(id); } List allKeys = new ArrayList<>(snpSiftHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList()); @@ -475,6 +482,7 @@ public void onTraversalStart() { continue; } header.addMetaDataLine(line); + allAnnotationKeys.add(id); } List allKeys = new ArrayList<>(funcotatorHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList()); @@ -485,6 +493,7 @@ public void onTraversalStart() { } header.addMetaDataLine(UNABLE_TO_LIFT); + allAnnotationKeys.add(UNABLE_TO_LIFT.getID()); writer.writeHeader(header); } @@ -493,6 +502,8 @@ public void onTraversalStart() { public void apply(VariantContext variant, ReadsContext readsContext, ReferenceContext referenceContext, FeatureContext featureContext) { VariantContextBuilder vcb = new VariantContextBuilder(variant); + vcb.rmAttributes(allAnnotationKeys); + if (clinvarVariants != null) { for (VariantContext vc : featureContext.getValues(clinvarVariants)) { if (!matches(variant, vc)) {