-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration tests for cna-genes and sv-genes (#11221)
Co-authored-by: Bryan Lai <[email protected]>
- Loading branch information
Showing
4 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/test/java/org/cbioportal/persistence/mybatisclickhouse/CNAGenesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.cbioportal.persistence.mybatisclickhouse; | ||
|
||
import org.cbioportal.model.AlterationFilter; | ||
import org.cbioportal.model.CNA; | ||
import org.cbioportal.persistence.helper.AlterationFilterHelper; | ||
import org.cbioportal.persistence.helper.StudyViewFilterHelper; | ||
import org.cbioportal.persistence.mybatisclickhouse.config.MyBatisConfig; | ||
import org.cbioportal.web.parameter.StudyViewFilter; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(SpringRunner.class) | ||
@Import(MyBatisConfig.class) | ||
@DataJpaTest | ||
@DirtiesContext | ||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) | ||
@ContextConfiguration(initializers = AbstractTestcontainers.Initializer.class) | ||
public class CNAGenesTest extends AbstractTestcontainers { | ||
|
||
private static final String STUDY_TCGA_PUB = "study_tcga_pub"; | ||
|
||
@Autowired | ||
private StudyViewMapper studyViewMapper; | ||
|
||
@Test | ||
public void getCnaGenes() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); | ||
var alterationCountByGenes = studyViewMapper.getCnaGenes(StudyViewFilterHelper.build(studyViewFilter, null, null), | ||
AlterationFilterHelper.build(studyViewFilter.getAlterationFilter())); | ||
assertEquals(3, alterationCountByGenes.size()); | ||
|
||
// Test cna count for akt1 | ||
var testAKT1AlterationCount = alterationCountByGenes.stream().filter(a -> Objects.equals(a.getHugoGeneSymbol(), "AKT1")) | ||
.mapToInt(c -> c.getTotalCount().intValue()) | ||
.sum(); | ||
assertEquals(3, testAKT1AlterationCount); | ||
} | ||
|
||
@Test | ||
public void getCnaGenesWithAlterationFilter() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); | ||
|
||
// Create AlterationFilter | ||
AlterationFilter alterationFilter = new AlterationFilter(); | ||
Map<CNA, Boolean> cnaEventTypeFilterMap = new HashMap<>(); | ||
cnaEventTypeFilterMap.put(CNA.HOMDEL, false); | ||
cnaEventTypeFilterMap.put(CNA.AMP, true); | ||
alterationFilter.setCopyNumberAlterationEventTypes(cnaEventTypeFilterMap); | ||
|
||
var alterationCountByGenes = studyViewMapper.getCnaGenes(StudyViewFilterHelper.build(studyViewFilter, null, null), | ||
AlterationFilterHelper.build(alterationFilter)); | ||
assertEquals(2, alterationCountByGenes.size()); | ||
|
||
// Test cna count for akt1 filtering for AMP | ||
var testAKT1AlterationCount = alterationCountByGenes.stream().filter(a -> Objects.equals(a.getHugoGeneSymbol(), "AKT1")) | ||
.mapToInt(c -> c.getTotalCount().intValue()) | ||
.sum(); | ||
assertEquals(2, testAKT1AlterationCount); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/test/java/org/cbioportal/persistence/mybatisclickhouse/StructuralVariantGenesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.cbioportal.persistence.mybatisclickhouse; | ||
|
||
import org.cbioportal.persistence.helper.AlterationFilterHelper; | ||
import org.cbioportal.persistence.helper.StudyViewFilterHelper; | ||
import org.cbioportal.persistence.mybatisclickhouse.config.MyBatisConfig; | ||
import org.cbioportal.web.parameter.StudyViewFilter; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(SpringRunner.class) | ||
@Import(MyBatisConfig.class) | ||
@DataJpaTest | ||
@DirtiesContext | ||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) | ||
@ContextConfiguration(initializers = AbstractTestcontainers.Initializer.class) | ||
public class StructuralVariantGenesTest extends AbstractTestcontainers { | ||
|
||
private static final String STUDY_TCGA_PUB = "study_tcga_pub"; | ||
private static final String STUDY_ACC_TCGA = "acc_tcga"; | ||
|
||
@Autowired | ||
private StudyViewMapper studyViewMapper; | ||
|
||
@Test | ||
public void getStructuralVariantGenes() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB, STUDY_ACC_TCGA)); | ||
var alterationCountByGenes = studyViewMapper.getStructuralVariantGenes(StudyViewFilterHelper.build(studyViewFilter, null, null), | ||
AlterationFilterHelper.build(studyViewFilter.getAlterationFilter())); | ||
assertEquals(8, alterationCountByGenes.size()); | ||
|
||
// Test sv count for eml4 which is in one study | ||
var testeml4AlterationCount = alterationCountByGenes.stream().filter(a -> Objects.equals(a.getHugoGeneSymbol(), "eml4")) | ||
.mapToInt(c -> c.getTotalCount().intValue()) | ||
.sum(); | ||
assertEquals(1, testeml4AlterationCount); | ||
|
||
// Test sv count for ncoa4 which is in both studies | ||
var testncoa4AlterationCount = alterationCountByGenes.stream().filter(a -> Objects.equals(a.getHugoGeneSymbol(), "ncoa4")) | ||
.mapToInt(c -> c.getTotalCount().intValue()) | ||
.sum(); | ||
assertEquals(3, testncoa4AlterationCount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters