Skip to content

Commit

Permalink
Fix case list filtering/counting
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed Jun 20, 2024
1 parent 2b5547a commit adec9e2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package org.cbioportal.persistence.mybatisclickhouse;

import org.apache.ibatis.annotations.MapKey;
import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.CaseListDataCount;
import org.cbioportal.model.ClinicalData;
import org.cbioportal.model.ClinicalDataCount;
import org.cbioportal.model.GenomicDataCount;
import org.cbioportal.model.Sample;
import org.cbioportal.persistence.helper.AlterationFilterHelper;
import org.cbioportal.web.parameter.CategorizedClinicalDataCountFilter;
import org.cbioportal.web.parameter.StudyViewFilter;

import java.util.List;
import java.util.Map;


public interface StudyViewMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.cbioportal.persistence.mybatisclickhouse;
import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.CaseListDataCount;
import org.cbioportal.model.ClinicalData;
import org.cbioportal.model.ClinicalDataCount;
import org.cbioportal.model.GenomicDataCount;
import org.cbioportal.model.Sample;
import org.cbioportal.persistence.StudyViewRepository;
import org.cbioportal.persistence.enums.ClinicalAttributeDataSource;
import org.cbioportal.persistence.enums.ClinicalAttributeDataType;
import org.cbioportal.persistence.helper.AlterationFilterHelper;
import org.cbioportal.web.parameter.CategorizedClinicalDataCountFilter;
import org.cbioportal.web.parameter.StudyViewFilter;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.cbioportal.web.parameter.*;
import org.cbioportal.web.util.DataBinner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.*;
Expand All @@ -26,6 +27,9 @@ public ClinicalDataBinner(
this.dataBinner = dataBinner;
}

@Cacheable(
cacheResolver = "staticRepositoryCacheOneResolver"
)
public List<ClinicalDataBin> fetchClinicalDataBinCounts(
DataBinMethod dataBinMethod,
ClinicalDataBinCountFilter dataBinCountFilter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.validation.Valid;
import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.AlterationFilter;
import org.cbioportal.model.CaseListDataCount;
import org.cbioportal.model.ClinicalData;
import org.cbioportal.model.ClinicalDataBin;
import org.cbioportal.model.ClinicalDataCountItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@
<!-- filter for samples which belong to the sample lists (aka case lists) selected by the user and appearing in the studyViewFilter.caseLists collection -->
<if test="studyViewFilter.caseLists != null and !studyViewFilter.caseLists.isEmpty()">
INTERSECT
SELECT sample_unique_id
FROM sample_list_list sll
LEFT JOIN sample_view sv ON sll.sample_id=sv.internal_id
LEFT JOIN sample_list sl on sll.list_id=sl.list_id
<!-- a sample is in a sample list if the sampleListId is part of the sample's list stable id (stable_id) -->
<where>
<foreach item="sampleLists" collection="studyViewFilter.caseLists" separator="INTERSECT">
<foreach item="sampleListId" collection="sampleLists" open="(" separator="OR" close=")">
stable_id LIKE '%_${sampleListId}'
SELECT * FROM (
<foreach item="listGroup" collection="studyViewFilter.caseLists" separator="INTERSECT">
SELECT sample_unique_id
FROM sample_list_list sll
LEFT JOIN sample_mv s ON sll.sample_id=s.internal_id
LEFT JOIN sample_list sl on sll.list_id=sl.list_id
WHERE
<foreach item="list" collection="listGroup" separator="OR">
sl.stable_id LIKE '%_${list}'
</foreach>
</foreach>
</where>
)
</if>



<if test="studyViewFilter.genomicProfiles != null and !studyViewFilter.genomicProfiles.isEmpty()">
INTERSECT
SELECT * FROM (
Expand All @@ -50,7 +49,6 @@
gp.stable_id LIKE '%_${genomicProfileId}'
</foreach>
</where>

</foreach>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@
REPLACE(stable_id, CONCAT(cancer_study_identifier, '_'), '') AS value,
count(sample_id) AS count
FROM sample_list_list sll
LEFT JOIN sample_view sv ON sll.sample_id=sv.internal_id
LEFT JOIN sample_list sl on sll.list_id=sl.list_id
LEFT JOIN sample_mv s ON sll.sample_id=s.internal_id
LEFT JOIN sample_list sl on sll.list_id=sl.list_id
<where>
sample_unique_id IN ( <include refid="sampleUniqueIdsFromStudyViewFilter"/>)
</where>
GROUP BY cancer_study_identifier, stable_id, name;
GROUP BY s.cancer_study_identifier, sl.stable_id, sl.name;
</select>

<sql id="getCategoricalClinicalDataCountsQuery">
Expand Down

0 comments on commit adec9e2

Please sign in to comment.