Browse Source

Created a chado_semweb table for storing mapping of terms to Chado table columns.

Stephen Ficklin 8 years ago
parent
commit
662962e541

+ 0 - 1
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -430,7 +430,6 @@ function tripal_insert_cv($name, $definition) {
  *        $term['id'] and it needs to be explicitly set.  Use this argument
  *        only if the database name cannot be specififed in the term ID
  *        (e.g. <DB>:<ACCESSION>).
- *    - namespace: DEPRECATED. Please use cv_name instead.
  * @param $options
  *   An associative array with the following keys:
  *    - update_existing: By default this is TRUE.  If the term exists it is

+ 36 - 0
tripal_chado/api/tripal_chado.api.inc

@@ -254,3 +254,39 @@ function tripal_replace_chado_tokens($string, $record) {
   }
   return $string;
 }
+
+/**
+ *
+ */
+function tripal_associate_chado_semweb_term($chado_table, $chado_column, $term) {
+
+  // Check to see if the record has already been added to the chado_semweb table
+  $query = db_select('chado_semweb', 'CS');
+  $query->fields('CS', array('chado_semweb_id'));
+  $query->condition('chado_column', $chado_column);
+  $query->condition('cvterm_id', $term->cvterm_id);
+  if ($chado_table) {
+    $query->condition('chado_table', $chado_table);
+  }
+  $id = $query->execute()->fetchField();
+
+  $values = array(
+    'chado_table' => $chado_table,
+    'chado_column' => $chado_column,
+    'cvterm_id' => $term->cvterm_id,
+  );
+  // If we have an ID then this is an update, otherwise it's an insert.
+  if ($id) {
+    $values['chado_semweb_id'] = $id;
+    $success = drupal_write_record('chado_semweb', $values, 'chado_semweb_id');
+  }
+  else {
+    $success = drupal_write_record('chado_semweb', $values);
+  }
+  if (!$success) {
+    FALSE;
+  }
+
+  return TRUE;
+}
+

+ 212 - 0
tripal_chado/includes/tripal_chado.setup.inc

@@ -1848,4 +1848,216 @@ function tripal_insert_misc_cvterms() {
     ),
     array('update_existing' => TRUE)
   );
