Skip to content

Commit

Permalink
Ensure MultiSourceAnnotator removes pre-existing annotations prior to…
Browse files Browse the repository at this point in the history
… transfer (#260)
  • Loading branch information
bbimber authored Jul 6, 2023
1 parent c976601 commit e206a48
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ public class MultiSourceAnnotator extends VariantWalker {
"OMIMMUS",
"LiftedContig",
"LiftedStart",
"LiftedStop"
"LiftedStop",
"ReverseComplementedAlleles"
);

private long clinvar = 0L;
Expand All @@ -403,6 +404,8 @@ public class MultiSourceAnnotator extends VariantWalker {

private final Impact IMPACT_ANNOTATION = new Impact();

private final List<String> allAnnotationKeys = new ArrayList<>();

private final Collection<String> ALLOWABLE_FILTERS = Arrays.asList("ReverseComplementedIndel", "NoTarget", "MismatchedRefAllele", "IndelStraddlesMultipleIntevals");

@Override
Expand All @@ -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);
Expand All @@ -421,6 +425,7 @@ public void onTraversalStart() {
throw new GATKException("Clinvar missing expected header line: " + id);
}
header.addMetaDataLine(line);
allAnnotationKeys.add(id);
}

List<String> allKeys = new ArrayList<>(clinvarHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList());
Expand All @@ -439,6 +444,7 @@ public void onTraversalStart() {
continue;
}
header.addMetaDataLine(line);
allAnnotationKeys.add(id);
}

List<String> allKeys = new ArrayList<>(cassandraHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList());
Expand All @@ -457,6 +463,7 @@ public void onTraversalStart() {
continue;
}
header.addMetaDataLine(line);
allAnnotationKeys.add(id);
}

List<String> allKeys = new ArrayList<>(snpSiftHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList());
Expand All @@ -475,6 +482,7 @@ public void onTraversalStart() {
continue;
}
header.addMetaDataLine(line);
allAnnotationKeys.add(id);
}

List<String> allKeys = new ArrayList<>(funcotatorHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList());
Expand All @@ -485,6 +493,7 @@ public void onTraversalStart() {
}

header.addMetaDataLine(UNABLE_TO_LIFT);
allAnnotationKeys.add(UNABLE_TO_LIFT.getID());

writer.writeHeader(header);
}
Expand All @@ -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)) {
Expand Down

0 comments on commit e206a48

Please sign in to comment.