diff --git a/src/main/java/org/cbioportal/persistence/StudyViewRepository.java b/src/main/java/org/cbioportal/persistence/StudyViewRepository.java index 3888850473c..a05f09da29c 100644 --- a/src/main/java/org/cbioportal/persistence/StudyViewRepository.java +++ b/src/main/java/org/cbioportal/persistence/StudyViewRepository.java @@ -54,15 +54,15 @@ public interface StudyViewRepository { int getSampleProfileCountWithoutPanelData(StudyViewFilter studyViewFilter, String alterationType, List customDataSamples); - List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter); + List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, List customDataSamples); - List getPatientTreatments(StudyViewFilter studyViewFilter); + List getPatientTreatments(StudyViewFilter studyViewFilter, List customDataSamples); - int getTotalPatientTreatmentCount(StudyViewFilter studyViewFilter); + int getTotalPatientTreatmentCount(StudyViewFilter studyViewFilter, List customDataSamples); - List getSampleTreatments(StudyViewFilter studyViewFilter); + List getSampleTreatments(StudyViewFilter studyViewFilter, List customDataSamples); - int getTotalSampleTreatmentCount(StudyViewFilter studyViewFilter); + int getTotalSampleTreatmentCount(StudyViewFilter studyViewFilter, List customDataSamples); List getCNACounts(StudyViewFilter studyViewFilter, List genomicDataFilters); diff --git a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java index 117ce7dcf7e..e0aec7ca2c2 100644 --- a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java +++ b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java @@ -59,12 +59,12 @@ List getClinicalDataCounts(StudyViewFilter studyViewFilter, C int getSampleProfileCountWithoutPanelData(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, String alterationType, List customDataSamples); - List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters); + List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List customDataSamples); - List getPatientTreatments(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters); - int getPatientTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters); - List getSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters); - int getTotalSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters); + List getPatientTreatments(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List customDataSamples); + int getPatientTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List customDataSamples); + List getSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List customDataSamples); + int getTotalSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List customDataSamples); List getCNACounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, List genomicDataFilters); diff --git a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java index 8c327625d5c..14a923130a2 100644 --- a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java +++ b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java @@ -205,37 +205,37 @@ public int getSampleProfileCountWithoutPanelData(StudyViewFilter studyViewFilter @Override - public List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter) { + public List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, List customDataSamples) { CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter); return mapper.getClinicalEventTypeCounts(studyViewFilter, categorizedClinicalDataCountFilter, - shouldApplyPatientIdFilters(studyViewFilter,categorizedClinicalDataCountFilter)); + shouldApplyPatientIdFilters(studyViewFilter,categorizedClinicalDataCountFilter), customDataSamples); } @Override - public List getPatientTreatments(StudyViewFilter studyViewFilter) { + public List getPatientTreatments(StudyViewFilter studyViewFilter, List customDataSamples) { CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter); - return mapper.getPatientTreatments(studyViewFilter, categorizedClinicalDataCountFilter, shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter)); + return mapper.getPatientTreatments(studyViewFilter, categorizedClinicalDataCountFilter, shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter), customDataSamples); } @Override - public int getTotalPatientTreatmentCount(StudyViewFilter studyViewFilter) { + public int getTotalPatientTreatmentCount(StudyViewFilter studyViewFilter, List customDataSamples) { CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter); return mapper.getPatientTreatmentCounts(studyViewFilter, categorizedClinicalDataCountFilter, - shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter)); + shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter), customDataSamples); } @Override - public List getSampleTreatments(StudyViewFilter studyViewFilter) { + public List getSampleTreatments(StudyViewFilter studyViewFilter, List customDataSamples) { CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter); return mapper.getSampleTreatmentCounts(studyViewFilter, categorizedClinicalDataCountFilter, - shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter)); + shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter), customDataSamples); } @Override - public int getTotalSampleTreatmentCount(StudyViewFilter studyViewFilter) { + public int getTotalSampleTreatmentCount(StudyViewFilter studyViewFilter, List customDataSamples) { CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter); return mapper.getTotalSampleTreatmentCounts(studyViewFilter, categorizedClinicalDataCountFilter, - shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter)); + shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter), customDataSamples); } private void buildClinicalAttributeNameMap() { diff --git a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java index d70c3b218ae..57b6d546aa2 100644 --- a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java @@ -71,17 +71,20 @@ public List getMolecularProfileSampleCounts(StudyViewFilter st @Override public List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter) { - return studyViewRepository.getClinicalEventTypeCounts(studyViewFilter); + List customDataSamples = customDataFilterUtil.extractCustomDataSamples(studyViewFilter); + return studyViewRepository.getClinicalEventTypeCounts(studyViewFilter, customDataSamples); } @Override public PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyViewFilter) { - return treatmentCountReportService.getPatientTreatmentReport(studyViewFilter); + List customDataSamples = customDataFilterUtil.extractCustomDataSamples(studyViewFilter); + return treatmentCountReportService.getPatientTreatmentReport(studyViewFilter, customDataSamples); } @Override public SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter) { - return treatmentCountReportService.getSampleTreatmentReport(studyViewFilter); + List customDataSamples = customDataFilterUtil.extractCustomDataSamples(studyViewFilter); + return treatmentCountReportService.getSampleTreatmentReport(studyViewFilter, customDataSamples); } public List getCnaGenes(StudyViewFilter studyViewFilter) { diff --git a/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportService.java b/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportService.java index 5c275fefc26..27e3c8a210c 100644 --- a/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportService.java +++ b/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportService.java @@ -2,9 +2,12 @@ import org.cbioportal.model.PatientTreatmentReport; import org.cbioportal.model.SampleTreatmentReport; +import org.cbioportal.web.parameter.CustomSampleIdentifier; import org.cbioportal.web.parameter.StudyViewFilter; +import java.util.List; + public interface TreatmentCountReportService { - PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyViewFilter); - SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter); + PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyViewFilter, List customDataSamples); + SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter, List customDataSamples); } diff --git a/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportServiceImpl.java b/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportServiceImpl.java index 8af2139a814..0820cefdadf 100644 --- a/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportServiceImpl.java +++ b/src/main/java/org/cbioportal/service/treatment/TreatmentCountReportServiceImpl.java @@ -5,10 +5,12 @@ import org.cbioportal.model.SampleTreatmentRow; import org.cbioportal.model.TemporalRelation; import org.cbioportal.persistence.StudyViewRepository; +import org.cbioportal.web.parameter.CustomSampleIdentifier; import org.cbioportal.web.parameter.StudyViewFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Set; import java.util.stream.Stream; @@ -23,22 +25,22 @@ public TreatmentCountReportServiceImpl(StudyViewRepository studyViewRepository) } @Override - public PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyViewFilter) { - var patientTreatments = studyViewRepository.getPatientTreatments(studyViewFilter); - var totalPatientTreatmentCount = studyViewRepository.getTotalPatientTreatmentCount(studyViewFilter); + public PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyViewFilter, List customDataSamples) { + var patientTreatments = studyViewRepository.getPatientTreatments(studyViewFilter, customDataSamples); + var totalPatientTreatmentCount = studyViewRepository.getTotalPatientTreatmentCount(studyViewFilter, customDataSamples); return new PatientTreatmentReport(totalPatientTreatmentCount, 0, patientTreatments); } @Override - public SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter) { - var sampleTreatments = studyViewRepository.getSampleTreatments(studyViewFilter) + public SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter, List customDataSamples) { + var sampleTreatments = studyViewRepository.getSampleTreatments(studyViewFilter, customDataSamples) .stream() .flatMap(sampleTreatment -> Stream.of(new SampleTreatmentRow(TemporalRelation.Pre, sampleTreatment.treatment(), sampleTreatment.preSampleCount(), Set.of()), new SampleTreatmentRow(TemporalRelation.Post, sampleTreatment.treatment(), sampleTreatment.postSampleCount(), Set.of() )) ) .toList(); - var totalSampleTreatmentCount = studyViewRepository.getTotalSampleTreatmentCount(studyViewFilter); + var totalSampleTreatmentCount = studyViewRepository.getTotalSampleTreatmentCount(studyViewFilter, customDataSamples); return new SampleTreatmentReport(totalSampleTreatmentCount, sampleTreatments); } diff --git a/src/test/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapperTest.java b/src/test/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapperTest.java index 7159eb8c38b..73cea7c75c3 100644 --- a/src/test/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapperTest.java +++ b/src/test/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapperTest.java @@ -135,7 +135,7 @@ public void getClinicalEventTypeCounts() { studyViewFilter.setStudyIds(List.of(STUDY_TCGA_PUB)); var clinicalEventTypeCounts = studyViewMapper.getClinicalEventTypeCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), false); + CategorizedClinicalDataCountFilter.getBuilder().build(), false, null); assertEquals(4, clinicalEventTypeCounts.size()); @@ -152,7 +152,7 @@ public void getClinicalEventTypeCounts() { studyViewFilter.setClinicalEventFilters(List.of(dataFilter)); clinicalEventTypeCounts = studyViewMapper.getClinicalEventTypeCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), true); + CategorizedClinicalDataCountFilter.getBuilder().build(), true, null); assertEquals(3, clinicalEventTypeCounts.size()); @@ -169,10 +169,10 @@ public void getPatientTreatmentReportCounts() { var patientTreatmentCounts = studyViewMapper.getPatientTreatmentCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), false ); + CategorizedClinicalDataCountFilter.getBuilder().build(), false, null ); var patientTreatments = studyViewMapper.getPatientTreatments(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), false ); + CategorizedClinicalDataCountFilter.getBuilder().build(), false, null ); assertEquals(1, patientTreatmentCounts); assertEquals("madeupanib", patientTreatments.getFirst().treatment()); @@ -188,10 +188,10 @@ public void getPatientTreatmentReportCounts() { studyViewFilter.setPatientTreatmentFilters(andedPatientTreatmentFilters); patientTreatmentCounts = studyViewMapper.getPatientTreatmentCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), true ); + CategorizedClinicalDataCountFilter.getBuilder().build(), true, null ); patientTreatments = studyViewMapper.getPatientTreatments(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), true ); + CategorizedClinicalDataCountFilter.getBuilder().build(), true, null ); assertEquals(1, patientTreatmentCounts); assertEquals("madeupanib", patientTreatments.getFirst().treatment()); @@ -205,10 +205,10 @@ public void getSampleTreatmentCounts() { var totalSampleTreatmentCount = studyViewMapper.getTotalSampleTreatmentCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), false ); + CategorizedClinicalDataCountFilter.getBuilder().build(), false, null ); var sampleTreatmentCounts = studyViewMapper.getSampleTreatmentCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), false ); + CategorizedClinicalDataCountFilter.getBuilder().build(), false, null ); assertEquals(1, totalSampleTreatmentCount); assertEquals("madeupanib", sampleTreatmentCounts.getFirst().treatment()); @@ -227,10 +227,10 @@ public void getSampleTreatmentCounts() { studyViewFilter.setSampleTreatmentFilters(andedSampleTreatmentFilters); totalSampleTreatmentCount = studyViewMapper.getTotalSampleTreatmentCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), false ); + CategorizedClinicalDataCountFilter.getBuilder().build(), false, null ); sampleTreatmentCounts = studyViewMapper.getSampleTreatmentCounts(studyViewFilter, - CategorizedClinicalDataCountFilter.getBuilder().build(), false ); + CategorizedClinicalDataCountFilter.getBuilder().build(), false, null ); assertEquals(0, totalSampleTreatmentCount); assertEquals(0, sampleTreatmentCounts.size());