|
4 | 4 | <mapper namespace="org.cbioportal.legacy.persistence.mybatis.MutationMapper"> |
5 | 5 |
|
6 | 6 | <sql id="select"> |
7 | | - genetic_profile.stable_id AS "molecularProfileId", |
8 | | - sample.stable_id AS "sampleId", |
9 | | - patient.stable_id AS "patientId", |
10 | | - mutation.entrez_gene_id AS "entrezGeneId", |
11 | | - cancer_study.cancer_study_identifier AS "studyId" |
| 7 | + molecularProfileId, |
| 8 | + sampleId, |
| 9 | + patientId, |
| 10 | + entrezGeneId, |
| 11 | + studyId |
12 | 12 | <if test="projection == 'SUMMARY' || projection == 'DETAILED'"> |
13 | 13 | , |
14 | | - mutation.center AS "center", |
15 | | - mutation.mutation_status AS "mutationStatus", |
16 | | - mutation.validation_status AS "validationStatus", |
17 | | - mutation.tumor_alt_count AS "tumorAltCount", |
18 | | - mutation.tumor_ref_count AS "tumorRefCount", |
19 | | - mutation.normal_alt_count AS "normalAltCount", |
20 | | - mutation.normal_ref_count AS "normalRefCount", |
21 | | - mutation.amino_acid_change AS "aminoAcidChange", |
22 | | - mutation_event.chr AS "chr", |
23 | | - mutation_event.start_position AS "startPosition", |
24 | | - mutation_event.end_position AS "endPosition", |
25 | | - mutation_event.reference_allele AS "referenceAllele", |
26 | | - mutation_event.tumor_seq_allele AS "tumorSeqAllele", |
27 | | - mutation_event.protein_change AS "proteinChange", |
28 | | - mutation_event.mutation_type AS "mutationType", |
29 | | - mutation_event.ncbi_build AS "ncbiBuild", |
30 | | - mutation_event.variant_type AS "variantType", |
31 | | - mutation_event.refseq_mrna_id AS "refseqMrnaId", |
32 | | - mutation_event.protein_pos_start AS "proteinPosStart", |
33 | | - mutation_event.protein_pos_end AS "proteinPosEnd", |
34 | | - mutation_event.keyword AS "keyword", |
35 | | - mutation.annotation_json AS "annotationJSON", |
36 | | - alteration_driver_annotation.driver_filter AS "driverFilter", |
37 | | - alteration_driver_annotation.driver_filter_annotation AS "driverFilterAnnotation", |
38 | | - alteration_driver_annotation.driver_tiers_filter AS "driverTiersFilter", |
39 | | - alteration_driver_annotation.driver_tiers_filter_annotation as "driverTiersFilterAnnotation" |
| 14 | + center, |
| 15 | + mutationStatus, |
| 16 | + validationStatus, |
| 17 | + tumorAltCount, |
| 18 | + tumorRefCount, |
| 19 | + normalAltCount, |
| 20 | + normalRefCount, |
| 21 | + aminoAcidChange, |
| 22 | + chr, |
| 23 | + startPosition, |
| 24 | + endPosition, |
| 25 | + referenceAllele, |
| 26 | + tumorSeqAllele, |
| 27 | + proteinChange, |
| 28 | + mutationType, |
| 29 | + ncbiBuild, |
| 30 | + variantType, |
| 31 | + refseqMrnaId, |
| 32 | + proteinPosStart, |
| 33 | + proteinPosEnd, |
| 34 | + keyword, |
| 35 | + annotationJSON, |
| 36 | + driverFilter, |
| 37 | + driverFilterAnnotation, |
| 38 | + driverTiersFilter, |
| 39 | + driverTiersFilterAnnotation |
40 | 40 | </if> |
41 | 41 | <if test="projection == 'DETAILED'"> |
42 | | - , |
43 | | - <include refid="org.cbioportal.legacy.persistence.mybatis.GeneMapper.select"> |
44 | | - <property name="prefix" value="GENE."/> |
45 | | - </include> |
46 | | - , |
| 42 | + , |
| 43 | + GENE.entrezGeneId, |
| 44 | + GENE.hugoGeneSymbol, |
| 45 | + GENE.type, |
47 | 46 | <include refid="getAlleleSpecificCopyNumber"> |
48 | | - <property name="prefix" value="alleleSpecificCopyNumber."/> |
49 | | - </include> |
| 47 | + <property name="prefix" value="alleleSpecificCopyNumber."/> |
| 48 | + </include> |
| 49 | + |
50 | 50 | </if> |
51 | 51 | </sql> |
52 | 52 |
|
|
55 | 55 | ORDER BY "${sortBy}" ${direction} |
56 | 56 | </if> |
57 | 57 | <if test="projection == 'ID'"> |
58 | | - ORDER BY genetic_profile.stable_id ASC, sample.stable_id ASC, mutation.entrez_gene_id ASC |
| 58 | + ORDER BY molecularProfileId ASC, sampleId ASC, entrezGeneId ASC |
59 | 59 | </if> |
60 | 60 | <if test="limit != null and limit != 0"> |
61 | 61 | LIMIT #{limit} OFFSET #{offset} |
62 | 62 | </if> |
63 | 63 | </sql> |
64 | 64 |
|
65 | 65 | <sql id="from"> |
66 | | - FROM mutation |
67 | | - INNER JOIN genetic_profile ON mutation.genetic_profile_id = genetic_profile.genetic_profile_id |
68 | | - INNER JOIN sample ON mutation.sample_id = sample.internal_id |
69 | | - INNER JOIN patient ON sample.patient_id = patient.internal_id |
70 | | - INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id |
71 | | - LEFT JOIN alteration_driver_annotation ON |
72 | | - mutation.genetic_profile_id = alteration_driver_annotation.genetic_profile_id |
73 | | - AND mutation.sample_id = alteration_driver_annotation.sample_id |
74 | | - AND mutation.mutation_event_id = alteration_driver_annotation.alteration_event_id |
| 66 | + FROM mutation_derived |
75 | 67 | </sql> |
76 | 68 |
|
77 | 69 | <sql id="where"> |
78 | 70 | <where> |
79 | | - genetic_profile.stable_id = #{molecularProfileId} |
| 71 | + molecularProfileId = #{molecularProfileId} |
80 | 72 | <if test="sampleIds != null and !sampleIds.isEmpty()"> |
81 | | - AND sample.stable_id IN |
| 73 | + AND sampleId IN |
82 | 74 | <foreach item="item" collection="sampleIds" open="(" separator="," close=")">#{item}</foreach> |
83 | 75 | </if> |
84 | 76 | <if test="_parameter.containsKey('entrezGeneIds') and entrezGeneIds != null and !entrezGeneIds.isEmpty()"> |
85 | | - AND mutation.entrez_gene_id IN |
| 77 | + AND entrezGeneId IN |
86 | 78 | <foreach item="item" collection="entrezGeneIds" open="(" separator="," close=")">#{item}</foreach> |
87 | 79 | </if> |
88 | 80 | <if test="_parameter.containsKey('geneQueries') and geneQueries != null and !geneQueries.isEmpty()"> |
89 | 81 | <include refid="whereWithGeneQueries"/> |
90 | 82 | </if> |
91 | 83 | <if test="snpOnly == true"> |
92 | | - AND mutation_event.reference_allele IN ('A','T','C','G') |
93 | | - AND mutation_event.tumor_seq_allele IN ('A','T','C','G') |
| 84 | + AND referenceAllele IN ('A','T','C','G') |
| 85 | + AND tumorSeqAllele IN ('A','T','C','G') |
94 | 86 | </if> |
95 | 87 | </where> |
96 | 88 | </sql> |
97 | 89 |
|
98 | 90 | <sql id="whereBySampleListId"> |
99 | 91 | <where> |
100 | | - genetic_profile.stable_id = #{molecularProfileId} |
101 | | - AND mutation.sample_id IN |
| 92 | + molecularProfileId = #{molecularProfileId} |
| 93 | + AND sampleInternalId IN |
102 | 94 | ( |
103 | 95 | SELECT sample_list_list.sample_id FROM sample_list_list |
104 | 96 | INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id |
105 | 97 | WHERE sample_list.stable_id = #{sampleListId} |
106 | 98 | ) |
107 | 99 | <if test="entrezGeneIds != null and !entrezGeneIds.isEmpty()"> |
108 | | - AND mutation.entrez_gene_id IN |
| 100 | + AND entrezGeneId IN |
109 | 101 | <foreach item="item" collection="entrezGeneIds" open="(" separator="," close=")">#{item}</foreach> |
110 | 102 | </if> |
111 | 103 | <if test="snpOnly == true"> |
112 | | - AND mutation_event.reference_allele IN ('A','T','C','G') |
113 | | - AND mutation_event.tumor_seq_allele IN ('A','T','C','G') |
| 104 | + AND referenceAllele IN ('A','T','C','G') |
| 105 | + AND tumorSeqAllele IN ('A','T','C','G') |
114 | 106 | </if> |
115 | 107 | </where> |
116 | 108 | </sql> |
117 | 109 |
|
118 | 110 | <sql id="whereInMultipleMolecularProfiles"> |
119 | 111 | <where> |
120 | 112 | <if test="sampleIds != null and !sampleIds.isEmpty()"> |
121 | | - mutation.sample_id IN ( |
| 113 | + sample_id IN ( |
122 | 114 | SELECT sample.internal_id FROM sample |
123 | 115 | INNER JOIN patient ON sample.patient_id = patient.internal_id |
124 | 116 | INNER JOIN genetic_profile ON patient.cancer_study_id = genetic_profile.cancer_study_id |
|
143 | 135 | ) |
144 | 136 | </if> |
145 | 137 | <if test="sampleIds == null || sampleIds.isEmpty()"> |
146 | | - genetic_profile.stable_id IN |
| 138 | + molecularProfileId IN |
147 | 139 | <foreach item="item" collection="molecularProfileIds" open="(" separator="," close=")">#{item}</foreach> |
148 | 140 | </if> |
149 | 141 | <if test="_parameter.containsKey('entrezGeneIds') and entrezGeneIds != null and !entrezGeneIds.isEmpty()"> |
150 | | - AND mutation.entrez_gene_id IN |
| 142 | + AND entrezGeneId IN |
151 | 143 | <foreach item="item" collection="entrezGeneIds" open="(" separator="," close=")">#{item}</foreach> |
152 | 144 | </if> |
153 | 145 | <if test="_parameter.containsKey('geneQueries') and geneQueries != null and !geneQueries.isEmpty()"> |
154 | 146 | <include refid="whereWithGeneQueries"/> |
155 | 147 | </if> |
156 | 148 | <if test="snpOnly == true"> |
157 | | - AND mutation_event.reference_allele IN ('A','T','C','G') |
158 | | - AND mutation_event.tumor_seq_allele IN ('A','T','C','G') |
| 149 | + AND referenceAllele IN ('A','T','C','G') |
| 150 | + AND tumorSeqAllele IN ('A','T','C','G') |
159 | 151 | </if> |
160 | 152 | </where> |
161 | 153 | </sql> |
|
245 | 237 | </sql> |
246 | 238 |
|
247 | 239 | <sql id="getAlleleSpecificCopyNumber"> |
248 | | - allele_specific_copy_number.ascn_integer_copy_number AS "${prefix}ascnIntegerCopyNumber", |
249 | | - allele_specific_copy_number.ascn_method AS "${prefix}ascnMethod", |
250 | | - allele_specific_copy_number.ccf_expected_copies_upper AS "${prefix}ccfExpectedCopiesUpper", |
251 | | - allele_specific_copy_number.ccf_expected_copies AS "${prefix}ccfExpectedCopies", |
252 | | - allele_specific_copy_number.clonal AS "${prefix}clonal", |
253 | | - allele_specific_copy_number.minor_copy_number AS "${prefix}minorCopyNumber", |
254 | | - allele_specific_copy_number.expected_alt_copies AS "${prefix}expectedAltCopies", |
255 | | - allele_specific_copy_number.total_copy_number AS "${prefix}totalCopyNumber" |
| 240 | + alleleSpecificCopyNumber.ascnIntegerCopyNumber, |
| 241 | + alleleSpecificCopyNumber.ascnMethod, |
| 242 | + alleleSpecificCopyNumber.ccfExpectedCopiesUpper, |
| 243 | + alleleSpecificCopyNumber.ccfExpectedCopies, |
| 244 | + alleleSpecificCopyNumber.clonal, |
| 245 | + alleleSpecificCopyNumber.minorCopyNumber, |
| 246 | + alleleSpecificCopyNumber.expectedAltCopies, |
| 247 | + alleleSpecificCopyNumber.totalCopyNumber |
256 | 248 | </sql> |
257 | 249 |
|
258 | 250 | <sql id="includeAlleleSpecificCopyNumber"> |
259 | | - LEFT JOIN allele_specific_copy_number ON mutation.mutation_event_id = allele_specific_copy_number.mutation_event_id |
260 | | - AND mutation.genetic_profile_id = allele_specific_copy_number.genetic_profile_id |
261 | | - AND mutation.sample_id = allele_specific_copy_number.sample_id |
| 251 | +-- LEFT JOIN allele_specific_copy_number ON mutation.mutation_event_id = allele_specific_copy_number.mutation_event_id |
| 252 | +-- AND mutation.genetic_profile_id = allele_specific_copy_number.genetic_profile_id |
| 253 | +-- AND mutation.sample_id = allele_specific_copy_number.sample_id |
262 | 254 | </sql> |
263 | 255 |
|
264 | 256 | <resultMap id="genomicDataCountItem" type="org.cbioportal.legacy.model.GenomicDataCountItem"> |
|
279 | 271 | SELECT |
280 | 272 | <include refid="select"/> |
281 | 273 | <include refid="from"/> |
282 | | - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id |
283 | 274 | <if test="projection == 'DETAILED'"> |
284 | | - INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id |
285 | | - <include refid="includeAlleleSpecificCopyNumber"/> |
| 275 | + |
286 | 276 | </if> |
287 | 277 | <include refid="whereBySampleListId"/> |
288 | 278 | <if test="sortBy != null and projection != 'ID'"> |
|
299 | 289 | <select id="getMetaMutationsBySampleListId" resultType="org.cbioportal.legacy.model.meta.MutationMeta"> |
300 | 290 | SELECT |
301 | 291 | COUNT(*) AS "totalCount", |
302 | | - COUNT(DISTINCT(mutation.sample_id)) AS "sampleCount" |
| 292 | + COUNT(DISTINCT(sampleId)) AS "sampleCount" |
303 | 293 | <include refid="from"/> |
304 | | - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id |
305 | 294 | <include refid="whereBySampleListId"/> |
306 | 295 | </select> |
307 | 296 |
|
308 | 297 | <select id="getMutationsInMultipleMolecularProfiles" resultType="org.cbioportal.legacy.model.Mutation"> |
309 | 298 | SELECT |
310 | 299 | <include refid="select"/> |
311 | 300 | <include refid="from"/> |
312 | | - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id |
313 | 301 | <if test="projection == 'DETAILED'"> |
314 | | - INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id |
315 | 302 | <include refid="includeAlleleSpecificCopyNumber"/> |
316 | 303 | </if> |
317 | 304 | <include refid="whereInMultipleMolecularProfiles"/> |
|
322 | 309 | SELECT |
323 | 310 | <include refid="select"/> |
324 | 311 | <include refid="from"/> |
325 | | - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id |
326 | 312 | <if test="projection == 'DETAILED'"> |
327 | | - INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id |
328 | 313 | <include refid="includeAlleleSpecificCopyNumber"/> |
329 | 314 | </if> |
330 | 315 | <include refid="whereInMultipleMolecularProfiles"/> |
|
334 | 319 | <select id="getMetaMutationsInMultipleMolecularProfiles" resultType="org.cbioportal.legacy.model.meta.MutationMeta"> |
335 | 320 | SELECT |
336 | 321 | COUNT(*) AS "totalCount", |
337 | | - COUNT(DISTINCT(mutation.sample_id)) AS "sampleCount" |
| 322 | + COUNT(DISTINCT(sampleId)) AS "sampleCount" |
338 | 323 | <include refid="from"/> |
339 | | - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id |
340 | 324 | <include refid="whereInMultipleMolecularProfiles"/> |
341 | 325 | </select> |
342 | 326 |
|
343 | 327 | <select id="getMetaMutationsBySampleIds" resultType="org.cbioportal.legacy.model.meta.MutationMeta"> |
344 | 328 | SELECT |
345 | 329 | COUNT(*) AS "totalCount", |
346 | | - COUNT(DISTINCT(mutation.sample_id)) AS "sampleCount" |
| 330 | + COUNT(DISTINCT(sampleId)) AS "sampleCount" |
347 | 331 | <include refid="from"/> |
348 | | - INNER JOIN mutation_event ON mutation_event.mutation_event_id = mutation.mutation_event_id |
| 332 | + |
349 | 333 | <include refid="where"/> |
350 | 334 | </select> |
351 | 335 |
|
352 | 336 | <select id="getSampleCountByEntrezGeneIdsAndSampleIds" resultType="org.cbioportal.legacy.model.MutationCountByGene"> |
353 | 337 | SELECT |
354 | | - mutation.entrez_gene_id AS "entrezGeneId", |
| 338 | + entrezGeneId AS "entrezGeneId", |
355 | 339 | <!-- TODO: check this--> |
356 | | - ANY_VALUE(gene.hugo_gene_symbol) AS "hugoGeneSymbol", |
| 340 | + ANY_VALUE(GENE.hugoGeneSymbol) AS "hugoGeneSymbol", |
357 | 341 | COUNT(*) AS "totalCount", |
358 | | - COUNT(DISTINCT(mutation.sample_id)) AS "numberOfAlteredCases" |
359 | | - FROM mutation |
360 | | - INNER JOIN mutation_event ON mutation_event.mutation_event_id = mutation.mutation_event_id |
361 | | - INNER JOIN genetic_profile ON mutation.genetic_profile_id = genetic_profile.genetic_profile_id |
362 | | - INNER JOIN sample ON mutation.sample_id = sample.internal_id |
363 | | - INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id |
| 342 | + COUNT(DISTINCT(sampleId)) AS "numberOfAlteredCases" |
| 343 | + FROM mutation_derived |
364 | 344 | <include refid="where"/> |
365 | 345 | GROUP BY mutation.entrez_gene_id |
366 | 346 | </select> |
|
371 | 351 | #{proteinPosStart} AS "proteinPosStart", |
372 | 352 | #{proteinPosEnd} AS "proteinPosEnd", |
373 | 353 | COUNT(*) AS "count" |
374 | | - FROM mutation |
375 | | - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id |
376 | | - WHERE mutation_event.entrez_gene_id = #{entrezGeneId} |
377 | | - AND mutation_event.protein_pos_start >= #{proteinPosStart} |
378 | | - AND mutation_event.protein_pos_end <![CDATA[ <= ]]> #{proteinPosEnd} |
| 354 | + FROM mutation_derived |
| 355 | + |
| 356 | + WHERE entrezGeneId = #{entrezGeneId} |
| 357 | + AND proteinPosStart >= #{proteinPosStart} |
| 358 | + AND proteinPosEnd <![CDATA[ <= ]]> #{proteinPosEnd} |
379 | 359 | </select> |
380 | 360 |
|
381 | 361 | <select id="getMutationCountsByType" resultMap="genomicDataCountItem"> |
382 | 362 | SELECT |
383 | 363 | <!-- TODO: check this--> |
384 | | - ANY_VALUE(gene.hugo_gene_symbol) as hugoGeneSymbol, |
| 364 | + ANY_VALUE(GENE.hugoGeneSymbol) as hugoGeneSymbol, |
385 | 365 | #{profileType} as profileType, |
386 | | - REPLACE(mutation_event.mutation_type, '_', ' ') AS label, |
387 | | - mutation_event.mutation_type AS value, |
| 366 | + REPLACE(mutationType, '_', ' ') AS label, |
| 367 | + mutationType AS value, |
388 | 368 | COUNT(*) AS count, |
389 | | - COUNT(DISTINCT(sample.internal_id)) AS uniqueCount |
| 369 | + COUNT(DISTINCT(sampleInternalId)) AS uniqueCount |
390 | 370 | <include refid="from"/> |
391 | | - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id |
392 | | - INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id |
393 | 371 | <include refid="whereInMultipleMolecularProfiles"/> |
394 | | - GROUP BY mutation_event.mutation_type |
| 372 | + GROUP BY mutationType |
395 | 373 | </select> |
396 | 374 | </mapper> |
0 commit comments