Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leexgh committed Jan 8, 2025
1 parent f6c9d04 commit 645f222
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class IsoformAnnotationEnricherTest
{
@Mock
EnsemblService ensemblService;
@Mock
OncokbService oncokbService;

private final VariantAnnotationMockData variantAnnotationMockData = new VariantAnnotationMockData();
Expand Down Expand Up @@ -69,9 +70,9 @@ public void enrichAnnotationWithNoOverride() throws IOException
public void enrichAnnotationWithSingleOverride() throws IOException
{
Map<String, VariantAnnotation> 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
Expand Down Expand Up @@ -105,7 +106,7 @@ public void enrichAnnotationWithSingleOverride() throws IOException
public void enrichAnnotationWithMultipleOverride() throws IOException
{
Map<String, VariantAnnotation> variantMockData = this.variantAnnotationMockData.generateData();

this.mockOncokbServiceMethods();
IsoformAnnotationEnricher enricher = new IsoformAnnotationEnricher(
"mskcc", "mskcc", this.ensemblService, this.oncokbService
);
Expand Down Expand Up @@ -148,4 +149,11 @@ public void enrichAnnotationWithMultipleOverride() throws IOException
canonicalTranscripts.get(2).getTranscriptId()
);
}

private void mockOncokbServiceMethods()
{
Set<String> oncokbGeneSymbolList = new HashSet<>();
oncokbGeneSymbolList.add("TPRXL");
Mockito.when(this.oncokbService.getOncokbGeneSymbolList()).thenReturn(oncokbGeneSymbolList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,6 +80,9 @@ public class VariantAnnotationServiceTest
@Mock
private MyVariantInfoService myVariantInfoService;

@Mock
private OncokbService oncokbService;

@Spy
private NotationConverter notationConverter;

Expand Down Expand Up @@ -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
Expand All @@ -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<VariantAnnotation> annotations = variantAnnotationService.getAnnotations(variants);
assertEquals(variantMockData.get("7:g.140453136A>T").getStart(), annotations.get(0).getStart());
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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<String, VariantAnnotation> variantMockData)
Expand All @@ -289,19 +308,22 @@ private void mockVariantFetcherMethods(Map<String, VariantAnnotation> 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<String> variants = new ArrayList<>(4);
variants.add("7:g.140453136A>T");
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<VariantAnnotation> 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);
}
Expand Down Expand Up @@ -358,14 +380,28 @@ private void mockPtmServiceMethods(Map<String, List<PostTranslationalModificatio

private void mockEnsemblServiceMethods()
{
// when called for "mskcc" override, set first transcript "ENST00000288602" as canonical
Set<String> 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<String> 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<String> oncokbGeneSymbolList = new HashSet<>();
oncokbGeneSymbolList.add("BRAF");
oncokbGeneSymbolList.add("KMT2A");
Mockito.when(this.oncokbService.getOncokbGeneSymbolList()).thenReturn(oncokbGeneSymbolList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public Map<String, VariantAnnotation> 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;
}
}
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}

0 comments on commit 645f222

Please sign in to comment.