Datasets:

Modalities:
Tabular
Text
Formats:
parquet
Languages:
English
License:
File size: 24,873 Bytes
70837a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
CREATE TABLE allele_specific_copy_number
(
    `mutation_event_id` Int64,
    `genetic_profile_id` Int64,
    `sample_id` Int64,
    `ascn_integer_copy_number` Nullable(Int64),
    `ascn_method` String,
    `ccf_expected_copies_upper` Nullable(Float64),
    `ccf_expected_copies` Nullable(Float64),
    `clonal` Nullable(String),
    `minor_copy_number` Nullable(Int64),
    `expected_alt_copies` Nullable(Int64),
    `total_copy_number` Nullable(Int64)
)
ENGINE = MergeTree
ORDER BY (mutation_event_id, genetic_profile_id, sample_id)
SETTINGS index_granularity = 8192;

CREATE TABLE alteration_driver_annotation
(
    `alteration_event_id` Int64,
    `genetic_profile_id` Int64,
    `sample_id` Int64,
    `driver_filter` Nullable(String),
    `driver_filter_annotation` Nullable(String),
    `driver_tiers_filter` Nullable(String),
    `driver_tiers_filter_annotation` Nullable(String)
)
ENGINE = MergeTree
ORDER BY (alteration_event_id, genetic_profile_id, sample_id)
SETTINGS index_granularity = 8192;

CREATE TABLE cancer_study
(
    `cancer_study_id` Int64,
    `cancer_study_identifier` Nullable(String),
    `type_of_cancer_id` String,
    `name` String,
    `description` String,
    `public` Int32,
    `pmid` Nullable(String),
    `citation` Nullable(String),
    `groups` Nullable(String),
    `status` Nullable(Int64),
    `import_date` Nullable(DateTime64(6)),
    `reference_genome_id` Nullable(Int64)
)
ENGINE = MergeTree
ORDER BY cancer_study_id
SETTINGS index_granularity = 8192;

CREATE TABLE cancer_study_tags
(
    `cancer_study_id` Int64,
    `tags` String
)
ENGINE = MergeTree
ORDER BY cancer_study_id
SETTINGS index_granularity = 8192;

CREATE TABLE cbioportal_sequence_state
(
    `sequence_name` String,
    `last_value` UInt64
)
ENGINE = ReplacingMergeTree
ORDER BY sequence_name
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_attribute_meta
(
    `attr_id` String,
    `display_name` String,
    `description` String,
    `datatype` String,
    `patient_attribute` Int32,
    `priority` String,
    `cancer_study_id` Int64
)
ENGINE = MergeTree
ORDER BY (attr_id, cancer_study_id)
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_data_derived
(
    `internal_id` Int32,
    `sample_unique_id` String,
    `patient_unique_id` String,
    `attribute_name` LowCardinality(String),
    `attribute_value` String,
    `cancer_study_identifier` LowCardinality(String),
    `type` LowCardinality(String)
)
ENGINE = MergeTree
ORDER BY (cancer_study_identifier, type, attribute_name, sample_unique_id)
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_event
(
    `clinical_event_id` Int64,
    `patient_id` Int64,
    `start_date` Int64,
    `stop_date` Nullable(Int64),
    `event_type` String
)
ENGINE = MergeTree
ORDER BY clinical_event_id
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_event_data
(
    `clinical_event_id` Int64,
    `key` String,
    `value` String
)
ENGINE = MergeTree
ORDER BY clinical_event_id
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_event_data_derived
(
    `patient_unique_id` String,
    `key` String,
    `value` String,
    `start_date` Int32,
    `stop_date` Int32 DEFAULT 0,
    `event_type` LowCardinality(String),
    `cancer_study_identifier` LowCardinality(String)
)
ENGINE = MergeTree
ORDER BY (cancer_study_identifier, event_type, patient_unique_id)
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_event_derived
(
    `clinical_event_id` Int64,
    `patient_id` Nullable(Int64),
    `patient_stable_id` String,
    `start_date` Nullable(Int64),
    `stop_date` Nullable(Int64),
    `event_type` LowCardinality(String),
    `cancer_study_identifier` LowCardinality(String)
)
ENGINE = MergeTree
PRIMARY KEY (cancer_study_identifier, event_type, clinical_event_id)
ORDER BY (cancer_study_identifier, event_type, clinical_event_id)
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_patient
(
    `internal_id` Int64,
    `attr_id` String,
    `attr_value` String
)
ENGINE = ReplacingMergeTree
ORDER BY (internal_id, attr_id)
SETTINGS index_granularity = 8192;

