|  | @@ -15,6 +15,14 @@
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Provides the form to load an already existing controlled
 | 
	
		
			
				|  |  |   *  Vocabulary into chado
 | 
	
		
			
				|  |  | + *  
 | 
	
		
			
				|  |  | + * @param $form
 | 
	
		
			
				|  |  | + *   The form array 
 | 
	
		
			
				|  |  | + * @param $form_state
 | 
	
		
			
				|  |  | + *   The form state array
 | 
	
		
			
				|  |  | + *   
 | 
	
		
			
				|  |  | + * @return
 | 
	
		
			
				|  |  | + *   The form array with new additions
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -95,8 +103,14 @@ function tripal_cv_obo_form($form, &$form_state) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * The submit function for the load ontology form. It registers a
 | 
	
		
			
				|  |  | - *   tripal job to run the obo_loader.php script
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + *   tripal job to import the user specified ontology file
 | 
	
		
			
				|  |  | + *   
 | 
	
		
			
				|  |  | + * @param $form
 | 
	
		
			
				|  |  | + *   The form array 
 | 
	
		
			
				|  |  | + * @param $form_state
 | 
	
		
			
				|  |  | + *   The form state array
 | 
	
		
			
				|  |  | + *   
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_form_submit($form, &$form_state) {
 | 
	
	
		
			
				|  | @@ -109,6 +123,15 @@ function tripal_cv_obo_form_submit($form, &$form_state) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | + * A wrapper function for importing the user specified OBO file into Chado by 
 | 
	
		
			
				|  |  | + * specifying the obo_id of the OBO. It requires that the file be in OBO v1.2 
 | 
	
		
			
				|  |  | + * compatible format.  This function is typically executed via the Tripal jobs 
 | 
	
		
			
				|  |  | + * management after a user submits a job via the Load Onotloies form.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $obo_id
 | 
	
		
			
				|  |  | + *   An obo_id from the tripal_cv_obo file that specifies which OBO file to import
 | 
	
		
			
				|  |  | + * @param $job_id
 | 
	
		
			
				|  |  | + *   The job_id of the job from the Tripal jobs management system. 
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -143,6 +166,20 @@ function tripal_cv_load_obo_v1_2_id($obo_id, $jobid = NULL) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | + * A wrapper function for importing the user specified OBO file into Chado by 
 | 
	
		
			
				|  |  | + * specifying the filename and path of the OBO. It requires that the file be in OBO v1.2 
 | 
	
		
			
				|  |  | + * compatible format.  This function is typically executed via the Tripal jobs 
 | 
	
		
			
				|  |  | + * management after a user submits a job via the Load Onotloies form.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $obo_name
 | 
	
		
			
				|  |  | + *   The name of the OBO (typially the ontology or controlled vocabulary name)
 | 
	
		
			
				|  |  | + * @param $file
 | 
	
		
			
				|  |  | + *   The path on the file system where the ontology can be found
 | 
	
		
			
				|  |  | + * @param $job_id
 | 
	
		
			
				|  |  | + *   The job_id of the job from the Tripal jobs management system. 
 | 
	
		
			
				|  |  | + * @param $is_new
 | 
	
		
			
				|  |  | + *   Set to TRUE if this is a new ontology that does not yet exist in the 
 | 
	
		
			
				|  |  | + *   tripal_cv_obo table.  If TRUE the OBO will be added to the table.
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -159,11 +196,23 @@ function tripal_cv_load_obo_v1_2_file($obo_name, $file, $jobid = NULL, $is_new =
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    // update the cvtermpath table
 | 
	
		
			
				|  |  |    tripal_cv_load_update_cvtermpath($newcvs, $jobid);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | + * A wrapper function for importing the user specified OBO file into Chado by 
 | 
	
		
			
				|  |  | + * specifying the remote URL of the OBO. It requires that the file be in OBO v1.2 
 | 
	
		
			
				|  |  | + * compatible format.  This function is typically executed via the Tripal jobs 
 | 
	
		
			
				|  |  | + * management after a user submits a job via the Load Onotloies form.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $obo_name
 | 
	
		
			
				|  |  | + *   The name of the OBO (typially the ontology or controlled vocabulary name)
 | 
	
		
			
				|  |  | + * @param $url
 | 
	
		
			
				|  |  | + *   The remote URL of the OBO file.
 | 
	
		
			
				|  |  | + * @param $job_id
 | 
	
		
			
				|  |  | + *   The job_id of the job from the Tripal jobs management system. 
 | 
	
		
			
				|  |  | + * @param $is_new
 | 
	
		
			
				|  |  | + *   Set to TRUE if this is a new ontology that does not yet exist in the 
 | 
	
		
			
				|  |  | + *   tripal_cv_obo table.  If TRUE the OBO will be added to the table.
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -205,7 +254,16 @@ function tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = T
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * A function for executing the cvtermpath function of Chado.  This function
 | 
	
		
			
				|  |  | + * populates the cvtermpath table of Chado for quick lookup of term 
 | 
	
		
			
				|  |  | + * relationships
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $newcvs
 | 
	
		
			
				|  |  | + *   An associative array of controlled vocabularies to update.  The key must be
 | 
	
		
			
				|  |  | + *   the name of the vocabulary and the value the cv_id from the cv table of chado.
 | 
	
		
			
				|  |  | + * @param $jobid
 | 
	
		
			
				|  |  | + *   The job_id of the job from the Tripal jobs management system. 
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_load_update_cvtermpath($newcvs, $jobid) {
 | 
	
	
		
			
				|  | @@ -217,7 +275,22 @@ function tripal_cv_load_update_cvtermpath($newcvs, $jobid) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * Imports a given OBO file into Chado.  This function is usually called by
 | 
	
		
			
				|  |  | + * one of three wrapper functions:  tripal_cv_load_obo_v1_2_id, 
 | 
	
		
			
				|  |  | + * tripal_cv_load_obo_v1_2_file or tirpal_cv_load_obo_v1_2_url. But, it can
 | 
	
		
			
				|  |  | + * be called directly if the full path to an OBO file is available on the 
 | 
	
		
			
				|  |  | + * file system.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $flie
 | 
	
		
			
				|  |  | + *   The full path to the OBO file on the file system
 | 
	
		
			
				|  |  | + * @param $jobid
 | 
	
		
			
				|  |  | + *   The job_id of the job from the Tripal jobs management system.
 | 
	
		
			
				|  |  | + * @param $newcvs
 | 
	
		
			
				|  |  | + *   An empty array passed by reference that upon return will contain the list 
 | 
	
		
			
				|  |  | + *   of newly added vocabularies.  The key will contain the CV name and the
 | 
	
		
			
				|  |  | + *   value the new cv_id
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
 | 
	
	
		
			
				|  | @@ -278,7 +351,11 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * Immediately terminates loading of the OBO file.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $message
 | 
	
		
			
				|  |  | + *   The error message to present to the user
 | 
	
		
			
				|  |  | + *   
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_quiterror($message) {
 | 
	
	
		
			
				|  | @@ -289,8 +366,20 @@ function tripal_cv_obo_quiterror($message) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * OBO files are divided into a typedefs terms section and vocabulary terms section.  
 | 
	
		
			
				|  |  | + * This function loads the typedef terms from the OBO.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $defaultcv
 | 
	
		
			
				|  |  | + *   A database object containing a record from the cv table for the 
 | 
	
		
			
				|  |  | + *   default controlled vocabulary
 | 
	
		
			
				|  |  | + * @param $newcvs
 | 
	
		
			
				|  |  | + *   An associative array of controlled vocabularies for this OBO.  The key must be
 | 
	
		
			
				|  |  | + *   the name of the vocabulary and the value the cv_id from the cv table of chado.
 | 
	
		
			
				|  |  | + * @param $default_db
 | 
	
		
			
				|  |  | + *   The name of the default database.
 | 
	
		
			
				|  |  | + * @param $jobid
 | 
	
		
			
				|  |  | + *   The job_id of the job from the Tripal jobs management system.
 | 
	
		
			
				|  |  | + *   
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
 | 
	
	
		
			
				|  | @@ -340,7 +429,19 @@ function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * OBO files are divided into a typedefs section and a terms section.  This 
 | 
	
		
			
				|  |  | + * function loads the typedef terms from the OBO.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $defaultcv
 | 
	
		
			
				|  |  | + *   A database object containing a record from the cv table for the 
 | 
	
		
			
				|  |  | + *   default controlled vocabulary
 | 
	
		
			
				|  |  | + * @param $jobid
 | 
	
		
			
				|  |  | + *  The job_id of the job from the Tripal jobs management system.
 | 
	
		
			
				|  |  | + * @param $newcvs
 | 
	
		
			
				|  |  | + *   An associative array of controlled vocabularies for this OBO.  The key must be
 | 
	
		
			
				|  |  | + *   the name of the vocabulary and the value the cv_id from the cv table of chado.
 | 
	
		
			
				|  |  | + * @param $default_db
 | 
	
		
			
				|  |  | + *   The name of the default database.
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $default_db) {
 | 
	
	
		
			
				|  | @@ -402,7 +503,19 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * Uses the provided term array to add/update information to Chado about the 
 | 
	
		
			
				|  |  | + * term including the term, dbxref, synonyms, properties, and relationships.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $term
 | 
	
		
			
				|  |  | + *   An array representing the cvterm. 
 | 
	
		
			
				|  |  | + * @param $defaultcv
 | 
	
		
			
				|  |  | + *   A database object containing a record from the cv table for the 
 | 
	
		
			
				|  |  | + *   default controlled vocabulary
 | 
	
		
			
				|  |  | + * @is_relationship
 | 
	
		
			
				|  |  | + *   Set to 1 if this term is a relationship term
 | 
	
		
			
				|  |  | + * @default_db
 | 
	
		
			
				|  |  | + *   The name of the default database.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$newcvs, $default_db) {
 | 
	
	
		
			
				|  | @@ -563,7 +676,21 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - * Add a cvterm relationship
 | 
	
		
			
				|  |  | + * Adds a cvterm relationship
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param $cvterm
 | 
	
		
			
				|  |  | + *   A database object for the cvterm 
 | 
	
		
			
				|  |  | + * @param $rel
 | 
	
		
			
				|  |  | + *   The relationship name
 | 
	
		
			
				|  |  | + * @param $objname
 | 
	
		
			
				|  |  | + *   The relationship term name
 | 
	
		
			
				|  |  | + * @param $defaultcv
 | 
	
		
			
				|  |  | + *   A database object containing a record from the cv table for the 
 | 
	
		
			
				|  |  | + *   default controlled vocabulary
 | 
	
		
			
				|  |  | + * @object_is_relationship
 | 
	
		
			
				|  |  | + *   Set to 1 if this term is a relationship term
 | 
	
		
			
				|  |  | + * @default_db
 | 
	
		
			
				|  |  | + *   The name of the default database.
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -643,7 +770,11 @@ function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * Retreives the term array from the temp loading table for a given term id.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param id
 | 
	
		
			
				|  |  | + *   The id of the term to retrieve
 | 
	
		
			
				|  |  | + *   
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_get_term($id) {
 | 
	
	
		
			
				|  | @@ -657,7 +788,13 @@ function tripal_cv_obo_get_term($id) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | + * Adds the synonyms to a term
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param term
 | 
	
		
			
				|  |  | + *   An array representing the cvterm. It must have a 'synonym' key/value pair.
 | 
	
		
			
				|  |  | + * @param cvterm
 | 
	
		
			
				|  |  | + *   The database object of the cvterm to which the synonym will be added.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_add_synonyms($term, $cvterm) {
 | 
	
	
		
			
				|  | @@ -749,8 +886,16 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - * Actually parse the OBO file
 | 
	
		
			
				|  |  | + * Parse the OBO file and populate the templ loading table
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  | + * @param $file
 | 
	
		
			
				|  |  | + *   The path on the file system where the ontology can be found 
 | 
	
		
			
				|  |  | + * @param $header
 | 
	
		
			
				|  |  | + *   An array passed by reference that will be populated with the header
 | 
	
		
			
				|  |  | + *   information from the OBO file
 | 
	
		
			
				|  |  | + * @param $jobid
 | 
	
		
			
				|  |  | + *   The job_id of the job from the Tripal jobs management system.
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
 | 
	
	
		
			
				|  | @@ -874,7 +1019,12 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - * Add database reference to cvterm
 | 
	
		
			
				|  |  | + * Adds a database reference to a cvterm
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param cvterm
 | 
	
		
			
				|  |  | + *   The database object of the cvterm to which the synonym will be added.
 | 
	
		
			
				|  |  | + * @param xref
 | 
	
		
			
				|  |  | + *   The cross refernce.  It should be of the form from the OBO specification
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -932,7 +1082,16 @@ function tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - * Add property to CVterm
 | 
	
		
			
				|  |  | + * Adds a property to a cvterm
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param cvterm
 | 
	
		
			
				|  |  | + *   A database object for the cvterm to which properties will be added
 | 
	
		
			
				|  |  | + * @param $property
 | 
	
		
			
				|  |  | + *   The name of the property to add
 | 
	
		
			
				|  |  | + * @param $value 
 | 
	
		
			
				|  |  | + *   The value of the property
 | 
	
		
			
				|  |  | + * @param rank
 | 
	
		
			
				|  |  | + *   The rank of the property
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 | 
	
	
		
			
				|  | @@ -999,7 +1158,16 @@ function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - * Add Database Reference
 | 
	
		
			
				|  |  | + * Adds a database cross reference to a cvterm
 | 
	
		
			
				|  |  | + * 
 | 
	
		
			
				|  |  | + * @param db_id
 | 
	
		
			
				|  |  | + *   The database ID of the cross reference
 | 
	
		
			
				|  |  | + * @param accession
 | 
	
		
			
				|  |  | + *   The cross reference's accession
 | 
	
		
			
				|  |  | + * @param $version
 | 
	
		
			
				|  |  | + *   The version of the dbxref
 | 
	
		
			
				|  |  | + * @param $description
 | 
	
		
			
				|  |  | + *   The description of the cross reference
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @ingroup tripal_obo_loader
 | 
	
		
			
				|  |  |   */
 |