|
@@ -641,181 +641,6 @@ function tripal_cv_cvterm_callback() {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-///////////////////////////////
|
|
|
-// Ontology Loader
|
|
|
-//////////////////////////////
|
|
|
-
|
|
|
-/**
|
|
|
- * Purpose: Provides the form to load an already existing controlled
|
|
|
- * Vocabulary into chado
|
|
|
- *
|
|
|
- * @ingroup tripal_obo_loader
|
|
|
- */
|
|
|
-function tripal_cv_obo_form(&$form_state = NULL) {
|
|
|
-
|
|
|
- // get a list of db from chado for user to choose
|
|
|
- $sql = "SELECT * FROM {tripal_cv_obo} ORDER BY obo_id";
|
|
|
- $results = db_query($sql);
|
|
|
-
|
|
|
- $obos = array();
|
|
|
- $obos[] = '';
|
|
|
- while ($obo = db_fetch_object($results)) {
|
|
|
- $obos[$obo->obo_id] = "$obo->name | $obo->path";
|
|
|
- }
|
|
|
-
|
|
|
- $form['obo_existing'] = array(
|
|
|
- '#type' => 'fieldset',
|
|
|
- '#title' => t('Use a Saved Ontology OBO Reference')
|
|
|
- );
|
|
|
-
|
|
|
- $form['obo_new'] = array(
|
|
|
- '#type' => 'fieldset',
|
|
|
- '#title' => t('Use a New Ontology OBO Reference')
|
|
|
- );
|
|
|
-
|
|
|
- $form['obo_existing']['existing_instructions']= array(
|
|
|
- '#value' => t('The Ontology OBO files listed in the drop down below have been automatically added upon
|
|
|
- installation of the Tripal CV module or were added from a previous upload. Select
|
|
|
- an OBO, then click the submit button to load the vocabulary into the database. If the
|
|
|
- vocabularies already exist then the ontology will be updated.'),
|
|
|
- '#weight' => -1
|
|
|
- );
|
|
|
-
|
|
|
- $form['obo_existing']['obo_id'] = array(
|
|
|
- '#title' => t('Ontology OBO File Reference'),
|
|
|
- '#type' => 'select',
|
|
|
- '#options' => $obos,
|
|
|
- '#weight' => 0
|
|
|
- );
|
|
|
-
|
|
|
- $form['obo_new']['path_instructions']= array(
|
|
|
- '#value' => t('Provide the name and path for the OBO file. If the vocabulary OBO file
|
|
|
- is stored local to the server provide a file name. If the vocabulry is stored remotely,
|
|
|
- provide a URL. Only provide a URL or a local file, not both.'),
|
|
|
- '#weight' => 0
|
|
|
- );
|
|
|
-
|
|
|
- $form['obo_new']['obo_name']= array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('New Vocabulary Name'),
|
|
|
- '#description' => t('Please provide a name for this vocabulary. After upload, this name will appear in the drop down
|
|
|
- list above for use again later.'),
|
|
|
- '#weight' => 1
|
|
|
- );
|
|
|
-
|
|
|
- $form['obo_new']['obo_url']= array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Remote URL'),
|
|
|
- '#description' => t('Please enter a URL for the online OBO file. The file will be downloaded and parsed.
|
|
|
- (e.g. http://www.obofoundry.org/ro/ro.obo'),
|
|
|
- '#default_value' => $default_desc,
|
|
|
- '#weight' => 2
|
|
|
- );
|
|
|
-
|
|
|
- $form['obo_new']['obo_file']= array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Local File'),
|
|
|
- '#description' => t('Please enter the full system path for an OBO definition file, or a path within the Drupal
|
|
|
- installation (e.g. /sites/default/files/xyz.obo). The path must be accessible to the
|
|
|
- server on which this Drupal instance is running.'),
|
|
|
- '#default_value' => $default_desc,
|
|
|
- '#weight' => 3
|
|
|
- );
|
|
|
-
|
|
|
- $form['submit'] = array(
|
|
|
- '#type' => 'submit',
|
|
|
- '#value' => t('Submit'),
|
|
|
- '#weight' => 5,
|
|
|
- '#executes_submit_callback' => TRUE,
|
|
|
- );
|
|
|
-
|
|
|
- $form['#redirect'] = 'admin/tripal/tripal_cv/obo_loader';
|
|
|
-
|
|
|
- return $form;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Purpose: The submit function for the load ontology form. It registers a
|
|
|
- * tripal job to run the obo_loader.php script
|
|
|
- *
|
|
|
- * @ingroup tripal_obo_loader
|
|
|
- */
|
|
|
-function tripal_cv_obo_form_submit($form, &$form_state) {
|
|
|
- global $user;
|
|
|
-
|
|
|
- $obo_id = $form_state['values']['obo_id'];
|
|
|
- $obo_name = $form_state['values']['obo_name'];
|
|
|
- $obo_url = $form_state['values']['obo_url'];
|
|
|
- $obo_file = $form_state['values']['obo_file'];
|
|
|
-
|
|
|
- $sql = "SELECT * FROM {tripal_cv_obo} WHERE obo_id = %d";
|
|
|
- $obo = db_fetch_object(db_query($sql, $obo_id));
|
|
|
-
|
|
|
- if ($obo_id) {
|
|
|
- $args = array($obo_id);
|
|
|
- tripal_add_job("Load OBO $obo->name", 'tripal_cv',
|
|
|
- "tripal_cv_load_obo_v1_2_id", $args, $user->uid);
|
|
|
- }
|
|
|
- else {
|
|
|
- if ($obo_url) {
|
|
|
- $args = array($obo_name, $obo_url);
|
|
|
- tripal_add_job("Load OBO $obo_name", 'tripal_cv',
|
|
|
- "tripal_cv_load_obo_v1_2_url", $args, $user->uid);
|
|
|
- }
|
|
|
- elseif ($obo_file) {
|
|
|
- $args = array($obo_name, $obo_file);
|
|
|
- tripal_add_job("Load OBO $obo_name", 'tripal_cv',
|
|
|
- "tripal_cv_load_obo_v1_2_file", $args, $user->uid);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-////////////////////////////////////
|
|
|
-// cvterm path management
|
|
|
-///////////////////////////////////
|
|
|
-
|
|
|
-/**
|
|
|
- * 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[] = '';
|
|
|
- while ($cv = db_fetch_object($results)) {
|
|
|
- $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
|
|
|
*
|
|
@@ -835,82 +660,4 @@ function tripal_cv_cvtermpath_form_submit($form, &$form_state) {
|
|
|
tripal_add_job("Update cvtermpath: $cv->name", 'tripal_cv',
|
|
|
'tripal_cv_update_cvtermpath', $job_args, $user->uid);
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Update the cvtermpath table
|
|
|
- *
|
|
|
- * @ingroup tripal_cv
|
|
|
- */
|
|
|
-function tripal_cv_update_cvtermpath($cvid = NULL, $job_id = NULL) {
|
|
|
-
|
|
|
- // first get the controlled vocabulary name:
|
|
|
- $cv = db_fetch_object(chado_query("SELECT * FROM {cv} WHERE cv_id = %d", $cvid));
|
|
|
- print "\nUpdating cvtermpath for $cv->name...\n";
|
|
|
-
|
|
|
- // now fill the cvtermpath table
|
|
|
- // @coder-ignore: using a function rather then tablename therefore table prefixing doesn't apply
|
|
|
- $sql = "SELECT * FROM fill_cvtermpath('%s')";
|
|
|
- chado_query($sql, $cv->name);
|
|
|
-
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-//////////////////////////////////////
|
|
|
-// @section Miscellaneous
|
|
|
-// @todo check to see if these functions are still needed and/or if they
|
|
|
-// should be moved to the api file
|
|
|
-//////////////////////////////////////
|
|
|
-
|
|
|
-/**
|
|
|
- * Get the CV ID based on name
|
|
|
- *
|
|
|
- * @ingroup tripal_cv
|
|
|
- */
|
|
|
-function tripal_cv_get_cv_id($cv_name) {
|
|
|
-
|
|
|
- $sql = "
|
|
|
- SELECT cv_id FROM {cv} WHERE name = '%s'
|
|
|
- ";
|
|
|
- $cv = db_fetch_object(chado_query($sql, $cv_name));
|
|
|
-
|
|
|
- return $cv->cv_id;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Returns a themed cvterm definition table
|
|
|
- *
|
|
|
- * @ingroup tripal_cv
|
|
|
- */
|
|
|
-function tripal_cv_cvterm_edit($cvterm_id) {
|
|
|
-
|
|
|
- $sql = "
|
|
|
- SELECT CVT.name as cvtermname, CVT.definition, CV.name as cvname
|
|
|
- FROM {CVTerm} CVT
|
|
|
- INNER JOIN CV on CVT.cv_id = CV.cv_id
|
|
|
- WHERE CVT.cvterm_id = %d
|
|
|
- ";
|
|
|
- $cvterm = db_fetch_object(chado_query($sql, $cvterm_id));
|
|
|
-
|
|
|
- return theme('tripal_cv_cvterm_edit', $cvterm);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Does the actual themeing of the cvterm definition table
|
|
|
- *
|
|
|
- * @ingroup tripal_cv
|
|
|
- */
|
|
|
-function theme_tripal_cv_cvterm_edit(&$cvterm) {
|
|
|
-
|
|
|
- $output = "
|
|
|
- <div id=\"cvterm\">
|
|
|
- <table>
|
|
|
- <tr><th>Term</th><td>$cvterm->cvtermname</td></tr>
|
|
|
- <tr><th>Vocabulary</th><td>$cvterm->cvname</td></tr>
|
|
|
- <tr><th>Definition</th><td>$cvterm->definition</td></tr>
|
|
|
- </table>
|
|
|
- </div>
|
|
|
- ";
|
|
|
-
|
|
|
- return $output;
|
|
|
-}
|
|
|
+}
|