forked from cBioPortal/cbioportal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Molecular-profile-counts-service (cBioPortal#10934)
* add unit tests for molecular-profile-counts-service * fix multiple-study scenario Update method name getGenomicDataCounts -> getMolecularProfileSampleCounts
- Loading branch information
Showing
11 changed files
with
172 additions
and
20 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
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
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
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
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
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
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
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
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
123 changes: 123 additions & 0 deletions
123
src/test/java/org/cbioportal/persistence/mybatisclickhouse/MolecularProfileCountTest.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,123 @@ | ||
package org.cbioportal.persistence.mybatisclickhouse; | ||
|
||
import org.cbioportal.persistence.mybatisclickhouse.config.MyBatisConfig; | ||
import org.cbioportal.web.parameter.CategorizedClinicalDataCountFilter; | ||
|
||
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.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
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 MolecularProfileCountTest 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 getMolecularProfileCounts() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); | ||
|
||
var profiles = new ArrayList<String>(Arrays.asList("mutations")); | ||
var profileGroups = new ArrayList<List<String>>(Arrays.asList(profiles)); | ||
|
||
studyViewFilter.setGenomicProfiles(profileGroups); | ||
|
||
var molecularProfileCounts = studyViewMapper.getMolecularProfileSampleCounts(studyViewFilter, | ||
CategorizedClinicalDataCountFilter.getBuilder().build(), false ); | ||
|
||
var size = molecularProfileCounts.stream().filter(gc->gc.getValue().equals("mutations")) | ||
.findFirst().get().getCount().intValue(); | ||
assertEquals(10, size); | ||
|
||
} | ||
|
||
@Test | ||
public void getMolecularProfileCountsMultipleStudies() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB, STUDY_ACC_TCGA)); | ||
|
||
var profiles = new ArrayList<String>(Arrays.asList("mutations")); | ||
var profileGroups = new ArrayList<List<String>>(Arrays.asList(profiles)); | ||
|
||
studyViewFilter.setGenomicProfiles(profileGroups); | ||
|
||
var molecularProfileCounts = studyViewMapper.getMolecularProfileSampleCounts(studyViewFilter, | ||
CategorizedClinicalDataCountFilter.getBuilder().build(), false ); | ||
|
||
var size = molecularProfileCounts.stream().filter(gc->gc.getValue().equals("mutations")) | ||
.findFirst().get().getCount().intValue(); | ||
assertEquals(10, size); | ||
|
||
} | ||
|
||
@Test | ||
public void getMolecularProfileCountsMultipleProfilesUnion() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); | ||
|
||
var profiles = new ArrayList<String>(Arrays.asList("mutations","mrna")); | ||
var profileGroups = new ArrayList<List<String>>(Arrays.asList(profiles)); | ||
|
||
studyViewFilter.setGenomicProfiles(profileGroups); | ||
|
||
var molecularProfileCounts = studyViewMapper.getMolecularProfileSampleCounts(studyViewFilter, | ||
CategorizedClinicalDataCountFilter.getBuilder().build(), false ); | ||
|
||
var sizeMutations = molecularProfileCounts.stream().filter(gc->gc.getValue().equals("mutations")) | ||
.findFirst().get().getCount().intValue(); | ||
assertEquals(10, sizeMutations); | ||
|
||
var sizeMrna = molecularProfileCounts.stream().filter(gc->gc.getValue().equals("mrna")) | ||
.findFirst().get().getCount().intValue(); | ||
assertEquals(9, sizeMrna); | ||
|
||
} | ||
|
||
@Test | ||
public void getMolecularProfileCountsMultipleProfilesIntersect() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); | ||
|
||
var profile1 = new ArrayList<String>(Arrays.asList("mutations")); | ||
var profile2 = new ArrayList<String>(Arrays.asList("mrna")); | ||
var profileGroups = new ArrayList<List<String>>(Arrays.asList(profile1, profile2)); | ||
|
||
studyViewFilter.setGenomicProfiles(profileGroups); | ||
|
||
var molecularProfileCounts = studyViewMapper.getMolecularProfileSampleCounts(studyViewFilter, | ||
CategorizedClinicalDataCountFilter.getBuilder().build(), false ); | ||
|
||
var sizeMutations = molecularProfileCounts.stream().filter(gc->gc.getValue().equals("mutations")) | ||
.findFirst().get().getCount().intValue(); | ||
assertEquals(9, sizeMutations); | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
} |
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