Skip to content

Commit

Permalink
Bugfix to the order in which SnpSift fields are renamed relative to t…
Browse files Browse the repository at this point in the history
…he VCF header in MultiSourceAnnotator (#291)
  • Loading branch information
bbimber authored Oct 26, 2023
1 parent 9677e2a commit 278ed24
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,15 @@ public void onTraversalStart() {
}
}

// NOTE: run this before generating the header to ensure to translate IDs correctly:
if (renamedSnpSiftFields != null && !renamedSnpSiftFields.isEmpty()) {
if (renamedSnpSiftFields.size() != snpSiftFields.size()) {
throw new GATKException("--renamed-snpsift-fields must be the same length as --snpsift-fields");
}

IntStream.range(0, renamedSnpSiftFields.size()).forEach(j -> snpSiftFieldMapping.put(snpSiftFields.get(j), renamedSnpSiftFields.get(j)));
}

if (snpSiftVariants != null) {
VCFHeader snpSiftHeader = (VCFHeader) getHeaderForFeatures(snpSiftVariants);
for (String id : snpSiftFields) {
Expand All @@ -488,16 +497,13 @@ public void onTraversalStart() {
continue;
}
}
header.addMetaDataLine(line);
allAnnotationKeys.add(id);
}

if (renamedSnpSiftFields != null && !renamedSnpSiftFields.isEmpty()) {
if (renamedSnpSiftFields.size() != snpSiftFields.size()) {
throw new GATKException("--renamed-snpsift-fields must be the same length as --snpsift-fields");
if (snpSiftFieldMapping.containsKey(line.getID())) {
line = new VCFInfoHeaderLine(snpSiftFieldMapping.get(line.getID()), line.getCount(), line.getType(), line.getDescription(), line.getSource(), line.getVersion());
}

IntStream.range(0, renamedSnpSiftFields.size()).forEach(j -> snpSiftFieldMapping.put(snpSiftFields.get(j), renamedSnpSiftFields.get(j)));
header.addMetaDataLine(line);
allAnnotationKeys.add(id);
}

List<String> allKeys = new ArrayList<>(snpSiftHeader.getInfoHeaderLines().stream().map(VCFInfoHeaderLine::getID).toList());
Expand Down

0 comments on commit 278ed24

Please # to comment.