-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move clinical data bin related SQL queries to a separate file
- Loading branch information
Showing
3 changed files
with
102 additions
and
96 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
...resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewClinicalDataBinMapper.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,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
|
||
<mapper namespace="org.cbioportal.persistence.mybatisclickhouse.StudyViewMapper"> | ||
<sql id="sampleClinicalDataFromStudyViewFilter"> | ||
<where> | ||
sample_unique_id IN ( | ||
<include refid="sampleUniqueIdsFromStudyViewFilter"/> | ||
<if test="applyPatientIdFilters == true"> | ||
INTERSECT <include refid="getSampleIdsFromPatientIds"/> | ||
</if> | ||
) | ||
</where> | ||
<if test="attributeIds != null and !attributeIds.isEmpty()"> | ||
AND attribute_name IN | ||
<foreach item="attributeId" collection="attributeIds" open="(" separator="," close=")"> | ||
#{attributeId} | ||
</foreach> | ||
</if> | ||
</sql> | ||
|
||
<sql id="patientClinicalDataFromStudyViewFilter"> | ||
<where> | ||
patient_unique_id IN ( | ||
<include refid="getPatientIdsFromSampleIdFilters"/> | ||
<if test="applyPatientIdFilters == true"> | ||
INTERSECT <include refid="patientUniqueIdsFromStudyViewFilter"/> | ||
</if> | ||
) | ||
</where> | ||
<if test="attributeIds != null and !attributeIds.isEmpty()"> | ||
AND attribute_name IN | ||
<foreach item="attributeId" collection="attributeIds" open="(" separator="," close=")"> | ||
#{attributeId} | ||
</foreach> | ||
</if> | ||
</sql> | ||
|
||
<!-- TODO only fetching from sample_clinical_attribute_numeric, need to support sample_clinical_attribute_categorical as well --> | ||
<select id="getSampleCountWithoutClinicalData" resultType="Long"> | ||
SELECT | ||
COUNT (DISTINCT sample_unique_id) | ||
FROM sample_mv | ||
<where> | ||
sample_unique_id IN ( <include refid="sampleUniqueIdsFromStudyViewFilter"/>) | ||
<if test="applyPatientIdFilters == true"> | ||
AND patient_unique_id IN (<include refid="patientUniqueIdsFromStudyViewFilter"/>) | ||
</if> | ||
AND sample_unique_id NOT IN ( | ||
SELECT | ||
sample_unique_id | ||
FROM sample_clinical_attribute_numeric_view | ||
<include refid="sampleClinicalDataFromStudyViewFilter"/> | ||
) | ||
</where> | ||
</select> | ||
|
||
<select id="getSampleClinicalDataFromStudyViewFilter" resultType="org.cbioportal.model.ClinicalData"> | ||
SELECT | ||
sample_unique_id as sampleId, | ||
patient_unique_id as patientId, | ||
attribute_name as attrId, | ||
attribute_value as attrValue, | ||
cancer_study_identifier as studyId | ||
FROM sample_clinical_attribute_numeric_view | ||
<include refid="sampleClinicalDataFromStudyViewFilter"/> | ||
</select> | ||
|
||
<!-- TODO only fetching from patient_clinical_attribute_numeric, need to support patient_clinical_attribute_categorical as well --> | ||
<select id="getPatientCountWithoutClinicalData" resultType="Long"> | ||
SELECT | ||
COUNT (DISTINCT patient_unique_id) | ||
FROM sample_mv | ||
<where> | ||
patient_unique_id IN ( | ||
<include refid="getPatientIdsFromSampleIdFilters"/> | ||
<if test="applyPatientIdFilters == true"> | ||
INTERSECT <include refid="patientUniqueIdsFromStudyViewFilter"/> | ||
</if> | ||
) | ||
AND patient_unique_id NOT IN ( | ||
SELECT | ||
patient_unique_id | ||
FROM patient_clinical_attribute_numeric_view | ||
<include refid="patientClinicalDataFromStudyViewFilter"/> | ||
) | ||
</where> | ||
</select> | ||
|
||
<select id="getPatientClinicalDataFromStudyViewFilter" resultType="org.cbioportal.model.ClinicalData"> | ||
SELECT | ||
patient_unique_id as patientId, | ||
attribute_name as attrId, | ||
attribute_value as attrValue, | ||
cancer_study_identifier as studyId | ||
FROM patient_clinical_attribute_numeric_view | ||
<include refid="patientClinicalDataFromStudyViewFilter"/> | ||
</select> | ||
</mapper> | ||
|
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