Browse Source

Fixed a few minor bugs. Added the cvtermpath menu item back from Tv2 legacy code. Added an upated to fix a bad cvterm, and fixed the label for the analysis algorithm field

Stephen Ficklin 7 years ago
parent
commit
d95e68d23d

+ 0 - 68
legacy/tripal_cv/includes/tripal_cv.cvtermpath_form.inc

@@ -1,68 +0,0 @@
-<?php
-/**
- * @file
- * Provides a form for updating controlled vocabularies path
- */
-
-/**
- * Form for re-doing the cvterm path
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvtermpath_form() {
-
-  // get a list of db from chado for user to choose
-  $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
-  $results = chado_query($sql);
-
-  $cvs = array();
-  $cvs[] = '';
-  foreach ($results as $cv) {
-    $cvs[$cv->cv_id] = $cv->name;
-  }
-
-  $form['cvid'] = array(
-    '#title' => t('Controlled Vocabulary/Ontology Name'),
-    '#type' => 'select',
-    '#options' => $cvs,
-    '#description' => t('The Chado cvtermpath is a database table that provides lineage for ontology terms
-      and is useful for quickly finding any ancestor parent of a term.  This table must be populated for each
-      ontology.  Select a controlled vocabulary for which you would like to upate the cvtermpath.'),
-  );
-
-  $form['description'] = array(
-    '#type' => 'item',
-    '#value' => t("Submit a job to update chado cvtermpath table."),
-    '#weight' => 1,
-  );
-
-  $form['button'] = array(
-    '#type' => 'submit',
-    '#value' => t('Update cvtermpath'),
-    '#weight' => 2,
-  );
-
-  return $form;
-}
-
-/**
- * Cvterm path form submit
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvtermpath_form_submit($form, &$form_state) {
-  global $user;
-
-  $cvid =  $form_state['values']['cvid'];
-
-  // first get the controlled vocabulary name:
-  $sql = "SELECT * FROM {cv} WHERE cv_id = :cv_id";
-  $cv = chado_query($sql, array(':cv_id' => $cvid))->fetchObject();
-
-  // Submit a job to update cvtermpath
-  $job_args = array($cvid);
-  if ($form_state['values']['op'] == t('Update cvtermpath')) {
-    tripal_add_job("Update cvtermpath: $cv->name", 'tripal_cv',
-       'tripal_cv_update_cvtermpath', $job_args, $user->uid);
-  }
-}

+ 0 - 10
legacy/tripal_cv/tripal_cv.module

@@ -20,7 +20,6 @@ require_once 'includes/tripal_cv.admin.inc';
 require_once 'includes/tripal_cv.cv_form.inc';
 require_once 'includes/tripal_cv.cv_defaults.inc';
 require_once 'includes/tripal_cv.cvterm_form.inc';
-require_once 'includes/tripal_cv.cvtermpath_form.inc';
 
 /**
  * Implements hook_init().
@@ -61,15 +60,6 @@ function tripal_cv_menu() {
     'weight' => 10
   );
 
-  $items['admin/tripal/legacy/vocab/cvtermpath'] = array(
-    'title' => 'Update Chado cvtermpath table',
-    'description' => 'The Chado cvtermpath table provides lineage for terms and is useful for quickly finding any ancestor parent of a term.  However, this table must be populated.  This page allows for populating of this table one vocabulary at a time',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_cv_cvtermpath_form'),
-    'access arguments' => array('administer controlled vocabularies'),
-    'type' => MENU_CALLBACK,
-  );
-
   $items['admin/tripal/legacy/vocab/cv/edit/%'] = array(
     'title' => 'Edit a Controlled Vocabulary',
     'description' => 'Edit the details such as name and description for an existing controlled vocabulary.',

+ 2 - 3
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -338,7 +338,7 @@ function tripal_get_cvterm_select_options($cv_id, $rel_type = FALSE) {
  *
  * @ingroup tripal_chado_api
  */
-function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
+function tripal_update_cvtermpath_old($cv_id, $job_id = NULL) {
   // TODO: need better error checking in this function
 
   // first get the controlled vocabulary name:
@@ -376,7 +376,7 @@ function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
  *   The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id).
  * @param $job_id
  */