CREATE TABLE clinical_sample
(
    `internal_id` Int64,
    `attr_id` String,
    `attr_value` String
)
ENGINE = ReplacingMergeTree
ORDER BY (internal_id, attr_id)
SETTINGS index_granularity = 8192;

CREATE TABLE cna_event
(
    `cna_event_id` Int64,
    `entrez_gene_id` Int64,
    `alteration` Int32
)
ENGINE = MergeTree
ORDER BY cna_event_id
SETTINGS index_granularity = 8192;

CREATE TABLE copy_number_seg
(
    `seg_id` Int64,
    `cancer_study_id` Int64,
    `sample_id` Int64,
    `chr` String,
    `start` Int64,
    `end` Int64,
    `num_probes` Int64,
    `segment_mean` Float64
)
ENGINE = MergeTree
ORDER BY seg_id
SETTINGS index_granularity = 8192;

CREATE TABLE copy_number_seg_file
(
    `seg_file_id` Int64,
    `cancer_study_id` Int64,
    `reference_genome_id` String,
    `description` String,
    `filename` String
)
ENGINE = MergeTree
ORDER BY seg_file_id
SETTINGS index_granularity = 8192;

CREATE TABLE gene
(
    `entrez_gene_id` Int64,
    `hugo_gene_symbol` String,
    `genetic_entity_id` Int64,
    `type` Nullable(String)
)
ENGINE = MergeTree
ORDER BY entrez_gene_id
SETTINGS index_granularity = 8192;

CREATE TABLE gene_alias
(
    `entrez_gene_id` Int64,
    `gene_alias` String
)
ENGINE = MergeTree
ORDER BY (entrez_gene_id, gene_alias)
SETTINGS index_granularity = 8192;

CREATE TABLE gene_panel
(
    `internal_id` Int64,
    `stable_id` String,
    `description` Nullable(String)
)
ENGINE = MergeTree
ORDER BY internal_id
SETTINGS index_granularity = 8192;

CREATE TABLE gene_panel_list
(
    `internal_id` Int64,
    `gene_id` Int64
)
ENGINE = MergeTree
ORDER BY (internal_id, gene_id)
SETTINGS index_granularity = 8192;

CREATE TABLE gene_panel_to_gene_derived
(
    `gene_panel_id` LowCardinality(String),
    `gene` String
)
ENGINE = MergeTree
ORDER BY gene_panel_id
SETTINGS index_granularity = 8192;

CREATE TABLE generic_assay_data_derived
(
    `sample_unique_id` String,
    `patient_unique_id` String,
    `genetic_entity_id` String,
    `value` String,
    `generic_assay_type` String,
    `profile_stable_id` String,
    `entity_stable_id` String,
    `datatype` String,
    `patient_level` Decimal(10, 0),
    `profile_type` String
)
ENGINE = MergeTree
ORDER BY (profile_type, entity_stable_id, patient_unique_id, sample_unique_id)
SETTINGS index_granularity = 8192;

CREATE TABLE generic_assay_meta_derived
(
    `entity_stable_id` String,
    `entity_type` LowCardinality(String),
    `properties` Map(String, String)
)
ENGINE = MergeTree
ORDER BY entity_stable_id
SETTINGS index_granularity = 8192;

CREATE TABLE generic_assay_profile_entity_derived
(
    `profile_stable_id` LowCardinality(String),
    `entity_stable_id` String
)
ENGINE = MergeTree
ORDER BY (profile_stable_id, entity_stable_id)
SETTINGS index_granularity = 8192;

CREATE TABLE generic_entity_properties
(
    `id` Int64,
    `genetic_entity_id` Int64,
    `name` String,
    `value` String
)
ENGINE = MergeTree
ORDER BY id
SETTINGS index_granularity = 8192;

CREATE TABLE geneset
(
    `id` Int64,
    `genetic_entity_id` Int64,
    `external_id` String,
    `name` String,
    `description` String,
    `ref_link` Nullable(String)
)
ENGINE = MergeTree
ORDER BY id
SETTINGS index_granularity = 8192;

