-- DBMS: bigquery
CREATE TABLE `isb-cgc-bq.HTAN_versioned.id_provenance_r5`
(
  HTAN_Data_File_ID STRING OPTIONS(description="Self-identifier for this data file - HTAN ID of this file HTAN ID SOP (eg HTANx_yyy_zzz)"),
  Filename STRING OPTIONS(description="Name of a file"),
  entityId STRING OPTIONS(description="Synapse ID of entity"),
  Component STRING OPTIONS(description="Category of metadata (e.g. Diagnosis, Biospecimen, scRNA-seq Level 1, etc.)"),
  Data_Release STRING OPTIONS(description="Inclusion in HTAN Data Release e.g. Release 1.0"),
  CDS_Release STRING OPTIONS(description="CDS transfer package in which file was included e.g. v22.6.1.seq"),
  HTAN_Center STRING OPTIONS(description="Name of HTAN Center e.g. HTAN HTAPP"),
  HTAN_Assayed_Biospecimen_ID STRING OPTIONS(description="HTAN ID of the biospecimen directly assayed using the experimental platform"),
  HTAN_Parent_Data_File_ID STRING OPTIONS(description="HTAN Data File Identifier indicating the file(s) from which these files were derived"),
  HTAN_Originating_Biospecimen_ID STRING OPTIONS(description="HTAN ID of the biopsied or resected biospecimen from the patient from which the assay data were derived"),
  HTAN_Participant_ID STRING OPTIONS(description="HTAN ID associated with a patient based on HTAN ID SOP (eg HTANx_yyy )"),
  Biospecimen_Path STRING OPTIONS(description="Full Biospecimen ancestry path from HTAN_Assayed_Biospecimen_ID to HTAN_Originating_Biospecimen_ID as comma separated list")
)
OPTIONS(
  friendly_name="HTAN ID PROVENANCE TABLE R5 VERSIONED",
  description="This table contains biospecimen and participant IDs for each HTAN data file. This table was created in October 2022 and updated April 2024. The table corresponds to HTAN Data Release 5.1.",
  labels=[("access", "open"), ("data_type", "file_metadata"), ("program", "htan"), ("source", "htan"), ("category", "metadata"), ("status", "current")]
);

INSERT INTO `isb-cgc-bq.HTAN_versioned.id_provenance_r5` (HTAN_Data_File_ID, Filename, entityId, Component, Data_Release, CDS_Release, HTAN_Center, HTAN_Assayed_Biospecimen_ID, HTAN_Parent_Data_File_ID, HTAN_Originating_Biospecimen_ID, HTAN_Participant_ID, Biospecimen_Path) VALUES ('HTA3_8001_4152544161', 'sc_rna_seq_level_3/Linh_UCLA/Case1_Normal_rawCount.csv', 'syn24827008', 'ScRNA-seqLevel3', 'Release 1.0', NULL, 'HTAN BU', 'HTA3_8001_1001', 'HTA3_8001_6680165667', 'HTA3_8001_1001', 'HTA3_8001', 'HTA3_8001_1001'), ('HTA3_8001_0344122741', 'sc_rna_seq_level_3/Linh_UCLA/Case1_Normal_logNorm.csv', 'syn24827023', 'ScRNA-seqLevel3', 'Release 1.0', NULL, 'HTAN BU', 'HTA3_8001_1001', 'HTA3_8001_6680165667', 'HTA3_8001_1001', 'HTA3_8001', 'HTA3_8001_1001'), ('HTA3_8001_8707583701', 'sc_rna_seq_level_3/Linh_UCLA/Case1_Normal_batchAdj.csv', 'syn24827011', 'ScRNA-seqLevel3', 'Release 1.0', NULL, 'HTAN BU', 'HTA3_8001_1001', 'HTA3_8001_6680165667', 'HTA3_8001_1001', 'HTA3_8001', 'HTA3_8001_1001'), ('HTA3_8001_7463840742', 'sc_rna_seq_level_4/Linh_UCLA/Case1_Normal_CD45Neg_clusterID.csv', 'syn24875894', 'ScRNA-seqLevel4', 'Release 1.0', NULL, 'HTAN BU', 'HTA3_8001_1001', 'HTA3_8001_0344122741', 'HTA3_8001_1001', 'HTA3_8001', 'HTA3_8001_1001'), ('HTA3_8001_2586675862', 'sc_rna_seq_level_4/Linh_UCLA/Case1_Normal_CD45Pos_clusterID.csv', 'syn24875897', 'ScRNA-seqLevel4', 'Release 1.0', NULL, 'HTAN BU', 'HTA3_8001_1001', 'HTA3_8001_0344122741', 'HTA3_8001_1001', 'HTA3_8001', 'HTA3_8001_1001');