diff --git a/.gitignore b/.gitignore index 4dda110d9ac..c2b81971328 100644 --- a/.gitignore +++ b/.gitignore @@ -73,7 +73,7 @@ portal/src/main/webapp/WEB-INF/logback.xml !src/main/resource/*.EXAMPLE firehose-importer/reference_data/gene_info portal.properties -application.properties +src/main/resources/application.properties importer.properties log4j.properties build.properties @@ -103,7 +103,6 @@ package.json *.tramp_history pom.version.* pom.xml.* -pom.xml.* Dockerfile.local .factorypath .retype diff --git a/src/main/java/org/cbioportal/service/impl/MolecularProfileServiceImpl.java b/src/main/java/org/cbioportal/service/impl/MolecularProfileServiceImpl.java index 9d46158a2e2..3a4d6c8a1d7 100644 --- a/src/main/java/org/cbioportal/service/impl/MolecularProfileServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/MolecularProfileServiceImpl.java @@ -9,14 +9,17 @@ import org.cbioportal.service.exception.MolecularProfileNotFoundException; import org.cbioportal.service.exception.StudyNotFoundException; import org.cbioportal.service.util.MolecularProfileUtil; +import org.cbioportal.web.parameter.Projection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PostFilter; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Set; import java.util.function.Predicate; -import java.util.stream.Collectors; @Service public class MolecularProfileServiceImpl implements MolecularProfileService { @@ -145,13 +148,13 @@ public List getFirstStructuralVariantProfileCase private List getFirstFilteredMolecularProfileCaseIdentifiers(List studyIds, List sampleIds, Optional> profileFilter) { List molecularProfiles = - getMolecularProfilesInStudies(studyIds.stream().distinct().collect(Collectors.toList()), "SUMMARY"); + getMolecularProfilesInStudies(studyIds.stream().distinct().toList(), Projection.SUMMARY.name()); return molecularProfileUtil.getFirstFilteredMolecularProfileCaseIdentifiers(molecularProfiles, studyIds, sampleIds, profileFilter); } private List getFilteredMolecularProfileCaseIdentifiers(List studyIds, List sampleIds, Optional> profileFilter) { List molecularProfiles = - getMolecularProfilesInStudies(studyIds.stream().distinct().collect(Collectors.toList()), "SUMMARY"); + getMolecularProfilesInStudies(studyIds.stream().distinct().toList(), Projection.SUMMARY.name()); return molecularProfileUtil.getFilteredMolecularProfileCaseIdentifiers(molecularProfiles, studyIds, sampleIds, profileFilter); } } diff --git a/src/main/java/org/cbioportal/service/impl/StudyViewServiceImpl.java b/src/main/java/org/cbioportal/service/impl/StudyViewServiceImpl.java index dbcb40e8993..e3fdd9a27b2 100644 --- a/src/main/java/org/cbioportal/service/impl/StudyViewServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/StudyViewServiceImpl.java @@ -10,6 +10,8 @@ import org.cbioportal.service.exception.MolecularProfileNotFoundException; import org.cbioportal.service.exception.StudyNotFoundException; import org.cbioportal.service.util.MolecularProfileUtil; +import org.cbioportal.web.parameter.GeneIdType; +import org.cbioportal.web.parameter.Projection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -41,20 +43,20 @@ public class StudyViewServiceImpl implements StudyViewService { @Autowired private GeneService geneService; - - @Autowired + + @Autowired private MolecularDataService molecularDataService; - + @Autowired private MutationService mutationService; - + @Override public List getGenomicDataCounts(List studyIds, List sampleIds) { List molecularProfileSampleIdentifiers = molecularProfileService.getMolecularProfileCaseIdentifiers(studyIds, sampleIds); List molecularProfiles = molecularProfileService - .getMolecularProfilesInStudies(new ArrayList<>(new HashSet<>(studyIds)),"SUMMARY"); + .getMolecularProfilesInStudies(new ArrayList<>(new HashSet<>(studyIds)), Projection.SUMMARY.name()); Map molecularProfileMap = molecularProfiles .stream() .collect(Collectors.toMap(MolecularProfile::getStableId, Function.identity())); @@ -66,8 +68,8 @@ public List getGenomicDataCounts(List studyIds, List entry.getKey(), entry -> (int)entry.getValue().stream().map(d -> molecularProfileMap.get(entry.getKey()).getPatientLevel() ? d.getPatientId() : d.getSampleId()).distinct().count())); - + .collect(Collectors.toMap(entry -> entry.getKey(), entry -> (int) entry.getValue().stream().map(d -> molecularProfileMap.get(entry.getKey()).getPatientLevel() ? d.getPatientId() : d.getSampleId()).distinct().count())); + return molecularProfileUtil .categorizeMolecularProfilesByStableIdSuffixes(molecularProfiles) .entrySet() @@ -87,7 +89,7 @@ public List getGenomicDataCounts(List studyIds, List dataCount.getCount() > 0) - .collect(Collectors.toList()); + .toList(); } @Override @@ -119,11 +121,11 @@ public List getMutationCountsByGeneSpecific(List s .collect(Collectors.toSet()); List entrezGeneIds = geneService - .fetchGenes(new ArrayList<>(hugoGeneSymbols), "HUGO_GENE_SYMBOL", - "SUMMARY") + .fetchGenes(new ArrayList<>(hugoGeneSymbols), GeneIdType.HUGO_GENE_SYMBOL.name(), + Projection.SUMMARY.name()) .stream() .map(Gene::getEntrezGeneId) - .collect(Collectors.toList()); + .toList(); List alterationCountByGenes = alterationCountService.getSampleMutationGeneCounts( caseIdentifiers, @@ -155,7 +157,7 @@ public List getMutationCountsByGeneSpecific(List s int totalCount = sampleIds.size(); List genomicDataCounts = new ArrayList<>(); - + GenomicDataCount genomicDataCountMutated = new GenomicDataCount(); genomicDataCountMutated.setLabel(MutationFilterOption.MUTATED.getMutationFilterOption()); genomicDataCountMutated.setValue(MutationFilterOption.MUTATED.name()); @@ -180,8 +182,7 @@ public List getMutationCountsByGeneSpecific(List s genomicDataCountItem.setCounts(genomicDataCounts); return Stream.of(genomicDataCountItem); - }) - .collect(Collectors.toList()); + }).toList(); } @Override @@ -192,10 +193,10 @@ public List getMutationTypeCountsByGeneSpecific(List geneSymbolIdMap = geneService - .fetchGenes(new ArrayList<>(hugoGeneSymbols), "HUGO_GENE_SYMBOL", - "SUMMARY") + .fetchGenes(new ArrayList<>(hugoGeneSymbols), GeneIdType.HUGO_GENE_SYMBOL.name(), + Projection.SUMMARY.name()) .stream().collect(Collectors.toMap(Gene::getHugoGeneSymbol, Gene::getEntrezGeneId)); - + return genomicDataFilters .stream() .flatMap(gdFilter -> { @@ -203,7 +204,7 @@ public List getMutationTypeCountsByGeneSpecific(List stableIds = Collections.singletonList(geneSymbolIdMap.get(hugoGeneSymbol)); - + Pair, List> sampleAndProfileIds = getMappedSampleAndProfileIds(studyIds, sampleIds, profileType); List mappedSampleIds = sampleAndProfileIds.getFirst(); List mappedProfileIds = sampleAndProfileIds.getSecond(); @@ -211,17 +212,16 @@ public List getMutationTypeCountsByGeneSpecific(List studyIds, List mutSigMap = significantlyMutatedGeneService.getSignificantlyMutatedGenes( - studyIds.get(0), - "SUMMARY", - null, - null, - null, - null) + studyIds.get(0), + Projection.SUMMARY.name(), + null, + null, + null, + null) .stream() .collect(Collectors.toMap(MutSig::getEntrezGeneId, Function.identity())); alterationCountByGenes.forEach(r -> { @@ -282,7 +282,7 @@ public List getCNAAlterationCountByGenes(List stu throws StudyNotFoundException { List caseIdentifiers = molecularProfileService.getFirstDiscreteCNAProfileCaseIdentifiers(studyIds, sampleIds); - + List copyNumberCountByGenes = alterationCountService.getSampleCnaGeneCounts( caseIdentifiers, Select.all(), @@ -293,7 +293,7 @@ public List getCNAAlterationCountByGenes(List stu if (distinctStudyIds.size() == 1 && !copyNumberCountByGenes.isEmpty()) { List gisticList = significantCopyNumberRegionService.getSignificantCopyNumberRegions( studyIds.get(0), - "SUMMARY", + Projection.SUMMARY.name(), null, null, null, @@ -315,17 +315,17 @@ public List getCNAAlterationCountByGenes(List stu } @Override - public List getCNAAlterationCountsByGeneSpecific(List studyIds, + public List getCNAAlterationCountsByGeneSpecific(List studyIds, List sampleIds, List> genomicDataFilters) { Set hugoGeneSymbols = genomicDataFilters.stream().map(Pair::getKey) .collect(Collectors.toSet()); Map geneSymbolIdMap = geneService - .fetchGenes(new ArrayList<>(hugoGeneSymbols), "HUGO_GENE_SYMBOL", - "SUMMARY") + .fetchGenes(new ArrayList<>(hugoGeneSymbols), GeneIdType.HUGO_GENE_SYMBOL.name(), + Projection.SUMMARY.name()) .stream().collect(Collectors.toMap(Gene::getHugoGeneSymbol, Gene::getEntrezGeneId)); - + return genomicDataFilters .stream() .flatMap(gdFilter -> { @@ -334,7 +334,7 @@ public List getCNAAlterationCountsByGeneSpecific(List stableIds = Arrays.asList(geneSymbolIdMap.get(hugoGeneSymbol).toString()); Pair, List> sampleAndProfileIds = getMappedSampleAndProfileIds(studyIds, sampleIds, profileType); @@ -346,8 +346,8 @@ public List getCNAAlterationCountsByGeneSpecific(List geneMolecularDataList = molecularDataService.getMolecularDataInMultipleMolecularProfiles(mappedProfileIds, mappedSampleIds, - stableIds.stream().map(Integer::parseInt).collect(Collectors.toList()), "SUMMARY"); - + stableIds.stream().map(Integer::parseInt).toList(), Projection.SUMMARY.name()); + List genomicDataCounts = geneMolecularDataList .stream() .filter(g -> StringUtils.isNotEmpty(g.getValue()) && !g.getValue().equals("NA")) @@ -367,11 +367,11 @@ public List getCNAAlterationCountsByGeneSpecific(List 0) { GenomicDataCount genomicDataCount = new GenomicDataCount(); genomicDataCount.setLabel("NA"); @@ -379,15 +379,17 @@ public List getCNAAlterationCountsByGeneSpecific(List fetchGenericAssayDataCounts(List sampleIds, List studyIds, - List stableIds, List profileTypes) { + List stableIds, List profileTypes) { if (stableIds.isEmpty()) { return new ArrayList<>(); } @@ -398,12 +400,12 @@ public List fetchGenericAssayDataCounts(List List mappedProfileIds = sampleAndProfileIds.getSecond(); try { - return genericAssayService.fetchGenericAssayData(mappedProfileIds, mappedSampleIds, stableIds, "SUMMARY").stream(); + return genericAssayService.fetchGenericAssayData(mappedProfileIds, mappedSampleIds, stableIds, Projection.SUMMARY.name()).stream(); } catch (MolecularProfileNotFoundException e) { return new ArrayList().stream(); } - }).collect(Collectors.toList()); - + }).toList(); + return data .stream() .filter(g -> StringUtils.isNotEmpty(g.getValue()) && !g.getValue().equals("NA")) @@ -422,10 +424,9 @@ public List fetchGenericAssayDataCounts(List GenericAssayDataCount dataCount = new GenericAssayDataCount(); dataCount.setValue(datum.getKey()); dataCount.setCount(datum.getValue().size()); - return dataCount; - }) - .collect(Collectors.toList()); - + return dataCount; + }).toList(); + if (naCount > 0) { GenericAssayDataCount dataCount = new GenericAssayDataCount(); dataCount.setValue("NA"); @@ -437,14 +438,12 @@ public List fetchGenericAssayDataCounts(List genericAssayDataCountItem.setStableId(entry.getKey()); genericAssayDataCountItem.setCounts(counts); return genericAssayDataCountItem; - }) - .collect(Collectors.toList()); + }).toList(); } - + private Pair, List> getMappedSampleAndProfileIds(List studyIds, List sampleIds, String profileType) { - // Get data from fetchGenericAssayData service List molecularProfiles = molecularProfileService.getMolecularProfilesInStudies(studyIds, - "SUMMARY"); + Projection.SUMMARY.name()); Map> molecularProfileMap = molecularProfileUtil .categorizeMolecularProfilesByStableIdSuffixes(molecularProfiles); @@ -464,7 +463,7 @@ private Pair, List> getMappedSampleAndProfileIds(List(mappedSampleIds, mappedProfileIds); } } diff --git a/src/main/java/org/cbioportal/web/StudyViewController.java b/src/main/java/org/cbioportal/web/StudyViewController.java index d5f1399f579..2a690620593 100644 --- a/src/main/java/org/cbioportal/web/StudyViewController.java +++ b/src/main/java/org/cbioportal/web/StudyViewController.java @@ -517,8 +517,8 @@ public ResponseEntity fetchClinicalDataDensityPlot( if (CollectionUtils.isNotEmpty(patientAttributeIds)) { List samples = sampleService.fetchSamples(studyIds, sampleIds, Projection.DETAILED.name()); List patients = patientService.getPatientsOfSamples(studyIds, sampleIds); - patientIds = patients.stream().map(Patient::getStableId).collect(Collectors.toList()); - studyIdsOfPatients = patients.stream().map(Patient::getCancerStudyIdentifier).collect(Collectors.toList()); + patientIds = patients.stream().map(Patient::getStableId).toList(); + studyIdsOfPatients = patients.stream().map(Patient::getCancerStudyIdentifier).toList(); patientToSamples = samples.stream().collect( Collectors.groupingBy(Sample::getPatientStableId, Collectors.groupingBy(Sample::getCancerStudyIdentifier)) ); @@ -750,8 +750,8 @@ public ResponseEntity fetchClinicalDataViolinPlots( if (CollectionUtils.isNotEmpty(patientAttributeIds)) { List samplesWithoutNumericalFilter = sampleService.fetchSamples(studyIdsWithoutNumericalFilter, sampleIdsWithoutNumericalFilter, Projection.DETAILED.name()); List patients = patientService.getPatientsOfSamples(studyIdsWithoutNumericalFilter, sampleIdsWithoutNumericalFilter); - patientIds = patients.stream().map(Patient::getStableId).collect(Collectors.toList()); - studyIdsOfPatients = patients.stream().map(Patient::getCancerStudyIdentifier).collect(Collectors.toList()); + patientIds = patients.stream().map(Patient::getStableId).toList(); + studyIdsOfPatients = patients.stream().map(Patient::getCancerStudyIdentifier).toList(); patientToSamples = samplesWithoutNumericalFilter.stream().collect( Collectors.groupingBy(Sample::getPatientStableId, Collectors.groupingBy(Sample::getCancerStudyIdentifier)) ); @@ -865,7 +865,7 @@ public List fetchCaseListCounts( return dataCount; }) .filter(dataCount -> dataCount.getCount() > 0) - .collect(Collectors.toList()); + .toList(); } @@ -962,7 +962,7 @@ public ResponseEntity> fetchGenericAssayDataCoun List result = studyViewService.fetchGenericAssayDataCounts( sampleIds, studyIds, - gaFilters.stream().map(GenericAssayDataFilter::getStableId).collect(Collectors.toList()), + gaFilters.stream().map(GenericAssayDataFilter::getStableId).toList(), gaFilters.stream().map(GenericAssayDataFilter::getProfileType).collect(Collectors.toList())); return new ResponseEntity<>(result, HttpStatus.OK); @@ -1053,9 +1053,9 @@ public ResponseEntity fetchClinicalDataClinicalTable( final List> patientIdentifiers = sampleClinicalData.stream() .map(d -> new ImmutablePair<>(d.getStudyId(), d.getPatientId())) .distinct() - .collect(Collectors.toList()); - List patientStudyIds = patientIdentifiers.stream().map(p -> p.getLeft()).collect(Collectors.toList()); - List patientIds = patientIdentifiers.stream().map(p -> p.getRight()).collect(Collectors.toList()); + .toList(); + List patientStudyIds = patientIdentifiers.stream().map(p -> p.getLeft()).toList(); + List patientIds = patientIdentifiers.stream().map(p -> p.getRight()).toList(); List searchAllAttributes = null; @@ -1154,13 +1154,13 @@ public ResponseEntity> fetchMutationDataCounts( studyViewService.getMutationCountsByGeneSpecific( studyIds, sampleIds, - gdFilters.stream().map(gdFilter -> new Pair<>(gdFilter.getHugoGeneSymbol(), gdFilter.getProfileType())).collect(Collectors.toList()), + gdFilters.stream().map(gdFilter -> new Pair<>(gdFilter.getHugoGeneSymbol(), gdFilter.getProfileType())).toList(), studyViewFilter.getAlterationFilter() ) : studyViewService.getMutationTypeCountsByGeneSpecific( studyIds, sampleIds, - gdFilters.stream().map(gdFilter -> new Pair<>(gdFilter.getHugoGeneSymbol(), gdFilter.getProfileType())).collect(Collectors.toList()) + gdFilters.stream().map(gdFilter -> new Pair<>(gdFilter.getHugoGeneSymbol(), gdFilter.getProfileType())).toList() ); return new ResponseEntity<>(result, HttpStatus.OK); diff --git a/src/main/java/org/cbioportal/web/parameter/MutationDataFilter.java b/src/main/java/org/cbioportal/web/parameter/MutationDataFilter.java index 7ab935cef2b..216d409355b 100644 --- a/src/main/java/org/cbioportal/web/parameter/MutationDataFilter.java +++ b/src/main/java/org/cbioportal/web/parameter/MutationDataFilter.java @@ -4,13 +4,15 @@ import com.fasterxml.jackson.annotation.JsonInclude; import jakarta.validation.constraints.NotNull; + +import java.io.Serializable; import java.util.List; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(NON_NULL) -public class MutationDataFilter { +public class MutationDataFilter implements Serializable { private String hugoGeneSymbol; private String profileType; @NotNull diff --git a/src/main/java/org/cbioportal/web/util/ClinicalDataEqualityFilterApplier.java b/src/main/java/org/cbioportal/web/util/ClinicalDataEqualityFilterApplier.java index 82e4617051e..c197185ab95 100644 --- a/src/main/java/org/cbioportal/web/util/ClinicalDataEqualityFilterApplier.java +++ b/src/main/java/org/cbioportal/web/util/ClinicalDataEqualityFilterApplier.java @@ -33,7 +33,7 @@ public Integer apply(List attributes, return studyViewFilterUtil.getFilteredCountByDataEquality(attributes, clinicalDataMap, entityId, studyId, negateFilters); } - public static MultiKeyMap buildClinicalDataMap(List clinicalDatas) { + public static MultiKeyMap> buildClinicalDataMap(List clinicalDatas) { MultiKeyMap> clinicalDataMap = new MultiKeyMap<>(); clinicalDatas.forEach(clinicalData -> { diff --git a/src/main/java/org/cbioportal/web/util/ClinicalDataIntervalFilterApplier.java b/src/main/java/org/cbioportal/web/util/ClinicalDataIntervalFilterApplier.java index 49ad14f5808..2849974507a 100644 --- a/src/main/java/org/cbioportal/web/util/ClinicalDataIntervalFilterApplier.java +++ b/src/main/java/org/cbioportal/web/util/ClinicalDataIntervalFilterApplier.java @@ -1,10 +1,6 @@ package org.cbioportal.web.util; -import java.math.BigDecimal; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - +import com.google.common.collect.Range; import org.apache.commons.collections4.map.MultiKeyMap; import org.cbioportal.model.ClinicalData; import org.cbioportal.service.ClinicalDataService; @@ -14,7 +10,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.google.common.collect.Range; +import java.math.BigDecimal; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; @Component public class ClinicalDataIntervalFilterApplier extends ClinicalDataFilterApplier { @@ -134,14 +133,14 @@ private Boolean containsNA(ClinicalDataFilter filter) { return filter.getValues().stream().anyMatch( r -> r.getValue() != null && r.getValue().toUpperCase().equals("NA")); } - - public static MultiKeyMap buildClinicalDataMap(List clinicalDatas) { - MultiKeyMap clinicalDataMap = new MultiKeyMap(); - clinicalDatas.forEach(clinicalData -> { + public static MultiKeyMap buildClinicalDataMap(List clinicalDatas) { + MultiKeyMap clinicalDataMap = new MultiKeyMap<>(); + + clinicalDatas.forEach(clinicalData -> clinicalDataMap.put(clinicalData.getStudyId(), clinicalData.getSampleId(), clinicalData.getAttrId(), - clinicalData.getAttrValue()); - }); + clinicalData.getAttrValue()) + ); return clinicalDataMap; } diff --git a/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java b/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java index 5c484f2883e..51e72dd959b 100644 --- a/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java +++ b/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java @@ -1,24 +1,25 @@ package org.cbioportal.web.util; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.map.MultiKeyMap; -import org.cbioportal.model.*; import org.cbioportal.model.GeneFilter; +import org.cbioportal.model.*; import org.cbioportal.model.MolecularProfile.MolecularAlterationType; import org.cbioportal.service.*; import org.cbioportal.service.exception.MolecularProfileNotFoundException; import org.cbioportal.service.util.MolecularProfileUtil; import org.cbioportal.web.parameter.*; -import org.cbioportal.web.util.appliers.*; +import org.cbioportal.web.util.appliers.StudyViewSubFilterApplier; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + @Component public class StudyViewFilterApplier { @Autowired @@ -96,14 +97,14 @@ public List apply(StudyViewFilter studyViewFilter, Boolean neg List sampleIds = new ArrayList<>(); studyViewFilterUtil.extractStudyAndSampleIds(studyViewFilter.getSampleIdentifiers(), studyIds, sampleIds); sampleIdentifiers = sampleService.fetchSamples(studyIds, sampleIds, Projection.ID.name()).stream() - .map(sampleToSampleIdentifier).collect(Collectors.toList()); + .map(sampleToSampleIdentifier).toList(); } else { sampleIdentifiers = sampleService.getAllSamplesInStudies(studyViewFilter.getStudyIds(), Projection.ID.name(), - null, null, null, null).stream().map(sampleToSampleIdentifier).collect(Collectors.toList()); + null, null, null, null).stream().map(sampleToSampleIdentifier).toList(); } List studyIds = sampleIdentifiers.stream().map(SampleIdentifier::getStudyId).distinct() - .collect(Collectors.toList()); + .toList(); List clinicalDataEqualityFilters = new ArrayList<>(); List clinicalDataIntervalFilters = new ArrayList<>(); @@ -112,7 +113,7 @@ public List apply(StudyViewFilter studyViewFilter, Boolean neg if (!CollectionUtils.isEmpty(clinicalDataFilters)) { List attributeIds = clinicalDataFilters.stream().map(ClinicalDataFilter::getAttributeId) - .collect(Collectors.toList()); + .toList(); List clinicalAttributes = clinicalAttributeService .getClinicalAttributesByStudyIdsAndAttributeIds(studyIds, attributeIds); @@ -280,7 +281,7 @@ public List apply(StudyViewFilter studyViewFilter, Boolean neg sampleList.getCancerStudyIdentifier(), sampleId)); })) - .collect(Collectors.toList()); + .toList(); sampleIdentifiers.retainAll(filteredSampleIdentifiers); } @@ -349,7 +350,7 @@ private List filterMutatedGenes(List mutatedGenefi .getMolecularProfileIds() .stream() .map(molecularProfileId -> molecularProfileMap.get(molecularProfileId)) - .collect(Collectors.toList()); + .toList(); Map> mapByStudyId = filteredMolecularProfiles .stream() @@ -362,7 +363,7 @@ private List filterMutatedGenes(List mutatedGenefi List hugoGeneSymbols = geneQueries .stream() .map(GeneFilterQuery::getHugoGeneSymbol) - .collect(Collectors.toList()); + .toList(); Map symbolToEntrezGeneId = geneService .fetchGenes(new ArrayList<>(hugoGeneSymbols), @@ -397,7 +398,7 @@ private List filterMutatedGenes(List mutatedGenefi .stream() .map(m -> studyViewFilterUtil.buildSampleIdentifier(m.getStudyId(), m.getSampleId())) .distinct() - .collect(Collectors.toList()); + .toList(); } } @@ -417,7 +418,7 @@ private List filterStructuralVariantGenes(List svG .getMolecularProfileIds() .stream() .map(molecularProfileId -> molecularProfileMap.get(molecularProfileId)) - .collect(Collectors.toList()); + .toList(); Map> mapByStudyId = filteredMolecularProfiles .stream() @@ -430,7 +431,7 @@ private List filterStructuralVariantGenes(List svG List hugoGeneSymbols = geneQueries .stream() .map(GeneFilterQuery::getHugoGeneSymbol) - .collect(Collectors.toList()); + .toList(); Map symbolToEntrezGeneId = geneService .fetchGenes(new ArrayList<>(hugoGeneSymbols), @@ -465,7 +466,7 @@ private List filterStructuralVariantGenes(List svG .stream() .map(m -> studyViewFilterUtil.buildSampleIdentifier(m.getStudyId(), m.getSampleId())) .distinct() - .collect(Collectors.toList()); + .toList(); } } @@ -483,7 +484,7 @@ private List filterCNAGenes(List cnaGeneFilters, List filteredMolecularProfiles = geneFilter.getMolecularProfileIds().stream() .map(molecularProfileId -> molecularProfileMap.get(molecularProfileId)) - .collect(Collectors.toList()); + .toList(); for (List geneQueries : geneFilter.getGeneQueries()) { @@ -512,10 +513,10 @@ private List filterCNAGenes(List cnaGeneFilters, .filter(geneQuery -> geneQuery.getAlterations().stream() .filter(alteration -> alteration.getCode() == alterationType) .count() > 0) - .collect(Collectors.toList()); + .toList(); List hugoGeneSymbols = filteredGeneQueries.stream() - .map(GeneFilterQuery::getHugoGeneSymbol).collect(Collectors.toList()); + .map(GeneFilterQuery::getHugoGeneSymbol).toList(); Map symbolToEntrezGeneId = geneService .fetchGenes(new ArrayList<>(hugoGeneSymbols), @@ -540,11 +541,11 @@ private List filterCNAGenes(List cnaGeneFilters, Projection.ID.name()); } return copyNumberDatas.stream(); - }).collect(Collectors.toList()); + }).toList(); sampleIdentifiers = resultList.stream().map( d -> studyViewFilterUtil.buildSampleIdentifier(d.getStudyId(), d.getSampleId()) - ).distinct().collect(Collectors.toList()); + ).distinct().toList(); } } @@ -595,7 +596,7 @@ private List filterMutationData(List sampleI } } - return newSampleIdentifiers.stream().distinct().collect(Collectors.toList()); + return newSampleIdentifiers.stream().distinct().toList(); } return sampleIdentifiers; @@ -612,7 +613,7 @@ private void splitGeneFiltersByMolecularAlterationType(List genefilt // in filter but the study might already been filtered out .filter(molecularProfileMap::containsKey) .map(molecularProfileMap::get) - .collect(Collectors.toList()); + .toList(); Set alterationTypes = filteredMolecularProfiles.stream() .map(MolecularProfile::getMolecularAlterationType) @@ -698,7 +699,7 @@ public (U) transform(dataBinFilter, dataBin)); - }).collect(Collectors.toList()); + }).toList(); } else { // dataBinMethod == DataBinMethod.DYNAMIC resultDataBins = (List) dataBinFilters.stream().flatMap(dataBinFilter -> { @@ -708,7 +709,7 @@ public (U) transform(dataBinFilter, dataBin)); - }).collect(Collectors.toList()); + }).toList(); } return resultDataBins; @@ -745,7 +746,7 @@ private List fetchData( return genomicDataBinFilters.stream().flatMap(genomicDataBinFilter -> { Map studyIdToMolecularProfileIdMap = molecularProfileMap - .getOrDefault(genomicDataBinFilter.getProfileType(), new ArrayList()).stream() + .getOrDefault(genomicDataBinFilter.getProfileType(), new ArrayList<>()).stream() .collect(Collectors.toMap(MolecularProfile::getCancerStudyIdentifier, MolecularProfile::getStableId)); @@ -806,13 +807,12 @@ private interface FourParameterFunction { } FourParameterFunction, List, List, String, List> fetchMolecularData = ( - mappedProfileIds, mappedSampleIds, stableIds, attributeId) -> { - return molecularDataService.getMolecularDataInMultipleMolecularProfiles(mappedProfileIds, mappedSampleIds, - stableIds.stream().map(Integer::parseInt).collect(Collectors.toList()), Projection.SUMMARY.name()) - .stream().map(geneMolecularData -> + mappedProfileIds, mappedSampleIds, stableIds, attributeId) -> + molecularDataService.getMolecularDataInMultipleMolecularProfiles(mappedProfileIds, mappedSampleIds, + stableIds.stream().map(Integer::parseInt).toList(), Projection.SUMMARY.name()) + .stream().map(geneMolecularData -> transformDataToClinicalData(geneMolecularData, attributeId, geneMolecularData.getValue())) - .collect(Collectors.toList()); - }; + .toList(); FourParameterFunction, List, List, String, List> fetchGenericAssayData = ( mappedProfileIds, mappedSampleIds, stableIds, attributeId) -> { @@ -822,29 +822,27 @@ private interface FourParameterFunction { .fetchGenericAssayData(mappedProfileIds, mappedSampleIds, stableIds, Projection.SUMMARY.name()) .stream().map(genericAssayData -> transformDataToClinicalData(genericAssayData, attributeId, genericAssayData.getValue()) - ).collect(Collectors.toList()); + ).toList(); } catch (MolecularProfileNotFoundException e) { return new ArrayList<>(); } }; FourParameterFunction, List, List, String, List> fetchMutationData = ( - mappedProfileIds, mappedSampleIds, stableIds, attributeId) -> { - return mutationService.getMutationsInMultipleMolecularProfiles(mappedProfileIds, mappedSampleIds, - stableIds.stream().map(Integer::parseInt).collect(Collectors.toList()), Projection.DETAILED.name(), + mappedProfileIds, mappedSampleIds, stableIds, attributeId) -> + mutationService.getMutationsInMultipleMolecularProfiles(mappedProfileIds, mappedSampleIds, + stableIds.stream().map(Integer::parseInt).toList(), Projection.DETAILED.name(), null, null, null, null) .stream().map(mutationData -> transformDataToClinicalData(mutationData, attributeId, mutationData.getMutationType().toUpperCase()) - ).collect(Collectors.toList()); - }; + ).toList(); FourParameterFunction, List, List, String, List> fetchMutatedData = ( - mappedProfileIds, mappedSampleIds, stableIds, attributeId) -> { - return mutationService.getMutationsInMultipleMolecularProfiles(mappedProfileIds, mappedSampleIds, - stableIds.stream().map(Integer::parseInt).collect(Collectors.toList()), Projection.DETAILED.name(), + mappedProfileIds, mappedSampleIds, stableIds, attributeId) -> + mutationService.getMutationsInMultipleMolecularProfiles(mappedProfileIds, mappedSampleIds, + stableIds.stream().map(Integer::parseInt).toList(), Projection.DETAILED.name(), null, null, null, null) .stream().map(mutationData -> transformDataToClinicalData(mutationData, attributeId, MutationFilterOption.MUTATED.name()) - ).collect(Collectors.toList()); - }; + ).toList(); private List fetchDataBinFilters(T dataBinCountFilter) { if (dataBinCountFilter instanceof GenomicDataBinCountFilter) { @@ -963,7 +961,7 @@ public List filterExpressionData( } } - return newSampleIdentifiers.stream().distinct().collect(Collectors.toList()); + return newSampleIdentifiers.stream().distinct().toList(); } return sampleIdentifiers; @@ -999,7 +997,7 @@ private List fetchDataAndTransformToClinica Collections.singletonList(geneNameIdMap.get(genomicDataFilter.getHugoGeneSymbol()).toString()), studyIdToMolecularProfileIdMap, studyViewFilterUtil.getDataFilterUniqueKey(genomicDataFilter), fetchMolecularData); - }).collect(Collectors.toList()); + }).toList(); } else { return ((List) dataFilters).stream().flatMap(genericAssayDataFilter -> { @@ -1020,7 +1018,7 @@ private List fetchDataAndTransformToClinica } // don't change anything for non patient level data return dataStream; - }).collect(Collectors.toList()); + }).toList(); } } @@ -1060,7 +1058,7 @@ private List fetchMutationDataAndTransformToClinicalDataList( studyViewFilterUtil.getMutationDataFilterUniqueKey(mutationDataFilter), fetchMutationData); } - }).collect(Collectors.toList()); + }).toList(); } private List transformToClinicalDataFilter(List dataFilters) { List attributes; @@ -1069,7 +1067,7 @@ private List transformToClinicalDataF clinicalDataFilter.setAttributeId(studyViewFilterUtil.getDataFilterUniqueKey(dataFilter)); clinicalDataFilter.setValues(dataFilter.getValues()); return clinicalDataFilter; - }).collect(Collectors.toList()); + }).toList(); return attributes; } @@ -1102,7 +1100,7 @@ private List fetchMutationOptionDataByGene(List studyI List genePanelData = genePanelDataList .stream() .filter(GenePanelData::getProfiled) - .collect(Collectors.toList()); + .toList(); Set profiledCases = genePanelData .stream() @@ -1138,7 +1136,7 @@ private List fetchMutationOptionDataByGene(List studyI .stream() .filter(genePanelToGene -> genePanelToGene.getEntrezGeneId().equals(entrezGeneId)) .map(GenePanelToGene::getGenePanelId); - }).collect(Collectors.toList()); + }).toList(); List newSampleIdentifiers = new ArrayList<>(); // different calculations depending on if gene is linked to gene panels @@ -1170,12 +1168,12 @@ private Stream fetchMutatedAndWildTypeData( List mutatedClinicalDatas = invokeDataFunc(sampleIds, studyIds, Collections.singletonList(geneNameIdMap.get(mutationDataFilter.getHugoGeneSymbol()).toString()), studyIdToMolecularProfileIdMap, studyViewFilterUtil.getMutationDataFilterUniqueKey(mutationDataFilter), - fetchMutatedData).collect(Collectors.toList()); + fetchMutatedData).toList(); List mutatedSampleIdentifiers = mutatedClinicalDatas .stream() .map(datum -> studyViewFilterUtil.buildSampleIdentifier(datum.getStudyId(), datum.getSampleId()) - ).collect(Collectors.toList()); + ).toList(); List clinicalDatas = new ArrayList<>(mutatedClinicalDatas); @@ -1186,7 +1184,7 @@ private Stream fetchMutatedAndWildTypeData( List notProfiledSampleIdentifiers = sampleIdentifiers .stream() .filter(s -> profiledSampleIdentifiers.stream().noneMatch(p -> p.equals(s))) - .collect(Collectors.toList()); + .toList(); List notProfiledClinicalDatas = transformSampleIdentifiersToClinicalData( notProfiledSampleIdentifiers, @@ -1200,7 +1198,7 @@ private Stream fetchMutatedAndWildTypeData( List notMutatedSampleIdentifiers = profiledSampleIdentifiers .stream() .filter(p -> mutatedSampleIdentifiers.stream().noneMatch(m -> m.equals(p))) - .collect(Collectors.toList()); + .toList(); List notMutatedClinicalDatas = transformSampleIdentifiersToClinicalData( notMutatedSampleIdentifiers, @@ -1242,6 +1240,6 @@ private List transformSampleIdentifiersToClinicalData(List sampleIdentifiers, - List studyIds, + List sampleIdentifiers, + List studyIds, List sampleIds ) { for (SampleIdentifier sampleIdentifier : sampleIdentifiers) { @@ -39,10 +39,10 @@ public void removeSelfFromFilter(String attributeId, StudyViewFilter studyViewFi studyViewFilter.getClinicalDataFilters().removeIf(f -> f.getAttributeId().equals(attributeId)); } } - + public void removeSelfFromGenomicDataFilter(String hugoGeneSymbol, String profileType, StudyViewFilter studyViewFilter) { if (studyViewFilter != null && studyViewFilter.getGenomicDataFilters() != null) { - studyViewFilter.getGenomicDataFilters().removeIf(f -> + studyViewFilter.getGenomicDataFilters().removeIf(f -> f.getHugoGeneSymbol().equals(hugoGeneSymbol) && f.getProfileType().equals(profileType) ); } @@ -50,9 +50,9 @@ public void removeSelfFromGenomicDataFilter(String hugoGeneSymbol, String profil public void removeSelfFromMutationDataFilter(String hugoGeneSymbol, String profileType, MutationOption categorization, StudyViewFilter studyViewFilter) { if (studyViewFilter != null && studyViewFilter.getMutationDataFilters() != null) { - studyViewFilter.getMutationDataFilters().removeIf(f -> - f.getHugoGeneSymbol().equals(hugoGeneSymbol) && - f.getProfileType().equals(profileType) && + studyViewFilter.getMutationDataFilters().removeIf(f -> + f.getHugoGeneSymbol().equals(hugoGeneSymbol) && + f.getProfileType().equals(profileType) && f.getCategorization().equals(categorization) ); } @@ -69,32 +69,28 @@ public void removeSelfCustomDataFromFilter(String attributeId, StudyViewFilter s studyViewFilter.getCustomDataFilters().removeIf(f -> f.getAttributeId().equals(attributeId)); } } - + public String getCaseUniqueKey(String studyId, String caseId) { return studyId + caseId; } public String getDataFilterUniqueKey(S dataFilter) { - if (dataFilter instanceof GenomicDataFilter) { - GenomicDataFilter genomicDataFilter = (GenomicDataFilter) dataFilter; + if (dataFilter instanceof GenomicDataFilter genomicDataFilter) { return genomicDataFilter.getHugoGeneSymbol() + genomicDataFilter.getProfileType(); - } else if (dataFilter instanceof GenericAssayDataFilter) { - GenericAssayDataFilter genericAssayDataFilter = (GenericAssayDataFilter) dataFilter; + } else if (dataFilter instanceof GenericAssayDataFilter genericAssayDataFilter) { return genericAssayDataFilter.getStableId() + genericAssayDataFilter.getProfileType(); } return null; } - + public String getMutationDataFilterUniqueKey(MutationDataFilter mutationDataFilter) { return mutationDataFilter.getHugoGeneSymbol() + mutationDataFilter.getProfileType(); } public String getDataBinFilterUniqueKey(S dataBinFilter) { - if (dataBinFilter instanceof GenomicDataBinFilter) { - GenomicDataBinFilter genomicDataBinFilter = (GenomicDataBinFilter) dataBinFilter; + if (dataBinFilter instanceof GenomicDataBinFilter genomicDataBinFilter) { return genomicDataBinFilter.getHugoGeneSymbol() + genomicDataBinFilter.getProfileType(); - } else if (dataBinFilter instanceof GenericAssayDataBinFilter) { - GenericAssayDataBinFilter genericAssayDataBinFilter = (GenericAssayDataBinFilter) dataBinFilter; + } else if (dataBinFilter instanceof GenericAssayDataBinFilter genericAssayDataBinFilter) { return genericAssayDataBinFilter.getStableId() + genericAssayDataBinFilter.getProfileType(); } return null; @@ -123,26 +119,23 @@ public Map> categorizeSampleLists(List samp } public Integer getFilteredCountByDataEquality(List attributes, MultiKeyMap clinicalDataMap, - String entityId, String studyId, Boolean negateFilters) { + String entityId, String studyId, Boolean negateFilters) { Integer count = 0; for (ClinicalDataFilter s : attributes) { List filteredValues = s.getValues() - .stream() - .map(DataFilterValue::getValue) - .collect(Collectors.toList()); + .stream() + .map(DataFilterValue::getValue) + .collect(Collectors.toList()); filteredValues.replaceAll(String::toUpperCase); if (clinicalDataMap.containsKey(studyId, entityId, s.getAttributeId())) { -// for (String value: filteredValues) System.out.println(value); S value = clinicalDataMap.get(studyId, entityId, s.getAttributeId()); if (value instanceof String) { if (negateFilters ^ filteredValues.contains(value)) { count++; } - } else if (value instanceof List) { -// for (String val : (ArrayList) value) System.out.println("clinical value: " + val); - if (negateFilters ^ filteredValues.stream().anyMatch(((List) value)::contains)) { - count++; - } + } else if (value instanceof List && + negateFilters ^ filteredValues.stream().anyMatch(((List) value)::contains)) { + count++; } } else if (negateFilters ^ filteredValues.contains("NA")) { count++; @@ -152,7 +145,7 @@ public Integer getFilteredCountByDataEquality(List attri } public List getClinicalDataCountsFromCustomData(Collection customDataSessions, - Map filteredSamplesMap, List patients) { + Map filteredSamplesMap, List patients) { int totalSamplesCount = filteredSamplesMap.keySet().size(); int totalPatientsCount = patients.size(); @@ -167,22 +160,22 @@ public List getClinicalDataCountsFromCustomData(Collectio clinicalDataCountItem.setAttributeId(customDataSession.getId()); List clinicalDataCounts = groupedDatabyValue.entrySet().stream() - .map(entry -> { - long count = entry.getValue().stream().map(datum -> { - return getCaseUniqueKey(datum.getStudyId(), - customDataSession.getData().getPatientAttribute() - ? datum.getPatientId() - : datum.getSampleId()); - - }).distinct().count(); - ClinicalDataCount dataCount = new ClinicalDataCount(); - dataCount.setValue(entry.getKey()); - dataCount.setCount(Math.toIntExact(count)); - return dataCount; - }) - .filter(c -> !c.getValue().equalsIgnoreCase("NA") && !c.getValue().equalsIgnoreCase("NAN") - && !c.getValue().equalsIgnoreCase("N/A")) - .collect(Collectors.toList()); + .map(entry -> { + long count = entry.getValue().stream().map(datum -> { + return getCaseUniqueKey(datum.getStudyId(), + customDataSession.getData().getPatientAttribute() + ? datum.getPatientId() + : datum.getSampleId()); + + }).distinct().count(); + ClinicalDataCount dataCount = new ClinicalDataCount(); + dataCount.setValue(entry.getKey()); + dataCount.setCount(Math.toIntExact(count)); + return dataCount; + }) + .filter(c -> !c.getValue().equalsIgnoreCase("NA") && !c.getValue().equalsIgnoreCase("NAN") + && !c.getValue().equalsIgnoreCase("N/A")) + .collect(Collectors.toList()); int totalCount = clinicalDataCounts.stream().mapToInt(ClinicalDataCount::getCount).sum(); int naCount = 0; @@ -203,38 +196,38 @@ public List getClinicalDataCountsFromCustomData(Collectio return clinicalDataCountItem; }).collect(Collectors.toList()); } - + public boolean isSingleStudyUnfiltered(StudyViewFilter filter) { - return filter.getStudyIds() != null && - filter.getStudyIds().size() == 1 && - (filter.getClinicalDataFilters() == null || filter.getClinicalDataFilters().isEmpty()) && - (filter.getGeneFilters() == null || filter.getGeneFilters().isEmpty()) && - (filter.getSampleTreatmentFilters() == null || filter.getSampleTreatmentFilters().getFilters().isEmpty()) && - (filter.getPatientTreatmentFilters() == null || filter.getPatientTreatmentFilters().getFilters().isEmpty()) && - (filter.getGenomicProfiles() == null || filter.getGenomicProfiles().isEmpty()) && - (filter.getGenomicDataFilters() == null || filter.getGenomicDataFilters().isEmpty()) && - (filter.getGenericAssayDataFilters() == null || filter.getGenericAssayDataFilters().isEmpty()) && - (filter.getCaseLists() == null || filter.getCaseLists().isEmpty()) && - (filter.getCustomDataFilters() == null || filter.getCustomDataFilters().isEmpty()); + return filter.getStudyIds() != null && + filter.getStudyIds().size() == 1 && + (filter.getClinicalDataFilters() == null || filter.getClinicalDataFilters().isEmpty()) && + (filter.getGeneFilters() == null || filter.getGeneFilters().isEmpty()) && + (filter.getSampleTreatmentFilters() == null || filter.getSampleTreatmentFilters().getFilters().isEmpty()) && + (filter.getPatientTreatmentFilters() == null || filter.getPatientTreatmentFilters().getFilters().isEmpty()) && + (filter.getGenomicProfiles() == null || filter.getGenomicProfiles().isEmpty()) && + (filter.getGenomicDataFilters() == null || filter.getGenomicDataFilters().isEmpty()) && + (filter.getGenericAssayDataFilters() == null || filter.getGenericAssayDataFilters().isEmpty()) && + (filter.getCaseLists() == null || filter.getCaseLists().isEmpty()) && + (filter.getCustomDataFilters() == null || filter.getCustomDataFilters().isEmpty()); } - + public boolean shouldSkipFilterForClinicalDataBins(StudyViewFilter filter) { // if everything other than study ids and sample identifiers is null, // we can skip the filter for data bin calculation return ( filter != null && - filter.getClinicalDataFilters() == null && - filter.getGeneFilters() == null && - filter.getSampleTreatmentFilters() == null && - filter.getPatientTreatmentFilters() == null && - filter.getGenomicProfiles() == null && - filter.getGenomicDataFilters() == null && - filter.getGenericAssayDataFilters() == null && - filter.getCaseLists() == null && - filter.getCustomDataFilters() == null + filter.getClinicalDataFilters() == null && + filter.getGeneFilters() == null && + filter.getSampleTreatmentFilters() == null && + filter.getPatientTreatmentFilters() == null && + filter.getGenomicProfiles() == null && + filter.getGenomicDataFilters() == null && + filter.getGenericAssayDataFilters() == null && + filter.getCaseLists() == null && + filter.getCustomDataFilters() == null ); } - + public List filterClinicalData( List unfilteredClinicalDataForSamples, List unfilteredClinicalDataForPatients, @@ -248,9 +241,9 @@ public List filterClinicalData( List conflictingPatientAttributes ) { List combinedResult = new ArrayList<>(); - + Map patientIdToStudyId = null; - + if (CollectionUtils.isNotEmpty(sampleAttributeIds)) { // create lookups for faster filtering Map sampleIdToStudyId = mapCaseToStudy(sampleIds, studyIds); @@ -269,7 +262,7 @@ public List filterClinicalData( // create lookups for faster filtering Map patientAttributeIdLookup = listToMap(patientAttributeIds); patientIdToStudyId = mapCaseToStudy(patientIds, studyIdsOfPatients); - + combinedResult.addAll( filterClinicalDataByStudyAndPatientAndAttribute( unfilteredClinicalDataForPatients, @@ -285,7 +278,7 @@ public List filterClinicalData( if (patientIdToStudyId == null) { patientIdToStudyId = mapCaseToStudy(patientIds, studyIdsOfPatients); } - + combinedResult.addAll( filterClinicalDataByStudyAndPatientAndAttribute( unfilteredClinicalDataForConflictingPatientAttributes, @@ -349,7 +342,7 @@ public List resolveEntrezGeneIds(List (q.getGene1Query().getSpecialValue() != StructuralVariantSpecialValue.NO_GENE + q -> (q.getGene1Query().getSpecialValue() != StructuralVariantSpecialValue.NO_GENE && q.getGene1Query().getSpecialValue() != StructuralVariantSpecialValue.ANY_GENE && q.getGene1Query().getEntrezId() == null) || (q.getGene2Query().getSpecialValue() != StructuralVariantSpecialValue.NO_GENE @@ -378,7 +371,7 @@ private List filterClinicalDataByStudyAndSampleAndAttribute( .stream() .filter(d -> sampleToStudyId.getOrDefault(generateSampleToStudyKey(d), "").equals(d.getStudyId()) && - attributeIdLookup.getOrDefault(d.getAttrId(), false) + attributeIdLookup.getOrDefault(d.getAttrId(), false) ) .collect(Collectors.toList()); } @@ -392,40 +385,40 @@ private List filterClinicalDataByStudyAndPatientAndAttribute( .stream() .filter(d -> patientToStudyId.getOrDefault(generatePatientToStudyKey(d), "").equals(d.getStudyId()) && - attributeIdLookup.getOrDefault(d.getAttrId(), false) + attributeIdLookup.getOrDefault(d.getAttrId(), false) ) .collect(Collectors.toList()); } - + private Map listToMap(List list) { return list.stream().collect(Collectors.toMap(s -> s, s -> true, (s1, s2) -> s1)); } - private Map mapCaseToStudy(List caseIds, List studyIds) { + private Map mapCaseToStudy(List caseIds, List studyIds) { Map caseToStudy = new HashMap<>(); - - for (int i =0; i < caseIds.size(); i++) { + + for (int i = 0; i < caseIds.size(); i++) { String studyId = studyIds.get(i); String caseId = caseIds.get(i); String key = generateCaseToStudyKey(studyId, caseId); caseToStudy.put(key, studyId); } - + return caseToStudy; } private String generateSampleToStudyKey(Binnable clinicalData) { return generateCaseToStudyKey(clinicalData.getStudyId(), clinicalData.getSampleId()); } - + private String generatePatientToStudyKey(Binnable clinicalData) { return generateCaseToStudyKey(clinicalData.getStudyId(), clinicalData.getPatientId()); } - + private String generateCaseToStudyKey(String studyId, String caseId) { return studyId + ":" + caseId; } - + public SampleIdentifier buildSampleIdentifier(String studyId, String sampleId) { SampleIdentifier sampleIdentifier = new SampleIdentifier(); sampleIdentifier.setStudyId(studyId);