-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Demo rfc80 poc mutation&genomic data count unit tests #10961
Closed
fuzhaoyuan
wants to merge
2
commits into
cBioPortal:demo-rfc80-poc
from
fuzhaoyuan:demo-rfc80-poc-mutation&genomic_data_count_unit-tests
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
92 changes: 92 additions & 0 deletions
92
src/test/java/org/cbioportal/persistence/mybatisclickhouse/GenomicDataFilterTest.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,92 @@ | ||
package org.cbioportal.persistence.mybatisclickhouse; | ||
|
||
import org.cbioportal.model.GenomicDataCount; | ||
import org.cbioportal.model.GenomicDataCountItem; | ||
import org.cbioportal.persistence.helper.StudyViewFilterHelper; | ||
import org.cbioportal.persistence.mybatisclickhouse.config.MyBatisConfig; | ||
import org.cbioportal.web.parameter.GenomicDataFilter; | ||
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 static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(SpringRunner.class) | ||
@Import(MyBatisConfig.class) | ||
@DataJpaTest | ||
@DirtiesContext | ||
@AutoConfigureTestDatabase(replace= AutoConfigureTestDatabase.Replace.NONE) | ||
@ContextConfiguration(initializers = AbstractTestcontainers.Initializer.class) | ||
public class GenomicDataFilterTest 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 getCNACounts() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); | ||
|
||
GenomicDataFilter genomicDataFilterCNA = new GenomicDataFilter("AKT1", "cna"); | ||
List<GenomicDataCountItem> actualCountsCNA = studyViewMapper.getCNACounts(StudyViewFilterHelper.build(studyViewFilter, null, null), List.of(genomicDataFilterCNA)); | ||
List<GenomicDataCountItem> expectedCountsCNA = List.of( | ||
new GenomicDataCountItem("AKT1", "cna", List.of( | ||
new GenomicDataCount("Homozygously deleted", "-2", 2), | ||
new GenomicDataCount("Heterozygously deleted", "-1", 2), | ||
new GenomicDataCount("Diploid", "0", 2), | ||
new GenomicDataCount("Gained", "1", 2), | ||
new GenomicDataCount("Amplified", "2", 2), | ||
new GenomicDataCount("NA", "NA", 5) | ||
))); | ||
assertThat(actualCountsCNA) | ||
.usingRecursiveComparison() | ||
.ignoringCollectionOrder() | ||
.isEqualTo(expectedCountsCNA); | ||
|
||
GenomicDataFilter genomicDataFilterGISTIC = new GenomicDataFilter("AKT1", "gistic"); | ||
List<GenomicDataCountItem> actualCountsGISTIC = studyViewMapper.getCNACounts(StudyViewFilterHelper.build(studyViewFilter, null, null), List.of(genomicDataFilterGISTIC)); | ||
List<GenomicDataCountItem> expectedCountsGISTIC = List.of( | ||
new GenomicDataCountItem("AKT1", "gistic", List.of( | ||
new GenomicDataCount("Homozygously deleted", "-2", 2), | ||
new GenomicDataCount("Heterozygously deleted", "-1", 3), | ||
new GenomicDataCount("Diploid", "0", 3), | ||
new GenomicDataCount("Gained", "1", 3), | ||
new GenomicDataCount("Amplified", "2", 3), | ||
new GenomicDataCount("NA", "NA", 1) | ||
))); | ||
assertThat(actualCountsGISTIC) | ||
.usingRecursiveComparison() | ||
.ignoringCollectionOrder() | ||
.isEqualTo(expectedCountsGISTIC); | ||
} | ||
|
||
@Test | ||
public void getMutationCountsByType() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); | ||
|
||
GenomicDataFilter genomicDataFilterMutation = new GenomicDataFilter("AKT1", "mutation"); | ||
List<GenomicDataCountItem> actualMutationCountsByType = studyViewMapper.getMutationCountsByType(StudyViewFilterHelper.build(studyViewFilter, null, null), List.of(genomicDataFilterMutation)); | ||
List<GenomicDataCountItem> expectedMutationCountsByType = List.of( | ||
new GenomicDataCountItem("AKT1", "mutations", List.of( | ||
new GenomicDataCount("nonsense mutation", "nonsense_mutation", 1, 1), | ||
new GenomicDataCount("missense mutation", "missense_mutation", 1, 1) | ||
))); | ||
assertThat(actualMutationCountsByType) | ||
.usingRecursiveComparison() | ||
.ignoringCollectionOrder() | ||
.isEqualTo(expectedMutationCountsByType); | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fuzhaoyuan (@haynescd) if I understand correctly this PR switches from using it's own query (via the old getMututionCounts method of the repository) to just leveraging the getMutatedGenes method that was built for the mutated_genes endpoint. This is slightly painful because it means we're calling this thing at least twice for every filtering operation in the study view. I wonder if we could adapt getMutatedGenes so that it could take an optional gene parameter and then query only that, which would have massive savings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the same could be said for getFilteredSamplesCount. The study view is already calling that once. @haynescd this is probably too ambitious for this phase, but the solution for this redundancy would be a global cache of promises where the keys are hashes of the studyview filters. That way, we can fire off all these requests (endpoints) at the same time and whoever is first kicks off a given filtering operation and subsequent consumers just subscribe to that cached promise.