From 645f222e7406b2e074a2af019e7fd3659d1be789 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 6 Jan 2025 10:32:49 -0500 Subject: [PATCH] Add tests --- .../IsoformAnnotationEnricherTest.java | 14 +++-- .../VariantAnnotationServiceTest.java | 40 ++++++++++++++- .../mock/VariantAnnotationMockData.java | 1 + .../11_g.118392020_118392034delinsTTAC.json | 51 +++++++++++++++++++ 4 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 service/src/test/resources/variant/11_g.118392020_118392034delinsTTAC.json diff --git a/service/src/test/java/org/cbioportal/genome_nexus/service/enricher/IsoformAnnotationEnricherTest.java b/service/src/test/java/org/cbioportal/genome_nexus/service/enricher/IsoformAnnotationEnricherTest.java index 09c8aa95..dc115f84 100644 --- a/service/src/test/java/org/cbioportal/genome_nexus/service/enricher/IsoformAnnotationEnricherTest.java +++ b/service/src/test/java/org/cbioportal/genome_nexus/service/enricher/IsoformAnnotationEnricherTest.java @@ -26,6 +26,7 @@ public class IsoformAnnotationEnricherTest { @Mock EnsemblService ensemblService; + @Mock OncokbService oncokbService; private final VariantAnnotationMockData variantAnnotationMockData = new VariantAnnotationMockData(); @@ -69,9 +70,9 @@ public void enrichAnnotationWithNoOverride() throws IOException public void enrichAnnotationWithSingleOverride() throws IOException { Map variantMockData = this.variantAnnotationMockData.generateData(); - + this.mockOncokbServiceMethods(); IsoformAnnotationEnricher enricher = new IsoformAnnotationEnricher( - "uniprot", "uniprot", this.ensemblService, null + "uniprot", "uniprot", this.ensemblService, this.oncokbService ); // override canonical transcripts with just one matching transcript @@ -105,7 +106,7 @@ public void enrichAnnotationWithSingleOverride() throws IOException public void enrichAnnotationWithMultipleOverride() throws IOException { Map variantMockData = this.variantAnnotationMockData.generateData(); - + this.mockOncokbServiceMethods(); IsoformAnnotationEnricher enricher = new IsoformAnnotationEnricher( "mskcc", "mskcc", this.ensemblService, this.oncokbService ); @@ -148,4 +149,11 @@ public void enrichAnnotationWithMultipleOverride() throws IOException canonicalTranscripts.get(2).getTranscriptId() ); } + + private void mockOncokbServiceMethods() + { + Set oncokbGeneSymbolList = new HashSet<>(); + oncokbGeneSymbolList.add("TPRXL"); + Mockito.when(this.oncokbService.getOncokbGeneSymbolList()).thenReturn(oncokbGeneSymbolList); + } } diff --git a/service/src/test/java/org/cbioportal/genome_nexus/service/internal/VariantAnnotationServiceTest.java b/service/src/test/java/org/cbioportal/genome_nexus/service/internal/VariantAnnotationServiceTest.java index 9500b1ef..b27ca96b 100644 --- a/service/src/test/java/org/cbioportal/genome_nexus/service/internal/VariantAnnotationServiceTest.java +++ b/service/src/test/java/org/cbioportal/genome_nexus/service/internal/VariantAnnotationServiceTest.java @@ -17,6 +17,7 @@ import org.cbioportal.genome_nexus.service.EnsemblService; import org.cbioportal.genome_nexus.service.MutationAssessorService; import org.cbioportal.genome_nexus.service.MyVariantInfoService; +import org.cbioportal.genome_nexus.service.OncokbService; import org.cbioportal.genome_nexus.component.annotation.HugoGeneSymbolResolver; import org.cbioportal.genome_nexus.component.annotation.NotationConverter; import org.cbioportal.genome_nexus.component.annotation.ProteinChangeResolver; @@ -79,6 +80,9 @@ public class VariantAnnotationServiceTest @Mock private MyVariantInfoService myVariantInfoService; + @Mock + private OncokbService oncokbService; + @Spy private NotationConverter notationConverter; @@ -117,6 +121,10 @@ public void getAnnotationByVariantString() VariantAnnotation annotation5 = variantAnnotationService.getAnnotation("chr24:g.41242962_41242963insGA"); assertEquals(variantMockData.get("Y:g.41242962_41242963insGA").getStart(), annotation5.getStart()); assertEquals(variantMockData.get("Y:g.41242962_41242963insGA").getVariant(), annotation5.getVariant()); + + VariantAnnotation annotation6 = variantAnnotationService.getAnnotation("11:g.118392020_118392034delinsTTAC"); + assertEquals(variantMockData.get("11:g.118392020_118392034delinsTTAC").getStart(), annotation6.getStart()); + assertEquals(variantMockData.get("11:g.118392020_118392034delinsTTAC").getVariant(), annotation6.getVariant()); } @Test @@ -132,6 +140,7 @@ public void getAnnotationsByVariantString() variants.add("12:g.25398285C>A"); variants.add("chr23:g.41242962_41242963insGA"); variants.add("chr24:g.41242962_41242963insGA"); + variants.add("11:g.118392020_118392034delinsTTAC"); List annotations = variantAnnotationService.getAnnotations(variants); assertEquals(variantMockData.get("7:g.140453136A>T").getStart(), annotations.get(0).getStart()); @@ -142,6 +151,8 @@ public void getAnnotationsByVariantString() assertEquals(variantMockData.get("X:g.41242962_41242963insGA").getVariant(), annotations.get(2).getVariant()); assertEquals(variantMockData.get("Y:g.41242962_41242963insGA").getStart(), annotations.get(3).getStart()); assertEquals(variantMockData.get("Y:g.41242962_41242963insGA").getVariant(), annotations.get(3).getVariant()); + assertEquals(variantMockData.get("11:g.118392020_118392034delinsTTAC").getStart(), annotations.get(4).getStart()); + assertEquals(variantMockData.get("11:g.118392020_118392034delinsTTAC").getVariant(), annotations.get(4).getVariant()); } @Test @@ -265,6 +276,7 @@ public void getIsorformOverrideEnrichedAnnotationByVariantString() this.mockVariantFetcherMethods(variantMockData); this.mockEnsemblServiceMethods(); + this.mockOncokbServiceMethods(); VariantAnnotation annotation1 = variantAnnotationService.getAnnotation( "7:g.140453136A>T", "mskcc", null, null); @@ -279,6 +291,13 @@ public void getIsorformOverrideEnrichedAnnotationByVariantString() // second transcript of this annotation should be marked as canonical, the first one should NOT be marked assertEquals(null, annotation2.getTranscriptConsequences().get(0).getCanonical()); assertEquals("1", annotation2.getTranscriptConsequences().get(1).getCanonical()); + + // should choose canonical transcript based on oncokb gene symbol list + // choose the oncokb gene transcript as cannoical + VariantAnnotation annotation3 = variantAnnotationService.getAnnotation( + "11:g.118392020_118392034delinsTTAC", "mskcc", null, null); + assertEquals("1", annotation3.getTranscriptConsequences().get(0).getCanonical()); + assertEquals(null, annotation3.getTranscriptConsequences().get(1).getCanonical()); } private void mockVariantFetcherMethods(Map variantMockData) @@ -289,6 +308,7 @@ private void mockVariantFetcherMethods(Map variantMoc Mockito.when(this.fetcher.fetchAndCache("12:g.25398285C>A")).thenReturn(variantMockData.get("12:g.25398285C>A")); Mockito.when(this.fetcher.fetchAndCache("X:g.41242962_41242963insGA")).thenReturn(variantMockData.get("X:g.41242962_41242963insGA")); Mockito.when(this.fetcher.fetchAndCache("Y:g.41242962_41242963insGA")).thenReturn(variantMockData.get("Y:g.41242962_41242963insGA")); + Mockito.when(this.fetcher.fetchAndCache("11:g.118392020_118392034delinsTTAC")).thenReturn(variantMockData.get("11:g.118392020_118392034delinsTTAC")); Mockito.doNothing().when(this.baseVariantAnnotationServiceImpl).saveToIndexDb(any(), any()); List variants = new ArrayList<>(4); @@ -296,12 +316,14 @@ private void mockVariantFetcherMethods(Map variantMoc variants.add("12:g.25398285C>A"); variants.add("X:g.41242962_41242963insGA"); variants.add("Y:g.41242962_41242963insGA"); + variants.add("11:g.118392020_118392034delinsTTAC"); List returnValue = new ArrayList<>(3); returnValue.add(variantMockData.get("7:g.140453136A>T")); returnValue.add(variantMockData.get("12:g.25398285C>A")); returnValue.add(variantMockData.get("X:g.41242962_41242963insGA")); returnValue.add(variantMockData.get("Y:g.41242962_41242963insGA")); + returnValue.add(variantMockData.get("11:g.118392020_118392034delinsTTAC")); Mockito.when(this.fetcher.fetchAndCache(variants)).thenReturn(returnValue); } @@ -358,14 +380,28 @@ private void mockPtmServiceMethods(Map mskccOverrides = new HashSet<>(); + // For variant 7:g.140453136A>T + // when called for "mskcc" override, set first transcript "ENST00000288602" as canonical mskccOverrides.add("ENST00000288602"); + + // For variant 11:g.118392020_118392034delinsTTAC, two transcripts need to be added + mskccOverrides.add("ENST00000534358"); + mskccOverrides.add("ENST00000554407"); Mockito.when(this.ensemblService.getCanonicalTranscriptIdsBySource("mskcc")).thenReturn(mskccOverrides); - // when called for "uniprot" override, set second transcript "ENST00000479537" as canonical Set uniprotOverrides = new HashSet<>(); + // For variant 7:g.140453136A>T + // when called for "uniprot" override, set second transcript "ENST00000479537" as canonical uniprotOverrides.add("ENST00000479537"); Mockito.when(this.ensemblService.getCanonicalTranscriptIdsBySource("uniprot")).thenReturn(uniprotOverrides); } + + private void mockOncokbServiceMethods() + { + Set oncokbGeneSymbolList = new HashSet<>(); + oncokbGeneSymbolList.add("BRAF"); + oncokbGeneSymbolList.add("KMT2A"); + Mockito.when(this.oncokbService.getOncokbGeneSymbolList()).thenReturn(oncokbGeneSymbolList); + } } diff --git a/service/src/test/java/org/cbioportal/genome_nexus/service/mock/VariantAnnotationMockData.java b/service/src/test/java/org/cbioportal/genome_nexus/service/mock/VariantAnnotationMockData.java index d00d411b..c314f054 100644 --- a/service/src/test/java/org/cbioportal/genome_nexus/service/mock/VariantAnnotationMockData.java +++ b/service/src/test/java/org/cbioportal/genome_nexus/service/mock/VariantAnnotationMockData.java @@ -79,6 +79,7 @@ public Map generateData() throws IOException this.objectMapper.readVariantAnnotation("13_g.48954120_48954122delinsAAA.json")); mockData.put("10:g.8100129_8100132delinsAACT", this.objectMapper.readVariantAnnotation("10_g.8100129_8100132delinsAACT.json")); + mockData.put("11:g.118392020_118392034delinsTTAC", this.objectMapper.readVariantAnnotation("11_g.118392020_118392034delinsTTAC.json")); return mockData; } } diff --git a/service/src/test/resources/variant/11_g.118392020_118392034delinsTTAC.json b/service/src/test/resources/variant/11_g.118392020_118392034delinsTTAC.json new file mode 100644 index 00000000..4fa22615 --- /dev/null +++ b/service/src/test/resources/variant/11_g.118392020_118392034delinsTTAC.json @@ -0,0 +1,51 @@ +{ + "variant": "11:g.118392020_118392034delinsTTAC", + "originalVariantQuery": "11:g.118392020_118392034delinsTTAC", + "hgvsg": "11:g.118392020_118392034delinsTTAC", + "id": "11:g.118392020_118392034delinsTTAC", + "assembly_name": "GRCh37", + "seq_region_name": "11", + "start": 118392020, + "end": 118392034, + "allele_string": "GGGGTCTTTTCTGTA/TTAC", + "strand": 1, + "most_severe_consequence": "splice_acceptor_variant", + "transcript_consequences": [ + { + "exon": "35/36", + "transcript_id": "ENST00000534358", + "hgvsp": "ENSP00000436786.1:p.Arg3844LeufsTer6", + "hgvsc": "ENST00000534358.1:c.11531_11545delinsTTAC", + "variant_allele": "TTAC", + "codons": "cGGGGTCTTTTCTGTAag/cTTACag", + "protein_id": "ENSP00000436786", + "protein_start": 3844, + "protein_end": 3849, + "gene_symbol": "KMT2A", + "gene_id": "ENSG00000118058", + "amino_acids": "RGLFCK/LTX", + "hgnc_id": "7132", + "canonical": "1", + "refseq_transcript_ids": [ + "NM_005933.3", + "NM_001197104.1" + ], + "consequence_terms": [ + "frameshift_variant" + ] + }, + { + "exon": "2/3", + "transcript_id": "ENST00000554407", + "hgvsc": "ENST00000554407.1:n.273-5_282delinsGTAA", + "variant_allele": "TTAC", + "gene_symbol": "RP11-770J1.3", + "gene_id": "ENSG00000255435", + "consequence_terms": [ + "splice_acceptor_variant", + "non_coding_transcript_exon_variant", + "intron_variant" + ] + } + ] +} \ No newline at end of file