-
Notifications
You must be signed in to change notification settings - Fork 5
feat(nanno): if snpeff deems a variant to be in multiple genes report them all #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6516f60
460c9c4
283d201
6f724e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ public class AnnotationSourceTSV extends AnnotationSource { | |
| List<String> headerLines; | ||
| Map<String, Integer> headerNameAndPosition; | ||
|
|
||
| private String[] fieldNames; | ||
| private int[] fieldPositions; | ||
|
|
||
| public AnnotationSourceTSV(RecordReader<String> reader, int chrPositionInRecord, int positionPositionInRecord, | ||
| int refPositionInFile, int altPositionInFile, String fieldNames, boolean chrStartsWithChr) { | ||
| super(reader, chrPositionInRecord, positionPositionInRecord, refPositionInFile, altPositionInFile, chrStartsWithChr); | ||
|
|
@@ -46,6 +49,12 @@ public AnnotationSourceTSV(RecordReader<String> reader, int chrPositionInRecord, | |
| if (headerNameAndPosition.isEmpty()) { | ||
| throw new IllegalArgumentException("Could not find requested fields (" + fieldNames + ") in header: " + headerLine); | ||
| } | ||
| // precompute arrays for fast extraction | ||
| this.fieldNames = headerNameAndPosition.keySet().toArray(new String[0]); | ||
| this.fieldPositions = new int[this.fieldNames.length]; | ||
| for (int i = 0; i < this.fieldNames.length; i++) { | ||
| this.fieldPositions[i] = headerNameAndPosition.get(this.fieldNames[i]); | ||
| } | ||
|
Comment on lines
+52
to
+57
|
||
| } | ||
|
|
||
| /* | ||
|
|
@@ -96,20 +105,18 @@ public String annotationToReturn(String[] record) { | |
| /* | ||
| * entries in the INFO field are delimited by ';' | ||
| */ | ||
| return extractFieldsFromRecord(record, headerNameAndPosition); | ||
| return extractFieldsFromRecord(record, fieldNames, fieldPositions); | ||
| } | ||
|
|
||
| public static String extractFieldsFromRecord(String[] record, Map<String, Integer> fields) { | ||
| public static String extractFieldsFromRecord(String[] record, String[] fieldNames, int[] fieldPositions) { | ||
| StringBuilder dataToReturn = new StringBuilder(); | ||
| int recordLength = null != record ? record.length : 0; | ||
| if ( recordLength > 0 && null != fields) { | ||
| // String [] recordArray = TabTokenizer.tokenize(record); | ||
| for (Entry<String, Integer> entry : fields.entrySet()) { | ||
| /* | ||
| * make sure that array length is not shorter than entry value | ||
| */ | ||
| if (recordLength > entry.getValue()) { | ||
| dataToReturn.append(( ! dataToReturn.isEmpty()) ? FIELD_DELIMITER_TAB : "").append(entry.getKey()).append("=").append(record[entry.getValue()]); | ||
| if (recordLength > 0 && null != fieldNames && null != fieldPositions) { | ||
| for (int i = 0; i < Math.min(fieldNames.length, fieldPositions.length); i++) { | ||
| int pos = fieldPositions[i]; | ||
| if (recordLength > pos) { | ||
| dataToReturn.append((!dataToReturn.isEmpty()) ? FIELD_DELIMITER_TAB : "") | ||
|
Comment on lines
+111
to
+118
|
||
| .append(fieldNames[i]).append("=").append(record[pos]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getWorstConsequenceusesaa.startsWith(alt)to select consequences for an allele. This can incorrectly match alleles wherealtis a prefix (e.g., requested altAwill also match anANNentry starting withAA|...). To avoid mis-annotating multi-allelic records, match the allele token exactly (e.g.,aa.startsWith(alt + "|")or parse up to the first '|').There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Coplit please implement your suggestion