-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mock data and config for clickhouse testing on filtered samples a…
…nd mutated genes
- Loading branch information
Showing
4 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...st/java/org/cbioportal/persistence/mybatiscolumnstore/StudyViewMyBatisRepositoryTest.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,49 @@ | ||
package org.cbioportal.persistence.mybatiscolumnstore; | ||
|
||
import org.cbioportal.model.AlterationCountByGene; | ||
import org.cbioportal.model.Sample; | ||
import org.cbioportal.webparam.StudyViewFilter; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Configurable; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration("/testContextDatabaseClickhouse.xml") | ||
@Configurable | ||
public class StudyViewMyBatisRepositoryTest { | ||
|
||
@Autowired | ||
private StudyViewMyBatisRepository studyViewMyBatisRepository; | ||
|
||
@Test | ||
public void getFilteredSamples() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
|
||
List<String> studyIds = new ArrayList<>(); | ||
studyIds.add("msk_ch_2020"); | ||
studyViewFilter.setStudyIds(studyIds); | ||
|
||
List<Sample> samples = studyViewMyBatisRepository.getFilteredSamplesFromColumnstore(studyViewFilter); | ||
Assert.assertEquals(3, samples.size()); | ||
} | ||
|
||
@Test | ||
public void getMutatedGenes() { | ||
StudyViewFilter studyViewFilter = new StudyViewFilter(); | ||
|
||
List<String> studyIds = new ArrayList<>(); | ||
studyIds.add("msk_ch_2020"); | ||
studyViewFilter.setStudyIds(studyIds); | ||
|
||
List<AlterationCountByGene> mutations = studyViewMyBatisRepository.getMutatedGenes(studyViewFilter); | ||
Assert.assertEquals(2, mutations.size()); | ||
} | ||
|
||
} |
121 changes: 121 additions & 0 deletions
121
persistence/persistence-mybatis/src/test/resources/clickhouseSchema.sql
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,121 @@ | ||
create table cna_discrete | ||
( | ||
sample_unique_id varchar(255), | ||
alteration int, | ||
hugo_gene_symbol varchar(255), | ||
gene_panel_stable_id varchar(255), | ||
cancer_study_identifier varchar(255), | ||
genetic_profile_stable_id varchar(255), | ||
PRIMARY KEY (sample_unique_id, alteration, hugo_gene_symbol, cancer_study_identifier) | ||
); | ||
|
||
create table genetic_profile | ||
( | ||
sample_unique_id varchar(255), | ||
genetic_alteration_type varchar(255), | ||
datatype varchar(255), | ||
value varchar(255), | ||
cancer_study_identifier varchar(255), | ||
PRIMARY KEY (sample_unique_id, genetic_alteration_type, datatype, value, cancer_study_identifier) | ||
); | ||
|
||
create table genetic_profile_counts | ||
( | ||
sample_unique_id varchar(255), | ||
profile_name varchar(255), | ||
genetic_profile_stable_id varchar(255), | ||
cancer_study_identifier varchar(255), | ||
count int | ||
); | ||
|
||
create table genomic_event | ||
( | ||
sample_unique_id varchar(255), | ||
variant varchar(255), | ||
hugo_gene_symbol varchar(255), | ||
gene_panel_stable_id varchar(255), | ||
cancer_study_identifier varchar(255), | ||
genetic_profile_stable_id varchar(255), | ||
PRIMARY KEY (sample_unique_id, variant, hugo_gene_symbol, cancer_study_identifier, genetic_profile_stable_id) | ||
); | ||
|
||
create table mutation | ||
( | ||
sample_unique_id varchar(255), | ||
variant varchar(255), | ||
hugo_gene_symbol varchar(255), | ||
gene_panel_stable_id varchar(255), | ||
cancer_study_identifier varchar(255), | ||
genetic_profile_stable_id varchar(255), | ||
PRIMARY KEY (sample_unique_id, variant, hugo_gene_symbol, cancer_study_identifier) | ||
); | ||
|
||
create table patient_clinical_attribute_categorical | ||
( | ||
patient_unique_id varchar(255), | ||
attribute_name varchar(255), | ||
attribute_value varchar(255), | ||
cancer_study_identifier varchar(255), | ||
PRIMARY KEY (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) | ||
); | ||
|
||
create table patient_clinical_attribute_numeric | ||
( | ||
patient_unique_id varchar(255), | ||
attribute_name varchar(255), | ||
attribute_value float, | ||
cancer_study_identifier varchar(255), | ||
PRIMARY KEY (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) | ||
); | ||
|
||
create table sample | ||
( | ||
sample_unique_id varchar(255), | ||
sample_stable_id varchar(255), | ||
patient_unique_id varchar(255), | ||
patient_stable_id varchar(255), | ||
cancer_study_identifier varchar(255), | ||
sample_unique_id_base64 varchar(255), | ||
patient_unique_id_base64 varchar(255), | ||
PRIMARY KEY (sample_unique_id, patient_unique_id, cancer_study_identifier) | ||
); | ||
|
||
create table sample_clinical_attribute_categorical | ||
( | ||
patient_unique_id varchar(255), | ||
sample_unique_id varchar(255), | ||
attribute_name varchar(255), | ||
attribute_value varchar(255), | ||
cancer_study_identifier varchar(255), | ||
PRIMARY KEY (patient_unique_id, sample_unique_id, attribute_name, attribute_value, cancer_study_identifier) | ||
); | ||
|
||
create table sample_clinical_attribute_numeric | ||
( | ||
patient_unique_id varchar(255), | ||
sample_unique_id varchar(255), | ||
attribute_name varchar(255), | ||
attribute_value float, | ||
cancer_study_identifier varchar(255), | ||
PRIMARY KEY (patient_unique_id, sample_unique_id, attribute_name, attribute_value, cancer_study_identifier) | ||
); | ||
|
||
create table sample_list | ||
( | ||
sample_unique_id varchar(255), | ||
sample_list_stable_id varchar(255), | ||
name varchar(255), | ||
cancer_study_identifier varchar(255), | ||
PRIMARY KEY (sample_unique_id, sample_list_stable_id, name, cancer_study_identifier) | ||
); | ||
|
||
create table structural_variant | ||
( | ||
sample_unique_id varchar(255), | ||
hugo_symbol_gene1 varchar(255), | ||
hugo_symbol_gene2 varchar(255), | ||
gene_panel_stable_id varchar(255), | ||
cancer_study_identifier varchar(255), | ||
genetic_profile_stable_id varchar(255), | ||
PRIMARY KEY (sample_unique_id, hugo_symbol_gene1, hugo_symbol_gene2, cancer_study_identifier) | ||
); |
20 changes: 20 additions & 0 deletions
20
persistence/persistence-mybatis/src/test/resources/clickhouseTestSql.sql
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,20 @@ | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000004', 'AGE', 39.739902, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000004', 'TIME_FROM_DX_TO_SEQ', 991, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000004', 'TIME_TO_BLOOD_DRAW_FROM_TX', 609, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000015', 'AGE', 44.440792, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000015', 'TIME_FROM_DX_TO_SEQ', 2558, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000015', 'TIME_TO_BLOOD_DRAW_FROM_TX', 5, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000023', 'AGE', 61.319645, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000023', 'TIME_FROM_DX_TO_SEQ', 245, 'msk_ch_2020'); | ||
INSERT INTO patient_clinical_attribute_numeric (patient_unique_id, attribute_name, attribute_value, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000023', 'TIME_TO_BLOOD_DRAW_FROM_TX', 166, 'msk_ch_2020'); | ||
|
||
INSERT INTO sample (sample_unique_id, sample_unique_id_base64, sample_stable_id, patient_unique_id, patient_unique_id_base64, patient_stable_id, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000004-N01', '', 'P-0000004-N01', 'msk_ch_2020_P-0000004', '', 'P-0000004', 'msk_ch_2020'); | ||
INSERT INTO sample (sample_unique_id, sample_unique_id_base64, sample_stable_id, patient_unique_id, patient_unique_id_base64, patient_stable_id, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000015-N01', '', 'P-0000015-N01', 'msk_ch_2020_P-0000015', '', 'P-0000015', 'msk_ch_2020'); | ||
INSERT INTO sample (sample_unique_id, sample_unique_id_base64, sample_stable_id, patient_unique_id, patient_unique_id_base64, patient_stable_id, cancer_study_identifier) VALUES ('msk_ch_2020_P-0000023-N01', '', 'P-0000023-N01', 'msk_ch_2020_P-0000023', '', 'P-0000023', 'msk_ch_2020'); | ||
-- | ||
INSERT INTO genomic_event (sample_unique_id, variant, hugo_gene_symbol, gene_panel_stable_id, cancer_study_identifier, genetic_profile_stable_id) VALUES ('msk_ch_2020_P-0000004-N01', 'p.R1051Q', 'KDR', '', 'msk_ch_2020', 'msk_ch_2020_mutations'); | ||
INSERT INTO genomic_event (sample_unique_id, variant, hugo_gene_symbol, gene_panel_stable_id, cancer_study_identifier, genetic_profile_stable_id) VALUES ('msk_ch_2020_P-0000004-N01', 'p.T1884I', 'TET2', '', 'msk_ch_2020', 'msk_ch_2020_mutations'); | ||
|
||
INSERT INTO mutation (sample_unique_id, variant, hugo_gene_symbol, gene_panel_stable_id, cancer_study_identifier, genetic_profile_stable_id) VALUES ('msk_ch_2020_P-0000004-N01', 'p.R1051Q', 'KDR', '', 'msk_ch_2020', 'msk_ch_2020_mutations'); | ||
INSERT INTO mutation (sample_unique_id, variant, hugo_gene_symbol, gene_panel_stable_id, cancer_study_identifier, genetic_profile_stable_id) VALUES ('msk_ch_2020_P-0000004-N01', 'p.T1884I', 'TET2', '', 'msk_ch_2020', 'msk_ch_2020_mutations'); | ||
|
40 changes: 40 additions & 0 deletions
40
persistence/persistence-mybatis/src/test/resources/testContextDatabaseClickhouse.xml
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,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<beans | ||
xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:util="http://www.springframework.org/schema/util" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context.xsd | ||
http://www.springframework.org/schema/util | ||
http://www.springframework.org/schema/util/spring-util.xsd"> | ||
<bean id="dbcpDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> | ||
<property name="url" value="jdbc:h2:mem:;MODE=MySQL;DATABASE_TO_UPPER=false;INIT=RUNSCRIPT FROM 'classpath:clickhouseSchema.sql'\;RUNSCRIPT FROM 'classpath:clickhouseTestSql.sql'"/> | ||
<!-- | ||
Enable this to connect to an actual clickhouse Database instead of a mock one. | ||
Note that this is only intended for temporary local use, not for automated CI tests. | ||
--> | ||
<!-- <property name="url" value="jdbc:ch://localhost:8123/cbioportal"/>--> | ||
</bean> | ||
|
||
|
||
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> | ||
<property name="dataSource" ref="dbcpDataSource"/> | ||
<property name="typeAliasesPackage" value="org.mskcc.cbio.portal.model"/> | ||
<property name="typeHandlersPackage" value="org.cbioportal.persistence.mybatis.typehandler"/> | ||
</bean> | ||
|
||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> | ||
<property name="dataSource" ref="dbcpDataSource" /> | ||
</bean> | ||
|
||
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> | ||
<property name="basePackage" value="org.cbioportal.persistence.mybatiscolumnstore"/> | ||
</bean> | ||
|
||
<context:component-scan base-package="org.cbioportal.persistence.mybatiscolumnstore"/> | ||
|
||
</beans> |