Skip to content

Commit

Permalink
add customDataSamples parameter for treatment and event methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Lai authored and haynescd committed Aug 14, 2024
1 parent d46400f commit fb3da66
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public interface StudyViewRepository {

int getSampleProfileCountWithoutPanelData(StudyViewFilter studyViewFilter, String alterationType, List<CustomSampleIdentifier> customDataSamples);

List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilter studyViewFilter);
List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> customDataSamples);

List<PatientTreatment> getPatientTreatments(StudyViewFilter studyViewFilter);
List<PatientTreatment> getPatientTreatments(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> customDataSamples);

int getTotalPatientTreatmentCount(StudyViewFilter studyViewFilter);
int getTotalPatientTreatmentCount(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> customDataSamples);

List<SampleTreatment> getSampleTreatments(StudyViewFilter studyViewFilter);
List<SampleTreatment> getSampleTreatments(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> customDataSamples);

int getTotalSampleTreatmentCount(StudyViewFilter studyViewFilter);
int getTotalSampleTreatmentCount(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> customDataSamples);

List<GenomicDataCountItem> getCNACounts(StudyViewFilter studyViewFilter, List<GenomicDataFilter> genomicDataFilters);

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

int getSampleProfileCountWithoutPanelData(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, String alterationType, List<CustomSampleIdentifier> customDataSamples);

List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters);
List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<CustomSampleIdentifier> customDataSamples);

List<PatientTreatment> getPatientTreatments(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters);
int getPatientTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters);
List<SampleTreatment> getSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters);
int getTotalSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters);
List<PatientTreatment> getPatientTreatments(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<CustomSampleIdentifier> customDataSamples);
int getPatientTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<CustomSampleIdentifier> customDataSamples);
List<SampleTreatment> getSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<CustomSampleIdentifier> customDataSamples);
int getTotalSampleTreatmentCounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, boolean applyPatientIdFilters, List<CustomSampleIdentifier> customDataSamples);

List<GenomicDataCountItem> getCNACounts(StudyViewFilter studyViewFilter, CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter, List<GenomicDataFilter> genomicDataFilters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,37 +205,37 @@ public int getSampleProfileCountWithoutPanelData(StudyViewFilter studyViewFilter


@Override
public List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilter studyViewFilter) {
public List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> customDataSamples) {
CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter);
return mapper.getClinicalEventTypeCounts(studyViewFilter, categorizedClinicalDataCountFilter,
shouldApplyPatientIdFilters(studyViewFilter,categorizedClinicalDataCountFilter));
shouldApplyPatientIdFilters(studyViewFilter,categorizedClinicalDataCountFilter), customDataSamples);
}

@Override
public List<PatientTreatment> getPatientTreatments(StudyViewFilter studyViewFilter) {
public List<PatientTreatment> getPatientTreatments(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> 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<CustomSampleIdentifier> customDataSamples) {
CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter);
return mapper.getPatientTreatmentCounts(studyViewFilter, categorizedClinicalDataCountFilter,
shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter));
shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter), customDataSamples);
}

@Override
public List<SampleTreatment> getSampleTreatments(StudyViewFilter studyViewFilter) {
public List<SampleTreatment> getSampleTreatments(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> 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<CustomSampleIdentifier> customDataSamples) {
CategorizedClinicalDataCountFilter categorizedClinicalDataCountFilter = extractClinicalDataCountFilters(studyViewFilter);
return mapper.getTotalSampleTreatmentCounts(studyViewFilter, categorizedClinicalDataCountFilter,
shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter));
shouldApplyPatientIdFilters(studyViewFilter, categorizedClinicalDataCountFilter), customDataSamples);
}

private void buildClinicalAttributeNameMap() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ public List<GenomicDataCount> getMolecularProfileSampleCounts(StudyViewFilter st

@Override
public List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilter studyViewFilter) {
return studyViewRepository.getClinicalEventTypeCounts(studyViewFilter);
List<CustomSampleIdentifier> customDataSamples = customDataFilterUtil.extractCustomDataSamples(studyViewFilter);
return studyViewRepository.getClinicalEventTypeCounts(studyViewFilter, customDataSamples);
}

@Override
public PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyViewFilter) {
return treatmentCountReportService.getPatientTreatmentReport(studyViewFilter);
List<CustomSampleIdentifier> customDataSamples = customDataFilterUtil.extractCustomDataSamples(studyViewFilter);
return treatmentCountReportService.getPatientTreatmentReport(studyViewFilter, customDataSamples);
}

@Override
public SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter) {
return treatmentCountReportService.getSampleTreatmentReport(studyViewFilter);
List<CustomSampleIdentifier> customDataSamples = customDataFilterUtil.extractCustomDataSamples(studyViewFilter);
return treatmentCountReportService.getSampleTreatmentReport(studyViewFilter, customDataSamples);
}

public List<CopyNumberCountByGene> getCnaGenes(StudyViewFilter studyViewFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CustomSampleIdentifier> customDataSamples);
SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter, List<CustomSampleIdentifier> customDataSamples);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<CustomSampleIdentifier> 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<CustomSampleIdentifier> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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());

Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand Down

0 comments on commit fb3da66

Please sign in to comment.