Skip to content

Commit

Permalink
use the exact same queries which have been used for the clinical data…
Browse files Browse the repository at this point in the history
… counts endpoint
  • Loading branch information
onursumer committed Jun 27, 2024
1 parent b63c104 commit f7905ff
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public interface StudyViewRepository {

List<ClinicalData> getPatientClinicalData(StudyViewFilter studyViewFilter, List<String> attributeIds);

List<ClinicalDataCount>getSampleClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds);
List<ClinicalDataCount> getSampleClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds);

List<ClinicalDataCount>getPatientClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds);
List<ClinicalDataCount> getPatientClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds);

List<AlterationCountByGene> getMutatedGenes(StudyViewFilter studyViewFilter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ List<ClinicalDataCount> getClinicalDataCounts(StudyViewFilter studyViewFilter, C

List<ClinicalData> getPatientClinicalDataFromStudyViewFilter(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<String> attributeIds);

List<ClinicalDataCount> getSampleClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<String> attributeIds);

List<ClinicalDataCount> getPatientClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<String> attributeIds);

@MapKey("hugoGeneSymbol")
Map<String, AlterationCountByGene> getTotalProfiledCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, String alterationType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,26 @@ public List<ClinicalData> getSampleClinicalData(StudyViewFilter studyViewFilter,
return mapper.getSampleClinicalDataFromStudyViewFilter(studyViewFilter, categorizedClinicalDataCountFilter, shouldApplyPatientIdFilters(categorizedClinicalDataCountFilter), attributeIds);
}

public List<ClinicalDataCount> getSampleClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds) {
public List<ClinicalDataCount> getSampleClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds) {
CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter);
return mapper.getSampleClinicalDataCountsForBinning(studyViewFilter, categorizedClinicalDataCountFilter, shouldApplyPatientIdFilters(categorizedClinicalDataCountFilter), attributeIds);
return mapper.getSampleClinicalDataCounts(
studyViewFilter,
categorizedClinicalDataCountFilter,
shouldApplyPatientIdFilters(categorizedClinicalDataCountFilter),
attributeIds,
FILTERED_CLINICAL_ATTR_VALUES
);
}

public List<ClinicalDataCount> getPatientClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds) {
public List<ClinicalDataCount> getPatientClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds) {
CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter);
return mapper.getPatientClinicalDataCountsForBinning(studyViewFilter, categorizedClinicalDataCountFilter, shouldApplyPatientIdFilters(categorizedClinicalDataCountFilter), attributeIds);
return mapper.getPatientClinicalDataCounts(
studyViewFilter,
categorizedClinicalDataCountFilter,
shouldApplyPatientIdFilters(categorizedClinicalDataCountFilter),
attributeIds,
FILTERED_CLINICAL_ATTR_VALUES
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public interface StudyViewColumnarService {

List<ClinicalData> getSampleClinicalData(StudyViewFilter studyViewFilter, List<String> attributeIds);

List<ClinicalDataCount> getSampleClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds);
List<ClinicalDataCount> getSampleClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds);

List<ClinicalDataCount> getPatientClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds);
List<ClinicalDataCount> getPatientClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds);

List<GenomicDataCount> getGenomicDataCounts(StudyViewFilter studyViewFilter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public List<ClinicalData> getSampleClinicalData(StudyViewFilter studyViewFilter,
}

@Override
public List<ClinicalDataCount> getSampleClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds) {
return studyViewRepository.getSampleClinicalDataCountsForBinning(studyViewFilter, attributeIds);
public List<ClinicalDataCount> getSampleClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds) {
return studyViewRepository.getSampleClinicalDataCounts(studyViewFilter, attributeIds);
}

@Override
public List<ClinicalDataCount> getPatientClinicalDataCountsForBinning(StudyViewFilter studyViewFilter, List<String> attributeIds) {
return studyViewRepository.getPatientClinicalDataCountsForBinning(studyViewFilter, attributeIds);
public List<ClinicalDataCount> getPatientClinicalDataCounts(StudyViewFilter studyViewFilter, List<String> attributeIds) {
return studyViewRepository.getPatientClinicalDataCounts(studyViewFilter, attributeIds);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public List<ClinicalDataBin> fetchClinicalDataBinCounts(
// we use the filtered data to calculate the counts for each bin, we do not regenerate bins for the filtered data

// TODO investigate if we can directly use studyViewColumnarService.getClinicalDataCounts instead of adding new SQL
List<ClinicalDataCount> unfilteredClinicalDataCountsForSamples = studyViewColumnarService.getSampleClinicalDataCountsForBinning(partialFilter, attributeIds);
List<ClinicalDataCount> filteredClinicalDataCountsForSamples = studyViewColumnarService.getSampleClinicalDataCountsForBinning(studyViewFilter, attributeIds);
List<ClinicalDataCount> unfilteredClinicalDataCountsForPatients = studyViewColumnarService.getPatientClinicalDataCountsForBinning(partialFilter, attributeIds);
List<ClinicalDataCount> filteredClinicalDataCountsForPatients = studyViewColumnarService.getPatientClinicalDataCountsForBinning(studyViewFilter, attributeIds);
List<ClinicalDataCount> unfilteredClinicalDataCountsForSamples = studyViewColumnarService.getSampleClinicalDataCounts(partialFilter, attributeIds);
List<ClinicalDataCount> filteredClinicalDataCountsForSamples = studyViewColumnarService.getSampleClinicalDataCounts(studyViewFilter, attributeIds);
List<ClinicalDataCount> unfilteredClinicalDataCountsForPatients = studyViewColumnarService.getPatientClinicalDataCounts(partialFilter, attributeIds);
List<ClinicalDataCount> filteredClinicalDataCountsForPatients = studyViewColumnarService.getPatientClinicalDataCounts(studyViewFilter, attributeIds);

List<ClinicalData> unfilteredClinicalDataForSamples = convertCountsToData(unfilteredClinicalDataCountsForSamples);
List<ClinicalData> filteredClinicalDataForSamples = convertCountsToData(filteredClinicalDataCountsForSamples);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,6 @@
</foreach>
</if>
</sql>

<select id="getPatientClinicalDataCountsForBinning">
SELECT
attribute_name as attributeId,
<include refid="normalizeAttributeValueNA">
<property name="attribute_value" value="attribute_value"/>
<property name="as_value" value="value"/>
</include>,
count(value) as count
FROM clinical_data_derived
<include refid="patientClinicalDataFromStudyViewFilter" />
AND type = 'patient'
GROUP BY attribute_name, value
</select>

<select id="getSampleClinicalDataCountsForBinning">
SELECT
attribute_name as attributeId,
<include refid="normalizeAttributeValueNA">
<property name="attribute_value" value="attribute_value"/>
<property name="as_value" value="value"/>
</include>,
count(value) as count
FROM clinical_data_derived
<include refid="sampleClinicalDataFromStudyViewFilter" />
AND type = 'sample'
GROUP BY attribute_name, value
</select>

<select id="getSampleClinicalDataFromStudyViewFilter" resultType="org.cbioportal.model.ClinicalData">
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,18 @@

<!-- for /clinical-data-counts/fetch (returns ClinicalData) which will then be converted to clinicalDataCountItems -->
<select id="getClinicalDataCounts" resultType="org.cbioportal.model.ClinicalDataCount">
<include refid="getCategoricalClinicalDataCountsQuerySample" />
<include refid="getClinicalDataCountsQuerySample" />
UNION ALL
<include refid="getCategoricalClinicalDataCountsQueryPatient" />
<include refid="getClinicalDataCountsQueryPatient" />
</select>

<select id="getPatientClinicalDataCounts" resultType="org.cbioportal.model.ClinicalDataCount">
<include refid="getClinicalDataCountsQueryPatient" />
</select>

<select id="getSampleClinicalDataCounts" resultType="org.cbioportal.model.ClinicalDataCount">
<include refid="getClinicalDataCountsQuerySample" />
</select>

<!-- for /molecular-profile-sample-counts/fetch (returns GenomicDataCount) which will then be converted to clinicalDataCountItems -->
<select id="getGenomicDataCounts" resultType="org.cbioportal.model.GenomicDataCount">
Expand Down Expand Up @@ -115,7 +122,7 @@
</select>


<sql id="getCategoricalClinicalDataCountsQuerySample">
<sql id="getClinicalDataCountsQuerySample">
SELECT
attribute_name as attributeId,
<include refid="normalizeAttributeValueNA">
Expand Down Expand Up @@ -148,7 +155,7 @@
value
</sql>

<sql id="getCategoricalClinicalDataCountsQueryPatient">
<sql id="getClinicalDataCountsQueryPatient">
SELECT
attribute_name as attributeId,
<include refid="normalizeAttributeValueNA">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public SqlSessionFactoryBean sqlColumnarSessionFactory(ResourceLoader resourceLo
var studyViewMapperResource = resourceLoader.getResource("classpath:org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml") ;
var studyViewFilterMapperResource = resourceLoader.getResource("classpath:org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml");
var alterationFilterMapperResource = resourceLoader.getResource("classpath:org/cbioportal/persistence/mybatisclickhouse/StudyViewAlterationFilterMapper.xml");
var clinicalDataBinMapperResource = resourceLoader.getResource("classpath:org/cbioportal/persistence/mybatisclickhouse/StudyViewAlterationFilterMapper.xml");
var clinicalDataMapperResource = resourceLoader.getResource("classpath:org/cbioportal/persistence/mybatisclickhouse/StudyViewClinicalDataMapper.xml");
sessionFactory.setMapperLocations(
studyViewMapperResource,studyViewFilterMapperResource, alterationFilterMapperResource, clinicalDataBinMapperResource
studyViewMapperResource,studyViewFilterMapperResource, alterationFilterMapperResource, clinicalDataMapperResource
);
return sessionFactory;
}
Expand Down

0 comments on commit f7905ff

Please sign in to comment.