CREATE TABLE geneset_gene
(
    `geneset_id` Int64,
    `entrez_gene_id` Int64
)
ENGINE = MergeTree
ORDER BY (geneset_id, entrez_gene_id)
SETTINGS index_granularity = 8192;

CREATE TABLE geneset_hierarchy_leaf
(
    `node_id` Int64,
    `geneset_id` Int64
)
ENGINE = MergeTree
ORDER BY (node_id, geneset_id)
SETTINGS index_granularity = 8192;

CREATE TABLE geneset_hierarchy_node
(
    `node_id` Int64,
    `node_name` String,
    `parent_id` Nullable(Int64)
)
ENGINE = MergeTree
ORDER BY node_id
SETTINGS index_granularity = 8192;

CREATE TABLE genetic_alteration
(
    `genetic_profile_id` Int64,
    `genetic_entity_id` Int64,
    `values` String
)
ENGINE = ReplacingMergeTree
ORDER BY (genetic_profile_id, genetic_entity_id)
SETTINGS index_granularity = 8192;

CREATE TABLE genetic_alteration_derived
(
    `sample_unique_id` String,
    `cancer_study_identifier` LowCardinality(String),
    `hugo_gene_symbol` String,
    `profile_type` LowCardinality(String),
    `alteration_value` Nullable(String)
)
ENGINE = MergeTree
ORDER BY (cancer_study_identifier, hugo_gene_symbol, profile_type, sample_unique_id)
SETTINGS index_granularity = 8192;

CREATE TABLE genetic_entity
(
    `id` Int64,
    `entity_type` String,
    `stable_id` Nullable(String)
)
ENGINE = MergeTree
ORDER BY id
SETTINGS index_granularity = 8192;

CREATE TABLE genetic_profile
(
    `genetic_profile_id` Int64,
    `stable_id` String,
    `cancer_study_id` Int64,
    `genetic_alteration_type` String,
    `generic_assay_type` Nullable(String),
    `datatype` String,
    `name` String,
    `description` Nullable(String),
    `show_profile_in_analysis_tab` Int32,
    `pivot_threshold` Nullable(Float64),
    `sort_order` Nullable(String),
    `patient_level` Nullable(Int32)
)
ENGINE = MergeTree
ORDER BY genetic_profile_id
SETTINGS index_granularity = 8192;

CREATE TABLE genetic_profile_link
(
    `referring_genetic_profile_id` Int64,
    `referred_genetic_profile_id` Int64,
    `reference_type` Nullable(String)
)
ENGINE = MergeTree
ORDER BY (referring_genetic_profile_id, referred_genetic_profile_id)
SETTINGS index_granularity = 8192;

CREATE TABLE genetic_profile_samples
(
    `genetic_profile_id` Int64,
    `ordered_sample_list` String
)
ENGINE = ReplacingMergeTree
ORDER BY genetic_profile_id
SETTINGS index_granularity = 8192;

CREATE TABLE genomic_event_derived
(
    `sample_unique_id` String,
    `hugo_gene_symbol` String,
    `entrez_gene_id` Int32,
    `gene_panel_stable_id` LowCardinality(String),
    `cancer_study_identifier` LowCardinality(String),
    `genetic_profile_stable_id` LowCardinality(String),
    `variant_type` LowCardinality(String),
    `mutation_variant` String,
    `mutation_type` LowCardinality(String),
    `mutation_status` LowCardinality(String),
    `driver_filter` LowCardinality(String),
    `driver_filter_annotation` String,
    `driver_tiers_filter` LowCardinality(String),
    `driver_tiers_filter_annotation` String,
    `cna_alteration` Nullable(Int8),
    `cna_cytoband` String,
    `sv_event_info` String,
    `patient_unique_id` String,
    `off_panel` Bool DEFAULT false
)
ENGINE = MergeTree
ORDER BY (genetic_profile_stable_id, cancer_study_identifier, variant_type, entrez_gene_id, hugo_gene_symbol, sample_unique_id)
SETTINGS index_granularity = 8192;

