bioconice / restore.sql
seandavis's picture
biocOnIce release 2026-11 (v2026-11-01)
d824890 verified
Raw History Blame Contribute Delete
19.3 kB
CREATE SCHEMA IF NOT EXISTS annotation;
CREATE SCHEMA IF NOT EXISTS clinical;
CREATE SCHEMA IF NOT EXISTS ontology;
CREATE SCHEMA IF NOT EXISTS provenance;
CREATE SCHEMA IF NOT EXISTS raw;
CREATE SCHEMA IF NOT EXISTS reference;
CREATE SCHEMA IF NOT EXISTS resource;
CREATE OR REPLACE TABLE provenance.release AS SELECT * FROM read_parquet('./provenance/release.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene2ensembl AS SELECT * FROM read_parquet('./raw/ncbi__gene2ensembl.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene_info AS SELECT * FROM read_parquet('./raw/ncbi__gene_info.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene_history AS SELECT * FROM read_parquet('./raw/ncbi__gene_history.parquet');
CREATE OR REPLACE TABLE raw.bugsigdb__full_dump AS SELECT * FROM read_parquet('./raw/bugsigdb__full_dump.parquet');
CREATE OR REPLACE TABLE raw.ensembl__gtf AS SELECT * FROM read_parquet('./raw/ensembl__gtf.parquet');
CREATE OR REPLACE TABLE reference.genome AS SELECT * FROM read_parquet('./reference/genome.parquet');
CREATE OR REPLACE TABLE annotation.gene AS SELECT * FROM read_parquet('./annotation/gene.parquet');
CREATE OR REPLACE TABLE annotation.ncbi__gene AS SELECT * FROM read_parquet('./annotation/ncbi__gene.parquet');
CREATE OR REPLACE TABLE annotation.transcript AS SELECT * FROM read_parquet('./annotation/transcript.parquet');
CREATE OR REPLACE TABLE annotation.exon AS SELECT * FROM read_parquet('./annotation/exon.parquet');
CREATE OR REPLACE TABLE annotation.identifier_mapping AS SELECT * FROM read_parquet('./annotation/identifier_mapping.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene2pubmed AS SELECT * FROM read_parquet('./raw/ncbi__gene2pubmed.parquet');
CREATE OR REPLACE TABLE annotation.ncbi__gene_pubmed AS SELECT * FROM read_parquet('./annotation/ncbi__gene_pubmed.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene2accession AS SELECT * FROM read_parquet('./raw/ncbi__gene2accession.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene2go AS SELECT * FROM read_parquet('./raw/ncbi__gene2go.parquet');
CREATE OR REPLACE TABLE annotation.ncbi__gene_go AS SELECT * FROM read_parquet('./annotation/ncbi__gene_go.parquet');
CREATE OR REPLACE TABLE raw.icite__metadata AS SELECT * FROM read_parquet('./raw/icite__metadata.parquet');
CREATE OR REPLACE TABLE annotation.icite__publication AS SELECT * FROM read_parquet('./annotation/icite__publication.parquet');
CREATE OR REPLACE TABLE annotation.icite__metrics AS SELECT * FROM read_parquet('./annotation/icite__metrics.parquet');
CREATE OR REPLACE TABLE raw.cellxgene__dataset AS SELECT * FROM read_parquet('./raw/cellxgene__dataset.parquet');
CREATE OR REPLACE TABLE resource.cellxgene__dataset AS SELECT * FROM read_parquet('./resource/cellxgene__dataset.parquet');
CREATE OR REPLACE TABLE raw.obo__cl AS SELECT * FROM read_parquet('./raw/obo__cl.parquet');
CREATE OR REPLACE TABLE raw.obo__uberon AS SELECT * FROM read_parquet('./raw/obo__uberon.parquet');
CREATE OR REPLACE TABLE raw.obo__mondo AS SELECT * FROM read_parquet('./raw/obo__mondo.parquet');
CREATE OR REPLACE TABLE raw.obo__efo AS SELECT * FROM read_parquet('./raw/obo__efo.parquet');
CREATE OR REPLACE TABLE raw.obo__hsapdv AS SELECT * FROM read_parquet('./raw/obo__hsapdv.parquet');
CREATE OR REPLACE TABLE raw.obo__mmusdv AS SELECT * FROM read_parquet('./raw/obo__mmusdv.parquet');
CREATE OR REPLACE TABLE raw.obo__go AS SELECT * FROM read_parquet('./raw/obo__go.parquet');
CREATE OR REPLACE TABLE raw.obo__doid AS SELECT * FROM read_parquet('./raw/obo__doid.parquet');
CREATE OR REPLACE TABLE ontology.term AS SELECT * FROM read_parquet('./ontology/term.parquet');
CREATE OR REPLACE TABLE ontology.relationship AS SELECT * FROM read_parquet('./ontology/relationship.parquet');
CREATE OR REPLACE TABLE raw.bedbase__bed AS SELECT * FROM read_parquet('./raw/bedbase__bed.parquet');
CREATE OR REPLACE TABLE raw.bedbase__bedset AS SELECT * FROM read_parquet('./raw/bedbase__bedset.parquet');
CREATE OR REPLACE TABLE raw.bedbase__bedset_membership AS SELECT * FROM read_parquet('./raw/bedbase__bedset_membership.parquet');
CREATE OR REPLACE TABLE resource.bedbase__bedfile AS SELECT * FROM read_parquet('./resource/bedbase__bedfile.parquet');
CREATE OR REPLACE TABLE resource.bedbase__bedset AS SELECT * FROM read_parquet('./resource/bedbase__bedset.parquet');
CREATE OR REPLACE TABLE annotation.icite__citation AS SELECT * FROM read_parquet('./annotation/icite__citation.parquet');
CREATE OR REPLACE TABLE raw.pubtator3__gene AS SELECT * FROM read_parquet('./raw/pubtator3__gene.parquet');
CREATE OR REPLACE TABLE raw.pubtator3__disease AS SELECT * FROM read_parquet('./raw/pubtator3__disease.parquet');
CREATE OR REPLACE TABLE raw.pubtator3__chemical AS SELECT * FROM read_parquet('./raw/pubtator3__chemical.parquet');
CREATE OR REPLACE TABLE raw.pubtator3__species AS SELECT * FROM read_parquet('./raw/pubtator3__species.parquet');
CREATE OR REPLACE TABLE raw.pubtator3__mutation AS SELECT * FROM read_parquet('./raw/pubtator3__mutation.parquet');
CREATE OR REPLACE TABLE annotation.pubtator3__mention AS SELECT * FROM read_parquet('./annotation/pubtator3__mention.parquet');
CREATE OR REPLACE TABLE resource.resource_relationship AS SELECT * FROM read_parquet('./resource/resource_relationship.parquet');
CREATE OR REPLACE TABLE raw.encode__experiment AS SELECT * FROM read_parquet('./raw/encode__experiment.parquet');
CREATE OR REPLACE TABLE raw.encode__file AS SELECT * FROM read_parquet('./raw/encode__file.parquet');
CREATE OR REPLACE TABLE resource.encode__experiment AS SELECT * FROM read_parquet('./resource/encode__experiment.parquet');
CREATE OR REPLACE TABLE resource.encode__file AS SELECT * FROM read_parquet('./resource/encode__file.parquet');
CREATE OR REPLACE TABLE raw.hgnc__complete_set AS SELECT * FROM read_parquet('./raw/hgnc__complete_set.parquet');
CREATE OR REPLACE TABLE annotation.hgnc__gene AS SELECT * FROM read_parquet('./annotation/hgnc__gene.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene_orthologs AS SELECT * FROM read_parquet('./raw/ncbi__gene_orthologs.parquet');
CREATE OR REPLACE TABLE raw.ncbi__gene_group AS SELECT * FROM read_parquet('./raw/ncbi__gene_group.parquet');
CREATE OR REPLACE TABLE annotation.ortholog AS SELECT * FROM read_parquet('./annotation/ortholog.parquet');
CREATE OR REPLACE TABLE raw.ncbi__mane_summary AS SELECT * FROM read_parquet('./raw/ncbi__mane_summary.parquet');
CREATE OR REPLACE TABLE annotation.mane__transcript AS SELECT * FROM read_parquet('./annotation/mane__transcript.parquet');
CREATE OR REPLACE TABLE raw.cellosaurus__release AS SELECT * FROM read_parquet('./raw/cellosaurus__release.parquet');
CREATE OR REPLACE TABLE annotation.cellosaurus__cell_line AS SELECT * FROM read_parquet('./annotation/cellosaurus__cell_line.parquet');
CREATE OR REPLACE TABLE annotation.cellosaurus__xref AS SELECT * FROM read_parquet('./annotation/cellosaurus__xref.parquet');
CREATE OR REPLACE TABLE annotation.cellosaurus__disease AS SELECT * FROM read_parquet('./annotation/cellosaurus__disease.parquet');
CREATE OR REPLACE TABLE raw.wikipathways__gmt AS SELECT * FROM read_parquet('./raw/wikipathways__gmt.parquet');
CREATE OR REPLACE TABLE annotation.wikipathways__pathway AS SELECT * FROM read_parquet('./annotation/wikipathways__pathway.parquet');
CREATE OR REPLACE TABLE annotation.wikipathways__gene_pathway AS SELECT * FROM read_parquet('./annotation/wikipathways__gene_pathway.parquet');
CREATE OR REPLACE TABLE raw.eqtlcatalogue__dataset AS SELECT * FROM read_parquet('./raw/eqtlcatalogue__dataset.parquet');
CREATE OR REPLACE TABLE raw.eqtlcatalogue__tabix_ftp_paths AS SELECT * FROM read_parquet('./raw/eqtlcatalogue__tabix_ftp_paths.parquet');
CREATE OR REPLACE TABLE resource.eqtlcatalogue__dataset AS SELECT * FROM read_parquet('./resource/eqtlcatalogue__dataset.parquet');
CREATE OR REPLACE TABLE raw.gwas_catalog__associations AS SELECT * FROM read_parquet('./raw/gwas_catalog__associations.parquet');
CREATE OR REPLACE TABLE raw.gwas_catalog__studies AS SELECT * FROM read_parquet('./raw/gwas_catalog__studies.parquet');
CREATE OR REPLACE TABLE clinical.gwas_catalog__study AS SELECT * FROM read_parquet('./clinical/gwas_catalog__study.parquet');
CREATE OR REPLACE TABLE clinical.gwas_catalog__association AS SELECT * FROM read_parquet('./clinical/gwas_catalog__association.parquet');
CREATE OR REPLACE TABLE raw.rnacentral__id_mapping AS SELECT * FROM read_parquet('./raw/rnacentral__id_mapping.parquet');
CREATE OR REPLACE TABLE annotation.rnacentral__rna AS SELECT * FROM read_parquet('./annotation/rnacentral__rna.parquet');
CREATE OR REPLACE TABLE raw.biogrid__interactions AS SELECT * FROM read_parquet('./raw/biogrid__interactions.parquet');
CREATE OR REPLACE TABLE raw.intact__mitab AS SELECT * FROM read_parquet('./raw/intact__mitab.parquet');
CREATE OR REPLACE TABLE annotation.interaction AS SELECT * FROM read_parquet('./annotation/interaction.parquet');
CREATE OR REPLACE TABLE raw.complexportal__complex AS SELECT * FROM read_parquet('./raw/complexportal__complex.parquet');
CREATE OR REPLACE TABLE annotation.complexportal__complex AS SELECT * FROM read_parquet('./annotation/complexportal__complex.parquet');
CREATE OR REPLACE TABLE annotation.complexportal__participant AS SELECT * FROM read_parquet('./annotation/complexportal__participant.parquet');
CREATE OR REPLACE TABLE annotation.signature_taxon AS SELECT * FROM read_parquet('./annotation/signature_taxon.parquet');
CREATE OR REPLACE TABLE raw.metadata AS SELECT * FROM read_parquet('./raw/metadata.parquet');
CREATE OR REPLACE TABLE annotation.pubmed__article AS SELECT * FROM read_parquet('./annotation/pubmed__article.parquet');
SELECT CASE WHEN count(*) = 0 THEN 'row counts match manifest.json'
ELSE error('row counts differ from manifest.json: ' || string_agg(r.schema || '.' || r."table", ', ')) END AS restore_check
FROM (
SELECT 'provenance' AS schema, 'release' AS "table", count(*) AS n FROM provenance.release
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene2ensembl' AS "table", count(*) AS n FROM raw.ncbi__gene2ensembl
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene_info' AS "table", count(*) AS n FROM raw.ncbi__gene_info
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene_history' AS "table", count(*) AS n FROM raw.ncbi__gene_history
UNION ALL SELECT 'raw' AS schema, 'bugsigdb__full_dump' AS "table", count(*) AS n FROM raw.bugsigdb__full_dump
UNION ALL SELECT 'raw' AS schema, 'ensembl__gtf' AS "table", count(*) AS n FROM raw.ensembl__gtf
UNION ALL SELECT 'reference' AS schema, 'genome' AS "table", count(*) AS n FROM reference.genome
UNION ALL SELECT 'annotation' AS schema, 'gene' AS "table", count(*) AS n FROM annotation.gene
UNION ALL SELECT 'annotation' AS schema, 'ncbi__gene' AS "table", count(*) AS n FROM annotation.ncbi__gene
UNION ALL SELECT 'annotation' AS schema, 'transcript' AS "table", count(*) AS n FROM annotation.transcript
UNION ALL SELECT 'annotation' AS schema, 'exon' AS "table", count(*) AS n FROM annotation.exon
UNION ALL SELECT 'annotation' AS schema, 'identifier_mapping' AS "table", count(*) AS n FROM annotation.identifier_mapping
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene2pubmed' AS "table", count(*) AS n FROM raw.ncbi__gene2pubmed
UNION ALL SELECT 'annotation' AS schema, 'ncbi__gene_pubmed' AS "table", count(*) AS n FROM annotation.ncbi__gene_pubmed
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene2accession' AS "table", count(*) AS n FROM raw.ncbi__gene2accession
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene2go' AS "table", count(*) AS n FROM raw.ncbi__gene2go
UNION ALL SELECT 'annotation' AS schema, 'ncbi__gene_go' AS "table", count(*) AS n FROM annotation.ncbi__gene_go
UNION ALL SELECT 'raw' AS schema, 'icite__metadata' AS "table", count(*) AS n FROM raw.icite__metadata
UNION ALL SELECT 'annotation' AS schema, 'icite__publication' AS "table", count(*) AS n FROM annotation.icite__publication
UNION ALL SELECT 'annotation' AS schema, 'icite__metrics' AS "table", count(*) AS n FROM annotation.icite__metrics
UNION ALL SELECT 'raw' AS schema, 'cellxgene__dataset' AS "table", count(*) AS n FROM raw.cellxgene__dataset
UNION ALL SELECT 'resource' AS schema, 'cellxgene__dataset' AS "table", count(*) AS n FROM resource.cellxgene__dataset
UNION ALL SELECT 'raw' AS schema, 'obo__cl' AS "table", count(*) AS n FROM raw.obo__cl
UNION ALL SELECT 'raw' AS schema, 'obo__uberon' AS "table", count(*) AS n FROM raw.obo__uberon
UNION ALL SELECT 'raw' AS schema, 'obo__mondo' AS "table", count(*) AS n FROM raw.obo__mondo
UNION ALL SELECT 'raw' AS schema, 'obo__efo' AS "table", count(*) AS n FROM raw.obo__efo
UNION ALL SELECT 'raw' AS schema, 'obo__hsapdv' AS "table", count(*) AS n FROM raw.obo__hsapdv
UNION ALL SELECT 'raw' AS schema, 'obo__mmusdv' AS "table", count(*) AS n FROM raw.obo__mmusdv
UNION ALL SELECT 'raw' AS schema, 'obo__go' AS "table", count(*) AS n FROM raw.obo__go
UNION ALL SELECT 'raw' AS schema, 'obo__doid' AS "table", count(*) AS n FROM raw.obo__doid
UNION ALL SELECT 'ontology' AS schema, 'term' AS "table", count(*) AS n FROM ontology.term
UNION ALL SELECT 'ontology' AS schema, 'relationship' AS "table", count(*) AS n FROM ontology.relationship
UNION ALL SELECT 'raw' AS schema, 'bedbase__bed' AS "table", count(*) AS n FROM raw.bedbase__bed
UNION ALL SELECT 'raw' AS schema, 'bedbase__bedset' AS "table", count(*) AS n FROM raw.bedbase__bedset
UNION ALL SELECT 'raw' AS schema, 'bedbase__bedset_membership' AS "table", count(*) AS n FROM raw.bedbase__bedset_membership
UNION ALL SELECT 'resource' AS schema, 'bedbase__bedfile' AS "table", count(*) AS n FROM resource.bedbase__bedfile
UNION ALL SELECT 'resource' AS schema, 'bedbase__bedset' AS "table", count(*) AS n FROM resource.bedbase__bedset
UNION ALL SELECT 'annotation' AS schema, 'icite__citation' AS "table", count(*) AS n FROM annotation.icite__citation
UNION ALL SELECT 'raw' AS schema, 'pubtator3__gene' AS "table", count(*) AS n FROM raw.pubtator3__gene
UNION ALL SELECT 'raw' AS schema, 'pubtator3__disease' AS "table", count(*) AS n FROM raw.pubtator3__disease
UNION ALL SELECT 'raw' AS schema, 'pubtator3__chemical' AS "table", count(*) AS n FROM raw.pubtator3__chemical
UNION ALL SELECT 'raw' AS schema, 'pubtator3__species' AS "table", count(*) AS n FROM raw.pubtator3__species
UNION ALL SELECT 'raw' AS schema, 'pubtator3__mutation' AS "table", count(*) AS n FROM raw.pubtator3__mutation
UNION ALL SELECT 'annotation' AS schema, 'pubtator3__mention' AS "table", count(*) AS n FROM annotation.pubtator3__mention
UNION ALL SELECT 'resource' AS schema, 'resource_relationship' AS "table", count(*) AS n FROM resource.resource_relationship
UNION ALL SELECT 'raw' AS schema, 'encode__experiment' AS "table", count(*) AS n FROM raw.encode__experiment
UNION ALL SELECT 'raw' AS schema, 'encode__file' AS "table", count(*) AS n FROM raw.encode__file
UNION ALL SELECT 'resource' AS schema, 'encode__experiment' AS "table", count(*) AS n FROM resource.encode__experiment
UNION ALL SELECT 'resource' AS schema, 'encode__file' AS "table", count(*) AS n FROM resource.encode__file
UNION ALL SELECT 'raw' AS schema, 'hgnc__complete_set' AS "table", count(*) AS n FROM raw.hgnc__complete_set
UNION ALL SELECT 'annotation' AS schema, 'hgnc__gene' AS "table", count(*) AS n FROM annotation.hgnc__gene
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene_orthologs' AS "table", count(*) AS n FROM raw.ncbi__gene_orthologs
UNION ALL SELECT 'raw' AS schema, 'ncbi__gene_group' AS "table", count(*) AS n FROM raw.ncbi__gene_group
UNION ALL SELECT 'annotation' AS schema, 'ortholog' AS "table", count(*) AS n FROM annotation.ortholog
UNION ALL SELECT 'raw' AS schema, 'ncbi__mane_summary' AS "table", count(*) AS n FROM raw.ncbi__mane_summary
UNION ALL SELECT 'annotation' AS schema, 'mane__transcript' AS "table", count(*) AS n FROM annotation.mane__transcript
UNION ALL SELECT 'raw' AS schema, 'cellosaurus__release' AS "table", count(*) AS n FROM raw.cellosaurus__release
UNION ALL SELECT 'annotation' AS schema, 'cellosaurus__cell_line' AS "table", count(*) AS n FROM annotation.cellosaurus__cell_line
UNION ALL SELECT 'annotation' AS schema, 'cellosaurus__xref' AS "table", count(*) AS n FROM annotation.cellosaurus__xref
UNION ALL SELECT 'annotation' AS schema, 'cellosaurus__disease' AS "table", count(*) AS n FROM annotation.cellosaurus__disease
UNION ALL SELECT 'raw' AS schema, 'wikipathways__gmt' AS "table", count(*) AS n FROM raw.wikipathways__gmt
UNION ALL SELECT 'annotation' AS schema, 'wikipathways__pathway' AS "table", count(*) AS n FROM annotation.wikipathways__pathway
UNION ALL SELECT 'annotation' AS schema, 'wikipathways__gene_pathway' AS "table", count(*) AS n FROM annotation.wikipathways__gene_pathway
UNION ALL SELECT 'raw' AS schema, 'eqtlcatalogue__dataset' AS "table", count(*) AS n FROM raw.eqtlcatalogue__dataset
UNION ALL SELECT 'raw' AS schema, 'eqtlcatalogue__tabix_ftp_paths' AS "table", count(*) AS n FROM raw.eqtlcatalogue__tabix_ftp_paths
UNION ALL SELECT 'resource' AS schema, 'eqtlcatalogue__dataset' AS "table", count(*) AS n FROM resource.eqtlcatalogue__dataset
UNION ALL SELECT 'raw' AS schema, 'gwas_catalog__associations' AS "table", count(*) AS n FROM raw.gwas_catalog__associations
UNION ALL SELECT 'raw' AS schema, 'gwas_catalog__studies' AS "table", count(*) AS n FROM raw.gwas_catalog__studies
UNION ALL SELECT 'clinical' AS schema, 'gwas_catalog__study' AS "table", count(*) AS n FROM clinical.gwas_catalog__study
UNION ALL SELECT 'clinical' AS schema, 'gwas_catalog__association' AS "table", count(*) AS n FROM clinical.gwas_catalog__association
UNION ALL SELECT 'raw' AS schema, 'rnacentral__id_mapping' AS "table", count(*) AS n FROM raw.rnacentral__id_mapping
UNION ALL SELECT 'annotation' AS schema, 'rnacentral__rna' AS "table", count(*) AS n FROM annotation.rnacentral__rna
UNION ALL SELECT 'raw' AS schema, 'biogrid__interactions' AS "table", count(*) AS n FROM raw.biogrid__interactions
UNION ALL SELECT 'raw' AS schema, 'intact__mitab' AS "table", count(*) AS n FROM raw.intact__mitab
UNION ALL SELECT 'annotation' AS schema, 'interaction' AS "table", count(*) AS n FROM annotation.interaction
UNION ALL SELECT 'raw' AS schema, 'complexportal__complex' AS "table", count(*) AS n FROM raw.complexportal__complex
UNION ALL SELECT 'annotation' AS schema, 'complexportal__complex' AS "table", count(*) AS n FROM annotation.complexportal__complex
UNION ALL SELECT 'annotation' AS schema, 'complexportal__participant' AS "table", count(*) AS n FROM annotation.complexportal__participant
UNION ALL SELECT 'annotation' AS schema, 'signature_taxon' AS "table", count(*) AS n FROM annotation.signature_taxon
UNION ALL SELECT 'raw' AS schema, 'metadata' AS "table", count(*) AS n FROM raw.metadata
UNION ALL SELECT 'annotation' AS schema, 'pubmed__article' AS "table", count(*) AS n FROM annotation.pubmed__article
) r
LEFT JOIN (SELECT t.schema, t."table", t.row_count FROM (SELECT unnest(tables) AS t FROM read_json('./manifest.json'))) m
ON r.schema = m.schema AND r."table" = m."table"
WHERE m.row_count IS DISTINCT FROM r.n;