-- DBMS: bigquery
CREATE TABLE `isb-cgc-bq.CPTAC.copy_number_gene_level_hg38_gdc_current`
(
  project_short_name STRING OPTIONS(description="Project name abbreviation; the program name appended with a project name abbreviation; eg. TCGA-OV, etc."),
  case_barcode STRING OPTIONS(description="Original case barcode, eg TCGA-DX-A8BN"),
  primary_site STRING OPTIONS(description="Anatomical site of the cancer under investigation or review"),
  sample_barcode STRING OPTIONS(description="TCGA sample barcode, eg TCGA-12-1089-01A. One sample may have multiple sets of CN segmentations corresponding to multiple aliquots; use GROUP BY appropriately in queries"),
  aliquot_barcode STRING OPTIONS(description="TCGA aliquot barcode, eg TCGA-12-1089-01A-01D-0517-02"),
  Ensembl_gene_id STRING OPTIONS(description="The Ensembl gene ID from the underlying file, but stripped of the version suffix -- eg. ENSG00000185028"),
  Ensembl_gene_id_v STRING OPTIONS(description="The Ensembl gene ID from the underlying file, including the version suffix -- eg. ENSG00000235943.1"),
  gene_name STRING OPTIONS(description="Gene name eg. TTN, DDR1"),
  gene_type STRING OPTIONS(description="The type of genetic element the reads mapped to, eg. protein_coding, ribozyme"),
  chromosome STRING OPTIONS(description="Chromosome, possible values: chr1-22, and chrX"),
  start_pos INT64 OPTIONS(description="1-based start chromosome position of isoform"),
  end_pos INT64 OPTIONS(description="1-based end chromosome position of isoform"),
  copy_number INT64 OPTIONS(description="The weighted median of the strand copy numbers. Gene-level copy number data is generated by intersection of copy number segment and gene ranges. It is possible for one gene to overlap with multiple segments, and in this case, copy_number, min_copy_number and max_copy_number could take different values. In particular, the copy_number value is calculated as the median, weighted on length of overlapped bases, of segment copy numbers from all overlapped segments."),
  min_copy_number INT64 OPTIONS(description="The lowest copy number for overlapped segment (copy number variant only)."),
  max_copy_number INT64 OPTIONS(description="The highest copy number for overlapped segment (copy number variant only)."),
  case_gdc_id STRING OPTIONS(description="Unique GDC identifier for this case (corresponds to the case_barcode).  Can be used to access more information from the GDC data portal like this:   https://portal.gdc.cancer.gov/files/c21b332c-06c6-4403-9032-f91c8f407ba10"),
  sample_gdc_id STRING OPTIONS(description="Unique GDC identifier for this sample (corresponds to the sample_barcode), eg a1ec9279-c1a6-4e58-97ed-9ec1f36187c5  --  this can be used to access more information from the GDC data portal"),
  aliquot_gdc_id STRING OPTIONS(description="Unique GDC identifier for this aliquot (corresponds to the aliquot_barcode), eg 7fbfdb3e-1fd2-4206-8d2e-7f68e4a15844  --  this can be used to access more information from the GDC data portal"),
  file_gdc_id STRING OPTIONS(description="Unique GDC identifier for this file (corresponds to the file_barcode)  --  this can be used to access more information from the GDC data portal like this: https://portal.gdc.cancer.gov/files/c21b332c-06c6-4403-9032-f91c8f407ba17")
)
CLUSTER BY project_short_name, case_barcode, sample_barcode, aliquot_barcode
OPTIONS(
  friendly_name="CPTAC HG38 COPY NUMBER VARIATION GENE LEVEL",
  description="Data was extracted from release 36 of the active GDC archive in March, 2023 for CPTAC copy number variation gene level data. More details:https://docs.gdc.cancer.gov/Data/Release_Notes/Data_Release_Notes/#data-release-360",
  labels=[("access", "open"), ("program_0", "cptac2"), ("program_1", "cptac3"), ("data_type", "cnvr_gene_level"), ("reference_genome_0", "hg38"), ("source", "gdc"), ("category", "processed_-omics_data"), ("status", "current"), ("version", "r36")]
);

INSERT INTO `isb-cgc-bq.CPTAC.copy_number_gene_level_hg38_gdc_current` (project_short_name, case_barcode, primary_site, sample_barcode, aliquot_barcode, Ensembl_gene_id, Ensembl_gene_id_v, gene_name, gene_type, chromosome, start_pos, end_pos, copy_number, min_copy_number, max_copy_number, case_gdc_id, sample_gdc_id, aliquot_gdc_id, file_gdc_id) VALUES ('CPTAC-3', 'C3N-01651', 'Kidney', 'C3N-01651-01', 'CPT0088690009', 'ENSG00000285201', 'ENSG00000285201.1', 'AC104454.2', 'lncRNA', 'chr1', 84038529, 84065031, NULL, NULL, NULL, '947a6de8-a1fe-41f3-9568-2311f9fa341b', '9c039399-91c5-4779-a266-93fa3e03e03d', 'a5c7bfd1-43cf-4e91-b10a-7598ebd4345e', '2377f553-c16f-46f7-b910-82af16c6fc54'), ('CPTAC-3', 'C3N-01651', 'Kidney', 'C3N-01651-01', 'CPT0088690009', 'ENSG00000214812', 'ENSG00000214812.3', 'AL137792.1', 'processed_pseudogene', 'chr1', 28120449, 28121321, 2, 2, 2, '947a6de8-a1fe-41f3-9568-2311f9fa341b', '9c039399-91c5-4779-a266-93fa3e03e03d', 'a5c7bfd1-43cf-4e91-b10a-7598ebd4345e', '2377f553-c16f-46f7-b910-82af16c6fc54'), ('CPTAC-3', 'C3N-01651', 'Kidney', 'C3N-01651-01', 'CPT0088690009', 'ENSG00000243970', 'ENSG00000243970.3', 'PPIEL', 'transcribed_unprocessed_pseudogene', 'chr1', 39522280, 39559671, 2, 2, 2, '947a6de8-a1fe-41f3-9568-2311f9fa341b', '9c039399-91c5-4779-a266-93fa3e03e03d', 'a5c7bfd1-43cf-4e91-b10a-7598ebd4345e', '2377f553-c16f-46f7-b910-82af16c6fc54'), ('CPTAC-3', 'C3N-01651', 'Kidney', 'C3N-01651-01', 'CPT0088690009', 'ENSG00000225158', 'ENSG00000225158.2', 'HSPE1P24', 'processed_pseudogene', 'chr1', 10895761, 10895998, 2, 2, 2, '947a6de8-a1fe-41f3-9568-2311f9fa341b', '9c039399-91c5-4779-a266-93fa3e03e03d', 'a5c7bfd1-43cf-4e91-b10a-7598ebd4345e', '2377f553-c16f-46f7-b910-82af16c6fc54'), ('CPTAC-3', 'C3N-01651', 'Kidney', 'C3N-01651-01', 'CPT0088690009', 'ENSG00000215800', 'ENSG00000215800.2', 'RSL24D1P4', 'processed_pseudogene', 'chr1', 242772620, 242773103, 2, 2, 2, '947a6de8-a1fe-41f3-9568-2311f9fa341b', '9c039399-91c5-4779-a266-93fa3e03e03d', 'a5c7bfd1-43cf-4e91-b10a-7598ebd4345e', '2377f553-c16f-46f7-b910-82af16c6fc54');