-function tripal_update_cvtermpath_bak($cv_id, $job_id = NULL){
+function tripal_update_cvtermpath($cv_id, $job_id = NULL){
   // TODO: there's a function to determine the current Chado instance.
   // we should use that.
   $prev_db = chado_set_active('chado');
@@ -1655,4 +1655,3 @@ function tripal_set_default_cv($table, $field, $cv_name, $cv_id = FALSE) {
   }
 }
 
-

+ 4 - 1
tripal_chado/api/tripal_chado.semweb.api.inc

@@ -202,7 +202,10 @@ function tripal_get_chado_semweb_term($chado_table, $chado_column, $options = ar
  *   The semantic web name for the term.
  */
 function tripal_format_chado_semweb_term($cvterm) {
-  return $cvterm->dbxref_id->db_id->name . ':' . $cvterm->dbxref_id->accession;
+  if ($cvterm) {
+    return $cvterm->dbxref_id->db_id->name . ':' . $cvterm->dbxref_id->accession;
+  }
+  return '';
 }
 /**
  * Retreive the column name in a Chado table that matches a given term.

+ 4 - 6
tripal_chado/includes/TripalImporter/OBOImporter.inc

@@ -503,13 +503,11 @@ class OBOImporter extends TripalImporter {
     }
 
     // second, parse the OBO
-    $success = $this->loadOBO_v1_2($temp, $newcvs);
-    if ($success) {
+    $this->loadOBO_v1_2($temp, $newcvs);
+
+    // update the cvtermpath table
+    $this->load_cvtermpath($newcvs);
 
-      // update the cvtermpath table
-      $this->load_cvtermpath($newcvs);
-      print "Done\n";
-    }
     // now remove the temp file
     unlink($temp);
   }

+ 63 - 0
tripal_chado/includes/tripal_chado.cv.inc

@@ -775,3 +775,66 @@ function tripal_cv_cvterm_edit_form_ajax($form, $form_state) {
 
   return $elements;
 }
+
+/**
+ * Form for re-doing the cvterm path
+ *
+ * @ingroup tripal_cv
+ */
+function tripal_cv_cvtermpath_form() {
+
+  // get a list of db from chado for user to choose
+  $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
+  $results = chado_query($sql);
+
+  $cvs = array();
+  $cvs[] = '';
+  foreach ($results as $cv) {
+    $cvs[$cv->cv_id] = $cv->name;
+  }
+
+  $form['cvid'] = array(
+    '#title' => t('Controlled Vocabulary/Ontology Name'),
+    '#type' => 'select',
+    '#options' => $cvs,
+    '#description' => t('The Chado cvtermpath is a database table that provides lineage for ontology terms
+      and is useful for quickly finding any ancestor parent of a term.  This table must be populated for each
+      ontology.  Select a controlled vocabulary for which you would like to upate the cvtermpath.'),
+  );
+
+  $form['description'] = array(
+    '#type' => 'item',
+    '#value' => t("Submit a job to update chado cvtermpath table."),
+    '#weight' => 1,
+  );
+
+  $form['button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Update cvtermpath'),
+    '#weight' => 2,
+  );
+
+  return $form;
+}
+
+/**
+ * Cvterm path form submit
+ *
+ * @ingroup tripal_cv
+ */
+function tripal_cv_cvtermpath_form_submit($form, &$form_state) {
+  global $user;
+
+  $cvid =  $form_state['values']['cvid'];
+
+  // first get the controlled vocabulary name:
+  $sql = "SELECT * FROM {cv} WHERE cv_id = :cv_id";
+  $cv = chado_query($sql, array(':cv_id' => $cvid))->fetchObject();
+
+  // Submit a job to update cvtermpath
+  $job_args = array($cvid);
+  if ($form_state['values']['op'] == t('Update cvtermpath')) {
+    tripal_add_job("Update cvtermpath: $cv->name", 'tripal_cv',
+        'tripal_update_cvtermpath', $job_args, $user->uid, 10);
+  }
+}

+ 1 - 1
tripal_chado/includes/tripal_chado.fields.inc

@@ -934,7 +934,7 @@ function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle,
       $base_info['label'] = 'Program, Pipeline, Workflow or Method Name';
     }
     if ($table_name == 'analysis' and $column_name == 'algorithm') {
-      $base_info['label'] = 'Source Version';
+      $base_info['label'] = 'Algorithm';
       $base_info['description'] = 'The name of the algorithm used to produce the dataset if different from the program.';
     }
     if ($table_name == 'analysis' and $column_name == 'programversion') {

+ 2 - 2
tripal_chado/includes/tripal_chado.semweb.inc

@@ -213,8 +213,8 @@ function tripal_chado_populate_vocab_SCHEMA() {
   $term = tripal_insert_cvterm(array(
     'id' => 'schema:additionalType',
     'name' => 'additionalType',
-    'cv_name' => 'An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in.',
-    'definition' => 'URL of the item.',
+    'cv_name' => 'schema',
+    'definition' => 'An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in.',
   ));
   $tables = chado_get_table_names(TRUE);
   foreach ($tables as $table) {

+ 18 - 0
tripal_chado/tripal_chado.install

@@ -1221,4 +1221,22 @@ function tripal_chado_update_7314() {
     $error = $e->getMessage();
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
+}
+/**
+ * Fixes a mistake with the schema:additionalType term.
+ */
+function tripal_chado_update_7315() {
+  try {
+    $term = tripal_insert_cvterm(array(
+      'id' => 'schema:additionalType',
+      'name' => 'additionalType',
+      'cv_name' => 'schema',
+      'definition' => 'An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in.',
+    ));
+    chado_delete_record('cv', array('name' => 'An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in.'));
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
 }

+ 10 - 0
tripal_chado/tripal_chado.module

@@ -628,6 +628,16 @@ function tripal_chado_menu() {
     'type' => MENU_CALLBACK,
   );
 
+  $items['admin/tripal/storage/chado/cvtermpath'] = array(
+    'title' => 'Update Chado cvtermpath table',
+    'description' => 'The Chado cvtermpath table provides lineage for terms and is useful for quickly finding any ancestor parent of a term.  However, this table must be populated.  This page allows for populating of this table one vocabulary at a time',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_cv_cvtermpath_form'),
+    'access arguments' => array('administer controlled vocabularies'),
+    'file' => 'includes/tripal_chado.cv.inc',
+    'file path' => drupal_get_path('module', 'tripal_chado'),
+    'type' => MENU_NORMAL_ITEM,
+  );
   //////////////////////////////////////////////////////////////////////////////
   //                           Databases
   //////////////////////////////////////////////////////////////////////////////