diff --git a/pom.xml b/pom.xml index e61597ee3a1..8fc53f6787c 100644 --- a/pom.xml +++ b/pom.xml @@ -354,7 +354,7 @@ ${apache_httpclient.version} test - + com.clickhouse clickhouse-jdbc @@ -363,6 +363,9 @@ to http for smaller jar --> all + + + org.testcontainers clickhouse diff --git a/src/main/java/org/cbioportal/model/SampleToPanel.java b/src/main/java/org/cbioportal/model/SampleToPanel.java new file mode 100644 index 00000000000..4aea2af7f8d --- /dev/null +++ b/src/main/java/org/cbioportal/model/SampleToPanel.java @@ -0,0 +1,41 @@ +package org.cbioportal.model; + +import jakarta.validation.constraints.NotNull; + +import java.io.Serializable; + +public class SampleToPanel implements Serializable { + + + @NotNull + private String sampleUniqueId; + @NotNull + private String genePanelId; + private String geneticProfileId; + + public String getSampleUniqueId() { + return sampleUniqueId; + } + + public void setSampleUniqueId(String sampleUniqueId) { + this.sampleUniqueId = sampleUniqueId; + } + + public String getGenePanelId() { + return genePanelId; + } + + public void setGenePanelId(String genePanelId) { + this.genePanelId = genePanelId; + } + + public String getGeneticProfileId() { + return geneticProfileId; + } + + public void setGeneticProfileId(String geneticProfileId) { + this.geneticProfileId = geneticProfileId; + } + + +} diff --git a/src/main/java/org/cbioportal/persistence/StudyViewRepository.java b/src/main/java/org/cbioportal/persistence/StudyViewRepository.java index c39158ad433..068b6507bd3 100644 --- a/src/main/java/org/cbioportal/persistence/StudyViewRepository.java +++ b/src/main/java/org/cbioportal/persistence/StudyViewRepository.java @@ -1,6 +1,7 @@ package org.cbioportal.persistence; import org.cbioportal.model.AlterationCountByGene; +import org.cbioportal.model.AlterationEnrichment; import org.cbioportal.model.ClinicalAttribute; import org.cbioportal.model.CaseListDataCount; import org.cbioportal.model.ClinicalData; @@ -22,6 +23,7 @@ import org.cbioportal.web.parameter.GenomicDataBinFilter; import org.cbioportal.web.parameter.GenomicDataFilter; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -89,4 +91,6 @@ public interface StudyViewRepository { List getGenericAssayProfiles(); List getFilteredMolecularProfilesByAlterationType(StudyViewFilterContext studyViewFilterContext, String alterationType); + + HashMap getAlterationEnrichmentCounts(List sampleStableIds); } diff --git a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java index dca5ad64125..31e7c80cc84 100644 --- a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java +++ b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java @@ -16,6 +16,7 @@ import org.cbioportal.model.PatientTreatment; import org.cbioportal.model.MolecularProfile; import org.cbioportal.model.Sample; +import org.cbioportal.model.SampleToPanel; import org.cbioportal.model.SampleTreatment; import org.cbioportal.persistence.helper.AlterationFilterHelper; import org.cbioportal.persistence.helper.StudyViewFilterHelper; @@ -87,4 +88,12 @@ public interface StudyViewMapper { List getGenericAssayProfiles(); List getFilteredMolecularProfilesByAlterationType(StudyViewFilterHelper studyViewFilterHelper, String alterationType); + + List getAlterationEnrichmentCounts(String samplelist); + + List getSampleToGenePanels(String samplelist); + + List getGenePanelGenes(); + + } diff --git a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java index d3f594d61be..797c0b31f80 100644 --- a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java +++ b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java @@ -1,5 +1,6 @@ package org.cbioportal.persistence.mybatisclickhouse; import org.cbioportal.model.AlterationCountByGene; +import org.cbioportal.model.AlterationEnrichment; import org.cbioportal.model.ClinicalAttribute; import org.cbioportal.model.CaseListDataCount; import org.cbioportal.model.ClinicalData; @@ -14,6 +15,7 @@ import org.cbioportal.model.MolecularProfile; import org.cbioportal.model.PatientTreatment; import org.cbioportal.model.Sample; +import org.cbioportal.model.SampleToPanel; import org.cbioportal.model.SampleTreatment; import org.cbioportal.model.StudyViewFilterContext; import org.cbioportal.persistence.StudyViewRepository; @@ -28,15 +30,20 @@ import org.cbioportal.web.parameter.GenomicDataBinFilter; import org.cbioportal.web.parameter.GenomicDataFilter; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; +import com.clickhouse.client.*; +import java.util.Arrays; import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; @Repository @ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true") @@ -260,6 +267,157 @@ public List getGenericAssayDataCounts(StudyViewFilter return mapper.getGenericAssayDataCounts(createStudyViewFilterHelper(studyViewFilterContext), genericAssayDataFilters); } + private Map> _data = null; + + public Map> getGenePanelsToGenes(String str){ + + if (_data == null) { + List genesWithPanels = mapper.getGenePanelGenes(); + Map> panelsToGeneMaps = genesWithPanels.stream() + .collect(Collectors.groupingBy( + GenePanelToGene::getGenePanelId, + Collectors.toMap( + GenePanelToGene::getHugoGeneSymbol, + panelGene -> panelGene, + (existing, replacement) -> existing // handle duplicates by keeping the existing entry + ) + )); + + _data = panelsToGeneMaps; + + } + return _data; + } + +// private doIt(){ +// Map> alteredGenesWithCounts = new HashMap<>(); +// +// for (Map alteration : alterations) { +// String hugoGeneSymbol = (String) alteration.get("hugo_gene_symbol"); +// int count = Integer.parseInt(alteration.get("count").toString()); +// +// if (!alteredGenesWithCounts.containsKey(hugoGeneSymbol)) { +// alteredGenesWithCounts.put(hugoGeneSymbol, new HashMap<>()); +// alteredGenesWithCounts.get(hugoGeneSymbol).put("count", 0); +// } +// +// alteredGenesWithCounts.get(hugoGeneSymbol).put("count", +// alteredGenesWithCounts.get(hugoGeneSymbol).get("count") + count); +// } +// +// } + + + @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") + public List getSampleToGenePanels(List sampleStableIds) { + + //System.out.println("Console is: " + ping); + + return mapper.getSampleToGenePanels( + sampleStableIds.stream().map(s->"'"+s+"'").collect(Collectors.joining(",")) + ); + } + + @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") + public List getAlterationEnrichmentCountsCached(ListsampleStableIds){ + //return mapper.getAlterationEnrichmentCounts(sampleStableIds.toArray(String[]::new)); + + + return mapper.getAlterationEnrichmentCounts( + sampleStableIds.stream().map(s->"'"+s+"'").collect(Collectors.joining(",")) + ); + + } + + @Override + public HashMap getAlterationEnrichmentCounts(List sampleStableIds) { + + // we need a map of panels to genes which are profiled by them + var panelToGeneMap = getGenePanelsToGenes("help"); + + List sampleToGenePanels = getSampleToGenePanels(sampleStableIds); + // group the panels by the sample ids which they are associated with + // this tells us for each sample, what gene panels were applied + var samplesToPanelMap = sampleToGenePanels.stream() + .collect(Collectors.groupingBy( + SampleToPanel::getSampleUniqueId, + Collectors.mapping(e->e.getGenePanelId(), Collectors.toSet()) + ) + ); + + + // many of the samples are governed by the same combination of panels + // we want to group the samples by a key that represents the set of panels applied + Map> clumps = samplesToPanelMap.keySet().stream().collect(Collectors.groupingBy( + sampleId->samplesToPanelMap.get(sampleId).stream().collect(Collectors.joining(",")) + )); + + + var alterationCounts = getAlterationEnrichmentCountsCached(sampleStableIds); + + HashMap alteredGenesWithCounts = new HashMap(); + + // we need map of genes to alteration counts + alterationCounts.stream().forEach((alterationCountByGene) -> { + String hugoGeneSymbol = alterationCountByGene.getHugoGeneSymbol(); + int count = alterationCountByGene.getNumberOfAlteredCases(); + if (!alteredGenesWithCounts.containsKey(hugoGeneSymbol)) { + var acg = new AlterationCountByGene(); + acg.setHugoGeneSymbol(hugoGeneSymbol); + acg.setNumberOfAlteredCases(0); + alteredGenesWithCounts.put(hugoGeneSymbol,acg); + } + // add the count to existing tally + alteredGenesWithCounts.get(hugoGeneSymbol).setNumberOfAlteredCases( + count + alteredGenesWithCounts.get(hugoGeneSymbol).getNumberOfAlteredCases() + ); + + }); + + var geneCount = new HashMap(); + + clumps.entrySet().stream().forEach(entry->{ + + var geneLists = Arrays.stream(entry.getKey().split(",")) + .map(panelId -> panelToGeneMap.get(panelId)) + .collect(Collectors.toList()); + + Set mergeGenes = geneLists.stream() + .map(Map::keySet) + .reduce((set1, set2) -> { + set1.retainAll(set2); + return set1; + }).orElse(Collections.emptySet()); + + mergeGenes.stream().forEach( + gene->{ + if (geneCount.containsKey(gene)) { + var count = geneCount.get(gene); + count.setNumberOfProfiledCases(count.getNumberOfProfiledCases() + entry.getValue().size()); + } else { + var alterationCountByGene = new AlterationCountByGene(); + alterationCountByGene.setHugoGeneSymbol(gene); + alterationCountByGene.setNumberOfProfiledCases(entry.getValue().size()); + alterationCountByGene.setNumberOfAlteredCases(0); + geneCount.put(gene,alterationCountByGene); + } + }); + + }); + + geneCount.entrySet().stream().forEach( + n->{ + if (alteredGenesWithCounts.containsKey(n.getKey())) { + n.getValue().setNumberOfAlteredCases( + alteredGenesWithCounts.get(n.getKey()).getNumberOfAlteredCases() + ); + } + } + ); + + return geneCount; + } + public Map getMutationCounts(StudyViewFilterContext studyViewFilterContext, GenomicDataFilter genomicDataFilter) { return mapper.getMutationCounts(createStudyViewFilterHelper(studyViewFilterContext), genomicDataFilter); } @@ -268,4 +426,6 @@ public List getMutationCountsByType(StudyViewFilterContext return mapper.getMutationCountsByType(createStudyViewFilterHelper(studyViewFilterContext), genomicDataFilters); } + + } \ No newline at end of file diff --git a/src/main/java/org/cbioportal/service/StudyViewColumnarService.java b/src/main/java/org/cbioportal/service/StudyViewColumnarService.java index 4f13dc68f78..bf4ca512537 100644 --- a/src/main/java/org/cbioportal/service/StudyViewColumnarService.java +++ b/src/main/java/org/cbioportal/service/StudyViewColumnarService.java @@ -1,6 +1,7 @@ package org.cbioportal.service; import org.cbioportal.model.AlterationCountByGene; +import org.cbioportal.model.AlterationEnrichment; import org.cbioportal.model.CaseListDataCount; import org.cbioportal.model.ClinicalData; import org.cbioportal.model.ClinicalDataCountItem; @@ -20,6 +21,7 @@ import org.cbioportal.web.parameter.GenomicDataFilter; import org.cbioportal.web.parameter.StudyViewFilter; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -58,4 +60,6 @@ public interface StudyViewColumnarService { List getGenericAssayDataBinCounts(StudyViewFilter studyViewFilter, List genericAssayDataBinFilters); List getMutationTypeCountsByGeneSpecific(StudyViewFilter studyViewFilter, List genomicDataFilters); + + HashMap getAlterationEnrichmentCounts(List sampleStableIds); } diff --git a/src/main/java/org/cbioportal/service/impl/GeneMemoizerServiceImpl.java b/src/main/java/org/cbioportal/service/impl/GeneMemoizerServiceImpl.java index 2c0a097f16a..eb1b1171705 100644 --- a/src/main/java/org/cbioportal/service/impl/GeneMemoizerServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/GeneMemoizerServiceImpl.java @@ -32,10 +32,11 @@ public List fetchGenes(String genomeName) { private boolean allTablesUpToDate(Date expiration) { Map timestamps = timestampService.getTimestampsAsDates(TABLES); - return TABLES.stream() - .map((table) -> timestamps.containsKey(table) && timestamps.get(table).before(expiration)) - .reduce((all, next) -> all && next) - .orElse(false); + return true; +// TABLES.stream() +// .map((table) -> timestamps.containsKey(table) && timestamps.get(table).before(expiration)) +// .reduce((all, next) -> all && next) +// .orElse(false); } @Override diff --git a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java index a048d860656..ced4a089778 100644 --- a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java @@ -1,6 +1,7 @@ package org.cbioportal.service.impl; import org.cbioportal.model.AlterationCountByGene; +import org.cbioportal.model.AlterationEnrichment; import org.cbioportal.model.CaseListDataCount; import org.cbioportal.model.ClinicalAttribute; import org.cbioportal.model.ClinicalData; @@ -35,6 +36,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -272,7 +274,11 @@ public List getMutationCountsByGeneSpecific(StudyViewFilte public List getMutationTypeCountsByGeneSpecific(StudyViewFilter studyViewFilter, List genomicDataFilters) { return studyViewRepository.getMutationCountsByType(createContext(studyViewFilter), genomicDataFilters); } - + + + public HashMap getAlterationEnrichmentCounts(List sampleStableIds) { + return studyViewRepository.getAlterationEnrichmentCounts(sampleStableIds); + } private StudyViewFilterContext createContext(StudyViewFilter studyViewFilter) { List customSampleIdentifiers = customDataFilterUtil.extractCustomDataSamples(studyViewFilter); @@ -289,7 +295,7 @@ private List generateDataCountItemsFromDataCounts(List getGenomicDataCounts(List studyIds, List molecularProfileCaseCountSet = genePanelService - .fetchGenePanelDataInMultipleMolecularProfiles(molecularProfileSampleIdentifiers) + var moo = genePanelService + .fetchGenePanelDataInMultipleMolecularProfiles(molecularProfileSampleIdentifiers); + + + Map molecularProfileCaseCountSet = moo .stream() .filter(GenePanelData::getProfiled) .collect(Collectors.groupingBy(GenePanelData::getMolecularProfileId)) diff --git a/src/main/java/org/cbioportal/service/util/AlterationEnrichmentUtil.java b/src/main/java/org/cbioportal/service/util/AlterationEnrichmentUtil.java index 8113cc63f73..8b0414eff11 100644 --- a/src/main/java/org/cbioportal/service/util/AlterationEnrichmentUtil.java +++ b/src/main/java/org/cbioportal/service/util/AlterationEnrichmentUtil.java @@ -41,7 +41,35 @@ public class AlterationEnrichmentUtil { private GenePanelService genePanelService; @Autowired private MolecularProfileService molecularProfileService; - + + public double calculatePValue(List counts){ + double pValue; + if (counts.size() == 2) { + int alteredInNoneCount = counts.get(1).getProfiledCount() - counts.get(1).getAlteredCount(); + int alteredOnlyInQueryGenesCount = counts.get(0).getProfiledCount() + - counts.get(0).getAlteredCount(); + + pValue = fisherExactTestCalculator.getTwoTailedPValue(alteredInNoneCount, + counts.get(1).getAlteredCount(), alteredOnlyInQueryGenesCount, + counts.get(0).getAlteredCount()); + } else { + + long[][] array = counts.stream().map(count -> { + return new long[]{count.getAlteredCount(), + count.getProfiledCount() - count.getAlteredCount()}; + }).toArray(long[][]::new); + + ChiSquareTest chiSquareTest = new ChiSquareTest(); + pValue = chiSquareTest.chiSquareTest(array); + + // set p-value to 1 when the cases in all groups are altered + if (Double.isNaN(pValue)) { + pValue = 1; + } + } + return pValue; + } + public List createAlterationEnrichments(Map, Long>> mutationCountsbyGroup) { Map> mutationCountsbyEntrezGeneIdAndGroup = mutationCountsbyGroup diff --git a/src/main/java/org/cbioportal/web/columnar/EnrichmentsColumnStoreController.java b/src/main/java/org/cbioportal/web/columnar/EnrichmentsColumnStoreController.java new file mode 100644 index 00000000000..054c0da45b9 --- /dev/null +++ b/src/main/java/org/cbioportal/web/columnar/EnrichmentsColumnStoreController.java @@ -0,0 +1,268 @@ +package org.cbioportal.web.columnar; + +import com.clickhouse.jdbc.ClickHouseDataSource; +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.validation.Valid; +import org.apache.commons.math3.stat.inference.ChiSquareTest; +import org.cbioportal.model.AlterationCountByGene; +import org.cbioportal.model.AlterationEnrichment; +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; +import org.cbioportal.model.ClinicalEventKeyCode; +import org.cbioportal.model.ClinicalEventTypeCount; +import org.cbioportal.model.ClinicalViolinPlotData; +import org.cbioportal.model.CopyNumberCountByGene; +import org.cbioportal.model.CountSummary; +import org.cbioportal.model.DensityPlotData; +import org.cbioportal.model.EnrichmentType; +import org.cbioportal.model.GenericAssayDataBin; +import org.cbioportal.model.GenericAssayDataCountItem; +import org.cbioportal.model.GenomicDataBin; +import org.cbioportal.model.GenomicDataCount; +import org.cbioportal.model.GenomicDataCountItem; +import org.cbioportal.model.MolecularProfileCaseIdentifier; +import org.cbioportal.model.PatientTreatmentReport; +import org.cbioportal.model.Sample; +import org.cbioportal.model.SampleTreatmentReport; +import org.cbioportal.persistence.mybatisclickhouse.StudyViewMapper; +import org.cbioportal.properties.CustomDataSourceConfiguration; +import org.cbioportal.service.ClinicalDataDensityPlotService; +import org.cbioportal.service.CustomDataService; +import org.cbioportal.service.StudyViewColumnarService; +import org.cbioportal.service.ViolinPlotService; +import org.cbioportal.service.exception.MolecularProfileNotFoundException; +import org.cbioportal.service.exception.StudyNotFoundException; +import org.cbioportal.service.util.AlterationEnrichmentUtil; +import org.cbioportal.service.util.CustomDataSession; +import org.cbioportal.utils.config.annotation.ConditionalOnProperty; +import org.cbioportal.web.columnar.util.CustomDataFilterUtil; +import org.cbioportal.web.columnar.util.NewStudyViewFilterUtil; +import org.cbioportal.web.config.annotation.InternalApi; +import org.cbioportal.web.parameter.ClinicalDataBinCountFilter; +import org.cbioportal.web.parameter.ClinicalDataCountFilter; +import org.cbioportal.web.parameter.ClinicalDataFilter; +import org.cbioportal.web.parameter.DataBinMethod; +import org.cbioportal.web.parameter.GenericAssayDataBinCountFilter; +import org.cbioportal.web.parameter.GenericAssayDataCountFilter; +import org.cbioportal.web.parameter.GenericAssayDataFilter; +import org.cbioportal.web.parameter.GenomicDataBinCountFilter; +import org.cbioportal.web.parameter.GenomicDataCountFilter; +import org.cbioportal.web.parameter.GenomicDataFilter; +import org.cbioportal.web.parameter.MolecularProfileCasesGroupAndAlterationTypeFilter; +import org.cbioportal.web.parameter.MolecularProfileCasesGroupFilter; +import org.cbioportal.web.parameter.MutationOption; +import org.cbioportal.web.parameter.Projection; +import org.cbioportal.web.parameter.SampleIdentifier; +import org.cbioportal.web.parameter.StudyViewFilter; +import org.cbioportal.web.util.DensityPlotParameters; +import org.cbioportal.web.util.StudyViewFilterUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.xml.transform.Result; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + +import static org.cbioportal.web.columnar.util.ClinicalDataXyPlotUtil.fetchClinicalDataForXyPlot; + + + +@InternalApi +@RestController() +@RequestMapping("/api") +@Validated +@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true") +public class EnrichmentsColumnStoreController { + + private final StudyViewColumnarService studyViewColumnarService; + private final ClinicalDataBinner clinicalDataBinner; + + private final BasicDataBinner basicDataBinner; + private final ClinicalDataDensityPlotService clinicalDataDensityPlotService; + private final ViolinPlotService violinPlotService; + private final CustomDataService customDataService; + private final StudyViewFilterUtil studyViewFilterUtil; + private final CustomDataFilterUtil customDataFilterUtil; + + @Autowired + public EnrichmentsColumnStoreController(StudyViewColumnarService studyViewColumnarService, + ClinicalDataBinner clinicalDataBinner, + BasicDataBinner basicDataBinner, + ClinicalDataDensityPlotService clinicalDataDensityPlotService, + ViolinPlotService violinPlotService, + CustomDataService customDataService, + StudyViewFilterUtil studyViewFilterUtil, + CustomDataFilterUtil customDataFilterUtil + ) { + this.studyViewColumnarService = studyViewColumnarService; + this.clinicalDataBinner = clinicalDataBinner; + this.basicDataBinner = basicDataBinner; + this.clinicalDataDensityPlotService = clinicalDataDensityPlotService; + this.violinPlotService = violinPlotService; + this.customDataService = customDataService; + this.studyViewFilterUtil = studyViewFilterUtil; + this.customDataFilterUtil = customDataFilterUtil; + } + + + @PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection', T(org.cbioportal.utils.security.AccessLevel).READ)") + @RequestMapping(value = "/alteration-enrichmentss/fetch", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary ="Fetch alteration enrichments in molecular profiles") + @ApiResponse(responseCode = "200", description = "OK", + content = @Content(array = @ArraySchema(schema = @Schema(implementation = AlterationEnrichment.class)))) + public ResponseEntity> fetchAlterationEnrichmentsNew( + @Parameter(hidden = true) // prevent reference to this attribute in the swagger-ui interface + @RequestAttribute(required = false, value = "involvedCancerStudies") Collection involvedCancerStudies, + @Parameter(hidden = true) + // prevent reference to this attribute in the swagger-ui interface. this attribute is needed for the @PreAuthorize tag above. + @Valid @RequestAttribute(required = false, value = "interceptedMolecularProfileCasesGroupFilters") List interceptedMolecularProfileCasesGroupFilters, + @Parameter(hidden = true) + @Valid @RequestAttribute(required = false, value = "alterationEventTypes") AlterationFilter alterationEventTypes, + @Parameter(description = "Type of the enrichment e.g. SAMPLE or PATIENT") + @RequestParam(defaultValue = "SAMPLE") EnrichmentType enrichmentType, + @Parameter(required = true, description = "List of groups containing sample identifiers and list of Alteration Types") + @Valid @RequestBody(required = false) MolecularProfileCasesGroupAndAlterationTypeFilter groupsAndAlterationTypes) throws MolecularProfileNotFoundException { + + + var util = new AlterationEnrichmentUtil(); + + // this needs to be the response type + //List + + + Map> ret = new HashMap(); + + var groups = groupsAndAlterationTypes.getMolecularProfileCasesGroupFilter(); + +// groups +// .forEach(group ->{ +// List stringList = new ArrayList<>(); +// +// stringList.addAll( +// group.getMolecularProfileCaseIdentifiers().stream() +// .map(n->"genie_public_"+n.getCaseId()).toList()); +// +// var counts = studyViewColumnarService.getAlterationEnrichmentCounts(stringList); +// +// ret.put(group.getName(),counts); +// +// }); +// + + + List> futures = groups.stream() + .map(group -> CompletableFuture.runAsync(() -> { + List stringList = new ArrayList<>(); + + stringList.addAll( + group.getMolecularProfileCaseIdentifiers().stream() + .map(n -> "genie_public_" + n.getCaseId()).toList()); + + var counts = studyViewColumnarService.getAlterationEnrichmentCounts(stringList); + + synchronized (ret) { + ret.put(group.getName(), counts); + } + })).collect(Collectors.toList()); + + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + + + + List genes = ret.values().stream() + .flatMap(map -> map.keySet().stream()) + .distinct() + .collect(Collectors.toList()); + + var alterationEnrichments = genes.stream().map(hugoGeneSymbol->{ + + var enrichment = new AlterationEnrichment(); + enrichment.setHugoGeneSymbol(hugoGeneSymbol); + enrichment.setEntrezGeneId(0); + + var counts = groups.stream().map(g -> { + CountSummary summary = new CountSummary(); + summary.setName(g.getName()); + var geneCount = ret.get(g.getName()).get(hugoGeneSymbol); + // an entry may not exist + // because a group may not have an alteration in a particular gene + if (geneCount != null) { + summary.setProfiledCount( + geneCount.getNumberOfProfiledCases() + ); + summary.setAlteredCount( + geneCount.getNumberOfAlteredCases() + ); + } else { + summary.setProfiledCount(0); + summary.setAlteredCount(0); + } + return summary; + }).collect(Collectors.toList()); + enrichment.setCounts(counts); + + var filteredCounts = counts.stream().filter(groupCasesCount -> groupCasesCount.getProfiledCount() > 0) + .collect(Collectors.toList()); + + // groups where number of altered cases is greater than profiled cases. + // This is a temporary fix for https://github.com/cBioPortal/cbioportal/issues/7274 + // and https://github.com/cBioPortal/cbioportal/issues/7418 + long invalidDataGroups = filteredCounts + .stream() + .filter(groupCasesCount -> groupCasesCount.getAlteredCount() > groupCasesCount.getProfiledCount()) + .count(); + + // calculate p-value only if more than one group have profile cases count + // greater than 0 + if (filteredCounts.size() > 1 && invalidDataGroups == 0) { + enrichment.setpValue(BigDecimal.valueOf(util.calculatePValue(counts))); + } + + + return enrichment; + + }).collect(Collectors.toList()); + + var filtered = alterationEnrichments.stream().filter(enrichment->{ + // if any group has altered count above zero, let it through + return enrichment.getCounts().stream().anyMatch(c->c.getAlteredCount()>0); + }).collect(Collectors.toList()); + + return new ResponseEntity<>(filtered, HttpStatus.OK); + } + + + + +} diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml index f9e53a35b08..6487c7d3574 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml @@ -4,11 +4,12 @@ - + - + @@ -210,9 +212,9 @@ LEFT JOIN alteration_driver_annotation ON - mutation.MUTATION_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID - AND mutation.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - AND mutation.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID + mutation.mutation_event_id = alteration_driver_annotation.alteration_event_id + AND mutation.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND mutation.sample_id = alteration_driver_annotation.sample_id @@ -224,12 +226,12 @@ LEFT JOIN alteration_driver_annotation ON - sample_cna_event.CNA_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID - AND sample_cna_event.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - AND sample_cna_event.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID + sample_cna_event.cna_event_id = alteration_driver_annotation.alteration_event_id + AND sample_cna_event.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND sample_cna_event.sample_id = alteration_driver_annotation.sample_id - + @@ -238,18 +240,18 @@ LEFT JOIN alteration_driver_annotation ON - structural_variant.INTERNAL_ID = alteration_driver_annotation.ALTERATION_EVENT_ID - AND structural_variant.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - AND structural_variant.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID + structural_variant.internal_id = alteration_driver_annotation.alteration_event_id + AND structural_variant.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND structural_variant.sample_id = alteration_driver_annotation.sample_id ( - structural_variant.SITE2_ENTREZ_GENE_ID != structural_variant.SITE1_ENTREZ_GENE_ID + structural_variant.site2_entrez_gene_id != structural_variant.site1_entrez_gene_id OR - structural_variant.SITE1_ENTREZ_GENE_ID IS NULL + structural_variant.site1_entrez_gene_id IS NULL ) @@ -260,14 +262,14 @@ - OR LOWER(DRIVER_FILTER) = 'putative_driver' + OR LOWER(driver_filter) = 'putative_driver' - OR LOWER(DRIVER_FILTER) = 'putative_passenger' + OR LOWER(driver_filter) = 'putative_passenger' - OR DRIVER_FILTER IS NULL - OR LOWER(DRIVER_FILTER) IN ('unknown', 'na', '') + OR driver_filter IS NULL + OR LOWER(driver_filter) IN ('unknown', 'na', '') @@ -280,22 +282,20 @@ - + - + - OR DRIVER_TIERS_FILTER IN - - #{item} - + OR driver_tiers_filter IN + #{item} - OR DRIVER_TIERS_FILTER IS NULL - OR LOWER(DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR driver_tiers_filter IS NULL + OR LOWER(driver_tiers_filter) IN ('', 'na', 'unknown') @@ -307,7 +307,7 @@ - + @@ -316,15 +316,15 @@ OR - LOWER(mutation.MUTATION_STATUS) LIKE '%germline%' + LOWER(mutation.mutation_status) LIKE '%germline%' OR - LOWER(mutation.MUTATION_STATUS) = 'somatic' + LOWER(mutation.mutation_status) = 'somatic' OR - (LOWER(mutation.MUTATION_STATUS) != 'somatic' AND LOWER(mutation.MUTATION_STATUS) NOT LIKE '%germline%') + (LOWER(mutation.mutation_status) != 'somatic' AND LOWER(mutation.mutation_status) NOT LIKE '%germline%') @@ -345,15 +345,15 @@ OR - LOWER(SV_STATUS) = 'germline' + LOWER(sv_status) = 'germline' OR - LOWER(SV_STATUS) = 'somatic' + LOWER(sv_status) = 'somatic' OR - LOWER(SV_STATUS) NOT IN ('germline', 'somatic') + LOWER(sv_status) NOT IN ('germline', 'somatic') @@ -372,64 +372,59 @@ AND NULL - AND JoinedTable.ENTREZ_GENE_ID IN - - #{entrezGeneId} - + AND JoinedTable.entrez_gene_id IN + #{entrezGeneId} - + AND NULL - AND cna_event.ENTREZ_GENE_ID IN - - #{entrezGeneId} - + AND cna_event.entrez_gene_id IN + #{entrezGeneId} SELECT - as CASE_ID, - mutation.ENTREZ_GENE_ID, - gene.HUGO_GENE_SYMBOL, - mutation_event.MUTATION_TYPE - FROM mutation - INNER JOIN mutation_event ON mutation_event.MUTATION_EVENT_ID = mutation.MUTATION_EVENT_ID - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID - INNER JOIN genetic_profile ON mutation.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON sample.INTERNAL_ID = mutation.SAMPLE_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID + AS case_id, + mutation.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + mutation_event.mutation_type + FROM + mutation + INNER JOIN mutation_event ON mutation_event.mutation_event_id = mutation.mutation_event_id + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id + INNER JOIN genetic_profile ON mutation.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON sample.internal_id = mutation.sample_id + INNER JOIN patient ON sample.patient_id = patient.internal_id NULL - LOWER(mutation_event.MUTATION_TYPE) + LOWER(mutation_event.mutation_type) - - NOT IN - - - IN - - - - LOWER(#{type}) - + + NOT IN + + + IN + + + LOWER(#{type}) - + @@ -437,57 +432,56 @@ SELECT - as CASE_ID, - cna_event.ENTREZ_GENE_ID, - gene.HUGO_GENE_SYMBOL, - CAST(cna_event.ALTERATION AS CHAR(3)) - FROM cna_event - INNER JOIN sample_cna_event ON cna_event.CNA_EVENT_ID = sample_cna_event.CNA_EVENT_ID - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID - INNER JOIN genetic_profile ON sample_cna_event.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN patient ON patient.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID - INNER JOIN sample ON sample.PATIENT_ID = patient.INTERNAL_ID AND sample.INTERNAL_ID = sample_cna_event.SAMPLE_ID - INNER JOIN cancer_study ON cancer_study.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID + AS case_id, + cna_event.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + CAST(cna_event.alteration AS CHAR(3)) + FROM + cna_event + INNER JOIN sample_cna_event ON cna_event.cna_event_id = sample_cna_event.cna_event_id + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id + INNER JOIN genetic_profile ON sample_cna_event.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN patient ON patient.cancer_study_id = genetic_profile.cancer_study_id + INNER JOIN sample ON sample.patient_id = patient.internal_id AND sample.internal_id = sample_cna_event.sample_id + INNER JOIN cancer_study ON cancer_study.cancer_study_id = genetic_profile.cancer_study_id NULL - cna_event.ALTERATION IN - - #{type} - + cna_event.alteration IN + #{type} - + - + - SELECT - caseUniqueId as "CASE_ID", - entrezGeneId as "ENTREZ_GENE_ID", - hugoGeneSymbol as "HUGO_GENE_SYMBOL", - NULL as "DUMMY_COLUMN" + SELECT + caseUniqueId AS "case_id", + entrez_gene_id, + hugo_gene_symbol, + 7 AS "DUMMY_COLUMN" FROM - (SELECT - gene.ENTREZ_GENE_ID AS "entrezGeneId", - gene.HUGO_GENE_SYMBOL AS "hugoGeneSymbol", - as "caseUniqueId", - as "caseStableId", - genetic_profile.GENETIC_PROFILE_ID as "geneticProfileId", - structural_variant.SV_STATUS as "SV_STATUS" + (SELECT + gene.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + AS "caseUniqueId", + AS "caseStableId", + genetic_profile.genetic_profile_id AS "geneticProfileId", + structural_variant.sv_status AS "sv_status" FROM structural_variant - INNER JOIN genetic_profile ON structural_variant.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON structural_variant.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN gene ON structural_variant.SITE1_ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN genetic_profile ON structural_variant.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON structural_variant.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN gene ON structural_variant.site1_entrez_gene_id = gene.entrez_gene_id @@ -495,19 +489,19 @@ UNION ALL - SELECT - gene.ENTREZ_GENE_ID AS entrezGeneId, - gene.HUGO_GENE_SYMBOL AS hugoGeneSymbol, - as caseUniqueId, - as caseStableId, - genetic_profile.GENETIC_PROFILE_ID as geneticProfileId, - structural_variant.SV_STATUS as SV_STATUS + SELECT + gene.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + AS caseUniqueId, + AS caseStableId, + genetic_profile.genetic_profile_id AS geneticProfileId, + structural_variant.sv_status AS sv_status FROM structural_variant - INNER JOIN genetic_profile ON structural_variant.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON structural_variant.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN gene ON structural_variant.SITE2_ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN genetic_profile ON structural_variant.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON structural_variant.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN gene ON structural_variant.site2_entrez_gene_id = gene.entrez_gene_id @@ -521,7 +515,7 @@ - + @@ -534,15 +528,11 @@ AND ${geneticProfileIdentifier} = #{${identifiers}[0].molecularProfileId} AND IN - - #{id.caseId} - + #{id.caseId} - AND (${geneticProfileIdentifier}, ) IN - - (#{id.molecularProfileId}, #{id.caseId}) - + AND (${geneticProfileIdentifier},) IN + (#{id.molecularProfileId},#{id.caseId}) @@ -552,10 +542,10 @@ - sample.STABLE_ID + sample.stable_id - patient.STABLE_ID + patient.stable_id @@ -563,10 +553,10 @@ - sample.INTERNAL_ID + sample.internal_id - patient.INTERNAL_ID + patient.internal_id @@ -574,26 +564,27 @@ caseStableId - + caseUniqueId - + SELECT - alteration_driver_annotation.ALTERATION_EVENT_ID as alterationEventId, - alteration_driver_annotation.GENETIC_PROFILE_ID as geneticProfileId, - alteration_driver_annotation.SAMPLE_ID as sampleId, - alteration_driver_annotation.DRIVER_FILTER as driverFilter, - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION as driverFilterAnnotation, - alteration_driver_annotation.DRIVER_TIERS_FILTER as driverTiersFilter, - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION as driverTiersFilterAnnotation + alteration_driver_annotation.alteration_event_id as alterationEventId, + alteration_driver_annotation.genetic_profile_id as geneticProfileId, + alteration_driver_annotation.sample_id as sampleId, + alteration_driver_annotation.driver_filter as driverFilter, + alteration_driver_annotation.driver_filter_annotation as driverFilterAnnotation, + alteration_driver_annotation.driver_tiers_filter as driverTiersFilter, + alteration_driver_annotation.driver_tiers_filter_annotation as driverTiersFilterAnnotation FROM alteration_driver_annotation INNER JOIN genetic_profile ON - genetic_profile.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID + genetic_profile.genetic_profile_id = alteration_driver_annotation.genetic_profile_id - genetic_profile.STABLE_ID IN - - #{id} - + genetic_profile.stable_id IN + #{id} - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/CancerTypeMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/CancerTypeMapper.xml index 138ae3932bc..4aa626cab13 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/CancerTypeMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/CancerTypeMapper.xml @@ -4,16 +4,16 @@ - type_of_cancer.TYPE_OF_CANCER_ID AS "${prefix}typeOfCancerId" + type_of_cancer.type_of_cancer_id AS "${prefix}typeOfCancerId" , - type_of_cancer.NAME AS "${prefix}name", - type_of_cancer.DEDICATED_COLOR AS "${prefix}dedicatedColor", - type_of_cancer.SHORT_NAME AS "${prefix}shortName", - type_of_cancer.PARENT AS "${prefix}parent" + type_of_cancer.name AS "${prefix}name", + type_of_cancer.dedicated_color AS "${prefix}dedicatedColor", + type_of_cancer.short_name AS "${prefix}shortName", + type_of_cancer.parent AS "${prefix}parent" - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml index 8dbdbc9a942..d66596b9744 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml @@ -4,49 +4,45 @@ - clinical_attribute_meta.ATTR_ID AS "${prefix}attrId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier", - clinical_attribute_meta.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - clinical_attribute_meta.PATIENT_ATTRIBUTE AS "${prefix}patientAttribute", - clinical_attribute_meta.DISPLAY_NAME AS "${prefix}displayName" + clinical_attribute_meta.attr_id AS "${prefix}attrId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier", + clinical_attribute_meta.cancer_study_id AS "${prefix}cancerStudyId", + clinical_attribute_meta.patient_attribute AS "${prefix}patientAttribute", + clinical_attribute_meta.display_name AS "${prefix}displayName" , - clinical_attribute_meta.DESCRIPTION AS "${prefix}description", - clinical_attribute_meta.DATATYPE AS "${prefix}datatype", - clinical_attribute_meta.PRIORITY AS "${prefix}priority" + clinical_attribute_meta.description AS "${prefix}description", + clinical_attribute_meta.datatype AS "${prefix}datatype", + clinical_attribute_meta.priority AS "${prefix}priority" - INNER JOIN sample ON clinical_sample.INTERNAL_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN sample ON clinical_sample.internal_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - INNER JOIN patient ON clinical_patient.INTERNAL_ID = patient.INTERNAL_ID - INNER JOIN sample ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON clinical_patient.internal_id = patient.internal_id + INNER JOIN sample ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier, sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) @@ -54,12 +50,11 @@ - sample.INTERNAL_ID IN + sample.internal_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID = #{sampleListId} - AND sample_list_list.SAMPLE_ID = sample.INTERNAL_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id = #{sampleListId} ) @@ -70,20 +65,18 @@ FROM clinical_attribute_meta - INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON clinical_attribute_meta.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + cancer_study.cancer_study_identifier IN + #{item} ORDER BY "${sortBy}" ${direction} - ORDER BY clinical_attribute_meta.ATTR_ID ASC + ORDER BY clinical_attribute_meta.attr_id ASC LIMIT #{limit} OFFSET #{offset} @@ -94,13 +87,11 @@ SELECT COUNT(*) AS "totalCount" FROM clinical_attribute_meta - INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON clinical_attribute_meta.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + cancer_study.cancer_study_identifier IN + #{item} @@ -111,70 +102,66 @@ FROM clinical_attribute_meta - INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - WHERE clinical_attribute_meta.ATTR_ID = #{clinicalAttributeId} - AND cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + INNER JOIN cancer_study ON clinical_attribute_meta.cancer_study_id = cancer_study.cancer_study_id + WHERE clinical_attribute_meta.attr_id = #{clinicalAttributeId} + AND cancer_study.cancer_study_identifier = #{studyId} - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalDataMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalDataMapper.xml index bfe06321aff..e0ef17a4253 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalDataMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalDataMapper.xml @@ -4,14 +4,14 @@ - clinical_sample.INTERNAL_ID AS "${prefix}internalId", - sample.STABLE_ID AS "${prefix}sampleId", - patient.STABLE_ID AS "${prefix}patientId", - clinical_sample.ATTR_ID AS "${prefix}attrId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}studyId" + clinical_sample.internal_id AS "${prefix}internalId", + sample.stable_id AS "${prefix}sampleId", + patient.stable_id AS "${prefix}patientId", + clinical_sample.attr_id AS "${prefix}attrId", + cancer_study.cancer_study_identifier AS "${prefix}studyId" - , clinical_sample.ATTR_VALUE AS "${prefix}attrValue" + , clinical_sample.attr_value AS "${prefix}attrValue" , @@ -23,13 +23,13 @@ - clinical_patient.INTERNAL_ID AS "${prefix}internalId", - patient.STABLE_ID AS "${prefix}patientId", - clinical_patient.ATTR_ID AS "${prefix}attrId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}studyId" + clinical_patient.internal_id AS "${prefix}internalId", + patient.stable_id AS "${prefix}patientId", + clinical_patient.attr_id AS "${prefix}attrId", + cancer_study.cancer_study_identifier AS "${prefix}studyId" - , clinical_patient.ATTR_VALUE AS "${prefix}attrValue" + , clinical_patient.attr_value AS "${prefix}attrValue" , @@ -38,48 +38,46 @@ - - + FROM clinical_sample - INNER JOIN sample ON clinical_sample.INTERNAL_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN sample ON clinical_sample.internal_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + + + + + LEFT JOIN clinical_patient ON clinical_patient.internal_id = patient.internal_id FROM clinical_patient - INNER JOIN patient ON clinical_patient.INTERNAL_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON clinical_patient.internal_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier, sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - AND clinical_sample.ATTR_ID IN - - #{item} - + AND clinical_sample.attr_id IN + #{item} @@ -87,60 +85,28 @@ - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - patient.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + patient.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, patient.STABLE_ID) IN - - (#{studyIds[${i}]}, #{patientIds[${i}]}) - + (cancer_study.cancer_study_identifier, patient.stable_id) IN + (#{studyIds[${i}]},#{patientIds[${i}]}) - AND clinical_patient.ATTR_ID IN - - #{item} - + AND clinical_patient.attr_id IN + #{item} - - - - - + SELECT count(*) as count, - clinical_sample.ATTR_ID as attributeId, - clinical_sample.ATTR_VALUE as value + clinical_sample.attr_id as attributeId, + clinical_sample.attr_value as value - GROUP BY clinical_sample.ATTR_ID, clinical_sample.ATTR_VALUE + GROUP BY clinical_sample.attr_id, clinical_sample.attr_value - + SELECT + + + + + - - SELECT - DISTINCT sample.INTERNAL_ID sampleInternalId - FROM sample - INNER JOIN patient ON patient.INTERNAL_ID = sample.PATIENT_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN clinical_sample cs on sample.INTERNAL_ID = cs.INTERNAL_ID - INNER JOIN clinical_patient cp on patient.INTERNAL_ID = cp.INTERNAL_ID + + + + INNER JOIN ( + SELECT DISTINCT clinical_sample.internal_id + + + , sample.stable_id AS sort_by + + + , patient.stable_id AS sort_by + + + + + , CASE + WHEN clinical_sample.attr_id = #{sortBy} THEN clinical_sample.attr_value + WHEN clinical_patient.attr_id = #{sortBy} THEN clinical_patient.attr_value + ELSE NULL + END AS sort_by + + + - AND ( - cs.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') - OR cp.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') - OR sample.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') - OR patient.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') - ) - - - - - - SELECT sample.INTERNAL_ID sampleInternalId, sample.STABLE_ID sampleId, patient.STABLE_ID patientId, clinical_patient.ATTR_ID sortAttrId, + + AND + clinical_sample.attr_value LIKE CONCAT('%', #{searchTerm}, '%') + + + - CONVERT(clinical_patient.ATTR_VALUE, DECIMAL) sortAttrValue + + ORDER BY ISNULL(sort_by), sort_by ${direction} - - clinical_patient.ATTR_VALUE sortAttrValue - - - FROM sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - LEFT JOIN clinical_patient ON patient.INTERNAL_ID = clinical_patient.INTERNAL_ID AND clinical_patient.ATTR_ID = #{sortAttrId} - - - SELECT sample.INTERNAL_ID sampleInternalId, sample.STABLE_ID sampleId, patient.STABLE_ID patientId, clinical_sample.ATTR_ID sortAttrId, - - - CONVERT(clinical_sample.ATTR_VALUE, DECIMAL) sortAttrValue + + ORDER BY sort_by ${direction} NULLS LAST - - clinical_sample.ATTR_VALUE sortAttrValue - - FROM clinical_sample - INNER JOIN sample ON clinical_sample.INTERNAL_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - WHERE clinical_sample.ATTR_ID = #{sortAttrId} - - + + + + LIMIT #{limit} OFFSET #{offset} + + ) AS sample_id_subquery + ON clinical_sample.internal_id = sample_id_subquery.internal_id diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml index 828500a579c..2d41068d9a3 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml @@ -2,35 +2,35 @@ - + - clinical_event.CLINICAL_EVENT_ID AS "clinicalEventId", - clinical_event.EVENT_TYPE AS "eventType", - patient.STABLE_ID AS "patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId" + clinical_event.clinical_event_id AS "clinicalEventId", + clinical_event.event_type AS "eventType", + patient.stable_id AS "patientId", + cancer_study.cancer_study_identifier AS "studyId" , - clinical_event.START_DATE AS "startDate", - clinical_event.STOP_DATE AS "stopDate" + clinical_event.start_date AS "startDate", + clinical_event.stop_date AS "stopDate" FROM clinical_event - INNER JOIN patient ON clinical_event.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON clinical_event.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} - AND patient.STABLE_ID = #{patientId} + cancer_study.cancer_study_identifier = #{studyId} + AND patient.stable_id = #{patientId} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} @@ -43,7 +43,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY clinical_event.PATIENT_ID ASC + ORDER BY clinical_event.patient_id ASC LIMIT #{limit} OFFSET #{offset} @@ -59,16 +59,14 @@ @@ -82,59 +80,47 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY clinical_event.PATIENT_ID ASC + ORDER BY clinical_event.patient_id ASC LIMIT #{limit} OFFSET #{offset} - + - + - - - - - - - - - - - diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/CopyNumberSegmentMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/CopyNumberSegmentMapper.xml index 58e2a37da07..2ca4a4fe0a7 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/CopyNumberSegmentMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/CopyNumberSegmentMapper.xml @@ -2,67 +2,67 @@ - + - copy_number_seg.SEG_ID AS "segId", - copy_number_seg.CANCER_STUDY_ID AS "cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "cancerStudyIdentifier", - copy_number_seg.SAMPLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - sample.STABLE_ID AS "sampleStableId", - copy_number_seg.CHR AS "chr", - copy_number_seg.START AS "start", - copy_number_seg.END AS "end", - copy_number_seg.NUM_PROBES AS "numProbes", - copy_number_seg.SEGMENT_MEAN AS "segmentMean" + copy_number_seg.seg_id AS "segId", + copy_number_seg.cancer_study_id AS "cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudyIdentifier", + copy_number_seg.sample_id AS "sampleId", + patient.stable_id AS "patientId", + sample.stable_id AS "sampleStableId", + copy_number_seg.chr AS "chr", + copy_number_seg.start AS "start", + copy_number_seg.end AS "end", + copy_number_seg.num_probes AS "numProbes", + copy_number_seg.segment_mean AS "segmentMean" FROM copy_number_seg - INNER JOIN cancer_study ON copy_number_seg.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN sample ON copy_number_seg.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID + INNER JOIN cancer_study ON copy_number_seg.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN sample ON copy_number_seg.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id - + - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier, sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - + - - + + - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/CosmicCountMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/CosmicCountMapper.xml index df0fe7e0fe3..77b15dc79b7 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/CosmicCountMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/CosmicCountMapper.xml @@ -2,20 +2,18 @@ - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/DataAccessTokenMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/DataAccessTokenMapper.xml index f6aea8ca139..5821f98b071 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/DataAccessTokenMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/DataAccessTokenMapper.xml @@ -4,10 +4,10 @@ - data_access_tokens.TOKEN AS "${prefix}token", - data_access_tokens.USERNAME AS "${prefix}username", - data_access_tokens.EXPIRATION AS "${prefix}expiration", - data_access_tokens.CREATION AS "${prefix}creation" + data_access_tokens.token AS "${prefix}token", + data_access_tokens.username AS "${prefix}username", + data_access_tokens.expiration AS "${prefix}expiration", + data_access_tokens.creation AS "${prefix}creation" DELETE FROM data_access_tokens - WHERE TOKEN = #{token} + WHERE token = #{token} DELETE FROM data_access_tokens - WHERE USERNAME = #{username} + WHERE username = #{username} INSERT - INTO data_access_tokens(TOKEN, USERNAME, EXPIRATION, CREATION) + INTO data_access_tokens(token, username, expiration, creation) VALUES (#{token}, #{username}, #{expiration}, #{creation}) diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml index 3060a8a389e..a3222ce2e93 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml @@ -4,83 +4,72 @@ - cna_event.ENTREZ_GENE_ID as entrezGeneId, - cna_event.ALTERATION AS "alteration", - genetic_profile.STABLE_ID AS "molecularProfileId", - sample_cna_event.ANNOTATION_JSON as annotationJson, - sample.STABLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId", - alteration_driver_annotation.DRIVER_FILTER AS "driverFilter", - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION AS "driverFilterAnnotation", - alteration_driver_annotation.DRIVER_TIERS_FILTER AS "driverTiersFilter", - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION AS "driverTiersFilterAnnotation" + cna_event.entrez_gene_id as entrezGeneId, + cna_event.alteration AS "alteration", + genetic_profile.stable_id AS "molecularProfileId", + sample_cna_event.annotation_json as annotationJson, + sample.stable_id AS "sampleId", + patient.stable_id AS "patientId", + cancer_study.cancer_study_identifier AS "studyId", + alteration_driver_annotation.driver_filter AS "driverFilter", + alteration_driver_annotation.driver_filter_annotation AS "driverFilterAnnotation", + alteration_driver_annotation.driver_tiers_filter AS "driverTiersFilter", + alteration_driver_annotation.driver_tiers_filter_annotation AS "driverTiersFilterAnnotation" , - + FROM cna_event - INNER JOIN sample_cna_event ON cna_event.CNA_EVENT_ID = sample_cna_event.CNA_EVENT_ID - INNER JOIN genetic_profile ON sample_cna_event.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON sample_cna_event.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN sample_cna_event ON cna_event.cna_event_id = sample_cna_event.cna_event_id + INNER JOIN genetic_profile ON sample_cna_event.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON sample_cna_event.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id LEFT JOIN alteration_driver_annotation ON - sample_cna_event.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - and sample_cna_event.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID - and sample_cna_event.CNA_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID + sample_cna_event.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + and sample_cna_event.sample_id = alteration_driver_annotation.sample_id + and sample_cna_event.cna_event_id = alteration_driver_annotation.alteration_event_id - genetic_profile.STABLE_ID = #{molecularProfileId} + genetic_profile.stable_id = #{molecularProfileId} - AND sample.STABLE_ID IN - - #{item} - + AND sample.stable_id IN + #{item} - AND cna_event.ENTREZ_GENE_ID IN - - #{item} - + AND cna_event.entrez_gene_id IN + #{item} - AND cna_event.ALTERATION IN - - #{item} - + AND cna_event.alteration IN + #{item} - genetic_profile.STABLE_ID = #{molecularProfileId} - AND sample_cna_event.SAMPLE_ID IN + genetic_profile.stable_id = #{molecularProfileId} + AND sample_cna_event.sample_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID = #{sampleListId} - AND sample_list_list.SAMPLE_ID = sample_cna_event.SAMPLE_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id = #{sampleListId} ) - AND cna_event.ENTREZ_GENE_ID IN - - #{item} - + AND cna_event.entrez_gene_id IN + #{item} - AND cna_event.ALTERATION IN - - #{item} - + AND cna_event.alteration IN + #{item} @@ -88,29 +77,21 @@ - genetic_profile.STABLE_ID = #{molecularProfileIds[0]} AND - sample.STABLE_ID IN - - #{item} - + genetic_profile.stable_id = #{molecularProfileIds[0]} AND + sample.stable_id IN + #{item} - (sample.STABLE_ID, genetic_profile.STABLE_ID) IN - - (#{sampleIds[${i}]}, #{molecularProfileIds[${i}]}) - + (sample.stable_id, genetic_profile.stable_id) IN + (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) - AND cna_event.ENTREZ_GENE_ID IN - - #{item} - + AND cna_event.entrez_gene_id IN + #{item} - AND cna_event.ALTERATION IN - - #{item} - + AND cna_event.alteration IN + #{item} @@ -120,21 +101,21 @@ AND - ( cna_event.ENTREZ_GENE_ID = '${geneFilterQuery.getEntrezGeneId()}' + ( cna_event.entrez_gene_id = '${geneFilterQuery.getEntrezGeneId()}' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_driver' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_driver' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_passenger' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_passenger' - OR alteration_driver_annotation.DRIVER_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) IN ('unknown', 'na', '') + OR alteration_driver_annotation.driver_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_filter) IN ('unknown', 'na', '') @@ -150,20 +131,18 @@ - AND NOT alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - AND NOT LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + AND NOT alteration_driver_annotation.driver_tiers_filter IS NULL + AND NOT LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IN - - #{item} - + OR alteration_driver_annotation.driver_tiers_filter IN + #{item} - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR alteration_driver_annotation.driver_tiers_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') @@ -178,10 +157,8 @@ - OR cna_event.ALTERATION IN - - ${item.getCode()} - + OR cna_event.alteration IN + ${item.getCode()} @@ -198,7 +175,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -215,7 +192,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -225,7 +202,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -235,7 +212,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -249,30 +226,27 @@ diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/GeneMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/GeneMapper.xml index eb9bbf1f24a..3947ebd4cbc 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/GeneMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/GeneMapper.xml @@ -4,34 +4,34 @@ - gene.ENTREZ_GENE_ID AS "${prefix}entrezGeneId", - gene.HUGO_GENE_SYMBOL AS "${prefix}hugoGeneSymbol" + gene.entrez_gene_id AS "${prefix}entrezGeneId", + gene.hugo_gene_symbol AS "${prefix}hugoGeneSymbol" , - gene.TYPE AS "${prefix}type" + gene.type AS "${prefix}type" FROM gene - INNER JOIN gene_alias ON gene.ENTREZ_GENE_ID = gene_alias.ENTREZ_GENE_ID + INNER JOIN gene_alias ON gene.entrez_gene_id = gene_alias.entrez_gene_id - gene_alias.GENE_ALIAS = #{alias} + gene_alias.gene_alias = #{alias} - gene.HUGO_GENE_SYMBOL like CONCAT('%', #{item}, '%') + gene.hugo_gene_symbol like CONCAT('%', #{item}, '%') - + - + @@ -115,10 +115,8 @@ FROM gene - gene.ENTREZ_GENE_ID IN - - #{item} - + gene.entrez_gene_id IN + #{item} FALSE @@ -132,10 +130,8 @@ FROM gene - gene.ENTREZ_GENE_ID IN - - #{item} - + gene.entrez_gene_id IN + #{item} FALSE @@ -151,10 +147,8 @@ FROM gene - gene.HUGO_GENE_SYMBOL IN - - #{item} - + gene.hugo_gene_symbol IN + #{item} FALSE @@ -168,10 +162,8 @@ FROM gene - gene.HUGO_GENE_SYMBOL IN - - #{item} - + gene.hugo_gene_symbol IN + #{item} FALSE diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml index 96a1d434c15..f99ebe2e9cd 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/GenePanelMapper.xml @@ -2,34 +2,34 @@ - + - gene_panel.INTERNAL_ID AS "internalId", - gene_panel.STABLE_ID AS "stableId" + gene_panel.internal_id AS "internalId", + gene_panel.stable_id AS "stableId" , - gene_panel.DESCRIPTION AS "description" + gene_panel.description AS "description" - gene_panel.STABLE_ID AS "genePanelId", - sample.STABLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId", - genetic_profile.STABLE_ID AS "molecularProfileId", - sample_profile.GENETIC_PROFILE_ID IS NOT NULL AS "profiled" + gene_panel.stable_id AS "genePanelId", + sample.stable_id AS "sampleId", + patient.stable_id AS "patientId", + cancer_study.cancer_study_identifier AS "studyId", + genetic_profile.stable_id AS "molecularProfileId", + sample_profile.genetic_profile_id IS NOT NULL AS "profiled" FROM sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - LEFT JOIN genetic_profile ON cancer_study.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID - LEFT JOIN sample_profile ON sample_profile.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID AND sample.INTERNAL_ID = sample_profile.SAMPLE_ID - LEFT JOIN gene_panel ON sample_profile.PANEL_ID = gene_panel.INTERNAL_ID + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + LEFT JOIN genetic_profile ON cancer_study.cancer_study_id = genetic_profile.cancer_study_id + LEFT JOIN sample_profile ON sample_profile.genetic_profile_id = genetic_profile.genetic_profile_id AND sample.internal_id = sample_profile.sample_id + LEFT JOIN gene_panel ON sample_profile.panel_id = gene_panel.internal_id - + - + - + - + @@ -121,10 +115,8 @@ WHERE - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - SELECT genetic_entity.STABLE_ID as stableId, - genetic_entity.ENTITY_TYPE as entityType + SELECT genetic_entity.stable_id as stableId, + genetic_entity.entity_type as entityType FROM genetic_entity - genetic_entity.STABLE_ID IN - - #{item} - + genetic_entity.stable_id IN + #{item} diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/GenesetHierarchyMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/GenesetHierarchyMapper.xml index 6ed4252ada4..6b49ae26a05 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/GenesetHierarchyMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/GenesetHierarchyMapper.xml @@ -4,58 +4,54 @@ - a.NODE_ID AS nodeId, - a.NODE_NAME AS nodeName, - a.PARENT_ID AS parentId, - b.NODE_NAME AS parentNodeName + a.node_id AS nodeId, + a.node_name AS nodeName, + a.parent_id AS parentId, + b.node_name AS parentNodeName - + - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/GenesetMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/GenesetMapper.xml index 8c1fe553431..3b336f47c9d 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/GenesetMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/GenesetMapper.xml @@ -4,11 +4,11 @@ - geneset.ID AS "${prefix}internalId", - geneset.EXTERNAL_ID AS "${prefix}genesetId", - geneset.NAME as "${prefix}name", - geneset.DESCRIPTION as "${prefix}description", - geneset.REF_LINK as "${prefix}refLink" + geneset.id AS "${prefix}internalId", + geneset.external_id AS "${prefix}genesetId", + geneset.name AS "${prefix}name", + geneset.description AS "${prefix}description", + geneset.ref_link AS "${prefix}refLink" - + - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/MolecularDataMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/MolecularDataMapper.xml index 45a1e222e63..52089a3b8ac 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/MolecularDataMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/MolecularDataMapper.xml @@ -6,57 +6,49 @@ - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - AND gene.ENTREZ_GENE_ID IN - - #{item} - + AND gene.entrez_gene_id IN + #{item} - + @@ -69,24 +61,22 @@ --> @@ -94,52 +84,50 @@ @@ -147,24 +135,22 @@ @@ -177,24 +163,22 @@ --> diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/MolecularProfileMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/MolecularProfileMapper.xml index b51a2f9b5ab..ed73c799b39 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/MolecularProfileMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/MolecularProfileMapper.xml @@ -4,27 +4,36 @@ - genetic_profile.GENETIC_PROFILE_ID AS "${prefix}molecularProfileId", - genetic_profile.STABLE_ID AS "${prefix}stableId", - genetic_profile.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + genetic_profile.genetic_profile_id AS "${prefix}molecularProfileId", + genetic_profile.stable_id AS "${prefix}stableId", + genetic_profile.cancer_study_id AS "${prefix}cancerStudyId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier" , - genetic_profile.GENETIC_ALTERATION_TYPE AS "${prefix}molecularAlterationType", - genetic_profile.DATATYPE AS "${prefix}datatype", - genetic_profile.NAME AS "${prefix}name", - genetic_profile.DESCRIPTION AS "${prefix}description", - genetic_profile.SHOW_PROFILE_IN_ANALYSIS_TAB AS "${prefix}showProfileInAnalysisTab", - genetic_profile.PIVOT_THRESHOLD AS "${prefix}pivotThreshold", - genetic_profile.SORT_ORDER AS "${prefix}sortOrder", - genetic_profile.GENERIC_ASSAY_TYPE AS "${prefix}genericAssayType", - genetic_profile.PATIENT_LEVEL AS "${prefix}patientLevel" + genetic_profile.genetic_alteration_type AS "${prefix}molecularAlterationType", + genetic_profile.datatype AS "${prefix}datatype", + genetic_profile.name AS "${prefix}name", + genetic_profile.description AS "${prefix}description", + genetic_profile.show_profile_in_analysis_tab AS "${prefix}showProfileInAnalysisTab", + genetic_profile.pivot_threshold AS "${prefix}pivotThreshold", + genetic_profile.sort_order AS "${prefix}sortOrder", + genetic_profile.generic_assay_type AS "${prefix}genericAssayType", + genetic_profile.patient_level AS "${prefix}patientLevel" , - - - + cancer_study.cancer_study_id AS "cancerStudy.cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudy.cancerStudyIdentifier", + cancer_study.type_of_cancer_id AS "cancerStudy.typeOfCancerId", + cancer_study.name AS "cancerStudy.name", + cancer_study.description AS "cancerStudy.description", + cancer_study.public AS "cancerStudy.publicStudy", + cancer_study.pmid AS "cancerStudy.pmid", + cancer_study.citation AS "cancerStudy.citation", + cancer_study.groups AS "cancerStudy.groups", + cancer_study.status AS "cancerStudy.status", + cancer_study.import_date AS "cancerStudy.importDate", + reference_genome.name AS "cancerStudy.referenceGenome" @@ -34,24 +43,18 @@ FROM genetic_profile - INNER JOIN cancer_study ON genetic_profile.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN cancer_study ON genetic_profile.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - WHERE cancer_study.CANCER_STUDY_IDENTIFIER IN - - (NULL) - - - - #{item} - - + WHERE cancer_study.cancer_study_identifier IN + (NULL) + #{item} ORDER BY "${sortBy}" ${direction} - ORDER BY genetic_profile.STABLE_ID ASC + ORDER BY genetic_profile.stable_id ASC LIMIT #{limit} OFFSET #{offset} @@ -63,24 +66,22 @@ COUNT(*) AS totalCount FROM genetic_profile - INNER JOIN cancer_study ON genetic_profile.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID - WHERE cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + INNER JOIN cancer_study ON genetic_profile.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id + WHERE cancer_study.cancer_study_identifier IN + #{item} - + @@ -107,47 +106,45 @@ FROM genetic_profile - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - + - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml index de6a18dc104..1ff94cd2401 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml @@ -4,44 +4,44 @@ - genetic_profile.STABLE_ID AS "molecularProfileId", - sample.STABLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - mutation.ENTREZ_GENE_ID AS "entrezGeneId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId" + genetic_profile.stable_id AS "molecularProfileId", + sample.stable_id AS "sampleId", + patient.stable_id AS "patientId", + mutation.entrez_gene_id AS "entrezGeneId", + cancer_study.cancer_study_identifier AS "studyId" , - mutation.CENTER AS "center", - mutation.MUTATION_STATUS AS "mutationStatus", - mutation.VALIDATION_STATUS AS "validationStatus", - mutation.TUMOR_ALT_COUNT AS "tumorAltCount", - mutation.TUMOR_REF_COUNT AS "tumorRefCount", - mutation.NORMAL_ALT_COUNT AS "normalAltCount", - mutation.NORMAL_REF_COUNT AS "normalRefCount", - mutation.AMINO_ACID_CHANGE AS "aminoAcidChange", - mutation_event.CHR AS "chr", - mutation_event.START_POSITION AS "startPosition", - mutation_event.END_POSITION AS "endPosition", - mutation_event.REFERENCE_ALLELE AS "referenceAllele", - mutation_event.TUMOR_SEQ_ALLELE AS "tumorSeqAllele", - mutation_event.PROTEIN_CHANGE AS "proteinChange", - mutation_event.MUTATION_TYPE AS "mutationType", - mutation_event.NCBI_BUILD AS "ncbiBuild", - mutation_event.VARIANT_TYPE AS "variantType", - mutation_event.REFSEQ_MRNA_ID AS "refseqMrnaId", - mutation_event.PROTEIN_POS_START AS "proteinPosStart", - mutation_event.PROTEIN_POS_END AS "proteinPosEnd", - mutation_event.KEYWORD AS "keyword", - mutation.ANNOTATION_JSON AS "annotationJSON", - alteration_driver_annotation.DRIVER_FILTER AS "driverFilter", - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION AS "driverFilterAnnotation", - alteration_driver_annotation.DRIVER_TIERS_FILTER AS "driverTiersFilter", - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION as "driverTiersFilterAnnotation" + mutation.center AS "center", + mutation.mutation_status AS "mutationStatus", + mutation.validation_status AS "validationStatus", + mutation.tumor_alt_count AS "tumorAltCount", + mutation.tumor_ref_count AS "tumorRefCount", + mutation.normal_alt_count AS "normalAltCount", + mutation.normal_ref_count AS "normalRefCount", + mutation.amino_acid_change AS "aminoAcidChange", + mutation_event.chr AS "chr", + mutation_event.start_position AS "startPosition", + mutation_event.end_position AS "endPosition", + mutation_event.reference_allele AS "referenceAllele", + mutation_event.tumor_seq_allele AS "tumorSeqAllele", + mutation_event.protein_change AS "proteinChange", + mutation_event.mutation_type AS "mutationType", + mutation_event.ncbi_build AS "ncbiBuild", + mutation_event.variant_type AS "variantType", + mutation_event.refseq_mrna_id AS "refseqMrnaId", + mutation_event.protein_pos_start AS "proteinPosStart", + mutation_event.protein_pos_end AS "proteinPosEnd", + mutation_event.keyword AS "keyword", + mutation.annotation_json AS "annotationJSON", + alteration_driver_annotation.driver_filter AS "driverFilter", + alteration_driver_annotation.driver_filter_annotation AS "driverFilterAnnotation", + alteration_driver_annotation.driver_tiers_filter AS "driverTiersFilter", + alteration_driver_annotation.driver_tiers_filter_annotation as "driverTiersFilterAnnotation" , - + , @@ -49,13 +49,13 @@ - + ORDER BY "${sortBy}" ${direction} - ORDER BY genetic_profile.STABLE_ID ASC, sample.STABLE_ID ASC, mutation.ENTREZ_GENE_ID ASC + ORDER BY genetic_profile.stable_id ASC, sample.stable_id ASC, mutation.entrez_gene_id ASC LIMIT #{limit} OFFSET #{offset} @@ -64,60 +64,53 @@ FROM mutation - INNER JOIN genetic_profile ON mutation.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON mutation.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN genetic_profile ON mutation.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON mutation.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id LEFT JOIN alteration_driver_annotation ON - mutation.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - and mutation.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID - and mutation.MUTATION_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID + mutation.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND mutation.sample_id = alteration_driver_annotation.sample_id + AND mutation.mutation_event_id = alteration_driver_annotation.alteration_event_id - genetic_profile.STABLE_ID = #{molecularProfileId} + genetic_profile.stable_id = #{molecularProfileId} - AND sample.STABLE_ID IN - - #{item} - + AND sample.stable_id IN + #{item} - AND mutation.ENTREZ_GENE_ID IN - - #{item} - + AND mutation.entrez_gene_id IN + #{item} - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') - AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') + AND mutation_event.reference_allele IN ('A','T','C','G') + AND mutation_event.tumor_seq_allele IN ('A','T','C','G') - genetic_profile.STABLE_ID = #{molecularProfileId} - AND mutation.SAMPLE_ID IN + genetic_profile.stable_id = #{molecularProfileId} + AND mutation.sample_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID = #{sampleListId} - AND sample_list_list.SAMPLE_ID = mutation.SAMPLE_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id = #{sampleListId} ) - AND mutation.ENTREZ_GENE_ID IN - - #{item} - + AND mutation.entrez_gene_id IN + #{item} - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') - AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') + AND mutation_event.reference_allele IN ('A','T','C','G') + AND mutation_event.tumor_seq_allele IN ('A','T','C','G') @@ -125,49 +118,38 @@ - mutation.SAMPLE_ID IN ( - SELECT sample.INTERNAL_ID from sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN genetic_profile ON patient.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID + mutation.sample_id IN ( + SELECT sample.internal_id FROM sample + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN genetic_profile ON patient.cancer_study_id = genetic_profile.cancer_study_id WHERE - genetic_profile.STABLE_ID = #{molecularProfileIds[0]} AND - sample.STABLE_ID IN - - #{item} - + genetic_profile.stable_id = #{molecularProfileIds[0]} AND + sample.stable_id IN + #{item} - (sample.STABLE_ID, genetic_profile.STABLE_ID) IN - - (#{sampleIds[${i}]}, #{molecularProfileIds[${i}]}) - - AND genetic_profile.STABLE_ID IN - - #{item} - + (sample.stable_id, genetic_profile.stable_id) IN + (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) + AND genetic_profile.stable_id IN + #{item} - AND sample.INTERNAL_ID = mutation.SAMPLE_ID ) - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - AND mutation.ENTREZ_GENE_ID IN - - #{item} - + AND mutation.entrez_gene_id IN + #{item} - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') - AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') + AND mutation_event.reference_allele IN ('A','T','C','G') + AND mutation_event.tumor_seq_allele IN ('A','T','C','G') @@ -176,20 +158,20 @@ AND - ( mutation.ENTREZ_GENE_ID = '${geneFilterQuery.getEntrezGeneId()}' + ( mutation.entrez_gene_id = '${geneFilterQuery.getEntrezGeneId()}' - OR LOWER(mutation.MUTATION_STATUS) = 'germline' + OR LOWER(mutation.mutation_status) = 'germline' - OR LOWER(mutation.MUTATION_STATUS) = 'somatic' + OR LOWER(mutation.mutation_status) = 'somatic' - OR LOWER(mutation.MUTATION_STATUS) NOT IN ('somatic', 'germline') + OR LOWER(mutation.mutation_status) NOT IN ('somatic', 'germline') @@ -199,21 +181,21 @@ - + - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_driver' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_driver' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_passenger' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_passenger' - OR alteration_driver_annotation.DRIVER_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) IN ('unknown', 'na', '') + OR alteration_driver_annotation.driver_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_filter) IN ('unknown', 'na', '') @@ -229,20 +211,18 @@ - AND NOT alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - AND NOT LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + AND NOT alteration_driver_annotation.driver_tiers_filter IS NULL + AND NOT LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IN - - #{item} - + OR alteration_driver_annotation.driver_tiers_filter IN + #{item} - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR alteration_driver_annotation.driver_tiers_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') @@ -259,20 +239,20 @@ - allele_specific_copy_number.ASCN_INTEGER_COPY_NUMBER AS "${prefix}ascnIntegerCopyNumber", - allele_specific_copy_number.ASCN_METHOD AS "${prefix}ascnMethod", - allele_specific_copy_number.CCF_EXPECTED_COPIES_UPPER AS "${prefix}ccfExpectedCopiesUpper", - allele_specific_copy_number.CCF_EXPECTED_COPIES AS "${prefix}ccfExpectedCopies", - allele_specific_copy_number.CLONAL AS "${prefix}clonal", - allele_specific_copy_number.MINOR_COPY_NUMBER AS "${prefix}minorCopyNumber", - allele_specific_copy_number.EXPECTED_ALT_COPIES AS "${prefix}expectedAltCopies", - allele_specific_copy_number.TOTAL_COPY_NUMBER AS "${prefix}totalCopyNumber" + allele_specific_copy_number.ascn_integer_copy_number AS "${prefix}ascnIntegerCopyNumber", + allele_specific_copy_number.ascn_method AS "${prefix}ascnMethod", + allele_specific_copy_number.ccf_expected_copies_upper AS "${prefix}ccfExpectedCopiesUpper", + allele_specific_copy_number.ccf_expected_copies AS "${prefix}ccfExpectedCopies", + allele_specific_copy_number.clonal AS "${prefix}clonal", + allele_specific_copy_number.minor_copy_number AS "${prefix}minorCopyNumber", + allele_specific_copy_number.expected_alt_copies AS "${prefix}expectedAltCopies", + allele_specific_copy_number.total_copy_number AS "${prefix}totalCopyNumber" - LEFT JOIN allele_specific_copy_number ON mutation.MUTATION_EVENT_ID = allele_specific_copy_number.MUTATION_EVENT_ID - AND mutation.GENETIC_PROFILE_ID = allele_specific_copy_number.GENETIC_PROFILE_ID - AND mutation.SAMPLE_ID = allele_specific_copy_number.SAMPLE_ID + LEFT JOIN allele_specific_copy_number ON mutation.mutation_event_id = allele_specific_copy_number.mutation_event_id + AND mutation.genetic_profile_id = allele_specific_copy_number.genetic_profile_id + AND mutation.sample_id = allele_specific_copy_number.sample_id @@ -293,9 +273,9 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID + INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -303,7 +283,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY genetic_profile.STABLE_ID ASC, sample.STABLE_ID ASC, mutation.ENTREZ_GENE_ID ASC + ORDER BY genetic_profile.stable_id ASC, sample.stable_id ASC, mutation.entrez_gene_id ASC LIMIT #{limit} OFFSET #{offset} @@ -313,9 +293,9 @@ @@ -323,9 +303,9 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID + INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -336,9 +316,9 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID + INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -348,61 +328,63 @@ - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/PatientMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/PatientMapper.xml index 3b396bdfa6a..e33bc9852bf 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/PatientMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/PatientMapper.xml @@ -4,42 +4,49 @@ - patient.INTERNAL_ID AS "${prefix}internalId", - patient.STABLE_ID AS "${prefix}stableId", - patient.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + patient.internal_id AS "${prefix}internalId", + patient.stable_id AS "${prefix}stableId", + patient.cancer_study_id AS "${prefix}cancerStudyId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier" , - - - + cancer_study.cancer_study_id AS "cancerStudy.cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudy.cancerStudyIdentifier", + cancer_study.type_of_cancer_id AS "cancerStudy.typeOfCancerId", + cancer_study.name AS "cancerStudy.name", + cancer_study.description AS "cancerStudy.description", + cancer_study.public AS "cancerStudy.publicStudy", + cancer_study.pmid AS "cancerStudy.pmid", + cancer_study.citation AS "cancerStudy.citation", + cancer_study.groups AS "cancerStudy.groups", + cancer_study.status AS "cancerStudy.status", + cancer_study.import_date AS "cancerStudy.importDate", + reference_genome.name AS "cancerStudy.referenceGenome" FROM patient - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - (cancer_study.CANCER_STUDY_IDENTIFIER, patient.STABLE_ID) IN - - (#{studyIds[${i}]}, #{patientIds[${i}]}) - + (cancer_study.cancer_study_identifier,patient.stable_id) IN + (#{studyIds[${i}]},#{patientIds[${i}]}) - patient.STABLE_ID like CONCAT('%', #{item}, '%') + patient.stable_id like CONCAT('%', #{item}, '%') OR - sample.STABLE_ID like CONCAT('%', #{item}, '%') + sample.stable_id like CONCAT('%', #{item}, '%') @@ -52,17 +59,17 @@ - INNER JOIN sample ON patient.INTERNAL_ID = sample.PATIENT_ID + INNER JOIN sample ON patient.internal_id = sample.patient_id ORDER BY "${sortBy}" ${direction} - ORDER BY patient.STABLE_ID ASC + ORDER BY patient.stable_id ASC - ORDER BY CASE WHEN patient.STABLE_ID LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, patient.STABLE_ID + ORDER BY CASE WHEN patient.stable_id LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, patient.stable_id LIMIT #{limit} OFFSET #{offset} @@ -74,7 +81,7 @@ COUNT(*) AS totalCount - INNER JOIN sample ON patient.INTERNAL_ID = sample.PATIENT_ID + INNER JOIN sample ON patient.internal_id = sample.patient_id @@ -85,30 +92,26 @@ - WHERE patient.STABLE_ID = #{patientId} - AND cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + WHERE patient.stable_id = #{patientId} + AND cancer_study.cancer_study_identifier = #{studyId} @@ -37,15 +37,13 @@ FROM reference_genome_gene - INNER JOIN reference_genome ON reference_genome.REFERENCE_GENOME_ID = reference_genome_gene.REFERENCE_GENOME_ID - INNER JOIN gene ON gene.ENTREZ_GENE_ID = reference_genome_gene.ENTREZ_GENE_ID + INNER JOIN reference_genome ON reference_genome.reference_genome_id = reference_genome_gene.reference_genome_id + INNER JOIN gene ON gene.entrez_gene_id = reference_genome_gene.entrez_gene_id - gene.HUGO_GENE_SYMBOL IN - - #{item} - - AND reference_genome.NAME = #{genomeName} + gene.hugo_gene_symbol IN + #{item} + AND reference_genome.name = #{genomeName} FALSE @@ -59,34 +57,32 @@ FROM reference_genome_gene - INNER JOIN reference_genome ON reference_genome.REFERENCE_GENOME_ID = reference_genome_gene.REFERENCE_GENOME_ID - INNER JOIN gene ON gene.ENTREZ_GENE_ID = reference_genome_gene.ENTREZ_GENE_ID + INNER JOIN reference_genome ON reference_genome.reference_genome_id = reference_genome_gene.reference_genome_id + INNER JOIN gene ON gene.entrez_gene_id = reference_genome_gene.entrez_gene_id - gene.ENTREZ_GENE_ID IN - - #{item} - - AND reference_genome.NAME = #{genomeName} + gene.entrez_gene_id IN + #{item} + AND reference_genome.name = #{genomeName} FALSE - + - - - - - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/ResourceDefinitionMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/ResourceDefinitionMapper.xml index a10818544ec..cda24dcd016 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/ResourceDefinitionMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/ResourceDefinitionMapper.xml @@ -2,18 +2,18 @@ - + - resource_definition.RESOURCE_ID AS "${prefix}resourceId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier", - resource_definition.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - resource_definition.DISPLAY_NAME AS "${prefix}displayName" + resource_definition.resource_id AS "${prefix}resourceId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier", + resource_definition.cancer_study_id AS "${prefix}cancerStudyId", + resource_definition.display_name AS "${prefix}displayName" , - resource_definition.OPEN_BY_DEFAULT AS "${prefix}openByDefault", - resource_definition.DESCRIPTION AS "${prefix}description", - resource_definition.RESOURCE_TYPE AS "${prefix}resourceType", - resource_definition.PRIORITY AS "${prefix}priority" + resource_definition.open_by_default AS "${prefix}openByDefault", + resource_definition.description AS "${prefix}description", + resource_definition.resource_type AS "${prefix}resourceType", + resource_definition.priority AS "${prefix}priority" @@ -23,17 +23,15 @@ FROM resource_definition - INNER JOIN cancer_study ON resource_definition.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON resource_definition.cancer_study_id = cancer_study.cancer_study_id NULL - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{id} - + cancer_study.cancer_study_identifier IN + #{id} @@ -41,7 +39,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY resource_definition.RESOURCE_ID ASC + ORDER BY resource_definition.resource_id ASC LIMIT #{limit} OFFSET #{offset} @@ -54,13 +52,13 @@ FROM resource_definition - INNER JOIN cancer_study ON resource_definition.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON resource_definition.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} - AND resource_definition.RESOURCE_ID = #{resourceId} + AND resource_definition.resource_id = #{resourceId} diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/SampleListMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/SampleListMapper.xml index ffb47f850f5..756cf5dc124 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/SampleListMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/SampleListMapper.xml @@ -4,15 +4,16 @@ - sample_list.LIST_ID AS "${prefix}listId", - sample_list.STABLE_ID AS "${prefix}stableId" + + ANY_VALUE(sample_list.list_id) AS "${prefix}listId", + ANY_VALUE(sample_list.stable_id) AS "${prefix}stableId" , - sample_list.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier", - sample_list.CATEGORY AS "${prefix}category", - sample_list.NAME AS "${prefix}name", - sample_list.DESCRIPTION AS "${prefix}description" + ANY_VALUE(sample_list.cancer_study_id) AS "${prefix}cancerStudyId", + ANY_VALUE(cancer_study.cancer_study_identifier) AS "${prefix}cancerStudyIdentifier", + ANY_VALUE(sample_list.category) AS "${prefix}category", + ANY_VALUE(sample_list.name) AS "${prefix}name", + ANY_VALUE(sample_list.description) AS "${prefix}description" , @@ -28,25 +29,22 @@ FROM sample_list - INNER JOIN cancer_study ON sample_list.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN cancer_study ON sample_list.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id WHERE FALSE - WHERE cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + WHERE cancer_study.cancer_study_identifier IN + #{item} - + ORDER BY "${sortBy}" ${direction} - ORDER BY sample_list.STABLE_ID ASC + ORDER BY sample_list.stable_id ASC LIMIT #{limit} OFFSET #{offset} @@ -58,8 +56,8 @@ COUNT(*) AS totalCount FROM sample_list - INNER JOIN cancer_study ON sample_list.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - WHERE cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + INNER JOIN cancer_study ON sample_list.cancer_study_id = cancer_study.cancer_study_id + WHERE cancer_study.cancer_study_identifier = #{studyId} @@ -69,9 +67,9 @@ FROM sample_list - INNER JOIN cancer_study ON sample_list.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID - WHERE sample_list.STABLE_ID = #{sampleListId} + INNER JOIN cancer_study ON sample_list.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id + WHERE sample_list.stable_id = #{sampleListId} diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/SampleMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/SampleMapper.xml index 21f4e86da37..d37bcfddc08 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/SampleMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/SampleMapper.xml @@ -4,65 +4,55 @@ - sample.INTERNAL_ID AS "${prefix}internalId", - sample.STABLE_ID AS "${prefix}stableId", - patient.STABLE_ID AS "${prefix}patientStableId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + sample.internal_id AS "${prefix}internalId", + sample.stable_id AS "${prefix}stableId", + patient.stable_id AS "${prefix}patientStableId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier" , - sample.SAMPLE_TYPE AS "${prefix}sampleType", - sample.PATIENT_ID AS "${prefix}patientId" + sample.sample_type AS "${prefix}sampleType", + sample.patient_id AS "${prefix}patientId" , - + FROM sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - (NULL) - - - - #{item} - - + cancer_study.cancer_study_identifier IN + (NULL) + #{item} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier,sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - AND patient.STABLE_ID = #{patientId} + AND patient.stable_id = #{patientId} AND - sample.STABLE_ID like CONCAT('%', #{item}, '%') + sample.stable_id like CONCAT('%', #{item}, '%') @@ -79,10 +69,10 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY sample.STABLE_ID ASC + ORDER BY sample.stable_id ASC - ORDER BY CASE WHEN sample.STABLE_ID LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, sample.STABLE_ID + ORDER BY CASE WHEN sample.stable_id LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, sample.stable_id LIMIT #{limit} OFFSET #{offset} @@ -95,15 +85,12 @@ - WHERE sample.INTERNAL_ID IN + WHERE sample.internal_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID IN - - #{item} - - AND sample_list_list.SAMPLE_ID = sample.INTERNAL_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id IN + #{item} ) @@ -118,15 +105,13 @@ SELECT COUNT(*) AS "totalCount" - WHERE sample.INTERNAL_ID IN + WHERE sample.internal_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID IN - - #{item} - - AND sample_list_list.SAMPLE_ID = sample.INTERNAL_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id IN + #{item} + AND sample_list_list.sample_id = sample.internal_id ) @@ -136,8 +121,8 @@ - WHERE sample.STABLE_ID = #{sampleId} - AND cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + WHERE sample.stable_id = #{sampleId} + AND cancer_study.cancer_study_identifier = #{studyId} - + @@ -189,17 +170,13 @@ WHERE - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - patient.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + patient.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, patient.STABLE_ID) IN - - (#{studyIds[${i}]}, #{patientIds[${i}]}) - + (cancer_study.cancer_study_identifier,patient.stable_id) IN + (#{studyIds[${i}]},#{patientIds[${i}]}) diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/SecurityMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/SecurityMapper.xml index 77eb4a73004..d60fcc994c2 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/SecurityMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/SecurityMapper.xml @@ -4,7 +4,7 @@ - + @@ -40,9 +40,9 @@ diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/SignificantCopyNumberRegionMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/SignificantCopyNumberRegionMapper.xml index eeea7c87f8c..a55c5d1f5b5 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/SignificantCopyNumberRegionMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/SignificantCopyNumberRegionMapper.xml @@ -2,26 +2,26 @@ - + - gistic.GISTIC_ROI_ID AS "gisticRoiId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "cancerStudyId", - gistic.CHROMOSOME AS "chromosome", - gistic.CYTOBAND AS "cytoband", - gistic.WIDE_PEAK_START AS "widePeakStart", - gistic.WIDE_PEAK_END AS "widePeakEnd", - gistic.Q_VALUE AS "qValue", - gistic.AMP AS "amp" + gistic.gistic_roi_id AS "gisticRoiId", + cancer_study.cancer_study_identifier AS "cancerStudyId", + gistic.chromosome AS "chromosome", + gistic.cytoband AS "cytoband", + gistic.wide_peak_start AS "widePeakStart", + gistic.wide_peak_end AS "widePeakEnd", + gistic.q_value AS "qValue", + gistic.amp AS "amp" FROM gistic - INNER JOIN cancer_study ON gistic.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON gistic.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} @@ -34,7 +34,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY gistic.CANCER_STUDY_ID ASC + ORDER BY gistic.cancer_study_id ASC LIMIT #{limit} OFFSET #{offset} @@ -47,20 +47,18 @@ - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/SignificantlyMutatedGeneMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/SignificantlyMutatedGeneMapper.xml index 51d26473570..e509c8a0ca3 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/SignificantlyMutatedGeneMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/SignificantlyMutatedGeneMapper.xml @@ -4,25 +4,25 @@ - mut_sig.ENTREZ_GENE_ID AS "entrezGeneId", - mut_sig.CANCER_STUDY_ID AS "cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "cancerStudyIdentifier", - gene.HUGO_GENE_SYMBOL AS "hugoGeneSymbol", - mut_sig.`RANK` AS `rank`, + mut_sig.entrez_gene_id AS "entrezGeneId", + mut_sig.cancer_study_id AS "cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudyIdentifier", + gene.hugo_gene_symbol AS "hugoGeneSymbol", + mut_sig.`rank` AS `rank`, mut_sig.NumBasesCovered AS "numBasesCovered", mut_sig.NumMutations AS "numMutations", - mut_sig.P_VALUE AS "pValue", - mut_sig.Q_VALUE AS "qValue" + mut_sig.p_value AS "pValue", + mut_sig.q_value AS "qValue" FROM mut_sig - INNER JOIN cancer_study ON mut_sig.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON mut_sig.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} @@ -30,13 +30,13 @@ SELECT - INNER JOIN gene ON mut_sig.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mut_sig.entrez_gene_id = gene.entrez_gene_id ORDER BY "${sortBy}" ${direction} - ORDER BY mut_sig.ENTREZ_GENE_ID ASC + ORDER BY mut_sig.entrez_gene_id ASC LIMIT #{limit} OFFSET #{offset} diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/StaticDataTimestampMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/StaticDataTimestampMapper.xml index d1e69e5d8b7..67e6589e42a 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/StaticDataTimestampMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/StaticDataTimestampMapper.xml @@ -6,18 +6,16 @@ - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/StructuralVariantMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/StructuralVariantMapper.xml index 0fe8bbe8955..176c129a983 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/StructuralVariantMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/StructuralVariantMapper.xml @@ -2,79 +2,73 @@ - + - genetic_profile.STABLE_ID AS "${prefix}molecularProfileId", - sample.STABLE_ID AS "${prefix}sampleId", - patient.STABLE_ID AS "${prefix}patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}studyId", - structural_variant.SITE1_ENTREZ_GENE_ID AS "${prefix}site1EntrezGeneId", - gene1.HUGO_GENE_SYMBOL AS "${prefix}site1HugoSymbol", - structural_variant.SITE1_ENSEMBL_TRANSCRIPT_ID AS "${prefix}site1EnsemblTranscriptId", - structural_variant.SITE1_CONTIG AS "${prefix}site1Contig", - structural_variant.SITE1_REGION AS "${prefix}site1Region", - structural_variant.SITE1_REGION_NUMBER AS "${prefix}site1RegionNumber", - structural_variant.SITE1_CHROMOSOME AS "${prefix}site1Chromosome", - structural_variant.SITE1_POSITION AS "${prefix}site1Position", - structural_variant.SITE1_DESCRIPTION AS "${prefix}site1Description", - structural_variant.SITE2_ENTREZ_GENE_ID AS "${prefix}site2EntrezGeneId", - gene2.HUGO_GENE_SYMBOL AS "${prefix}site2HugoSymbol", - structural_variant.SITE2_ENSEMBL_TRANSCRIPT_ID AS "${prefix}site2EnsemblTranscriptId", - structural_variant.SITE2_CONTIG AS "${prefix}site2Contig", - structural_variant.SITE2_REGION AS "${prefix}site2Region", - structural_variant.SITE2_REGION_NUMBER AS "${prefix}site2RegionNumber", - structural_variant.SITE2_CHROMOSOME AS "${prefix}site2Chromosome", - structural_variant.SITE2_POSITION AS "${prefix}site2Position", - structural_variant.SITE2_DESCRIPTION AS "${prefix}site2Description", - structural_variant.SITE2_EFFECT_ON_FRAME AS "${prefix}site2EffectOnFrame", - structural_variant.NCBI_BUILD AS "${prefix}ncbiBuild", - structural_variant.DNA_SUPPORT AS "${prefix}dnaSupport", - structural_variant.RNA_SUPPORT AS "${prefix}rnaSupport", - structural_variant.NORMAL_READ_COUNT AS "${prefix}normalReadCount", - structural_variant.TUMOR_READ_COUNT AS "${prefix}tumorReadCount", - structural_variant.NORMAL_VARIANT_COUNT AS "${prefix}normalVariantCount", - structural_variant.TUMOR_VARIANT_COUNT AS "${prefix}tumorVariantCount", - structural_variant.NORMAL_PAIRED_END_READ_COUNT AS "${prefix}normalPairedEndReadCount", - structural_variant.TUMOR_PAIRED_END_READ_COUNT AS "${prefix}tumorPairedEndReadCount", - structural_variant.NORMAL_SPLIT_READ_COUNT AS "${prefix}normalSplitReadCount", - structural_variant.TUMOR_SPLIT_READ_COUNT AS "${prefix}tumorSplitReadCount", - structural_variant.ANNOTATION AS "${prefix}annotation", - structural_variant.BREAKPOINT_TYPE AS "${prefix}breakpointType", - structural_variant.CONNECTION_TYPE AS "${prefix}connectionType", - structural_variant.EVENT_INFO AS "${prefix}eventInfo", - structural_variant.CLASS AS "${prefix}variantClass", - structural_variant.LENGTH AS "${prefix}length", - structural_variant.COMMENTS AS "${prefix}comments", - structural_variant.SV_STATUS AS "${prefix}svStatus", - structural_variant.ANNOTATION_JSON AS "${prefix}annotationJson", - alteration_driver_annotation.DRIVER_FILTER AS "${prefix}driverFilter", - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION AS "${prefix}driverFilterAnn", - alteration_driver_annotation.DRIVER_TIERS_FILTER AS "${prefix}driverTiersFilter", - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION AS "${prefix}driverTiersFilterAnn" + genetic_profile.stable_id AS "${prefix}molecularProfileId", + sample.stable_id AS "${prefix}sampleId", + patient.stable_id AS "${prefix}patientId", + cancer_study.cancer_study_identifier AS "${prefix}studyId", + structural_variant.site1_entrez_gene_id AS "${prefix}site1EntrezGeneId", + gene1.hugo_gene_symbol AS "${prefix}site1HugoSymbol", + structural_variant.site1_ensembl_transcript_id AS "${prefix}site1EnsemblTranscriptId", + structural_variant.site1_contig AS "${prefix}site1Contig", + structural_variant.site1_region AS "${prefix}site1Region", + structural_variant.site1_region_number AS "${prefix}site1RegionNumber", + structural_variant.site1_chromosome AS "${prefix}site1Chromosome", + structural_variant.site1_position AS "${prefix}site1Position", + structural_variant.site1_description AS "${prefix}site1Description", + structural_variant.site2_entrez_gene_id AS "${prefix}site2EntrezGeneId", + gene2.hugo_gene_symbol AS "${prefix}site2HugoSymbol", + structural_variant.site2_ensembl_transcript_id AS "${prefix}site2EnsemblTranscriptId", + structural_variant.site2_contig AS "${prefix}site2Contig", + structural_variant.site2_region AS "${prefix}site2Region", + structural_variant.site2_region_number AS "${prefix}site2RegionNumber", + structural_variant.site2_chromosome AS "${prefix}site2Chromosome", + structural_variant.site2_position AS "${prefix}site2Position", + structural_variant.site2_description AS "${prefix}site2Description", + structural_variant.site2_effect_on_frame AS "${prefix}site2EffectOnFrame", + structural_variant.ncbi_build AS "${prefix}ncbiBuild", + structural_variant.dna_support AS "${prefix}dnaSupport", + structural_variant.rna_support AS "${prefix}rnaSupport", + structural_variant.normal_read_count AS "${prefix}normalReadCount", + structural_variant.tumor_read_count AS "${prefix}tumorReadCount", + structural_variant.normal_variant_count AS "${prefix}normalVariantCount", + structural_variant.tumor_variant_count AS "${prefix}tumorVariantCount", + structural_variant.normal_paired_end_read_count AS "${prefix}normalPairedEndReadCount", + structural_variant.tumor_paired_end_read_count AS "${prefix}tumorPairedEndReadCount", + structural_variant.normal_split_read_count AS "${prefix}normalSplitReadCount", + structural_variant.tumor_split_read_count AS "${prefix}tumorSplitReadCount", + structural_variant.annotation AS "${prefix}annotation", + structural_variant.breakpoint_type AS "${prefix}breakpointType", + structural_variant.connection_type AS "${prefix}connectionType", + structural_variant.event_info AS "${prefix}eventInfo", + structural_variant.class AS "${prefix}variantClass", + structural_variant.length AS "${prefix}length", + structural_variant.comments AS "${prefix}comments", + structural_variant.sv_status AS "${prefix}svStatus", + structural_variant.annotation_json AS "${prefix}annotationJson", + alteration_driver_annotation.driver_filter AS "${prefix}driverFilter", + alteration_driver_annotation.driver_filter_annotation AS "${prefix}driverFilterAnn", + alteration_driver_annotation.driver_tiers_filter AS "${prefix}driverTiersFilter", + alteration_driver_annotation.driver_tiers_filter_annotation AS "${prefix}driverTiersFilterAnn" - AND + AND - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - genetic_profile.STABLE_ID = #{molecularProfileIds[0]} AND - sample.STABLE_ID IN - - #{item} - + genetic_profile.stable_id = #{molecularProfileIds[0]} AND + sample.stable_id IN + #{item} - (sample.STABLE_ID, genetic_profile.STABLE_ID) IN - - (#{sampleIds[${i}]}, #{molecularProfileIds[${i}]}) - + (sample.stable_id,genetic_profile.stable_id) IN + (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) @@ -86,32 +80,32 @@ ( - (structural_variant.SITE1_ENTREZ_GENE_ID = ${geneFilterQuery.getEntrezGeneId()} - OR structural_variant.SITE2_ENTREZ_GENE_ID = ${geneFilterQuery.getEntrezGeneId()}) + (structural_variant.site1_entrez_gene_id = ${geneFilterQuery.getEntrezGeneId()} + OR structural_variant.site2_entrez_gene_id = ${geneFilterQuery.getEntrezGeneId()}) - AND structural_variant.SITE1_ENTREZ_GENE_ID IS NULL + AND structural_variant.site1_entrez_gene_id IS NULL - AND structural_variant.SITE1_ENTREZ_GENE_ID = ${geneFilterQuery.getGene1Query().getEntrezId()} + AND structural_variant.site1_entrez_gene_id = ${geneFilterQuery.getGene1Query().getEntrezId()} AND - structural_variant.SITE2_ENTREZ_GENE_ID IS NULL + structural_variant.site2_entrez_gene_id IS NULL AND - structural_variant.SITE2_ENTREZ_GENE_ID = ${geneFilterQuery.getGene2Query().getEntrezId()} + structural_variant.site2_entrez_gene_id = ${geneFilterQuery.getGene2Query().getEntrezId()} - + @@ -120,13 +114,13 @@ - OR LOWER(structural_variant.SV_STATUS) = 'germline' + OR LOWER(structural_variant.sv_status) = 'germline' - OR LOWER(structural_variant.SV_STATUS) = 'somatic' + OR LOWER(structural_variant.sv_status) = 'somatic' - OR LOWER(structural_variant.SV_STATUS) NOT IN ('somatic', 'germline') + OR LOWER(structural_variant.sv_status) NOT IN ('somatic', 'germline') ) @@ -145,14 +139,14 @@ - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_driver' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_driver' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_passenger' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_passenger' - OR alteration_driver_annotation.DRIVER_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) IN ('unknown', 'na', '') + OR alteration_driver_annotation.driver_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_filter) IN ('unknown', 'na', '') @@ -169,20 +163,18 @@ - AND NOT alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - AND NOT LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + AND NOT alteration_driver_annotation.driver_tiers_filter IS NULL + AND NOT LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IN - - #{item} - + OR alteration_driver_annotation.driver_tiers_filter IN + #{item} - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR alteration_driver_annotation.driver_tiers_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') @@ -196,19 +188,15 @@ ) - + OR ( - structural_variant.SITE1_ENTREZ_GENE_ID in - - #{item} - - OR - structural_variant.SITE2_ENTREZ_GENE_ID IN - - #{item} - + structural_variant.site1_entrez_gene_id IN + #{item} + OR + structural_variant.site2_entrez_gene_id IN + #{item} ) @@ -218,22 +206,22 @@ OR ( - structural_variant.SITE1_ENTREZ_GENE_ID=#{item.gene1.entrezId} + structural_variant.site1_entrez_gene_id=#{item.gene1.entrezId} - structural_variant.SITE1_ENTREZ_GENE_ID IS NULL - + structural_variant.site1_entrez_gene_id IS NULL + TRUE - + AND - + - structural_variant.SITE2_ENTREZ_GENE_ID=#{item.gene2.entrezId} + structural_variant.site2_entrez_gene_id=#{item.gene2.entrezId} - structural_variant.SITE2_ENTREZ_GENE_ID IS NULL + structural_variant.site2_entrez_gene_id IS NULL TRUE @@ -249,16 +237,15 @@ FROM structural_variant - JOIN genetic_profile ON structural_variant.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - LEFT JOIN gene gene1 ON structural_variant.SITE1_ENTREZ_GENE_ID = gene1.ENTREZ_GENE_ID - LEFT JOIN gene gene2 ON structural_variant.SITE2_ENTREZ_GENE_ID = gene2.ENTREZ_GENE_ID - JOIN sample ON structural_variant.SAMPLE_ID = sample.INTERNAL_ID - JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID AND genetic_profile.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - LEFT JOIN alteration_driver_annotation ON - structural_variant.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - and structural_variant.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID - and structural_variant.INTERNAL_ID = alteration_driver_annotation.ALTERATION_EVENT_ID + JOIN genetic_profile ON structural_variant.genetic_profile_id = genetic_profile.genetic_profile_id + LEFT JOIN gene gene1 ON structural_variant.site1_entrez_gene_id = gene1.entrez_gene_id + LEFT JOIN gene gene2 ON structural_variant.site2_entrez_gene_id = gene2.entrez_gene_id + JOIN sample ON structural_variant.sample_id = sample.internal_id + JOIN patient ON sample.patient_id = patient.internal_id + JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id AND genetic_profile.cancer_study_id = cancer_study.cancer_study_id + LEFT JOIN alteration_driver_annotation ON structural_variant.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND structural_variant.sample_id = alteration_driver_annotation.sample_id + AND structural_variant.internal_id = alteration_driver_annotation.alteration_event_id @@ -266,7 +253,7 @@ - ORDER BY gene1.HUGO_GENE_SYMBOL, gene2.HUGO_GENE_SYMBOL + ORDER BY gene1.hugo_gene_symbol, gene2.hugo_gene_symbol - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/StudyMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/StudyMapper.xml index 9b580a23507..f622055c3bc 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/StudyMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/StudyMapper.xml @@ -4,92 +4,93 @@ - cancer_study.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + ANY_VALUE(cancer_study.cancer_study_id) AS "${prefix}cancerStudyId", + ANY_VALUE(cancer_study.cancer_study_identifier) AS "${prefix}cancerStudyIdentifier" , - cancer_study.TYPE_OF_CANCER_ID AS "${prefix}typeOfCancerId", - cancer_study.NAME AS "${prefix}name", - cancer_study.DESCRIPTION AS "${prefix}description", - cancer_study.PUBLIC AS "${prefix}publicStudy", - cancer_study.PMID AS "${prefix}pmid", - cancer_study.CITATION AS "${prefix}citation", - cancer_study.GROUPS AS "${prefix}groups", - cancer_study.STATUS AS "${prefix}status", - cancer_study.IMPORT_DATE AS "${prefix}importDate", - reference_genome.NAME AS "${prefix}referenceGenome" + ANY_VALUE(cancer_study.type_of_cancer_id) AS "${prefix}typeOfCancerId", + ANY_VALUE(cancer_study.name) AS "${prefix}name", + ANY_VALUE(cancer_study.description) AS "${prefix}description", + ANY_VALUE(cancer_study.public) AS "${prefix}publicStudy", + ANY_VALUE(cancer_study.pmid) AS "${prefix}pmid", + ANY_VALUE(cancer_study.citation) AS "${prefix}citation", + ANY_VALUE(cancer_study.groups) AS "${prefix}groups", + ANY_VALUE(cancer_study.status) AS "${prefix}status", + ANY_VALUE(cancer_study.import_date) AS "${prefix}importDate", + ANY_VALUE(reference_genome.name) AS "${prefix}referenceGenome" , - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_sequenced') THEN 1 ELSE NULL END) AS sequencedSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_cna') THEN 1 ELSE NULL END) AS cnaSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_rna_seq_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_rna_seq_v2_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqV2SampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_microrna') THEN 1 ELSE NULL END) AS miRnaSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_mrna') THEN 1 ELSE NULL END) AS mrnaMicroarraySampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_methylation_hm27') THEN 1 ELSE NULL END) AS methylationHm27SampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_rppa') THEN 1 ELSE NULL END) AS rppaSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_protein_quantification') THEN 1 ELSE NULL END) AS massSpectrometrySampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_3way_complete') THEN 1 ELSE NULL END) AS completeSampleCount, - IFNULL(treatment.count, 0 ) as treatmentCount, - COALESCE(structural_variant.count, 0) as structuralVariantCount, - type_of_cancer.TYPE_OF_CANCER_ID AS "typeOfCancer.typeOfCancerId" + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_sequenced') THEN 1 ELSE NULL END) AS sequencedSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_cna') THEN 1 ELSE NULL END) AS cnaSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_rna_seq_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_rna_seq_v2_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqV2SampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_microrna') THEN 1 ELSE NULL END) AS miRnaSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_mrna') THEN 1 ELSE NULL END) AS mrnaMicroarraySampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_methylation_hm27') THEN 1 ELSE NULL END) AS methylationHm27SampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_rppa') THEN 1 ELSE NULL END) AS rppaSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_protein_quantification') THEN 1 ELSE NULL END) AS massSpectrometrySampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_3way_complete') THEN 1 ELSE NULL END) AS completeSampleCount, + IFNULL(ANY_VALUE(treatment.count), 0 ) as treatmentCount, + COALESCE(ANY_VALUE(structural_variant.count), 0) as structuralVariantCount, + ANY_VALUE(type_of_cancer.type_of_cancer_id) AS "typeOfCancer.typeOfCancerId" , - type_of_cancer.NAME AS "typeOfCancer.name", - type_of_cancer.DEDICATED_COLOR AS "typeOfCancer.dedicatedColor", - type_of_cancer.SHORT_NAME AS "typeOfCancer.shortName", - type_of_cancer.PARENT AS "typeOfCancer.parent" + ANY_VALUE(type_of_cancer.name) AS "typeOfCancer.name", + ANY_VALUE(type_of_cancer.dedicated_color) AS "typeOfCancer.dedicatedColor", + ANY_VALUE(type_of_cancer.short_name) AS "typeOfCancer.shortName", + ANY_VALUE(type_of_cancer.parent) AS "typeOfCancer.parent" FROM cancer_study - INNER JOIN sample_list ON cancer_study.CANCER_STUDY_ID = sample_list.CANCER_STUDY_ID - INNER JOIN sample_list_list ON sample_list.LIST_ID = sample_list_list.LIST_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN sample_list ON cancer_study.cancer_study_id = sample_list.cancer_study_id + + INNER JOIN sample_list_list ON sample_list.list_id = sample_list_list.list_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - INNER JOIN type_of_cancer ON cancer_study.TYPE_OF_CANCER_ID = type_of_cancer.TYPE_OF_CANCER_ID - left JOIN + INNER JOIN type_of_cancer ON cancer_study.type_of_cancer_id = type_of_cancer.type_of_cancer_id + LEFT JOIN ( - SELECT Count(Distinct(clinical_event.PATIENT_ID)) as count, - patient.CANCER_STUDY_ID as CANCER_STUDY_ID + SELECT + COUNT(DISTINCT(clinical_event.patient_id)) as count, + patient.cancer_study_id as cancer_study_id FROM cancer_study - INNER JOIN patient on cancer_study.CANCER_STUDY_ID = patient.CANCER_STUDY_ID - Left Join clinical_event on clinical_event.PATIENT_ID = patient.INTERNAL_ID - WHERE clinical_event.EVENT_TYPE = 'Treatment' - GROUP BY patient.CANCER_STUDY_ID - ) as treatment on cancer_study.CANCER_STUDY_ID = treatment.CANCER_STUDY_ID + INNER JOIN patient ON cancer_study.cancer_study_id = patient.cancer_study_id + LEFT JOIN clinical_event on clinical_event.patient_id = patient.internal_id + WHERE clinical_event.event_type = 'Treatment' + GROUP BY patient.cancer_study_id + ) as treatment on cancer_study.cancer_study_id = treatment.cancer_study_id LEFT JOIN ( - SELECT COUNT(DISTINCT(structural_variant.SAMPLE_ID)) as count, - patient.CANCER_STUDY_ID as CANCER_STUDY_ID + SELECT + COUNT(DISTINCT(structural_variant.sample_id)) as count, + patient.cancer_study_id as cancer_study_id FROM cancer_study - INNER JOIN patient on cancer_study.CANCER_STUDY_ID = patient.CANCER_STUDY_ID - LEFT JOIN sample on patient.INTERNAL_ID = sample.PATIENT_ID - INNER JOIN structural_variant on structural_variant.SAMPLE_ID = sample.INTERNAL_ID - GROUP BY patient.CANCER_STUDY_ID - ) as structural_variant on structural_variant.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON cancer_study.cancer_study_id = patient.cancer_study_id + LEFT JOIN sample ON patient.internal_id = sample.patient_id + INNER JOIN structural_variant on structural_variant.sample_id = sample.internal_id + GROUP BY patient.cancer_study_id + ) as structural_variant on structural_variant.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + cancer_study.cancer_study_identifier IN + #{item} - cancer_study.NAME like CONCAT('%', #{item}, '%') OR - cancer_study.CANCER_STUDY_IDENTIFIER like CONCAT('%', #{item}, '%') OR - type_of_cancer.NAME like CONCAT('%', #{item}, '%') OR - type_of_cancer.TYPE_OF_CANCER_ID like CONCAT('%', #{item}, '%') + cancer_study.name like CONCAT('%', #{item}, '%') OR + cancer_study.cancer_study_identifier like CONCAT('%', #{item}, '%') OR + type_of_cancer.name like CONCAT('%', #{item}, '%') OR + type_of_cancer.type_of_cancer_id like CONCAT('%', #{item}, '%') @@ -102,23 +103,25 @@ , - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_all') THEN 1 ELSE NULL END) AS allSampleCount + + + 1 AS allSampleCount - GROUP BY cancer_study.CANCER_STUDY_ID + GROUP BY cancer_study.cancer_study_id ORDER BY "${sortBy}" ${direction} - ORDER BY cancer_study.CANCER_STUDY_IDENTIFIER ASC + ORDER BY cancer_study.cancer_study_identifier ASC - ORDER BY CASE WHEN cancer_study.NAME LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, - CASE WHEN cancer_study.NAME LIKE '%tcga%' THEN 0 ELSE 1 END, cancer_study.NAME + ORDER BY CASE WHEN cancer_study.name LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, + CASE WHEN cancer_study.name LIKE '%tcga%' THEN 0 ELSE 1 END, cancer_study.name LIMIT #{limit} OFFSET #{offset} @@ -130,7 +133,7 @@ COUNT(*) AS totalCount FROM cancer_study - INNER JOIN type_of_cancer ON cancer_study.TYPE_OF_CANCER_ID = type_of_cancer.TYPE_OF_CANCER_ID + INNER JOIN type_of_cancer ON cancer_study.type_of_cancer_id = type_of_cancer.type_of_cancer_id @@ -142,38 +145,37 @@ , - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_all') THEN 1 ELSE NULL END) AS allSampleCount + + + 1 AS allSampleCount - WHERE cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} - GROUP BY cancer_study.CANCER_STUDY_ID + WHERE cancer_study.cancer_study_identifier = #{studyId} - + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/TreatmentMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/TreatmentMapper.xml index 58c93613077..9658b092119 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/TreatmentMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/TreatmentMapper.xml @@ -5,48 +5,48 @@ @@ -55,13 +55,13 @@ * FROM clinical_event - INNER JOIN clinical_event_data ON clinical_event.CLINICAL_EVENT_ID = clinical_event_data.CLINICAL_EVENT_ID - INNER JOIN patient ON clinical_event.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN sample ON patient.INTERNAL_ID = sample.PATIENT_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN clinical_event_data ON clinical_event.clinical_event_id = clinical_event_data.clinical_event_id + INNER JOIN patient ON clinical_event.patient_id = patient.internal_id + INNER JOIN sample ON patient.internal_id = sample.patient_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - AND clinical_event.EVENT_TYPE = 'TREATMENT' - AND clinical_event_data.KEY = #{key} LIMIT 1 + AND clinical_event.event_type = 'TREATMENT' + AND clinical_event_data.key = #{key} LIMIT 1 ) @@ -70,47 +70,35 @@ * FROM clinical_event - INNER JOIN clinical_event_data ON clinical_event.CLINICAL_EVENT_ID = clinical_event_data.CLINICAL_EVENT_ID - INNER JOIN patient ON clinical_event.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN sample ON clinical_event_data.VALUE = sample.STABLE_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN clinical_event_data ON clinical_event.clinical_event_id = clinical_event_data.clinical_event_id + INNER JOIN patient ON clinical_event.patient_id = patient.internal_id + INNER JOIN sample ON clinical_event_data.value = sample.stable_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - AND clinical_event_data.KEY = 'SAMPLE_ID' - AND (clinical_event.EVENT_TYPE LIKE 'Sample Acquisition' OR clinical_event.EVENT_TYPE LIKE 'SPECIMEN') LIMIT 1) + AND clinical_event_data.key = 'SAMPLE_ID' + AND (clinical_event.event_type LIKE 'Sample Acquisition' OR clinical_event.event_type LIKE 'SPECIMEN') LIMIT 1) - cancer_study.CANCER_STUDY_IDENTIFIER IN - - (NULL) - - - - #{item} - - + cancer_study.cancer_study_identifier IN + (NULL) + #{item} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - - AND (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + cancer_study.cancer_study_identifier IN + #{item} + AND (cancer_study.cancer_study_identifier,sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/VariantCountMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/VariantCountMapper.xml index 92dcfc2788b..8540c51c86f 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/VariantCountMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/VariantCountMapper.xml @@ -5,25 +5,25 @@ + --fudge + SELECT hugo_gene_symbol as hugoGeneSymbol, variant_type, count(DISTINCT sample_unique_id) as numberOfAlteredCases FROM genomic_event_derived + WHERE sample_unique_id IN + ( + ${samplelist} + ) + AND genetic_profile_stable_id IN ('genie_public_mutations','genie_public_cna','genie_public_structural_variants') + GROUP BY (hugo_gene_symbol, variant_type) + + + + + +