+}
+
+/**
+ * Adds defaults to the chado_semweb table.
+ */
+function tripal_chado_populate_chado_semweb_table() {
+  //
+  // VOCABUARIES:
+  // Add in vocabularies of terms that will be used for the semantic web
+  //
+  tripal_insert_db(array(
+    'name' => 'foaf',
+    'description' => 'Friend of a Friend. A dictionary of people-related terms that can be used in structured data).',
+    'url' => 'http://www.foaf-project.org/',
+    'urlprefix' => 'http://xmlns.com/foaf/spec/#',
+  ));
+  tripal_insert_cv('foaf','Friend of a Friend');
+
+  tripal_insert_db(array(
+    'name' => 'schema',
+    'description' => 'Schema.org. Schema.org is sponsored by Google, Microsoft, Yahoo and Yandex. The vocabularies are developed by an open community process.',
+    'url' => 'https://schema.org/',
+    'urlprefix' => 'https://schema.org/',
+  ));
+  tripal_insert_cv('schema','Schema.org');
+
+  tripal_insert_db(array(
+    'name' => 'TAXRANK',
+    'description' => 'Taxonomic rank vocabulary. A vocabulary of taxonomic ranks (species, family, phylum, etc).',
+    'url' => 'https://github.com/phenoscape/taxrank',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/TAXRANK_',
+  ));
+  tripal_insert_cv('taxrank','Taxonomic rank vocabulary');
+
+  tripal_insert_db(array(
+    'name' => 'NCBITaxon',
+    'description' => 'NCBI organismal classification. An ontology representation of the NCBI organismal taxonomy.',
+    'url' => 'http://www.berkeleybop.org/ontologies/ncbitaxon/',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/ncbitaxon#',
+  ));
+  tripal_insert_cv('ncbitaxon','NCBI organismal classification');
+
+  tripal_insert_db(array(
+    'name' => 'SWO',
+    'description' => 'Software Ontology. An ontology representation of the NCBI organismal taxonomy.',
+    'url' => 'http://theswo.sourceforge.net/',
+    'urlprefix' => '',
+  ));
+  tripal_insert_cv('swo','Software Ontology');
+
+  tripal_insert_db(array(
+    'name' => 'IAO',
+    'description' => 'The Information Artifact Ontology (IAO) is a new ' .
+      'ontology of information entities, originally driven by work by the ' .
+      'OBI digital entity and realizable information entity branch.',
+    'url' => 'https://github.com/information-artifact-ontology/IAO/',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/IAO_',
+  ));
+  tripal_insert_cv('IAO','Information Artifact Ontology');
+
+  //
+  // GENERIC TERMS
+  //
+  $name = tripal_insert_cvterm(array(
+    'id' => 'schema:name',
+    'name' => 'name',
+    'cv_name' => 'schema',
+    'definition' => 'The name of the item.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'uniquename', $name);
+  tripal_associate_chado_semweb_term(NULL, 'name', $name);
+
+  $alternate_name = tripal_insert_cvterm(array(
+    'id' => 'schema:alternateName',
+    'name' => 'alternateName',
+    'cv_name' => 'schema',
+    'definition' => 'The name of the item.',
+  ));
+
+  $description = tripal_insert_cvterm(array(
+    'id' => 'schema:description',
+    'name' => 'description',
+    'cv_name' => 'schema',
+    'definition' => 'A description of the item.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'definition', $description);
+  tripal_associate_chado_semweb_term(NULL, 'description', $description);
+
+  $comment = tripal_insert_cvterm(array(
+    'id' => 'schema:comment',
+    'name' => 'comment',
+    'cv_name' => 'schema',
+    'definition' => 'Comments, typically from users.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'comment', $comment);
+
+  $time_last_modified = tripal_insert_cvterm(array(
+    'id' => 'local:timelastmodified',
+    'name' => 'time_last_modified',
+    'cv_name' => 'local',
+    'definition' => 'The time at which a record for an item was first added.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'timelastmodified', $time_last_modified);
+
+
+  $time_accessioned = tripal_insert_cvterm(array(
+    'id' => 'local:timeaccessioned',
+    'name' => 'time_accessioned',
+    'cv_name' => 'local',
+    'definition' => 'The time at which a record for an item was last upated or modified.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'timeaccessioned', $time_accessioned);
+
+  $time_executed = tripal_insert_cvterm(array(
+    'id' => 'local:timeexecuted',
+    'name' => 'time_executed',
+    'cv_name' => 'local',
+    'definition' => 'The time at which a task was executed.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'timeaccessioned', $time_executed);
+
+  //
+  // ANALYSIS TABLE
+  //
+  $term = tripal_insert_cvterm(array(
+    'id' => 'SWO:0000001',
+    'name' => 'software',
+    'cv_name' => 'schema',
+    'definition' => 'Computer software, or generally just software, is any ' .
+      'set of machine-readable instructions (most often in the form of a ' .
+      'computer program) that conform to a given syntax (sometimes ' .
+      'referred to as a language) that is interpretable by a given ' .
+      'processor and that directs a computer\'s processor to perform ' .
+      'specific operations.',
+  ));
+  tripal_associate_chado_semweb_term('analysis', 'program', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'IAO:0000129',
+    'name' => 'version number',
+    'cv_name' => 'IAO',
+    'definition' => 'A version number is an ' .
+      'information content entity which is a sequence of characters ' .
+      'borne by part of each of a class of manufactured products or its ' .
+      'packaging and indicates its order within a set of other products ' .
+      'having the same name.',
+  ));
+  tripal_associate_chado_semweb_term('analysis', 'programversion', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'IAO:0000064',
+    'name' => 'algorithm',
+    'cv_name' => 'IAO',
+    'definition' => 'An algorithm is a set of instructions for performing a paticular calculation.',
+  ));
+  tripal_associate_chado_semweb_term('analysis', 'algorithm', $term);
+
+  //
+  // ORGANISM TABLE
+  //
+  $term = tripal_insert_cvterm(array(
+    'id' => 'TAXRANK:0000005',
+    'name' => 'genus',
+    'cv_name' => 'taxrank',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'genus', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'TAXRANK:0000006',
+    'name' => 'species',
+    'cv_name' => 'taxrank',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'species', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'TAXRANK:0000045',
+    'name' => 'infraspecies',
+    'cv_name' => 'taxrank',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'infraspecific_name', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'NCBITaxon:common_name',
+    'name' => 'common name',
+    'cv_name' => 'ncbitaxon',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'common_name', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'local:abbreviation',
+    'name' => 'abbreviation',
+    'cv_name' => 'local',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'abbreviation', $term);
+
+  //
+  // FEATURE TABLE
+  //
+  tripal_associate_chado_semweb_term('feature', 'name', $alternate_name);
+
+  //
+  // PUB TABLE
+  //
+  tripal_associate_chado_semweb_term('pub', 'uniquename', $comment);
+
+
+  //
+  // STOCK TABLE
+  //
+  tripal_associate_chado_semweb_term('stock', 'name', $alternate_name);
+
+
 }