CREATE TABLE gistic
(
    `gistic_roi_id` Int64,
    `cancer_study_id` Int64,
    `chromosome` Int64,
    `cytoband` String,
    `wide_peak_start` Int64,
    `wide_peak_end` Int64,
    `q_value` Float64,
    `amp` Int32
)
ENGINE = MergeTree
ORDER BY gistic_roi_id
SETTINGS index_granularity = 8192;

CREATE TABLE gistic_to_gene
(
    `gistic_roi_id` Int64,
    `entrez_gene_id` Int64
)
ENGINE = MergeTree
ORDER BY (gistic_roi_id, entrez_gene_id)
SETTINGS index_granularity = 8192;

CREATE TABLE info
(
    `db_schema_version` Nullable(String),
    `geneset_version` Nullable(String),
    `gene_table_version` Nullable(String)
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS index_granularity = 8192;

CREATE TABLE mut_sig
(
    `cancer_study_id` Int64,
    `entrez_gene_id` Int64,
    `rank` Int64,
    `NumBasesCovered` Int64,
    `NumMutations` Int64,
    `p_value` Float64,
    `q_value` Float64
)
ENGINE = MergeTree
ORDER BY (cancer_study_id, entrez_gene_id)
SETTINGS index_granularity = 8192;

CREATE TABLE mutation
(
    `mutation_event_id` Int64 COMMENT 'References mutation_event.mutation_event_id.',
    `genetic_profile_id` Int64 COMMENT 'References genetic_profile.genetic_profile_id.',
    `sample_id` Int64 COMMENT 'References sample.internal_id.',
    `entrez_gene_id` Int64 COMMENT 'References gene.entrez_gene_id.',
    `center` Nullable(String) COMMENT 'Center where sequencing was performed.',
    `sequencer` Nullable(String) COMMENT 'Sequencing platform used.',
    `mutation_status` Nullable(String) COMMENT 'Mutation status: Germline,\n    Somatic,\n    or LOH.',
    `validation_status` Nullable(String) COMMENT 'Validation status.',
    `tumor_seq_allele1` Nullable(String) COMMENT 'Tumor allele 1 sequence.',
    `tumor_seq_allele2` Nullable(String) COMMENT 'Tumor allele 2 sequence.',
    `matched_norm_sample_barcode` Nullable(String) COMMENT 'Matched normal sample barcode.',
    `match_norm_seq_allele1` Nullable(String) COMMENT 'Matched normal allele 1 sequence.',
    `match_norm_seq_allele2` Nullable(String) COMMENT 'Matched normal allele 2 sequence.',
    `tumor_validation_allele1` Nullable(String) COMMENT 'Tumor validation allele 1 sequence.',
    `tumor_validation_allele2` Nullable(String) COMMENT 'Tumor validation allele 2 sequence.',
    `match_norm_validation_allele1` Nullable(String) COMMENT 'Matched normal validation allele 1.',
    `match_norm_validation_allele2` Nullable(String) COMMENT 'Matched normal validation allele 2.',
    `verification_status` Nullable(String) COMMENT 'Verification status.',
    `sequencing_phase` Nullable(String) COMMENT 'Sequencing phase.',
    `sequence_source` String COMMENT 'Source of sequencing data.',
    `validation_method` Nullable(String) COMMENT 'Validation method used.',
    `score` Nullable(String) COMMENT 'Score or quality metric.',
    `bam_file` Nullable(String) COMMENT 'Associated BAM file.',
    `tumor_alt_count` Nullable(Int64) COMMENT 'Tumor alternate allele count.',
    `tumor_ref_count` Nullable(Int64) COMMENT 'Tumor reference allele count.',
    `normal_alt_count` Nullable(Int64) COMMENT 'Normal alternate allele count.',
    `normal_ref_count` Nullable(Int64) COMMENT 'Normal reference allele count.',
    `amino_acid_change` Nullable(String) COMMENT 'Amino acid change from mutation.',
    `annotation_json` Nullable(String) COMMENT 'JSON-formatted annotations.'
)
ENGINE = MergeTree
ORDER BY (genetic_profile_id, entrez_gene_id)
SETTINGS index_granularity = 8192
COMMENT 'Mutation observations in specific samples and profiles. References mutation_event, gene, genetic_profile, and sample.';

CREATE TABLE mutation_count_by_keyword
(
    `genetic_profile_id` Int64,
    `keyword` Nullable(String),
    `entrez_gene_id` Int64,
    `keyword_count` Int64,
    `gene_count` Int64
)
ENGINE = MergeTree
ORDER BY (genetic_profile_id, entrez_gene_id)
SETTINGS index_granularity = 8192;

CREATE TABLE mutation_derived
(
    `molecularProfileId` String COMMENT 'Stable ID of the genetic profile',
    `sampleId` String COMMENT 'Stable ID of the sample',
    `sampleInternalId` Int64,
    `patientId` String COMMENT 'Stable ID of the patient',
    `entrezGeneId` Int64 COMMENT 'Entrez Gene ID from mutation table (NOT NULL)',
    `studyId` String COMMENT 'Cancer study identifier',
    `center` Nullable(String) COMMENT 'Sequencing center',
    `mutationStatus` Nullable(String) COMMENT 'Mutation status (e.g., Somatic, Germline)',
    `validationStatus` Nullable(String) COMMENT 'Validation status',
    `tumorAltCount` Nullable(Int64) COMMENT 'Tumor alternate allele count',
    `tumorRefCount` Nullable(Int64) COMMENT 'Tumor reference allele count',
    `normalAltCount` Nullable(Int64) COMMENT 'Normal alternate allele count',
    `normalRefCount` Nullable(Int64) COMMENT 'Normal reference allele count',
    `aminoAcidChange` Nullable(String) COMMENT 'Amino acid change',
    `chr` Nullable(String) COMMENT 'Chromosome',
    `startPosition` Nullable(Int64) COMMENT 'Start position',
    `endPosition` Nullable(Int64) COMMENT 'End position',
    `referenceAllele` Nullable(String) COMMENT 'Reference allele',
    `tumorSeqAllele` Nullable(String) COMMENT 'Tumor sequence allele',
    `proteinChange` Nullable(String) COMMENT 'Protein change',
    `mutationType` Nullable(String) COMMENT 'Type of mutation',
    `ncbiBuild` Nullable(String) COMMENT 'NCBI build version',
    `variantType` Nullable(String) COMMENT 'Variant type',
    `refseqMrnaId` Nullable(String) COMMENT 'RefSeq mRNA ID',
    `proteinPosStart` Nullable(Int64) COMMENT 'Protein position start',
    `proteinPosEnd` Nullable(Int64) COMMENT 'Protein position end',
    `keyword` Nullable(String) COMMENT 'Keyword',
    `annotationJSON` Nullable(String) COMMENT 'Annotation JSON',
    `driverFilter` Nullable(String) COMMENT 'Driver filter',
    `driverFilterAnnotation` Nullable(String) COMMENT 'Driver filter annotation',
    `driverTiersFilter` Nullable(String) COMMENT 'Driver tiers filter',
    `driverTiersFilterAnnotation` Nullable(String) COMMENT 'Driver tiers filter annotation',
    `GENE.entrezGeneId` Nullable(Int64) COMMENT 'Gene entrez ID',
    `GENE.hugoGeneSymbol` Nullable(String) COMMENT 'HUGO gene symbol',
    `GENE.type` Nullable(String) COMMENT 'Gene type',
    `alleleSpecificCopyNumber.ascnIntegerCopyNumber` Nullable(Int64) COMMENT 'ASCN integer copy number',
    `alleleSpecificCopyNumber.ascnMethod` Nullable(String) COMMENT 'ASCN method',
    `alleleSpecificCopyNumber.ccfExpectedCopiesUpper` Nullable(Float64) COMMENT 'CCF expected copies upper bound',
    `alleleSpecificCopyNumber.ccfExpectedCopies` Nullable(Float64) COMMENT 'CCF expected copies',
    `alleleSpecificCopyNumber.clonal` Nullable(String) COMMENT 'Clonality annotation',
    `alleleSpecificCopyNumber.minorCopyNumber` Nullable(Int64) COMMENT 'Minor copy number',
    `alleleSpecificCopyNumber.expectedAltCopies` Nullable(Int64) COMMENT 'Expected alternate copies',
    `alleleSpecificCopyNumber.totalCopyNumber` Nullable(Int64) COMMENT 'Total copy number'
)
ENGINE = MergeTree
ORDER BY (molecularProfileId, sampleId, entrezGeneId)
SETTINGS index_granularity = 8192
COMMENT 'Mutation query results with detailed annotations including driver status and allele-specific copy numbers';

CREATE TABLE mutation_event
(
    `mutation_event_id` Int64,
    `entrez_gene_id` Int64,
    `chr` Nullable(String),
    `start_position` Nullable(Int64),
    `end_position` Nullable(Int64),
    `reference_allele` Nullable(String),
    `tumor_seq_allele` Nullable(String),
    `protein_change` Nullable(String),
    `mutation_type` Nullable(String),
    `ncbi_build` Nullable(String),
    `strand` Nullable(String),
    `variant_type` Nullable(String),
    `db_snp_rs` Nullable(String),
    `db_snp_val_status` Nullable(String),
    `refseq_mrna_id` Nullable(String),
    `codon_change` Nullable(String),
    `uniprot_accession` Nullable(String),
    `protein_pos_start` Nullable(Int64),
    `protein_pos_end` Nullable(Int64),
    `canonical_transcript` Nullable(Int32),
    `keyword` Nullable(String)
)
ENGINE = MergeTree
ORDER BY mutation_event_id
SETTINGS index_granularity = 8192;

CREATE TABLE patient
(
    `internal_id` Int64,
    `stable_id` String,
    `cancer_study_id` Int64
)
ENGINE = MergeTree
ORDER BY internal_id
SETTINGS index_granularity = 8192;

CREATE TABLE reference_genome
(
    `reference_genome_id` Int64,
    `species` String,
    `name` String,
    `build_name` String,
    `genome_size` Nullable(Int64),
    `url` String,
    `release_date` Nullable(DateTime64(6))
)
ENGINE = MergeTree
ORDER BY reference_genome_id
SETTINGS index_granularity = 8192;

CREATE TABLE reference_genome_gene
(
    `entrez_gene_id` Int64,
    `reference_genome_id` Int64,
    `chr` Nullable(String),
    `cytoband` Nullable(String),
    `start` Nullable(Int64),
    `end` Nullable(Int64)
)
ENGINE = MergeTree
ORDER BY (entrez_gene_id, reference_genome_id)
SETTINGS index_granularity = 8192;

CREATE TABLE resource_definition
(
    `resource_id` String,
    `display_name` String,
    `description` Nullable(String),
    `resource_type` String,
    `open_by_default` Nullable(Int32),
    `priority` Int64,
    `cancer_study_id` Int64,
    `custom_metadata` Nullable(String)
)
ENGINE = MergeTree
ORDER BY (resource_id, cancer_study_id)
SETTINGS index_granularity = 8192;

CREATE TABLE resource_patient
(
    `internal_id` Int64,
    `resource_id` String,
    `url` String
)
ENGINE = MergeTree
ORDER BY (internal_id, resource_id, url)
SETTINGS index_granularity = 8192;

CREATE TABLE resource_sample
(
    `internal_id` Int64,
    `resource_id` String,
    `url` String
)
ENGINE = MergeTree
ORDER BY (internal_id, resource_id, url)
SETTINGS index_granularity = 8192;

CREATE TABLE resource_study
(
    `internal_id` Int64,
    `resource_id` String,
    `url` String
)
ENGINE = MergeTree
ORDER BY (internal_id, resource_id, url)
SETTINGS index_granularity = 8192;

CREATE TABLE sample
(
    `internal_id` Int64,
    `stable_id` String,
    `sample_type` String,
    `patient_id` Int64
)
ENGINE = MergeTree
ORDER BY internal_id
SETTINGS index_granularity = 8192;

CREATE TABLE sample_cna_event
(
    `cna_event_id` Int64 COMMENT 'References cna_event.cna_event_id.',
    `sample_id` Int64 COMMENT 'References sample.internal_id.',
    `genetic_profile_id` Int64 COMMENT 'References genetic_profile.genetic_profile_id.',
    `annotation_json` Nullable(String) COMMENT 'JSON-formatted annotation details.'
)
ENGINE = MergeTree
PRIMARY KEY (genetic_profile_id, cna_event_id, sample_id)
ORDER BY (genetic_profile_id, cna_event_id, sample_id)
SETTINGS index_granularity = 8192
COMMENT 'Observed CNA events per sample and profile. References cna_event, sample, and genetic_profile.';

CREATE TABLE sample_derived
(
    `sample_unique_id` String,
    `sample_unique_id_base64` String,
    `sample_stable_id` String,
    `patient_unique_id` String,
    `patient_unique_id_base64` String,
    `patient_stable_id` String,
    `cancer_study_identifier` LowCardinality(String),
    `internal_id` Int32,
    `patient_internal_id` Int32,
    `sample_type` String,
    `sequenced` Int32,
    `copy_number_segment_present` Int32
)
ENGINE = MergeTree
ORDER BY (cancer_study_identifier, sample_unique_id)
SETTINGS index_granularity = 8192;

CREATE TABLE sample_list
(
    `list_id` Int64,
    `stable_id` String,
    `category` String,
    `cancer_study_id` Int64,
    `name` String,
    `description` Nullable(String)
)
ENGINE = MergeTree
ORDER BY list_id
SETTINGS index_granularity = 8192;

CREATE TABLE sample_list_list
(
    `list_id` Int64,
    `sample_id` Int64
)
ENGINE = MergeTree
ORDER BY (list_id, sample_id)
SETTINGS index_granularity = 8192;

CREATE TABLE sample_profile
(
    `sample_id` Int64,
    `genetic_profile_id` Int64,
    `panel_id` Nullable(Int64)
)
ENGINE = ReplacingMergeTree
ORDER BY (sample_id, genetic_profile_id)
SETTINGS index_granularity = 8192;

CREATE TABLE sample_to_gene_panel_derived
(
    `sample_unique_id` String,
    `alteration_type` LowCardinality(String),
    `gene_panel_id` LowCardinality(String),
    `cancer_study_identifier` LowCardinality(String),
    `genetic_profile_id` LowCardinality(String)
)
ENGINE = MergeTree
ORDER BY (gene_panel_id, alteration_type, genetic_profile_id, sample_unique_id)
SETTINGS index_granularity = 8192;

CREATE TABLE structural_variant
(
    `internal_id` Int64,
    `genetic_profile_id` Int64,
    `sample_id` Int64,
    `site1_entrez_gene_id` Nullable(Int64),
    `site1_ensembl_transcript_id` Nullable(String),
    `site1_chromosome` Nullable(String),
    `site1_region` Nullable(String),
    `site1_region_number` Nullable(Int64),
    `site1_contig` Nullable(String),
    `site1_position` Nullable(Int64),
    `site1_description` Nullable(String),
    `site2_entrez_gene_id` Nullable(Int64),
    `site2_ensembl_transcript_id` Nullable(String),
    `site2_chromosome` Nullable(String),
    `site2_region` Nullable(String),
    `site2_region_number` Nullable(Int64),
    `site2_contig` Nullable(String),
    `site2_position` Nullable(Int64),
    `site2_description` Nullable(String),
    `site2_effect_on_frame` Nullable(String),
    `ncbi_build` Nullable(String),
    `dna_support` Nullable(String),
    `rna_support` Nullable(String),
    `normal_read_count` Nullable(Int64),
    `tumor_read_count` Nullable(Int64),
    `normal_variant_count` Nullable(Int64),
    `tumor_variant_count` Nullable(Int64),
    `normal_paired_end_read_count` Nullable(Int64),
    `tumor_paired_end_read_count` Nullable(Int64),
    `normal_split_read_count` Nullable(Int64),
    `tumor_split_read_count` Nullable(Int64),
    `annotation` Nullable(String),
    `breakpoint_type` Nullable(String),
    `connection_type` Nullable(String),
    `event_info` Nullable(String),
    `class` Nullable(String),
    `length` Nullable(Int64),
    `comments` Nullable(String),
    `sv_status` String,
    `annotation_json` Nullable(String)
)
ENGINE = MergeTree
ORDER BY (sample_id, genetic_profile_id)
SETTINGS index_granularity = 8192;

CREATE TABLE type_of_cancer
(
    `type_of_cancer_id` String,
    `name` String,
    `dedicated_color` String,
    `short_name` Nullable(String),
    `parent` Nullable(String)
)
ENGINE = MergeTree
ORDER BY type_of_cancer_id
SETTINGS index_granularity = 8192;