def update_PDB_ihm_related_datasets(model): # -- add columns utils.create_column_if_not_exist( model, 'PDB', 'ihm_related_datasets', Column.define( 'transformation_id', builtin_types.int8, comment= 'Identifier corresponding to the transformation matrix to be applied to the derived dataset in order to transform it to the primary dataset', nullok=True)) utils.create_column_if_not_exist( model, 'PDB', 'ihm_related_datasets', Column.define('Transformation_RID', builtin_types.text, comment='Identifier to the transformation RID', nullok=True)) # -- add fk utils.create_foreign_key_if_not_exists( model, 'PDB', 'ihm_related_datasets', 'ihm_related_datasets_ihm_data_transformation_combo2_fkey', ForeignKey.define( ['Transformation_RID', 'transformation_id'], 'PDB', 'ihm_data_transformation', ['RID', 'id'], constraint_names=[[ 'PDB', 'ihm_related_datasets_ihm_data_transformation_combo2_fkey' ]], on_update='CASCADE', on_delete='NO ACTION'))
def create_study_collection_table(self): schema = self.model.schemas[self.DATA] table_def = Table.define( "Study_Collection", column_defs=[ Column.define("Study", builtin_types.text, nullok=False), Column.define("Collection", builtin_types.text, nullok=False) ], key_defs=[Key.define(["Study", "Collection"])], fkey_defs=[ ForeignKey.define(["Study"], self.DATA, "Study", ["RID"], constraint_names=[[ self.DATA, "Study_Collection_Study_fkey" ]]), ForeignKey.define(["Collection"], self.DATA, "Collection", ["RID"], constraint_names=[[ self.DATA, "Study_Collection_Collection_fkey" ]]) ], comment="Many-to-many associations between studies and collection") self.try_create_table(schema, table_def)
def unit_setup(self): # get public schema model = self._ermrest_catalog.getCatalogModel() public = model.schemas['public'] assert isinstance(public, Schema) # create schema for sname in self._unit_schema_names: model.create_schema(Schema.define(sname)) # create table public.create_table( Table.define( self.samples, column_defs=[ Column.define(self.FIELDS[0], builtin_types.int8, False) ] + [ Column.define(field_name, builtin_types.text) for field_name in self.FIELDS[1:] ], key_defs=[Key.define(['id'])])) # insert test data pb = self._ermrest_catalog.getPathBuilder() samples = pb.schemas['public'].tables[self.samples] samples.insert(self.test_data)
def define_tdoc_Data_Dictionary(): table_name = 'Data_Dictionary' comment = 'Dictionary containing all available versions.' column_defs = [ Column.define('Name', builtin_types.text, comment='The name of the dictionary', nullok=False), Column.define('Category', builtin_types.text, comment='The category of the dictionary', nullok=False), Column.define('Version', builtin_types.text, comment='The version of the dictionary', nullok=False), Column.define('Location', builtin_types.text, comment='The location of the dictionary', nullok=False) ] key_defs = [ Key.define(['Name', 'Version'], constraint_names=[['PDB', 'Data_Dictionary_primary_key']]), Key.define( ['RID', 'Category'], constraint_names=[['PDB', 'Data_Dictionary_RID_Category_key']]), Key.define(['RID'], constraint_names=[['PDB', 'Data_Dictionary_RID_key']]), ] fkey_defs = [ ForeignKey.define( ['Name'], 'Vocab', 'Data_Dictionary_Name', ['Name'], constraint_names=[['PDB', 'Data_Dictionary_Name_fkey']], on_update='CASCADE', on_delete='CASCADE'), ForeignKey.define( ['Category'], 'Vocab', 'Data_Dictionary_Category', ['Name'], constraint_names=[['PDB', 'Data_Dictionary_Category_fkey']], on_update='CASCADE', on_delete='CASCADE') ] table_def = Table.define(table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=comment, provide_system=True) return table_def
def define_tdoc_Conform_Dictionary(): table_name = 'Conform_Dictionary' comment = 'Dictionary associated to the export mmCIF file.' column_defs = [ Column.define( 'Exported_mmCIF_RID', builtin_types.text, comment='The reference to the RID of the exported mmCIF file.', nullok=False), Column.define( 'Data_Dictionary_RID', builtin_types.text, comment= 'The reference to the RID of the Data_Dictionary version for the mmCIF file.', nullok=False) ] key_defs = [ Key.define(['Exported_mmCIF_RID', 'Data_Dictionary_RID'], constraint_names=[['PDB', 'Conform_Dictionary_primary_key']]), Key.define(['RID'], constraint_names=[['PDB', 'Conform_Dictionary_RID_key']]), ] fkey_defs = [ ForeignKey.define(['Exported_mmCIF_RID'], 'PDB', 'Entry_mmCIF_File', ['RID'], constraint_names=[[ 'PDB', 'Conform_Dictionary_Entry_mmCIF_File_fkey' ]], on_update='CASCADE', on_delete='CASCADE'), ForeignKey.define(['Data_Dictionary_RID'], 'PDB', 'Data_Dictionary', ['RID'], constraint_names=[[ 'PDB', 'Conform_Dictionary_Data_Dictionary_fkey' ]], on_update='CASCADE', on_delete='CASCADE') ] table_def = Table.define(table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=comment, provide_system=True) return table_def
def update_PDB_ihm_cross_link_restraint(model): # Add the PDB.ihm_cross_link_restraint.pseudo_site_flag column utils.create_column_if_not_exist( model, 'PDB', 'ihm_cross_link_restraint', Column.define( 'pseudo_site_flag', builtin_types.text, comment= 'A flag indicating if the cross link involves a pseudo site that is not part of the model representation', nullok=True)) # Create the foreign key PDB.ihm_cross_link_restraint.pseudo_site_flag references Vocab.pseudo_site_flag.Name utils.create_foreign_key_if_not_exists( model, 'PDB', 'ihm_cross_link_restraint', 'ihm_cross_link_restraint_pseudo_site_flag_fkey', ForeignKey.define(['pseudo_site_flag'], 'Vocab', 'pseudo_site_flag', ['Name'], constraint_names=[[ 'Vocab', 'ihm_cross_link_restraint_pseudo_site_flag_fkey' ]], on_update='CASCADE', on_delete='NO ACTION')) # Create combo1 key utils.create_key_if_not_exists(model, 'PDB', 'ihm_cross_link_restraint', ['RID', 'structure_id', 'id'], 'ihm_cross_link_restraint_combo1_key')
def create_chromosome_table(self): schema = self.model.schemas[self.chromosome_schema] schema.create_table( Table.define(self.chromosome_table, [ Column.define("Name", builtin_types.text, nullok=False), Column.define("Species", builtin_types.text, nullok=False) ], key_defs=[Key.define(["Name", "Species"])], fkey_defs=[ ForeignKey.define(["Species"], self.species_schema, self.species_table, self.adjust_fkey_columns_case( self.species_schema, self.species_table, ["ID"])) ]))
def update_PDB_ihm_derived_distance_restraint(model): # -- add columns utils.create_column_if_not_exist( model, 'PDB', 'ihm_derived_distance_restraint', Column.define( 'distance_threshold_mean', builtin_types.float8, comment='The distance threshold mean applied to the restraint', nullok=True)) utils.create_column_if_not_exist( model, 'PDB', 'ihm_derived_distance_restraint', Column.define( 'distance_threshold_esd', builtin_types.float8, comment= 'The estimated standard deviation of the distance threshold applied to the restraint', nullok=True))
def update_PDB_ihm_ensemble_info(model): # Add the PDB.ihm_ensemble_info.sub_sample_flag and PDB.ihm_ensemble_info.sub_sampling_type columns utils.create_column_if_not_exist( model, 'PDB', 'ihm_ensemble_info', Column.define( 'sub_sample_flag', builtin_types.text, comment= 'A flag that indicates whether the ensemble consists of sub samples', nullok=True)) utils.create_column_if_not_exist( model, 'PDB', 'ihm_ensemble_info', Column.define('sub_sampling_type', builtin_types.text, comment='Type of sub sampling', nullok=True)) # Create the foreign keys utils.create_foreign_key_if_not_exists( model, 'PDB', 'ihm_ensemble_info', 'ihm_ensemble_info_sub_sample_flag_fkey', ForeignKey.define(['sub_sample_flag'], 'Vocab', 'sub_sample_flag', ['Name'], constraint_names=[[ 'Vocab', 'ihm_ensemble_info_sub_sample_flag_fkey' ]], on_update='CASCADE', on_delete='NO ACTION')) utils.create_foreign_key_if_not_exists( model, 'PDB', 'ihm_ensemble_info', 'ihm_ensemble_info_sub_sampling_type_fkey', ForeignKey.define(['sub_sampling_type'], 'Vocab', 'sub_sampling_type', ['Name'], constraint_names=[[ 'Vocab', 'ihm_ensemble_info_sub_sampling_type_fkey' ]], on_update='CASCADE', on_delete='NO ACTION')) utils.create_key_if_not_exists(model, 'PDB', 'ihm_ensemble_info', ['RID', 'structure_id', 'ensemble_id'], 'ihm_ensemble_info_combo1_key')
def define_tdoc_Supported_Dictionary(): table_name = 'Supported_Dictionary' comment = 'Dictionary containing the latest supported versions.' column_defs = [ Column.define( 'Data_Dictionary_RID', builtin_types.text, comment= 'The reference to the RID of the latest Data_Dictionary version', nullok=False), Column.define( 'Data_Dictionary_Category', builtin_types.text, comment= 'The reference to the category of the latest Data_Dictionary version', nullok=False) ] key_defs = [ Key.define( ['Data_Dictionary_Category'], constraint_names=[['PDB', 'Supported_Dictionary_primary_key']]), Key.define(['RID'], constraint_names=[['PDB', 'Supported_Dictionary_RID_key']]), ] fkey_defs = [ ForeignKey.define( ['Data_Dictionary_RID', 'Data_Dictionary_Category'], 'PDB', 'Data_Dictionary', ['RID', 'Category'], constraint_names=[['PDB', 'Supported_Dictionary_fkey']], on_update='CASCADE', on_delete='CASCADE') ] table_def = Table.define(table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=comment, provide_system=True) return table_def
def create_study_table(self): schema = self.model.schemas[self.DATA] table_def = Table.define( "Study", column_defs=[ Column.define( "Internal_ID", builtin_types.text, nullok=False, comment="data-provider-defined unique identifier"), Column.define("Title", builtin_types.text, nullok=False), Column.define("Summary", builtin_types.text, nullok=False), Column.define("Pubmed_ID", builtin_types.text, nullok=True), ], key_defs=[Key.define(["Internal_ID"]), Key.define(["Title"])], comment="A sequencing or metabolomics study") self.try_create_table(schema, table_def)
def tdef(tname): return Table.define( tname, [ Column.define( "descendant", builtin_types.text, nullok=False, comment="Contained dataset in transitive relationship." ), Column.define( "ancestor", builtin_types.text, nullok=False, comment="Containing dataset in transitive relationship." ), ], [ Key.define( ["descendant", "ancestor"], constraint_names=[["CFDE", tname + "_assoc_key"]]), ], [ ForeignKey.define( ["descendant"], "CFDE", "dataset", ["id"], constraint_names=[["CFDE", tname + "_descendant_fkey"] ], ), ForeignKey.define( ["ancestor"], "CFDE", "dataset", ["id"], constraint_names=[["CFDE", tname + "_ancestor_fkey"]], ), ], comment= "Flattened, transitive closure of nested DatasetsInDatasets relationship.", )
def create_collection_table(self): schema = self.model.schemas[self.DATA] table_def = Table.define("Collection", column_defs=[ Column.define("Title", builtin_types.text, nullok=False), Column.define("Description", builtin_types.text, nullok=False), Column.define("Persistent_ID", builtin_types.text, nullok=True), Column.define("Details", builtin_types.markdown, nullok=True) ], key_defs=[Key.define(["Title"])], comment="A collection of data") self.try_create_table(schema, table_def)
def create_experiment_table(self): schema = self.model.schemas[self.DATA] table_def = Table.define( "Experiment", column_defs=[ # rbk Notes becomes experiment Internal_ID Column.define( "Internal_ID", builtin_types.text, nullok=False, comment="data-provider-defined unique identifier"), Column.define("Study", builtin_types.text, nullok=False, comment="study that this experiment is part of"), Column.define("Molecule_Type", builtin_types.text, nullok=False), Column.define("Cell_Count", builtin_types.int4, nullok=True), Column.define("Notes", builtin_types.markdown, nullok=True), ], key_defs=[ Key.define(["Internal_ID"]), ], fkey_defs=[ ForeignKey.define( ["Study"], self.DATA, "Study", ["RID"], constraint_names=[[self.DATA, "Experiment_Study_fkey"]]), ForeignKey.define(["Molecule_Type"], self.VOCABULARY, "Molecule_Type", ["Name"], constraint_names=[[ self.DATA, "Experiment_Molecule_Type_fkey" ]]) ], comment="A sequencing or metabolomics experiment") self.try_create_table(schema, table_def)
def create_source_file_table(self): schema = self.model.schemas[self.source_file_schema] schema.create_table( Table.define(self.source_file_table, [ Column.define("Species", builtin_types.text, nullok=False, comment="Species this file represents"), Column.define( "Downloaded_From", builtin_types.text, comment= "URL of remote file (e.g., from NCBI) that this was downladoed from" ), Column.define("File_Name", builtin_types.text, nullok=False), Column.define("File_URL", builtin_types.text, nullok=False), Column.define("File_Bytes", builtin_types.int4, nullok=False), Column.define("File_MD5", builtin_types.text, nullok=False) ], key_defs=[Key.define(["Species"])], fkey_defs=[ ForeignKey.define(["Species"], self.species_schema, self.species_table, self.adjust_fkey_columns_case( self.species_schema, self.species_table, ["ID"])) ]))
def create_dbxref_table(self): schema = self.model.schemas[self.dbxref_schema] schema.create_table( Table.define(self.dbxref_table, [ Column.define("Gene", builtin_types.text, nullok=False, comment='Gene that this identifier refers to'), Column.define("Alternate_ID", builtin_types.text, nullok=False), Column.define("Alternate_Ontology", builtin_types.text, nullok=False, comment='Ontology this identifier is from'), Column.define( "Reference_URL", builtin_types.text, nullok=True, comment= 'URL to a description, in this alternate ontology, of this gene' ) ], key_defs=[Key.define(["Gene", "Alternate_ID"])], fkey_defs=[ ForeignKey.define(["Gene"], self.gene_schema, self.gene_table, self.adjust_fkey_columns_case( self.gene_schema, self.gene_table, ["ID"])), ForeignKey.define(["Alternate_Ontology"], self.ontology_schema, self.ontology_table, self.adjust_fkey_columns_case( self.ontology_schema, self.ontology_table, ["ID"])) ], comment= 'Alternate gene identifiers from different ontologies' ))
def create_file_table(self): schema = self.model.schemas[self.DATA] table_def = Table.define( "File", column_defs=[ Column.define("Replicate", builtin_types.text, nullok=False, comment="Replicate that generated this file"), Column.define("File_URI", builtin_types.text, nullok=False, comment="URI for this file"), Column.define("File_Name", builtin_types.text, nullok=False, comment="Name of file when uploaded"), Column.define("File_Size", builtin_types.int8, nullok=False, comment="Size of file in bytes"), Column.define("File_MD5", builtin_types.text, nullok=False, comment="MD5 checksum of this file"), Column.define("File_SHA256", builtin_types.text, nullok=False, comment="SHA256 checksum of this file"), Column.define("File_Type", builtin_types.text, nullok=False), Column.define("Caption", builtin_types.text, nullok=True) ], key_defs=[Key.define(["File_MD5"]), Key.define(["File_URI"])], fkey_defs=[ ForeignKey.define( ["Replicate"], self.DATA, "Replicate", ["RID"], constraint_names=[[self.DATA, "File_Replicate_fkey"]]), ForeignKey.define( ["File_Type"], self.VOCABULARY, "File_Type", ["Name"], constraint_names=[[self.DATA, "File_File_Type_fkey"]]) ], comment="Data files") self.try_create_table(schema, table_def)
def dataset_property(srctable, srccolumn): tname = 'dataset_denorm_%s' % srccolumn.name return ( tname, Table.define( tname, [ Column.define( "dataset", builtin_types.text, nullok=False), Column.define(srccolumn.name, builtin_types.text, srccolumn.nullok), ], [ Key.define(["dataset", srccolumn.name]), ], [ ForeignKey.define( ["dataset"], "CFDE", "dataset", ["id"], constraint_names=[["CFDE", "%s_ds_fkey" % tname]], ) ] + [ ForeignKey.define( [srccolumn.name], 'CFDE', fkey.referenced_columns[0].table.name, [c.name for c in fkey.referenced_columns], constraint_names=[['CFDE', '%s_prop_fkey' % tname]]) for fkey in srctable.foreign_keys if {srccolumn.name} == set([c.name for c in fkey.foreign_key_columns]) ], ))
def create_ontology_table(self): schema = self.model.schemas[self.ontology_schema] table = schema.create_table( Table.define_vocabulary( self.ontology_table, '{prefix}:{{RID}}'.format(prefix=self.curie_prefix), key_defs=[Key.define(['Name'])], uri_template='https://{host}/id/{{RID}}'.format( host=self.host), comment="Ontologies")) table.create_column( Column.define("Ontology_Home", builtin_types.text, nullok=True, comment="Home page for this ontology"))
def make_column(cdef): cdef = dict(cdef) constraints = cdef.get("constraints", {}) cdef_name = cdef.pop("name") nullok = not constraints.pop("required", False) description = cdef.pop("description", None) return Column.define(cdef_name, make_type( cdef.get("type", "string"), cdef.get("format", "default"), ), nullok=nullok, comment=description, annotations={ schema_tag: cdef, })
def create_specimen_table(self): schema = self.model.schemas[self.DATA] table_def = Table.define( "Specimen", column_defs=[ Column.define("Species", builtin_types.text, nullok=False), Column.define("Sex", builtin_types.text, nullok=True), Column.define("Stage", builtin_types.text, nullok=True, comment="developmental stage of this specimen"), Column.define("Anatomy", builtin_types.text, nullok=True), Column.define( "Assay_Type", builtin_types.text, nullok=False, comment="type of assay performed on this specimen"), Column.define( "Internal_ID", builtin_types.text, nullok=True, comment="data-provider-defined unique identifier") ], key_defs=[Key.define(["Internal_ID"])], fkey_defs=[ ForeignKey.define( ["Species"], self.VOCABULARY, "Species", ["Name"], constraint_names=[[self.DATA, "Specimen_Species_fkey"]]), ForeignKey.define( ["Sex"], self.VOCABULARY, "Sex", ["Name"], constraint_names=[[self.DATA, "Specimen_Sex_fkey"]]), ForeignKey.define( ["Stage"], self.VOCABULARY, "Stage", ["Name"], constraint_names=[[self.DATA, "Specimen_Stage_fkey"]]), ForeignKey.define( ["Assay_Type"], self.VOCABULARY, "Assay_Type", ["Name"], constraint_names=[[self.DATA, "Specimen_Assay_Type_fkey"]]), ForeignKey.define( ["Anatomy"], self.VOCABULARY, "Anatomy", ["ID"], constraint_names=[[self.DATA, "Specimen_Anatomy_fkey"]]) ], comment="A biospeciment") self.try_create_table(schema, table_def)
def create_replicate_table(self): schema = self.model.schemas[self.DATA] table_def = Table.define( "Replicate", column_defs=[ Column.define( "Experiment", builtin_types.text, nullok=False, comment="Experiment that produced this replicate"), Column.define("Biological_Replicate_Number", builtin_types.int4, nullok=False), Column.define("Technical_Replicate_Number", builtin_types.int4, nullok=False), Column.define("Mapped_Reads", builtin_types.float8, nullok=True), Column.define("RNA_Reads", builtin_types.float8, nullok=True), Column.define("Specimen", builtin_types.text, nullok=False), Column.define("Description", builtin_types.text, nullok=True) ], key_defs=[ Key.define([ "Experiment", "Biological_Replicate_Number", "Technical_Replicate_Number" ]) ], fkey_defs=[ ForeignKey.define( ["Experiment"], self.DATA, "Experiment", ["RID"], constraint_names=[[self.DATA, "Replicate_Experiment_fkey"]]), ForeignKey.define( ["Specimen"], self.DATA, "Specimen", ["RID"], constraint_names=[[self.DATA, "Replicate_Specimen_fkey"]]) ], comment= "A biological or technical replicate in a sequencing experiment") self.try_create_table(schema, table_def)
def make_column(tname, cdef, configurator): cdef = dict(cdef) constraints = cdef.get("constraints", {}) cdef_name = cdef.pop("name") title = cdef.get("title", None) nullok = not constraints.pop("required", False) default = cdef.pop("default", None) description = cdef.pop("description", None) annotations = { schema_tag: cdef, } if title is not None: annotations[tag.display] = {"name": title} pre_annotations = cdef.get("deriva", {}) for k, t in tag.items(): if k in pre_annotations: annotations[t] = pre_annotations.pop(k) acls = acls_union( configurator.schema_table_column_acls.get( (schema_name, tname, cdef_name), {}), pre_annotations.pop('acls', {})) acl_bindings = aclbindings_merge( configurator.schema_table_column_aclbindings.get( (schema_name, tname, cdef_name), {}), pre_annotations.pop('acl_bindings', {})) return Column.define( cdef_name, make_type( cdef.get("type", "string"), cdef.get("format", "default"), ), nullok=nullok, default=default, comment=description, annotations=annotations, acls=acls, acl_bindings=acl_bindings, )
def create_gene_table(self, extra_boolean_cols=[]): schema = self.model.schemas[self.gene_schema] common_cols = [ Column.define("Gene_Type", builtin_types.text, nullok=False), Column.define("Species", builtin_types.text, nullok=False), Column.define("Chromosome", builtin_types.text), Column.define("Location", builtin_types.text, comment="Location on chromosome"), Column.define( "Source_Date", builtin_types.date, comment="Last-updated date reported by the gene data source") ] for colname in extra_boolean_cols: common_cols.append(Column.define(colname, builtin_types.boolean)) fkey_defs = [ ForeignKey.define(["Gene_Type"], self.gene_type_schema, self.gene_type_table, self.adjust_fkey_columns_case(["ID"])), ForeignKey.define(["Species"], self.species_schema, self.species_table, self.adjust_fkey_columns_case( self.species_schema, self.species_table, ["ID"])), ForeignKey.define(["Chromosome"], self.chromosome_schema, self.chromosome_table, ["RID"]) ] key_defs = [["NCBI_GeneID"]] table = schema.create_table( Table.define_vocabulary( self.gene_table, '{prefix}:{{RID}}'.format(prefix=self.curie_prefix), column_defs=column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment="Genes"))
def define_Vocab_table(table_name, table_comment): column_defs = [ Column.define( "ID", builtin_types.ermrest_curie, comment='The preferred Compact URI (CURIE) for this term.', nullok=False, default="PDB:{RID}"), Column.define("URI", builtin_types.ermrest_uri, nullok=False, default="/id/{RID}", comment="The preferred URI for this term."), Column.define("Name", builtin_types.text, nullok=False), Column.define("Description", builtin_types.markdown, nullok=False), Column.define("Synonyms", builtin_types["text[]"], nullok=True, comment="Alternate human-readable names for this term."), Column.define("Owner", builtin_types.text, comment='Group that can update the record.', nullok=True) ] key_defs = [ Key.define( ["URI"], constraint_names=[["Vocab", '{}_URI_key'.format(table_name)]]), Key.define( ["Name"], constraint_names=[["Vocab", '{}_Name_key'.format(table_name)]]), Key.define(["ID"], constraint_names=[["Vocab", '{}_ID_key'.format(table_name)]]), Key.define( ["RID"], constraint_names=[["Vocab", '{}_RID_key'.format(table_name)]]) ] fkey_defs = [ ForeignKey.define( ["RCB"], "public", "ERMrest_Client", ["ID"], constraint_names=[["Vocab", '{}_RCB_fkey'.format(table_name)]], on_update="NO ACTION", on_delete="NO ACTION"), ForeignKey.define( ["RMB"], "public", "ERMrest_Client", ["ID"], constraint_names=[["Vocab", '{}_RMB_fkey'.format(table_name)]], on_update="NO ACTION", on_delete="NO ACTION"), ForeignKey.define( ["Owner"], "public", "Catalog_Group", ["ID"], constraint_names=[["Vocab", '{}_Owner_fkey'.format(table_name)]], on_update="NO ACTION", on_delete="NO ACTION") ] table_def = Table.define(table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=table_comment, provide_system=True) return table_def
def define_tdoc_ihm_hdx_restraint(): table_name = 'ihm_hdx_restraint' comment = 'Details of restraint derived from hydrogen-deuterium (H/D) exchange experiments; can be uploaded as CSV/TSV file above; mmCIF category: ihm_hdx_restraint' column_defs = [ Column.define('id', builtin_types.int8, comment='A unique id for the H/D exchange restraint', nullok=False), Column.define( 'feature_id', builtin_types.int8, comment='An identifier for the peptide / residue feature', nullok=False), Column.define('Feature_RID', builtin_types.text, comment='Identifier to the feature RID', nullok=False), Column.define( 'protection_factor', builtin_types.float8, comment= 'The value of the protection factor determined from H/D exchange experiments', nullok=True), Column.define( 'dataset_list_id', builtin_types.int8, comment= 'Identifier to the H/D exchange input data from which the restraints are derived', nullok=False), Column.define('Dataset_List_RID', builtin_types.text, comment='Identifier to the dataset list RID', nullok=False), Column.define( 'details', builtin_types.text, comment='Additional details regarding the H/D exchange restraint', nullok=True), Column.define('structure_id', builtin_types.text, comment='Structure identifier', nullok=False), Column.define( 'Entry_Related_File', builtin_types.text, comment= 'A reference to the uploaded restraint file in the table Entry_Related_File.id', nullok=True) ] key_defs = [ Key.define(['structure_id', 'id'], constraint_names=[['PDB', 'ihm_hdx_restraint_primary_key']]), Key.define(['RID'], constraint_names=[['PDB', 'ihm_hdx_restraint_RID_key']]), ] fkey_defs = [ ForeignKey.define( ['structure_id'], 'PDB', 'entry', ['id'], constraint_names=[['PDB', 'ihm_hdx_restraint_structure_id_fkey']], on_update='CASCADE', on_delete='NO ACTION'), ForeignKey.define(['Feature_RID', 'structure_id', 'feature_id'], 'PDB', 'ihm_feature_list', ['RID', 'structure_id', 'feature_id'], constraint_names=[[ 'PDB', 'ihm_hdx_restraint_ihm_feature_list_combo1_fkey' ]], on_update='CASCADE', on_delete='NO ACTION'), ForeignKey.define( ['Dataset_List_RID', 'structure_id', 'dataset_list_id'], 'PDB', 'ihm_dataset_list', ['RID', 'structure_id', 'id'], constraint_names=[[ 'PDB', 'ihm_hdx_restraint_ihm_dataset_list_combo1_fkey' ]], on_update='CASCADE', on_delete='NO ACTION'), ForeignKey.define(['Entry_Related_File'], 'PDB', 'Entry_Related_File', ['RID'], constraint_names=[[ 'PDB', 'ihm_hdx_restraint_Entry_Related_File_fkey' ]], on_update='CASCADE', on_delete='NO ACTION') ] table_def = Table.define(table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=comment, provide_system=True) return table_def
hostname = args.hostname schema_name = args.schema_name catalog = args.catalog_number credential = get_credential(hostname) server = DerivaServer('https', hostname, credential) catalog = server.connect_ermrest(catalog) model = catalog.getCatalogModel() schema = model.schemas[schema_name] config = catalog.getCatalogConfig() column_defs = [ Column.define("Step_RID", typ.text), Column.define("File_RID", typ.text), ] key_defs = [ Key.define( ["Step_RID","File_RID"], # this is a list to allow for compound keys constraint_names=[ [schema_name, "Step_OutputFile_Mapping_RID_key"] ], comment="Step plus file must be distinct.", annotations={}, ) ] fkey_defs = [ ForeignKey.define( ["Step_RID"], # this is a list to allow for compound foreign keys "Core",
def define_tdoc_ihm_cross_link_pseudo_site(): table_name='ihm_cross_link_pseudo_site' comment='Details of pseudo sites involved in crosslinks; can be uploaded as CSV/TSV file above; mmCIF category: ihm_cross_link_pseudo_site' column_defs = [ Column.define( 'id', builtin_types.int8, comment='An identifier for a pseudo site involved in a crosslink', nullok=False ), Column.define( 'restraint_id', builtin_types.int8, comment='An identifier for the crosslink restraint between a pair of residues', nullok=False ), Column.define( 'cross_link_partner', builtin_types.text, comment='The identity of the crosslink partner corresponding to the pseudo site', nullok=False ), Column.define( 'pseudo_site_id', builtin_types.int8, comment='The pseudo site identifier corresponding to the crosslink partner', nullok=False ), Column.define( 'model_id', builtin_types.int8, comment='Identifier to the model that the pseudo site corresponds to', nullok=True ), Column.define( 'Entry_Related_File', builtin_types.text, comment='A reference to the uploaded restraint file in the table Entry_Related_File.id.', nullok=True ), Column.define( 'structure_id', builtin_types.text, comment='Structure identifier', nullok=False ), # HT: to use for Chaise Column.define( 'Model_RID', builtin_types.text, comment='Identifier to the model RID', nullok=True ), Column.define( 'Pseudo_Site_RID', builtin_types.text, comment='Identifier to the pseudo site RID', nullok=False ), Column.define( 'Restraint_RID', builtin_types.text, comment='Identifier to the restraint RID', nullok=False ) ] #BV: This is a leaf table; so no combo1/combo2 keys required key_defs = [ Key.define(['structure_id', 'id'], constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_primary_key']] ), Key.define(['RID'], constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_RID_key']] ), ] # @brinda: add fk pseudo-definition fkey_defs = [ # HT: it own fk to Entry table ForeignKey.define(['structure_id'], 'PDB', 'entry', ['id'], constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_structure_id_fkey']], on_update='CASCADE', on_delete='NO ACTION' ), # -- begin ihm_cross_link_restraint # HT: In annotation, apply domain_filter to filter the RID list by constraining structure_id ForeignKey.define(['Restraint_RID', 'structure_id', 'restraint_id'], 'PDB', 'ihm_cross_link_restraint', ['RID', 'structure_id', 'id'], constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_ihm_cross_link_restraint_combo1_fkey']], on_update='CASCADE', on_delete='NO ACTION' ), # -- end ihm_cross_link_restraint # -- begin ihm_model_list table # HT: This is for chaise optional foreign key --> check naming convention # HT: In annotation, apply domain_filter to filter the RID list by constraining structure_id # BV: Not required anymore based on the google doc with fkey conventions #ForeignKey.define(['Model_RID'], 'PDB', 'ihm_model_list', ['RID'], # constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_Model_RID_fkey']], # on_update='CASCADE', # on_delete='NO ACTION' #), # HT: equivalent fk so that Chaise will automatically fill in automatically --> check constraint naming convention ForeignKey.define(['Model_RID', 'model_id'], 'PDB', 'ihm_model_list', ['RID', 'model_id'], constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_ihm_model_list_combo2_fkey']], on_update='CASCADE', on_delete='NO ACTION' ), # -- end ihm_model_list table ForeignKey.define(['Pseudo_Site_RID', 'structure_id', 'pseudo_site_id'], 'PDB', 'ihm_pseudo_site', ['RID', 'structure_id', 'id'], constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_ihm_pseudo_site_combo1_fkey']], on_update='CASCADE', on_delete='NO ACTION' ), ForeignKey.define(['cross_link_partner'], 'Vocab', 'cross_link_partner', ['Name'], constraint_names=[ ['Vocab', 'ihm_cross_link_pseudo_site_cross_link_partner_fkey'] ], on_update='CASCADE', on_delete='NO ACTION' ), ForeignKey.define(['Entry_Related_File'], 'PDB', 'Entry_Related_File', ['RID'], constraint_names=[['PDB', 'ihm_cross_link_pseudo_site_Entry_Related_File_fkey']], on_update='CASCADE', on_delete='NO ACTION' ) ] table_def = Table.define( table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=comment, provide_system=True ) return table_def
def define_tdoc_ihm_data_transformation(): table_name = 'ihm_data_transformation' comment = 'Details of rotation matrix and translation vector that can be applied to transform data; mmCIF category: ihm_data_transformation' column_defs = [ Column.define('id', builtin_types.int8, comment='An identifier to the transformation matrix', nullok=False), Column.define( 'rot_matrix[1][1]', builtin_types.float8, comment= 'Data item [1][1] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[2][1]', builtin_types.float8, comment= 'Data item [2][1] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[3][1]', builtin_types.float8, comment= 'Data item [3][1] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[1][2]', builtin_types.float8, comment= 'Data item [1][2] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[2][2]', builtin_types.float8, comment= 'Data item [2][2] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[3][2]', builtin_types.float8, comment= 'Data item [3][2] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[1][3]', builtin_types.float8, comment= 'Data item [1][3] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[2][3]', builtin_types.float8, comment= 'Data item [2][3] of the rotation matrix used in the transformation', nullok=True), Column.define( 'rot_matrix[3][3]', builtin_types.float8, comment= 'Data item [3][3] of the rotation matrix used in the transformation', nullok=True), Column.define( 'tr_vector[1]', builtin_types.float8, comment= 'Data item [1] of the translation vector used in the transformation', nullok=True), Column.define( 'tr_vector[2]', builtin_types.float8, comment= 'Data item [2] of the translation vector used in the transformation', nullok=True), Column.define( 'tr_vector[3]', builtin_types.float8, comment= 'Data item [3] of the translation vector used in the transformation', nullok=True), Column.define('structure_id', builtin_types.text, comment='Structure identifier', nullok=False) ] #BV: This is a parent table with optional columns in the child table; so combo2 key is defined key_defs = [ Key.define( ['structure_id', 'id'], constraint_names=[['PDB', 'ihm_data_transformation_primary_key']]), Key.define( ['RID'], constraint_names=[['PDB', 'ihm_data_transformation_RID_key']]), Key.define( ['RID', 'id'], constraint_names=[['PDB', 'ihm_data_transformation_combo2_key']]) ] # @brinda: add fk pseudo-definition #BV: No outgoing fkeys other than structure_id fkey_defs = [ ForeignKey.define(['structure_id'], 'PDB', 'entry', ['id'], constraint_names=[[ 'PDB', 'ihm_data_transformation_structure_id_fkey' ]], on_update='CASCADE', on_delete='NO ACTION') ] table_def = Table.define(table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=comment, provide_system=True) return table_def
def define_tdoc_ihm_derived_angle_restraint(): table_name = 'ihm_derived_angle_restraint' comment = 'Details of angle restraints used in integrative modeling; can be uploaded as CSV/TSV file above; mmCIF category: ihm_derived_angle_restraint' column_defs = [ Column.define("id", builtin_types.int8, comment='An identifier for the angle restraint', nullok=False), Column.define("group_id", builtin_types.int8, comment='An identifier to group the angle restraints', nullok=True), Column.define( "feature_id_1", builtin_types.int8, comment= 'The feature identifier for the first partner in the angle restraint', nullok=False), Column.define( "feature_id_2", builtin_types.int8, comment= 'The feature identifier for the second partner in the angle restraint', nullok=False), Column.define( "feature_id_3", builtin_types.int8, comment= 'The feature identifier for the third partner in the angle restraint', nullok=False), Column.define( "group_conditionality", builtin_types.text, comment= 'If a group of angles are restrained together, this data item defines the conditionality based on which the restraint is applied in the modeling', nullok=True), Column.define( "angle_lower_limit", builtin_types.float8, comment= 'The lower limit to the threshold applied to this angle restraint', nullok=True), Column.define( "angle_upper_limit", builtin_types.float8, comment= 'The upper limit to the threshold applied to this angle restraint', nullok=True), Column.define( "angle_lower_limit_esd", builtin_types.float8, comment= 'The estimated standard deviation of the lower limit angle threshold applied', nullok=True), Column.define( "angle_upper_limit_esd", builtin_types.float8, comment= 'The estimated standard deviation of the upper limit angle threshold applied', nullok=True), Column.define( "probability", builtin_types.float8, comment='The probability that the angle restraint is correct', nullok=True), Column.define("restraint_type", builtin_types.text, comment='The type of angle restraint applied', nullok=False), Column.define( "angle_threshold_mean", builtin_types.float8, comment='The angle threshold mean applied to the restraint', nullok=True), Column.define( "angle_threshold_mean_esd", builtin_types.float8, comment= 'The estimated standard deviation of the angle threshold mean applied to the restraint', nullok=True), Column.define( "dataset_list_id", builtin_types.int8, comment= 'Identifier to the input data from which the angle restraint is derived', nullok=False), Column.define( "Entry_Related_File", builtin_types.text, comment= 'A reference to the uploaded restraint file in the table Entry_Related_File.id.', nullok=True), Column.define("structure_id", builtin_types.text, comment='Structure identifier', nullok=False), # HT: to use for Chaise Column.define("Feature_Id_1_RID", builtin_types.text, comment='Identifier to the feature 1 RID', nullok=False), Column.define("Feature_Id_2_RID", builtin_types.text, comment='Identifier to the feature 2 RID', nullok=False), Column.define("Feature_Id_3_RID", builtin_types.text, comment='Identifier to the feature 3 RID', nullok=False), Column.define("Dataset_List_RID", builtin_types.text, comment='Identifier to the dataset list RID', nullok=False) ] #BV: This is a leaf table; so no combo1/combo2 keys required key_defs = [ Key.define(["structure_id", "id"], constraint_names=[[ "PDB", "ihm_derived_angle_restraint_primary_key" ]]), Key.define( ["RID"], constraint_names=[["PDB", "ihm_derived_angle_restraint_RID_key"]]), ] # @brinda: add fk pseudo-definition fkey_defs = [ # HT: it own fk to Entry table ForeignKey.define(["structure_id"], "PDB", "entry", ["id"], constraint_names=[[ "PDB", "ihm_derived_angle_restraint_structure_id_fkey" ]], on_update="CASCADE", on_delete="NO ACTION"), # HT: In annotation, apply domain_filter to filter the RID list by constraining structure_id ForeignKey.define( ["Feature_Id_1_RID", "structure_id", "feature_id_1"], "PDB", "ihm_feature_list", ["RID", "structure_id", "feature_id"], constraint_names=[[ "PDB", "ihm_derived_angle_restraint_ihm_feature_list_1_combo1_fkey" ]], on_update="CASCADE", on_delete="NO ACTION"), ForeignKey.define( ["Feature_Id_2_RID", "structure_id", "feature_id_2"], "PDB", "ihm_feature_list", ["RID", "structure_id", "feature_id"], constraint_names=[[ "PDB", "ihm_derived_angle_restraint_ihm_feature_list_2_combo1_fkey" ]], on_update="CASCADE", on_delete="NO ACTION"), ForeignKey.define( ["Feature_Id_3_RID", "structure_id", "feature_id_3"], "PDB", "ihm_feature_list", ["RID", "structure_id", "feature_id"], constraint_names=[[ "PDB", "ihm_derived_angle_restraint_ihm_feature_list_3_combo1_fkey" ]], on_update="CASCADE", on_delete="NO ACTION"), ForeignKey.define( ["Dataset_List_RID", "structure_id", "dataset_list_id"], "PDB", "ihm_dataset_list", ["RID", "structure_id", "id"], constraint_names=[[ "PDB", "ihm_derived_angle_restraint_ihm_dataset_list_combo1_fkey" ]], on_update="CASCADE", on_delete="NO ACTION"), ForeignKey.define( ["group_conditionality"], "Vocab", "ihm_derived_angle_restraint_group_conditionality", ["Name"], constraint_names=[[ "Vocab", "ihm_derived_angle_restraint_group_conditionality_fkey" ]], on_update="CASCADE", on_delete="NO ACTION"), ForeignKey.define(["restraint_type"], "Vocab", "ihm_derived_angle_restraint_restraint_type", ["Name"], constraint_names=[[ "Vocab", "ihm_derived_angle_restraint_restraint_type_fkey" ]], on_update="CASCADE", on_delete="NO ACTION"), ForeignKey.define( ["Entry_Related_File"], "PDB", "Entry_Related_File", ["RID"], constraint_names=[[ "PDB", "ihm_derived_angle_restraint_Entry_Related_File_fkey" ]], on_update="CASCADE", on_delete="NO ACTION") ] table_def = Table.define(table_name, column_defs, key_defs=key_defs, fkey_defs=fkey_defs, comment=comment, provide_system=True) return table_def