TransvarConverter { @Nullable static TransvarRecord toTransvarRecord(@NotNull String transvarLine) { String[] fields = transvarLine.split(FIELD_DELIMITER); String messageField = fields[MESSAGE_COLUMN]; if (messageField.contains(MSG_NO_VALID_TRANSCRIPT_FOUND) || messageField.trim().startsWith(MSG_ERROR_INDICATION_PREFIX)) { return null; } TransvarRecord record = createRecord(fields[TRANSCRIPT_COLUMN], fields[COORDINATES_COLUMN], fields[LOCATION_COLUMN], messageField); if (record.annotation() instanceof TransvarInsertion && isInteger(((TransvarInsertion) record.annotation()).insertedBases())) { return null; } if (record.annotation() instanceof TransvarDuplication && !transvarLine.contains(HGVS_DUPLICATION)) { return null; } return record; } private  TransvarConverter();   }
@Test public void longInsertLeadsToNull() { String line = "BRCA2:p.V1839_E1901ins\tENST00000544455 (protein_coding)\tBRCA2\t+\tchr13:g.32914008_32914196ins189/" + "c.5516_5704del189/p.V1839_E1901del63\tinside_[cds_in_exon_11]\tCSQN=InFrameDeletion;left_align_gDNA=" + "g.32914004_32914192del189;unaligned_gDNA=g.32914007_32914195del189;left_align_cDNA=c.5512_5700del189;" + "unalign_cDNA=c.5515_5703del189;left_align_protein=p.E1838_S1900del63;unalign_protein=p.V1839_E1901del63;" + "imprecise;aliases=ENSP00000439902;source=Ensembl"; assertNull(TransvarConverter.toTransvarRecord(line)); }
@Test public void weirdVariantsShouldNotLeadToDuplications() { String line = "CARD11:p.L225LI\tENST00000396946 (protein_coding)\tCARD11\t-\tchr7:g.2983855_2983857/c.673_675/p.L225\t" + "inside_[cds_in_exon_5]\tCSQN=Unclassified;aliases=ENSP00000380150;source=Ensembl"; assertNull(TransvarConverter.toTransvarRecord(line)); }
@Test public void unresolvedProteinAnnotationLeadsToNull() { String line = "RAD50:p.L1273F\t.\t.\t.\t././.\t.\tno_valid_transcript_found"; assertNull(TransvarConverter.toTransvarRecord(line)); }
@Test public void invalidMutationStringLeadsToNull() { String line = "ERBB2:p.Exon 20 insertions\t.\t.\t.\t././.\t.\tError_invalid_mutation_string_p.Exon 20 insertions"; assertNull(TransvarConverter.toTransvarRecord(line)); }
@Test public void noneTypeLeadsToNull() { String line = "BRAF:p.T599insTT\t.\t.\t.\t././.\t.\tError_int() argument must be a string or a number, not 'NoneType'"; assertNull(TransvarConverter.toTransvarRecord(line)); }