Browse Source

Feature: cleaned up and added doc

Lacey Sanderson 11 years ago
parent
commit
a73d2fa391

+ 25 - 7
tripal_feature/api/tripal_feature.api.inc

@@ -1,4 +1,9 @@
 <?php
+/**
+ * @file
+ * Provides an application programming interface (API) for working with features
+ */
+
 /**
  * @defgroup tripal_feature_api Feature API
  * @ingroup tripal_api
@@ -202,6 +207,7 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
     return chado_update_propertyID('analysisfeature',
       $analysisfeatureprop_id, $property, $cv_name, $value);
 }
+
 /**
  * Delete an analysis feature property using the property name.  Use this
  * when a property only exists once for a given analysis feature.  When more
@@ -255,6 +261,7 @@ function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_i
   // get the property.
   return chado_delete_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
 }
+
 /**
  * Delete a property using the analysisfeatureprop_id
  *
@@ -270,6 +277,7 @@ function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id)
   // get the property.
   return chado_delete_propertyID('analysisfeature', $analysisfeatureprop_id);
 }
+
 /**
  * Retrieve properties of a given type for a given feature
  *
@@ -315,6 +323,7 @@ function tripal_feature_insert_property($feature_id, $property, $value,
   return chado_insert_property('feature', $feature_id, $property,
     $cv_name, $value, $update_if_present);
 }
+
 /**
  * Update a feature property using the property name. Only use this
  * if the property is unique and only exist once for the feature.
@@ -390,6 +399,7 @@ function tripal_feature_update_property_by_id($featureprop_id, $property,
 function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal') {
   return chado_delete_property('feature', $feature_id, $property, $cv_name);
 }
+
 /**
  * Delete a given feature property using the featureprop_id
  *
@@ -436,6 +446,7 @@ function tripal_feature_reverse_complement($sequence) {
   $seq = str_replace("B", "v", $seq);
   return strtoupper($seq);
 }
+
 /**
  * Retrieves the sequence for a feature.
  *
@@ -831,11 +842,9 @@ function tripal_feature_get_formatted_sequence($feature_id, $feature_name,
   return $residues;
 }
 
-
-
-/*
+/**
  * This function adds an entry to the feature_dbxref table.
-  *
+ *
  * @param $feature_id
  *   The numeric feature_if of the feature
  * @param $dbname
@@ -891,9 +900,9 @@ function tripal_feature_add_dbxref($feature_id, $dbname, $accession) {
   return TRUE;
 }
 
-/*
+/**
  * This function adds an entry to the feature_cvterm table.
-  *
+ *
  * @param $feature_id
  *   The numeric feature_if of the feature
  * @param $cvname
@@ -950,9 +959,18 @@ function tripal_feature_add_cvterm($feature_id, $cvname, $cvterm) {
 }
 
 /**
+ * Returns a fasta record for the passed in feature
  *
+ * @param $feature
+ *   A single feature object containing all the fields from the chado.feature table
+ * @param $desc
+ *   A string containing any additional details you want added to the definition line of
+ *   the fasta record.
  *
- * @ingroup tripal_feature
+ * Note: the feature accession and name separated by a | will be added
+ *   before the description but on the same line
+ *
+ * @ingroup tripal_feature_api
  */
 function tripal_feature_return_fasta($feature, $desc) {
   $fasta  = ">" . variable_get('chado_feature_accession_prefix', 'FID') . "$feature->feature_id|$feature->name";

+ 4 - 0
tripal_feature/api/tripal_feature.schema.api.inc

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Further describe some of the feature tables to the tripal schema
+ */
 
 /**
  * Implements hook_chado_schema_v1_2_tripal_gff_temp()

+ 16 - 17
tripal_feature/includes/tripal_feature.admin.inc

@@ -1,12 +1,13 @@
 <?php
-
 /**
  * @file
- * @todo Add file header description
+ * Administration of features
  */
 
 /**
+ * Launchpad for feature administration.
  *
+ * @ingroup tripal_feature
  */
 function tripal_feature_admin_feature_view() {
   $output = '';
@@ -38,9 +39,8 @@ function tripal_feature_admin_feature_view() {
   return $output;
 }
 
-
 /**
- *
+ * Feature Settings page
  *
  * @ingroup tripal_feature
  */
@@ -178,7 +178,7 @@ function tripal_feature_admin() {
 }
 
 /**
- *
+ * Validate the feature settings forms
  *
  * @ingroup tripal_feature
  */
@@ -220,9 +220,8 @@ function tripal_feature_admin_validate($form, &$form_state) {
 
 }
 
-
 /**
- *
+ * Form: Reindex feature nodes for the drupal search
  *
  * @ingroup tripal_feature
  */
@@ -250,7 +249,7 @@ function get_tripal_feature_admin_form_reindex_set(&$form) {
 }
 
 /**
- *
+ * Form: Set taxonomy for features
  *
  * @ingroup tripal_feature
  */
@@ -297,8 +296,9 @@ function get_tripal_feature_admin_form_taxonomy_set(&$form) {
 }
 
 /**
+ * Form: Set the definition of titles for features
  *
- * @param $form
+ * @ingroup tripal_feature
  */
 function get_tripal_feature_admin_form_title_set(&$form) {
 
@@ -333,13 +333,14 @@ function get_tripal_feature_admin_form_title_set(&$form) {
     '#default_value' => variable_get('chado_feature_title', 'unique_constraint'),
   );
 }
+
 /**
+ * Form: Set the URL definition for feature nodes
  *
- * @param $form
+ * @ingroup tripal_feature
  */
 function get_tripal_feature_admin_form_url_set(&$form) {
 
-
   $form['url'] = array(
     '#type' => 'fieldset',
     '#title' => t('Feature URL Path'),
@@ -401,7 +402,7 @@ function get_tripal_feature_admin_form_url_set(&$form) {
 }
 
 /**
- *
+ * Set feature taxonomy
  *
  * @ingroup tripal_feature
  */
@@ -444,7 +445,7 @@ function tripal_features_set_taxonomy($max_sync = 0, $job_id = NULL) {
 }
 
 /**
- *
+ * Set taxonomy for a single feature
  *
  * @ingroup tripal_feature
  */
@@ -550,7 +551,6 @@ function tripal_feature_set_taxonomy($node, $feature_id) {
 
 }
 
-
 /**
  *  This function is an extension of the chado_feature_view by providing
  *  the markup for the feature object THAT WILL BE INDEXED.
@@ -610,9 +610,8 @@ function theme_tripal_feature_search_results($node) {
   return $content;
 }
 
-
 /**
- *
+ * Set the vocabulary to use taxonomy terms from
  *
  * @ingroup tripal_feature
  */
@@ -720,4 +719,4 @@ function tripal_feature_set_vocabulary() {
     drupal_form_submit('taxonomy_form_vocabulary', $form_state, $values);
     drupal_form_submit('taxonomy_form_vocabulary', $form_state);
   }
-}
+}

+ 6 - 2
tripal_feature/includes/tripal_feature.blocks.inc

@@ -1,7 +1,11 @@
 <?php
+/**
+ * @file
+ *  Describes the feature blocks to drupal
+ */
 
 /**
- *
+ * Implements hook_block().
  *
  * @ingroup tripal_feature
  */
@@ -44,7 +48,7 @@ function tripal_feature_block_info() {
 }
 
 /**
- *
+ * Implements hook_block_view().
  *
  * @ingroup tripal_feature
  */

+ 46 - 22
tripal_feature/includes/tripal_feature.chado_node.inc

@@ -1,6 +1,13 @@
 <?php
 /**
- *  Provide information to drupal about the node types that we're creating
+ * @file
+ * Implementation of hooks to create a feature content type
+ */
+
+/**
+ * Implements hook_node_info().
+ *
+ * Provide information to drupal about the node types that we're creating
  *  in this module
  *
  * @ingroup tripal_feature
@@ -32,14 +39,9 @@ function tripal_feature_node_info() {
   );
   return $nodes;
 }
+
 /**
- * Implementation of hook_form
- *
- * @param  $node
- * @param  $param
- *
- * @return
- *   Drupal form array
+ * Implementation of hook_form().
  *
  * @ingroup tripal_feature
  */
@@ -236,16 +238,13 @@ function chado_feature_form($node, &$form_state) {
 }
 
 /**
- * Implementation of hook_validate
+ * Implementation of hook_validate().
  *
  * This validation is being used for three activities:
  *   CASE A: Update a node that exists in both drupal and chado
  *   CASE B: Synchronizing a node from chado to drupal
  *   CASE C: Inserting a new node that exists in niether drupal nor chado
  *
- * @param $node
- *
- *
  * @ingroup tripal_feature
  */
 function chado_feature_validate($node, $form, &$form_state) {
@@ -325,9 +324,8 @@ function chado_feature_validate($node, $form, &$form_state) {
   }
 }
 
-
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -374,7 +372,10 @@ function chado_feature_node_access($node, $op, $account) {
   }
   return NULL;
 }
+
 /**
+ * Implements hook_insert().
+ *
  *  When a new chado_feature node is created we also need to add information
  *  to our chado_feature table.  This function is called on insert of a new node
  *  of type 'chado_feature' and inserts the necessary information.
@@ -467,7 +468,7 @@ function chado_feature_insert($node) {
 }
 
 /**
- *
+ * Implements hook_update().
  *
  * @ingroup tripal_feature
  */
@@ -544,8 +545,9 @@ function chado_feature_update($node) {
 
 
 }
+
 /**
- *
+ * Implements hook_delete().
  *
  * @ingroup tripal_feature
  */
@@ -579,7 +581,12 @@ function chado_feature_delete($node) {
 }
 
 /**
+ * Add synonyms to a feature
  *
+ * @param $synonyms
+ *   A string containing synonyms separated by a return character
+ * @param $feature_id
+ *   The feature to attach the synonyms to
  *
  * @ingroup tripal_feature
  */
@@ -647,7 +654,9 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
 }
 
 /**
- *  When a node is requested by the user this function is called to allow us
+ * Implements hook_load().
+ *
+ * When a node is requested by the user this function is called to allow us
  *  to add auxiliary data to the node object.
  *
  * @ingroup tripal_feature
@@ -687,7 +696,10 @@ function chado_feature_load($nodes) {
     }
   }
 }
+
 /**
+ * Implements hook_node_presave().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -717,19 +729,21 @@ function tripal_feature_node_presave($node) {
         $ftype = chado_select_record('cv', array('name'), $values);
         $type = $ftype[0]->name;
       }
-     
+
       $values = array('organism_id' => $organism_id);
       $organism = chado_select_record('organism', array('genus', 'species'), $values);
       $node->title = "$name, $uname ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
-      
+
       if ($name == $uname) {
-        $node->title = "$name ($type) " . $organism[0]->genus . ' ' . $organism[0]->species; 
+        $node->title = "$name ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
       }
       break;
   }
 }
 
 /**
+ * Implements hook_node_insert().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -755,7 +769,9 @@ function tripal_feature_node_insert($node) {
       break;
   }
 }
+
 /**
+ * Return the url alias for a feature
  *
  * @param $node
  *   A node object containing at least the feature_id and nid
@@ -765,6 +781,8 @@ function tripal_feature_node_insert($node) {
  *   and [type].  These placeholders will be substituted for actual values.
  *   If this parameter is not provided then the value of the
  *   chado_feature_url_string Drupal variable will be used.
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_get_feature_url($node, $url_alias = NULL) {
 
@@ -822,7 +840,10 @@ function tripal_feature_get_feature_url($node, $url_alias = NULL) {
 
   return $url_alias;
 }
+
 /**
+ * Implements hook_node_view().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -848,7 +869,7 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
           '#weight' => -100,
         );
         $node->content['tripal_feature_featurepos'] = array(
-          '#markup' => theme('tripal_feature_featurepos', array('node' => $node)),          
+          '#markup' => theme('tripal_feature_featurepos', array('node' => $node)),
           '#tripal_toc_id'    => 'featurepos',
           '#tripal_toc_title' => 'Maps',
         );
@@ -918,7 +939,10 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
       break;
   }
 }
+
 /**
+ * Implements hook_node_update().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -936,4 +960,4 @@ function tripal_feature_node_update($node) {
       path_save($path_alias);
       break;
   }
-}
+}

+ 58 - 13
tripal_feature/includes/tripal_feature.delete.inc

@@ -1,9 +1,14 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Administration Interface for deleting multiple features
  */
 
+/**
+ * A form for indicating the features to delete
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_form() {
   // get the list of organisms
   $sql = "SELECT * FROM {organism} ORDER BY genus, species";
@@ -69,6 +74,11 @@ function tripal_feature_delete_form() {
   return $form;
 }
 
+/**
+ * Validation for the delete features form
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_form_validate($form, &$form_state) {
   $organism_id   = $form_state['values']['organism_id'];
   $seq_type      = trim($form_state['values']['seq_type']);
@@ -89,7 +99,7 @@ function tripal_feature_delete_form_validate($form, &$form_state) {
         LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
       WHERE cv.name = :cvname and (CVT.name = :name or CVTS.synonym = :synonym)
     ";
-    $cvterm = chado_query($cvtermsql, 
+    $cvterm = chado_query($cvtermsql,
       array(':cvname' => 'sequence', ':name' => $seq_type, ':synonym' => $seq_type))->fetchObject();
     if (!$cvterm) {
       form_set_error('seq_type', t("The Sequence Ontology (SO) term selected for the " .
@@ -98,6 +108,11 @@ function tripal_feature_delete_form_validate($form, &$form_state) {
   }
 }
 
+/**
+ * Submit for the delete features form
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_form_submit($form, &$form_state) {
   global $user;
 
@@ -113,7 +128,25 @@ function tripal_feature_delete_form_submit($form, &$form_state) {
     'tripal_feature_delete_features', $args, $user->uid);
 }
 
-
+/**
+ * Function to actually delete the features indicated
+ *
+ * @param $organism_id
+ *   (Optional) The organism_id of the features to delete
+ * @param $analysis_id
+ *   (Optional) The analysis_id of the features to delete
+ * @param $seq_type
+ *   (Optional) The cvterm.name of the feature types to delete
+ * @param $is_unique
+ *   (Optional) A Boolean stating whether the names are unique (ie: feature.uniquename)
+ *   or not (ie: feature.name)
+ * @param $feature_names
+ *   (Optional) A space separated list of the names of features to delete
+ * @param $job
+ *   The tripal_job id
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
   $is_unique, $feature_names, $job = NULL) {
 
@@ -163,17 +196,29 @@ function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
   tripal_features_cleanup(array(), $user->uid);
 }
 
+/**
+ * Function to delete features based on an analysis passed in. This has not yet been
+ * implemented in the form
+ *
+ * @todo: Implement this functionality and then add back in the form field
+ *
+ * @param $organism_id
+ *   (Optional) The organism_id of the features to delete
+ * @param $analysis_id
+ *   (Optional) The analysis_id of the features to delete
+ * @param $seq_type
+ *   (Optional) The cvterm.name of the feature types to delete
+ * @param $is_unique
+ *   (Optional) A Boolean stating whether the names are unique (ie: feature.uniquename)
+ *   or not (ie: feature.name)
+ * @param $feature_names
+ *   (Optional) A space separated list of the names of features to delete
+ * @param $job
+ *   The tripal_job id
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_by_analysis($organism_id, $analysis_id, $seq_type,
   $is_unique, $feature_names, $job = NULL) {
 
 }
-
-
-
-
-
-
-
-
-
-

+ 161 - 109
tripal_feature/includes/tripal_feature.fasta_loader.inc

@@ -1,26 +1,26 @@
 <?php
-
 /**
  * @file
- * @todo Add file header description
+ * Provides fasta loading functionality. Creates features based on their specification
+ * in a fasta file.
  */
 
-
 /**
  * @defgroup fasta_loader FASTA Feature Loader
  * @ingroup tripal_feature
  * @{
- * Provides fasta loading functionality. Creates features based on their specification in a fasta file.
+ * Provides fasta loading functionality. Creates features based on their specification
+ * in a fasta file.
  * @}
- * 
+ *
  */
 
 /**
- *
+ * The form to submit a fasta loading job
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form( ) {
+function tripal_feature_fasta_load_form() {
 
   $form['fasta_file']= array(
     '#type'          => 'textfield',
@@ -100,7 +100,7 @@ function tripal_feature_fasta_load_form( ) {
       t('Name'),
       t('Unique name'),
     ),
-    '#description' => t('Used for "updates only" or "insert and update" methods. Not required if method type is "insert".  
+    '#description' => t('Used for "updates only" or "insert and update" methods. Not required if method type is "insert".
       Feature data is stored in Chado with both a human-readable
       name and a unique name. If the features in your FASTA file are uniquely identified using
       a human-readable name then select the "Name" button. If your features are
@@ -267,7 +267,7 @@ function tripal_feature_fasta_load_form( ) {
 }
 
 /**
- *
+ * Validate the fasta loader job form
  *
  * @ingroup fasta_loader
  */
@@ -312,7 +312,7 @@ function tripal_feature_fasta_load_form_validate($form, &$form_state) {
   if (!$re_name and $re_uname and strcmp($match_type, 'Name')==0) {
     form_set_error('re_name', t("You must provide a regular expression to identify the sequence name"));
   }
-  
+
   // check to see if the file is located local to Drupal
   $fasta_file = trim($fasta_file);
   $dfile = $_SERVER['DOCUMENT_ROOT'] . base_path() . $fasta_file;
@@ -367,7 +367,7 @@ function tripal_feature_fasta_load_form_validate($form, &$form_state) {
 }
 
 /**
- *
+ * Submit a fasta loading job
  *
  * @ingroup fasta_loader
  */
@@ -410,14 +410,49 @@ function tripal_feature_fasta_load_form_submit($form, &$form_state) {
   $args = array($dfile, $organism_id, $type, $library_id, $re_name, $re_uname,
           $re_accession, $db_id, $rel_type, $re_subject, $parent_type, $method,
           $user->uid, $analysis_id, $match_type);
-  
-  $fname = preg_replace("/.*\/(.*)/", "$1", $dfile);         
+
+  $fname = preg_replace("/.*\/(.*)/", "$1", $dfile);
   tripal_add_job("Import FASTA file: $fname", 'tripal_feature',
     'tripal_feature_load_fasta', $args, $user->uid);
 }
 
 /**
+ * Actually load a fasta file. This is the function called by tripal jobs
  *
+ * @param $dfile
+ *  The full path to the fasta file to load
+ * @param $organism_id
+ *  The organism_id of the organism these features are from
+ * @param $type
+ *  The type of features contained in the fasta file
+ * @param $library_id
+ *  (Optional) The library_id to associate the features with
+ * @param $re_name
+ *  A regular expression to extract the feature.name from the fasta header
+ * @param $re_uname
+ *  A regular expression to extract the feature.uniquename from the fasta header
+ * @param $re_accession
+ *  A regular expression to extract the accession of the feature.dbxref_id
+ * @param $db_id
+ *  The db_id of the above dbxref
+ * @param $rel_type
+ *  The type of relationship when creating a feature_relationship between this
+ *   feature (object) and an extracted subject
+ * @param $re_subject
+ *  The regular expression to extract the uniquename of the feature to be the subject
+ *   of the above specified relationship
+ * @param $parent_type
+ *  The type of the parent feature
+ * @param $method
+ *  The method of feature adding. (ie: 'Insert only', 'Update only', 'Insert and update')
+ * @param $uid
+ *   The user id of the user who submitted the job
+ * @param $analysis_id
+ *   The analysis_id to associate the features in this fasta file with
+ * @param $match_type
+ *   Whether to match existing features based on the 'Name' or 'Unique name'
+ * @param $job = NULL
+ *   The tripal job
  *
  * @ingroup fasta_loader
  */
@@ -428,7 +463,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
 
   // begin the transaction
   $connection = tripal_db_start_transaction();
-      
+
   // if we cannot get a connection then let the user know the loading will be slow
   if (!$connection) {
      print "A persistant connection was not obtained. Loading will be slow\n";
@@ -445,7 +480,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
                   INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
                   LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
                WHERE cv.name = :cvname and (CVT.name = :name or CVTS.synonym = :synonym)";
-  $cvterm = chado_query($cvtermsql, array(':cvname' => 'sequence', ':name' => $type, ':synonym' => $type))->fetchObject();     
+  $cvterm = chado_query($cvtermsql, array(':cvname' => 'sequence', ':name' => $type, ':synonym' => $type))->fetchObject();
   if (!$cvterm) {
     tripal_report_error("T_fasta_loader", TRIPAL_ERROR, "Cannot find the term type: '%type'", array('%type' => $type));
     return 0;
@@ -464,7 +499,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
       return 0;
     }
   }
-  
+
   print "Opening FASTA file $dfile\n";
 
   //$lines = file($dfile, FILE_SKIP_EMPTY_LINES);
@@ -478,22 +513,22 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
 
   $name = '';
   $uname = '';
-  $residues = '';  
+  $residues = '';
   $interval = intval($filesize * 0.01);
   if ($interval < 1) {
     $interval = 1;
   }
   $inv_read = 0;
-  
-  // we need to get the table schema to make sure we don't overrun the 
+
+  // we need to get the table schema to make sure we don't overrun the
   // size of fields with what our regular expressions retrieve
   $feature_tbl = chado_get_schema('feature');
   $dbxref_tbl = chado_get_schema('dbxref');
 
-  //foreach ($lines as $line_num => $line) {  
+  //foreach ($lines as $line_num => $line) {
   while ($line = fgets($fh)) {
     $i++;  // update the line count
-    $num_read += drupal_strlen($line);   
+    $num_read += drupal_strlen($line);
     $intv_read += drupal_strlen($line);
 
     // if we encounter a definition line then get the name, uniquename,
@@ -501,7 +536,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
     if (preg_match('/^>/', $line)) {
       // if we have a feature name then we are starting a new sequence
       // so lets handle the previous one before moving on
-      if ($name or $uname) {       
+      if ($name or $uname) {
         tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id,
           $accession, $subject, $rel_type, $parent_type, $analysis_id, $organism_id, $cvterm,
           $source, $residues, $method, $re_name, $match_type, $parentcvterm, $relcvterm);
@@ -511,18 +546,18 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
       }
 
       $line = preg_replace("/^>/", '', $line); // remove the > symbol from the defline
-     
+
       // get the feature name
       if ($re_name) {
         if (!preg_match("/$re_name/", $line, $matches)) {
           tripal_report_error('trp-fasta', "ERROR: Regular expression for the feature name finds nothing. Line %line.", array('%line' => $i), 'error');
         }
         elseif (strlen($matches[1]) > $feature_tbl['fields']['name']['length']) {
-          tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a value too long for the feature name. Line %line.", array('%line' => $i), 'error');  
+          tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a value too long for the feature name. Line %line.", array('%line' => $i), 'error');
         }
         else {
           $name = trim($matches[1]);
-        }        
+        }
       }
       else {
         // if the match_type is name and no regular expression was provided
@@ -530,18 +565,18 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
         if (strcmp($match_type, 'Name')==0) {
           if (preg_match("/^\s*(.*?)[\s\|].*$/", $line, $matches)) {
             if (strlen($matches[1]) > $feature_tbl['fields']['name']['length']) {
-              tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a feature name too long for the feature name. Line %line.", array('%line' => $i), 'error');  
+              tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a feature name too long for the feature name. Line %line.", array('%line' => $i), 'error');
             }
             else {
               $name = trim($matches[1]);
             }
           }
           else {
-            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature name. Line %line.", array('%line' => $i), 'error');  
+            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature name. Line %line.", array('%line' => $i), 'error');
           }
         }
       }
-      
+
       // get the feature unique name
       if ($re_uname) {
         if (!preg_match("/$re_uname/", $line, $matches)) {
@@ -557,14 +592,14 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
             $uname = trim($matches[1]);
           }
           else {
-            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature unique name. Line %line.", array('%line' => $i), 'error');  
+            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature unique name. Line %line.", array('%line' => $i), 'error');
           }
         }
       }
       // get the accession
       preg_match("/$re_accession/", $line, $matches);
       if (strlen($matches[1]) > $dbxref_tbl['fields']['accession']['length']) {
-        tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves an accession too long for the feature name. Cannot add cross reference. Line %line.", array('%line' => $i), 'warning');  
+        tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves an accession too long for the feature name. Cannot add cross reference. Line %line.", array('%line' => $i), 'warning');
       }
       else {
         $accession = trim($matches[1]);
@@ -576,7 +611,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
     }
     else {
       $residues .= trim($line);
-      
+
       // update the job status every % features
       if ($job and $intv_read >= $interval) {
         $intv_read = 0;
@@ -585,25 +620,43 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
           print "Parsing Line $i (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes. Current feature: $name\r";
         }
         else {
-          print "Parsing Line $i (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes. Current feature: $uname\r";  
+          print "Parsing Line $i (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes. Current feature: $uname\r";
         }
         tripal_set_job_progress($job, intval(($num_read / $filesize) * 100));
       }
     }
   }
-  
+
   // now load the last sequence in the file
   tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id,
     $accession, $subject, $rel_type, $parent_type, $analysis_id, $organism_id, $cvterm,
     $source, $residues, $method, $re_name, $match_type, $parentcvterm, $relcvterm);
-  
+
   // commit the transaction
   tripal_db_commit_transaction();
   print "\nDone\n";
 }
 
 /**
+ * A helper function for tripal_feature_load_fasta() to load a single feature
  *
+ * @param $name
+ * @param $uname
+ * @param $db_id
+ * @param $accession
+ * @param $parent
+ * @param $rel_type
+ * @param $parent_type
+ * @param $analysis_id
+ * @param $organism_id
+ * @param $cvterm
+ * @param $source
+ * @param $residues
+ * @param $method
+ * @param $re_name
+ * @param $match_type
+ * @param $parentcvterm
+ * @param $relcvterm
  *
  * @ingroup fasta_loader
  */
@@ -616,44 +669,44 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $values = array(
       'organism_id' => $organism_id,
       'name' => $name,
-      'type_id' => $cvterm->cvterm_id,    
+      'type_id' => $cvterm->cvterm_id,
     );
     $options = array('statement_name' => 'sel_feature_ornaty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) > 1) {
-      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type 
+      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type
                '%type' for the organism.  skipping", array('%name' => $name, '%type' => $type));
       return 0;
-    } 
-    if (count($results) == 1) {  
+    }
+    if (count($results) == 1) {
       $feature = $results[0];
-    }     
+    }
   }
   // check to see if this feature already exists if the match_type is 'Unique Name'
   if (strcmp($match_type, 'Unique name')==0) {
     $values = array(
       'organism_id' => $organism_id,
       'uniquename' => $uname,
-      'type_id' => $cvterm->cvterm_id,    
+      'type_id' => $cvterm->cvterm_id,
     );
 
     $options = array('statement_name' => 'sel_feature_oruqty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) > 1) {
-      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type 
+      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type
                '%type' for the organism.  skipping", array('%name' => $name, '%type' => $type));
       return 0;
-    } 
-    if (count($results) == 1) {  
+    }
+    if (count($results) == 1) {
       $feature = $results[0];
-    }     
-    
-    // if the feature exists but this is an "insert only" method then skip this feature 
+    }
+
+    // if the feature exists but this is an "insert only" method then skip this feature
     if ($feature and (strcmp($method, 'Insert only')==0)) {
-      tripal_report_error('T_fasta_loader', TRIPAL_WARNING, "Feature already exists '%name' ('%uname') while matching on %type. Skipping insert.", 
+      tripal_report_error('T_fasta_loader', TRIPAL_WARNING, "Feature already exists '%name' ('%uname') while matching on %type. Skipping insert.",
         array('%name' => $name, '%uname' => $uname, '%type' => drupal_strtolower($match_type)));
       return 0;
-    } 
+    }
   }
 
   // if we don't have a feature and we're doing an insert then do the insert
@@ -666,7 +719,7 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     elseif (!$name) {
       $name = $uname;
     }
-    
+
     // insert the feature
     $values = array(
       'organism_id' => $organism_id,
@@ -680,44 +733,44 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
       'is_obsolete' => 'FALSE',
     );
     $options = array('statement_name' => 'ins_feature_all');
-    $success = chado_insert_record('feature', $values, $options);    
+    $success = chado_insert_record('feature', $values, $options);
     if (!$success) {
-      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to insert feature '%name (%uname)'", 
+      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to insert feature '%name (%uname)'",
         array('%name' => $name, '%uname' => $numane));
       return 0;
     }
-    
-    // now get the feature we just inserted    
+
+    // now get the feature we just inserted
     $values = array(
       'organism_id' => $organism_id,
       'uniquename' => $uname,
-      'type_id' => $cvterm->cvterm_id,    
+      'type_id' => $cvterm->cvterm_id,
     );
     $options = array('statement_name' => 'sel_feature_oruqty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) == 1) {
        $inserted = 1;
        $feature = $results[0];
-    } 
+    }
     else {
-      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted feature '%name (%uname)'", 
+      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted feature '%name (%uname)'",
         array('%name' => $name, '%uname' => $numane));
-      return 0;  
-    }     
+      return 0;
+    }
   }
-  
+
   // if we don't have a feature and the user wants to do an update then fail
   if (!$feature and (strcmp($method, 'Update only')==0 or drupal_strcmp($method, 'Insert and update')==0)) {
-    tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to find feature '%name' ('%uname') while matching on " . 
+    tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to find feature '%name' ('%uname') while matching on " .
       drupal_strtolower($match_type), array('%name' => $name, '%uname' => $uname));
     return 0;
   }
-  
+
   // if we do have a feature and this is an update then proceed with the update
   if ($feature and !$inserted and (strcmp($method, 'Update only')==0 or strcmp($method, 'Insert and update')==0)) {
     // if the user wants to match on the Name field
     if (strcmp($match_type, 'Name')==0) {
-      // if we're matching on the name but do not have a unique name then we don't want to update the uniquename.  
+      // if we're matching on the name but do not have a unique name then we don't want to update the uniquename.
       $values = array();
       if ($uname) {
         // first check to make sure that by changing the unique name of this feature that we won't conflict with
@@ -725,17 +778,17 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
         $values = array(
           'organism_id' => $organism_id,
           'uniquename' => $uname,
-          'type_id' => $cvterm->cvterm_id,    
-        );    
+          'type_id' => $cvterm->cvterm_id,
+        );
         $options = array('statement_name' => 'sel_feature_oruqty');
         $results = chado_select_record('feature', array('feature_id'), $values, $options);
         if (count($results) > 0) {
-          tripal_report_error('T_fasta_loader', "Cannot update the feature '%name' with a uniquename of '%uname' and type of '%type' as it 
-            conflicts with an existing feature with the same uniquename and type.", 
+          tripal_report_error('T_fasta_loader', "Cannot update the feature '%name' with a uniquename of '%uname' and type of '%type' as it
+            conflicts with an existing feature with the same uniquename and type.",
             array('%name' => $name, '%uname' => $uname, '%type' => $type));
           return 0;
-        } 
-        
+        }
+
         // the changes to the uniquename don't conflict so proceed with the update
         $values = array(
           'uniquename' => $uname,
@@ -746,15 +799,15 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
           'is_obsolete' => 'false',
         );
         $match = array(
-          'name' => $name,        
+          'name' => $name,
           'organism_id' => $organism_id,
-          'type_id' => $cvterm->cvterm_id,        
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_resemdisis_naorty_un');        
+        $options = array('statement_name' => 'upd_feature_resemdisis_naorty_un');
       }
       // if we do not have a new unique name then don't change the existing uniquename field
       else {
-        $values = array(                 
+        $values = array(
           'residues' => $residues,
           'seqlen' => drupal_strlen($residues),
           'md5checksum' => md5($residues),
@@ -762,24 +815,24 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
           'is_obsolete' => 'false',
         );
         $match = array(
-          'name' => $name,       
+          'name' => $name,
           'organism_id' => $organism_id,
-          'type_id' => $cvterm->cvterm_id,        
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_unresemdisis_naorty'); 
+        $options = array('statement_name' => 'upd_feature_unresemdisis_naorty');
       }
-      
+
       // perform the update
       $success = chado_update_record('feature', $match, $values, $options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, 
-          "Failed to update feature '%name' ('%name')", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR,
+          "Failed to update feature '%name' ('%name')",
           array('%name' => $name, '%uiname' => $uname));
         return 0;
       }
     }
     if (strcmp($match_type, 'Unique name')==0) {
-      // if we're matching on the uniquename but do not have a new name then we don't want to update the name.  
+      // if we're matching on the uniquename but do not have a new name then we don't want to update the name.
       $values = array();
       if ($name) {
         $values = array(
@@ -792,14 +845,14 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
         );
         $match = array(
           'uniquename' => $uname,
-          'organism_id' => $organism_id,          
-          'type_id' => $cvterm->cvterm_id,        
+          'organism_id' => $organism_id,
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_resemdisis_unorty_na');       
+        $options = array('statement_name' => 'upd_feature_resemdisis_unorty_na');
       }
       // if we have a unique name then update it after matching by the name
       else {
-        $values = array(                  
+        $values = array(
           'residues' => $residues,
           'seqlen' => drupal_strlen($residues),
           'md5checksum' => md5($residues),
@@ -807,21 +860,21 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
           'is_obsolete' => 'false',
         );
         $match = array(
-          'uniquename' => $uname,       
+          'uniquename' => $uname,
           'organism_id' => $organism_id,
-          'type_id' => $cvterm->cvterm_id,        
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_naresemdisis_unorty'); 
+        $options = array('statement_name' => 'upd_feature_naresemdisis_unorty');
       }
       $success = chado_update_record('feature', $match, $values, $options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to update feature '%name' ('%name')", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to update feature '%name' ('%name')",
           array('%name' => $name, '%uiname' => $uname));
         return 0;
       }
-    }    
+    }
   }
-  
+
   // add in the analysis link
   if ($analysis_id) {
     // if the association doens't alredy exist then add one
@@ -833,11 +886,11 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $results = chado_select_record('analysisfeature', array('analysisfeature_id'), $values, $sel_options);
     if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_analysisfeature_anfe');
-      $success = chado_insert_record('analysisfeature', $values, $ins_options);      
+      $success = chado_insert_record('analysisfeature', $values, $ins_options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to associate analysis and feature '%name' ('%name')", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to associate analysis and feature '%name' ('%name')",
           array('%name' => $name, '%uname' => $uname));
-        return 0;  
+        return 0;
       }
     }
   }
@@ -852,11 +905,11 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $sel_options = array('statement_name' => 'sel_dbxref_dbac');
     $results = chado_select_record('dbxref', array('dbxref_id'), $values, $sel_options);
     // if the accession doesn't exist then add it
-    if (count($results) == 0) {   
+    if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_dbxref_dbac');
       $results = chado_insert_record('dbxref', $values, $ins_options);
       if (!$results) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add database accession '%accession'", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add database accession '%accession'",
           array('%accession' => $accession));
         return 0;
       }
@@ -864,12 +917,12 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
       if (count($results) == 1) {
         $dbxref = $results[0];
       }
-      else { 
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted dbxref '%name (%uname)'", 
+      else {
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted dbxref '%name (%uname)'",
           array('%name' => $name, '%uname' => $numane));
         return 0;
       }
-    } 
+    }
     else {
       $dbxref = $results[0];
     }
@@ -881,15 +934,15 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     );
     $sel_options = array('statement_name' => 'sel_featuredbxref_fedb');
     $results = chado_select_record('feature_dbxref', array('feature_dbxref_id'), $values, $sel_options);
-    if (count($results) == 0) {  
+    if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_featuredbxref_fedb');
       $success = chado_insert_record('feature_dbxref', $values, $ins_options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature",
           array('%accession' => $accession));
         return 0;
       }
-    }              
+    }
   }
 
    // now add in the relationship if one exists. If not, then add it
@@ -897,34 +950,33 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $values = array(
       'organism_id' => $organism_id,
       'uniquename' => $parent,
-      'type_id' => $parentcvterm->cvterm_id,    
+      'type_id' => $parentcvterm->cvterm_id,
     );
     $options = array('statement_name' => 'sel_feature_oruqty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) != 1) {
-      tripal_report_error('T_fasta_loader', "Cannot find a unique fature for the parent '%parent' of type 
+      tripal_report_error('T_fasta_loader', "Cannot find a unique fature for the parent '%parent' of type
                '%type' for the feature.", array('%parent' => $parent, '%type' => $parent_type));
       return 0;
-    } 
+    }
     $parent_feature = $results[0];
-    
+
    // check to see if the relationship already exists if not then add it
     $values = array(
       'subject_id' => $feature->feature_id,
       'object_id' => $parent_feature->feature_id,
-      'type_id' => $relcvterm->cvterm_id,    
+      'type_id' => $relcvterm->cvterm_id,
     );
     $sel_options = array('statement_name' => 'sel_featurerelationship_suojty');
     $results = chado_select_record('feature_relationship', array('feature_relationship_id'), $values, $sel_options);
-    if (count($results) == 0) {    
+    if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_featurerelationship_suojty');
       $success = chado_insert_record('feature_relationship', $values, $ins_options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature",
           array('%accession' => $accession));
         return 0;
       }
-    }        
+    }
   }
 }
-

File diff suppressed because it is too large
+ 208 - 166
tripal_feature/includes/tripal_feature.gff_loader.inc


+ 124 - 103
tripal_feature/includes/tripal_feature.seq_extract.inc

@@ -1,10 +1,17 @@
 <?php
-/*
- * 
+/**
+ * @file
+ * Interface for downloading feature sequences
+ */
+
+/**
+ * The page allowing users to download feature sequences
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_page() {
-  
-  if ($_SESSION['tripal_feature_seq_extract']['download']) {   
+
+  if ($_SESSION['tripal_feature_seq_extract']['download']) {
     $genus      = $_SESSION['tripal_feature_seq_extract']['genus'];
     $species    = $_SESSION['tripal_feature_seq_extract']['species'];
     $analysis   = $_SESSION['tripal_feature_seq_extract']['analysis'];
@@ -18,7 +25,7 @@ function tripal_feature_seq_extract_page() {
     $agg_types  = $_SESSION['tripal_feature_seq_extract']['agg_types'];
 
     unset($_SESSION['tripal_feature_seq_extract']['download']);
-     
+
     if ($format == 'fasta_html') {
       drupal_add_http_header('Content-Type: text/html');
     }
@@ -26,32 +33,35 @@ function tripal_feature_seq_extract_page() {
       drupal_add_http_header('Content-Type: text');
       drupal_add_http_header('Content-Disposition: attachment; filename="sequences.fasta.txt"');
     }
-    
-    tripal_feature_seq_extract_get_features(NULL, $genus, $species, $analysis, 
-      $ftype, $fnames['items_array'], $upstream, $downstream, $format, $use_parent, $aggregate, 
+
+    tripal_feature_seq_extract_get_features(NULL, $genus, $species, $analysis,
+      $ftype, $fnames['items_array'], $upstream, $downstream, $format, $use_parent, $aggregate,
       $agg_types);
-      
+
     return;
   }
- 
-  
-  // generate the search form 
+
+
+  // generate the search form
   $output .= '';
-  if (user_access('access administration pages')) { 
+  if (user_access('access administration pages')) {
     $output .= theme('tripal_admin_message', array('message' => "
-        Administrators, the " . l('organism_feature_count', 'admin/tripal/schema/mviews') . " and 
+        Administrators, the " . l('organism_feature_count', 'admin/tripal/schema/mviews') . " and
         " . l('analysis_organism', 'admin/tripal/schema/mviews') . " materialized
-        views must be populated before using this form.  Those views should be re-populated 
+        views must be populated before using this form.  Those views should be re-populated
         when new data is added."
     ));
   }
   $output .= "<div id=\"tripal-feature-seq-extract-form-block\">";
-  $output .= drupal_get_form('tripal_feature_seq_extract_form');  
+  $output .= drupal_get_form('tripal_feature_seq_extract_form');
   $output .= "</div>";
   return $output;
 }
-/*
- * 
+
+/**
+ * Theme the Form to choose which features to extract sequence for
+ *
+ * @ingroup tripal_feature
  */
 function theme_tripal_feature_seq_extract_form($form) {
   $rows = array(
@@ -65,9 +75,9 @@ function theme_tripal_feature_seq_extract_form($form) {
     ),
     2 => array(
       array('data' => drupal_render($form['analysis']), 'colspan' => 3),
-      //drupal_render($form['format']),    
+      //drupal_render($form['format']),
     ),
-    3 => array(     
+    3 => array(
       array('data' =>  drupal_render($form['fnames']), 'colspan' => 2),
       drupal_render($form['upstream']) . drupal_render($form['downstream']) ,
     ),
@@ -75,18 +85,18 @@ function theme_tripal_feature_seq_extract_form($form) {
       array(
         'data' =>  drupal_render($form['advanced']),
         'colspan' => 3,
-      ),    
+      ),
     ),
     5 => array(
       array(
         'data' =>  drupal_render($form['retrieve_btn']) . drupal_render($form['reset_btn']),
         'colspan' => 3,
-      ),    
+      ),
     ),
   );
   $headers = array();
-  $table = theme('table', $headers, $rows, array('id' => 'tripal-feature-seq-extract-form-table', 'border' => '0'));   
-    
+  $table = theme('table', $headers, $rows, array('id' => 'tripal-feature-seq-extract-form-table', 'border' => '0'));
+
   $markup .= $table;
   $form['criteria'] = array(
     '#type' => 'markup',
@@ -95,42 +105,45 @@ function theme_tripal_feature_seq_extract_form($form) {
   );
   return drupal_render($form);
 }
+
 /**
-*
+ * Form to choose which features to extract sequence for
+ *
+ * @ingroup tripal_feature
  */
-function tripal_feature_seq_extract_form(&$form_state = NULL) {   
+function tripal_feature_seq_extract_form(&$form_state = NULL) {
   tripal_core_ahah_init_form();
-  
+
   // we want to allow the query string to provide values for the form
   if ($_GET['fnames']) {
-    $form_state['values']['fnames']['items'] = $_GET['fnames'];  
+    $form_state['values']['fnames']['items'] = $_GET['fnames'];
   }
   if ($_GET['genus']) {
-    $form_state['values']['genus'] = $_GET['genus'];  
+    $form_state['values']['genus'] = $_GET['genus'];
   }
   if ($_GET['species']) {
-    $form_state['values']['species'] = $_GET['species'];  
+    $form_state['values']['species'] = $_GET['species'];
   }
   if ($_GET['ftype']) {
-    $form_state['values']['ftype'] = $_GET['ftype'];  
+    $form_state['values']['ftype'] = $_GET['ftype'];
   }
   if ($_GET['analysis']) {
-    $form_state['values']['analysis'] = $_GET['analysis'];  
+    $form_state['values']['analysis'] = $_GET['analysis'];
   }
   if ($_GET['upstream']) {
-    $form_state['values']['upstream'] = $_GET['upstream'];  
+    $form_state['values']['upstream'] = $_GET['upstream'];
   }
   if ($_GET['downstream']) {
-    $form_state['values']['downstream'] = $_GET['downstream'];  
+    $form_state['values']['downstream'] = $_GET['downstream'];
   }
   if ($_GET['use_parent']) {
-    $form_state['values']['use_parent'] = $_GET['use_parent'];  
+    $form_state['values']['use_parent'] = $_GET['use_parent'];
   }
   if ($_GET['aggregate']) {
-    $form_state['values']['aggregate'] = $_GET['aggregate'];  
+    $form_state['values']['aggregate'] = $_GET['aggregate'];
   }
   if ($_GET['agg_types']) {
-    $form_state['values']['agg_types'] = $_GET['agg_types'];  
+    $form_state['values']['agg_types'] = $_GET['agg_types'];
   }
 
   // get defaults
@@ -146,36 +159,36 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
   $daggregate  = isset($form_state['values']['aggregate'])  ? $form_state['values']['aggregate']  : $_SESSION['tripal_feature_seq_extract']['aggregate'];
   $dagg_types  = isset($form_state['values']['agg_types'])  ? $form_state['values']['agg_types']  : $_SESSION['tripal_feature_seq_extract']['agg_types'];
 
-  
+
   $form = array();
-  
+
   // because we're using Tripal's file_upload_combo form element we
   // need to allow the form to upload files
   $form['#attributes']['enctype'] = 'multipart/form-data';
   $form['#method'] = 'POST';
-    
+
   $form['description'] = array(
     '#type' => 'markup',
     '#value' => t('Use this form to retrieve sequences in FASTA format.')
   );
-  
+
   $sql = "
-    SELECT DISTINCT genus 
-    FROM {organism} 
+    SELECT DISTINCT genus
+    FROM {organism}
     ORDER BY genus
   ";
   $results = chado_query($sql);
   $genus = array();
   $genus[] = '';
   while ($organism = $results->fetchObject()) {
-    $genus[$organism->genus] = $organism->genus;  
+    $genus[$organism->genus] = $organism->genus;
   }
-  
+
   $form['genus'] = array(
     '#title'         => t('Genus'),
     '#type'          => 'select',
-    '#options'       => $genus, 
-    '#default_value' => $dgenus,    
+    '#options'       => $genus,
+    '#default_value' => $dgenus,
     '#multiple'      => FALSE,
     '#description'   => t('The organism\'s genus. If specified, features for all organism with this genus will be retrieved.'),
     '#ahah' => array(
@@ -183,28 +196,28 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
       'wrapper' => 'tripal-feature-seq-extract-form-block',
       'event'   => 'change',
       'method'  => 'replace',
-    ), 
+    ),
   );
-  
-  $species = array();  
+
+  $species = array();
   $species[] = '';
   if ($dgenus) {
     $sql = "
-      SELECT DISTINCT species 
-      FROM {organism} 
+      SELECT DISTINCT species
+      FROM {organism}
       WHERE genus = :genus
       ORDER BY species
     ";
     $results = chado_query($sql, array(':genus' => $dgenus));
     while ($organism = $results->fetchObject()) {
-      $species[$organism->species] = $organism->species;  
+      $species[$organism->species] = $organism->species;
     }
-  }  
+  }
   $form['species'] = array(
     '#title'         => t('Species'),
     '#type'          => 'select',
     '#options'       => $species,
-    '#default_value' => $dspecies,     
+    '#default_value' => $dspecies,
     '#multiple'      => FALSE,
     '#description'   => t('The organism\'s species name. If specified, features for all organisms with this species will be retrieved.  Please first select a genus'),
     '#ahah' => array(
@@ -212,7 +225,7 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
       'wrapper' => 'tripal-feature-seq-extract-form-block',
       'event'   => 'change',
       'method'  => 'replace',
-    ), 
+    ),
   );
 
   $analyses = array();
@@ -220,7 +233,7 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
   if ($dgenus) {
     $sql = "
       SELECT DISTINCT A.analysis_id, A.name
-      FROM {analysis_organism} AO 
+      FROM {analysis_organism} AO
         INNER JOIN {analysis} A ON A.analysis_id = AO.analysis_id
         INNER JOIN {organism} O ON O.organism_id = AO.organism_id
       WHERE O.genus = :genus
@@ -232,26 +245,26 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
       $args[':species'] = $dspecies;
     }
     $sql .=" ORDER BY A.name ";
-    $results = chado_query($sql, $args);  
+    $results = chado_query($sql, $args);
     while ($analysis = $results->fetchObject()) {
-      $analyses[$analysis->name] = $analysis->name;  
+      $analyses[$analysis->name] = $analysis->name;
     }
   }
   $form['analysis'] = array(
     '#title'         => t('Analyses'),
     '#type'          => 'select',
-    '#options'       => $analyses, 
-    '#default_value' => $danalysis,    
+    '#options'       => $analyses,
+    '#default_value' => $danalysis,
     '#multiple'      => FALSE,
     '#description'  => t('You can limit sequences by the analyses to which it was derived or was used. If specified, only features associated with the specific analysis will be retrieved.'),
   );
-  
+
   $ftype = array();
   $ftype[] = '';
-  if ($dgenus) {  
+  if ($dgenus) {
     $sql = "
       SELECT DISTINCT OFC.cvterm_id, OFC.feature_type
-      FROM {organism_feature_count} OFC 
+      FROM {organism_feature_count} OFC
       WHERE OFC.genus = :genus
     ";
     $args = array();
@@ -262,20 +275,20 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
     }
     $sql .= " ORDER BY OFC.feature_type ";
     $results = chado_query($sql, $args);
-    
+
     while ($type = $results->fetchObject()) {
-      $ftype[$type->feature_type] = $type->feature_type;  
+      $ftype[$type->feature_type] = $type->feature_type;
     }
   }
   $form['ftype'] = array(
     '#title'         => t('Feature Type'),
     '#type'          => 'select',
-    '#options'       => $ftype,     
+    '#options'       => $ftype,
     '#multiple'      => FALSE,
     '#default_value' => $dftype,
     '#description'   => t('The type of feature to retrieve (e.g. mRNA). All features that match this type will be retrieved.'),
   );
-  
+
   $form['fnames'] = array(
     '#title'         => t('Feature Name'),
     '#type'          => 'file_upload_combo',
@@ -312,7 +325,7 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
     '#collapsible' => TRUE,
     '#collapsed' => TRUE
   );
-  
+
   $form['advanced']['use_parent'] = array(
     '#title'         => t('Use Parent'),
     '#type'          => 'checkbox',
@@ -343,40 +356,44 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
 }
 
 /**
- * 
+ * AJAX callback
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_form_ahah_update() {
   $status = TRUE;
-  
+
   // prepare and render the form. If no form is returned that means
   // we got here by an AHAH call after the form has been submitted.  This
   // is possible because results are downloaded and the page is not refreshed
   // but the form_id goes away.  So, we need to rebuild the form in this case.
   // otherwise, if the form already exists we just theme it.
-  $form = tripal_core_ahah_prepare_form();  
-  if ($form) { 
+  $form = tripal_core_ahah_prepare_form();
+  if ($form) {
     $data = theme('tripal_feature_seq_extract_form', $form);
   }
-  else {    
-    $data = drupal_get_form('tripal_feature_seq_extract_form');    
-  }  
+  else {
+    $data = drupal_get_form('tripal_feature_seq_extract_form');
+  }
 
-  // bind javascript events to the new objects that will be returned 
+  // bind javascript events to the new objects that will be returned
   // so that AHAH enabled elements will work.
   $settings = tripal_core_ahah_bind_events();
 
   // return the updated JSON
   drupal_json(
     array(
-      'status'   => $status, 
+      'status'   => $status,
       'data'     => $data,
       'settings' => $settings,
-    )  
+    )
   );
 }
 
 /**
- * 
+ * Validate the extract sequence form
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_form_validate($form, &$form_state) {
   $genus      = $form_state['values']['genus'];
@@ -389,9 +406,9 @@ function tripal_feature_seq_extract_form_validate($form, &$form_state) {
   $format     = $form_state['values']['format'];
   $use_parent = $form_state['values']['use_parent'];
   $aggregate  = $form_state['values']['aggregate'];
-  $agg_types  = $form_state['values']['agg_types'];  
+  $agg_types  = $form_state['values']['agg_types'];
   $op         = $form_state['values']['op'];
-  
+
   if ($op == 'Retrieve') {
     if ($upstream and !preg_match('/^\d+$/', $upstream)) {
       form_set_error('upstream', 'Please enter a positive numeric value for the upstream bases');
@@ -406,7 +423,9 @@ function tripal_feature_seq_extract_form_validate($form, &$form_state) {
 }
 
 /**
- * 
+ * Submit the extract sequence form
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_form_submit($form, &$form_state) {
   $genus      = $form_state['values']['genus'];
@@ -422,12 +441,12 @@ function tripal_feature_seq_extract_form_submit($form, &$form_state) {
   $agg_types  = $form_state['values']['agg_types'];
   $op         = $form_state['values']['op'];
 
-  // we must use the parent sequence if the user has selected 
+  // we must use the parent sequence if the user has selected
   // the upstream, downstream or to aggregate
   if ($upstream or $downstream or $aggregate) {
     $use_parent = 1;
   }
-  
+
   if ($op == 'Retrieve') {
     $_SESSION['tripal_feature_seq_extract']['genus']      = $genus;
     $_SESSION['tripal_feature_seq_extract']['species']    = $species;
@@ -447,19 +466,21 @@ function tripal_feature_seq_extract_form_submit($form, &$form_state) {
   }
 }
 
-/*
- * 
+/**
+ * Actually extract the sequences
+ *
+ * @ingroup tripal_feature
  */
-function tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name, 
-  $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent, $aggregate, 
+function tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name,
+  $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent, $aggregate,
   $child, $relationship, $rel_part) {
-    
+
   $sub_features = explode(',', $child);
-    
+
   if (!$output_format) {
     $output_format = 'fasta_txt';
   }
-  
+
   if (!$type and !$feature_name and !$genus) {
     print "Please provide a type, feature name or genus\n";
      return;
@@ -474,7 +495,7 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
   if ($analysis_name) {
      $sql .= "  INNER JOIN {analysisfeature} AF on AF.feature_id = F.feature_id " .
              "  INNER JOIN {analysis} A on AF.analysis_id = A.analysis_id ";
-  }         
+  }
   $sql .= "WHERE (1=1) ";
   if ($org_commonname) {
     $sql .= "AND O.common_name = :common_name ";
@@ -490,7 +511,7 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
   }
   if ($type) {
     $sql .= "AND CVT.name = ':cvtname ";
-    $vars[':cvtname'] = $type; 
+    $vars[':cvtname'] = $type;
   }
   if ($feature_name) {
     if (is_array($feature_name)) {
@@ -498,7 +519,7 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
       foreach ($feature_name as $i => $fname) {
         $sql .= ":fname$i, ";
         $vars[":fname$i"] = $fname;
-      } 
+      }
       // remove the trailing comma and close the paren
       $sql = substr($sql, 0, -2) . ")";
     }
@@ -514,29 +535,29 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
   $num_bases_per_line = 50;
   $num_seqs = 0;
   $q = chado_query($sql, $vars);
-  
+
   while ($feature = $q->fetchObject()) {
-    
+
     $feature_id = $feature->feature_id;
-    
+
     // build the header for each FASTA entry
     if ($feature->uniquename == $feature->name) {
       $feature_name = "$feature->uniquename $feature->feature_type ($feature->genus $feature->species)";
-    } 
+    }
     else {
       $feature_name = "$feature->uniquename $feature->name $feature->feature_type ($feature->genus $feature->species)";
     }
-      
+
     // generate the sequence
-    $sequence = tripal_feature_get_formatted_sequence($feature_id, $feature_name, 
+    $sequence = tripal_feature_get_formatted_sequence($feature_id, $feature_name,
       $num_bases_per_line, $derive_from_parent, $aggregate, $output_format,
       $upstream, $downstream, $sub_features, $relationship, $rel_part);
-    
+
     // print the sequence
     print $sequence;
     $num_seqs++;
   }
-  if ($num_seqs == 0) {    
+  if ($num_seqs == 0) {
     print "No Sequences Found";
   }
 }

+ 17 - 11
tripal_feature/tripal_feature.drush.inc

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * Contains function relating to drush-integration of this module.
@@ -10,6 +9,8 @@
  *
  * @return
  *   The first line of description when executing the help for a given command
+ *
+ * @ingroup tripal_drush
  */
 function tripal_feature_drush_help($command) {
   switch ($command) {
@@ -23,6 +24,8 @@ function tripal_feature_drush_help($command) {
  *
  * @return
  *   And array of command descriptions
+ *
+ * @ingroup tripal_drush
  */
 function tripal_feature_drush_command() {
   $items = array();
@@ -63,16 +66,16 @@ function tripal_feature_drush_command() {
 }
 
 /**
- * Executes jobs in the Tripal Jobs Queue
+ * Retrieves the sequence of the indicated features
  *
- * NOTE: The following code is executed when drush 'trpjob-run' or 'drush tripal-launch-jobs' is called
+ * @ingroup tripal_drush
  */
 function drush_tripal_feature_tripal_get_sequence() {
 
-  $org_commonname = drush_get_option('org');  
+  $org_commonname = drush_get_option('org');
   $genus = drush_get_option('genus');
   $species = drush_get_option('species');
-  $analysis_name = drush_get_option('analysis');  
+  $analysis_name = drush_get_option('analysis');
   $type = drush_get_option('type');
   $feature_name = drush_get_option('name');
   $upstream = drush_get_option('up');
@@ -88,15 +91,18 @@ function drush_tripal_feature_tripal_get_sequence() {
     print "Please specify both 'relationship' and a 'rel_part' arguments. Both must be used together\n";
     return;
   }
-    
-  tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name, 
-    $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent, 
+
+  tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name,
+    $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent,
     $aggregate, $child, $relationship, $rel_part);
 }
-/*
- * 
+
+/**
+ * Sync Chado Features with Drupal (ie: create nodes)
+ *
+ * @ingroup tripal_drush
  */
 function drush_tripal_feature_sync() {
-  $feature_id = drush_get_option('id');  
+  $feature_id = drush_get_option('id');
   tripal_feature_sync_feature($feature_id);
 }

+ 15 - 6
tripal_feature/tripal_feature.install

@@ -1,11 +1,15 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Installation of the feature module
  */
 
 /**
+ * Implements hook_disable().
+ *
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_disable() {
 
@@ -19,7 +23,9 @@ function tripal_feature_disable() {
 }
 
 /**
- * Implementation of hook_requirements().
+ * Implements hook_requirements().
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_requirements($phase) {
   $requirements = array();
@@ -37,7 +43,7 @@ function tripal_feature_requirements($phase) {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  *
  * @ingroup tripal_feature
  */
@@ -47,13 +53,13 @@ function tripal_feature_install() {
 
   // add the materialized view
   tripal_feature_add_organism_count_mview();
-  
+
   // create the temp table we will use for loading GFF files
   tripal_cv_create_tripal_gff_temp();
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  *
  * @ingroup tripal_feature
  */
@@ -62,7 +68,9 @@ function tripal_feature_uninstall() {
 }
 
 /**
- * 
+ * Create a temporary table used for loading gff3 files
+ *
+ * @ingroup tripal_feature
  */
 function tripal_cv_create_tripal_gff_temp() {
   // the tripal_obo_temp table is used for temporary housing of records when loading OBO files
@@ -137,6 +145,7 @@ function tripal_feature_schema() {
 };
 
 /**
+ * Creates a materialized view that stores the type & number of features per organism
  *
  * @ingroup tripal_feature
  */

+ 111 - 67
tripal_feature/tripal_feature.module

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Basic functionality for the tripal module
+ */
 
 /**
  * @defgroup tripal_feature Feature Module
@@ -8,30 +12,23 @@
  * @}
  */
 
-require_once "api/tripal_feature.api.inc";
-require_once "api/tripal_feature.schema.api.inc";
-require_once "theme/tripal_feature.theme.inc";
-require_once "includes/tripal_feature.admin.inc";
-require_once "includes/tripal_feature.fasta_loader.inc";
-require_once "includes/tripal_feature.gff_loader.inc";
-require_once "includes/tripal_feature.seq_extract.inc";
-require_once "includes/tripal_feature.delete.inc";
-require_once "includes/tripal_feature.chado_node.inc";
-require_once "includes/tripal_feature.blocks.inc";
+require_once 'api/tripal_feature.api.inc';
+require_once 'api/tripal_feature.schema.api.inc';
 
+require_once 'theme/tripal_feature.theme.inc';
 
-/**
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_init() {
-
-}
+require_once 'includes/tripal_feature.admin.inc';
+require_once 'includes/tripal_feature.fasta_loader.inc';
+require_once 'includes/tripal_feature.gff_loader.inc';
+require_once 'includes/tripal_feature.seq_extract.inc';
+require_once 'includes/tripal_feature.delete.inc';
+require_once 'includes/tripal_feature.chado_node.inc';
+require_once 'includes/tripal_feature.blocks.inc';
 
 /**
- * Implements hook_views_api()
+ * Implements hook_views_api().
  *
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_db.views.inc where all the
  *  views integration code is
  *
@@ -39,11 +36,13 @@ function tripal_feature_init() {
  */
 function tripal_feature_views_api() {
   return array(
-    'api' => 2.0,
+    'api' => 3.0,
   );
 }
 
 /**
+ * Implements hook_help().
+ *
  * Display help and module information
  *
  * @param
@@ -66,8 +65,6 @@ function tripal_feature_help($path, $arg) {
   return $output;
 }
 
-
-
 /**
  * Implements hook_permission().
  *
@@ -102,9 +99,10 @@ function tripal_feature_permission() {
   );
 }
 
-
 /**
- *  Menu items are automatically added for the new node types created
+ * Implements hook_menu().
+ *
+ * Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  adds more menu items needed for this module.
  *
@@ -212,8 +210,11 @@ function tripal_feature_menu() {
 
   return $items;
 }
+
 /**
- *  We need to let drupal know about our theme functions and their arguments.
+ * Implements hook_theme().
+ *
+ * We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
  *
@@ -323,9 +324,15 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
   return $items;
 }
 
-
 /**
+ * Load the locations for a given feature
  *
+ * @param $feature_id
+ *   The feature to look up locations for
+ * @param $side
+ *   Whether the feature is the scrfeature, 'as_parent', or feature, 'as_child'
+ * @param $aggregate
+ *   Whether or not to get the locations for related features
  *
  * @ingroup tripal_feature
  */
@@ -382,16 +389,31 @@ function tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggr
   usort($featurelocs, 'tripal_feature_sort_locations');
   return $featurelocs;
 }
+
 /**
- *  used to sort the feature locs by start position
+ * Used to sort the feature locs by start position
+ *
+ * @param $a
+ *   One featureloc record (as an object)
+ * @param $b
+ *   The other featureloc record (as an object)
+ *
+ * @return
+ *   Which feature location comes first
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_sort_locations($a, $b) {
   return strnatcmp($a->fmin, $b->fmin);
 }
+
 /**
+ * Get the relationships for a feature.
  *
+ * @param $feature_id
+ *   The feature to get relationships for
+ * @param $side
+ *   The side of the relationship this feature is (ie: 'as_subject' or 'as_object')
  *
  * @ingroup tripal_feature
  */
@@ -443,8 +465,15 @@ function tripal_feature_load_relationships($feature_id, $side = 'as_subject') {
   }
   return $relationships;
 }
+
 /**
+ * Get features related to the current feature to a given depth. Recursive function.
  *
+ * @param $feature_id
+ * @param $substitute
+ * @param $levels
+ * @param $base_type_id
+ * @param $depth
  *
  * @ingroup tripal_feature
  */
@@ -462,8 +491,12 @@ function tripal_feature_get_aggregate_relationships($feature_id, $substitute=1,
   return tripal_feature_load_relationships($feature_id, 'as_object');
 
 }
+
 /**
+ * Get the sequence this feature is located on
  *
+ * @param $feature_id
+ * @param $featurelocs
  *
  * @ingroup tripal_feature
  */
@@ -595,31 +628,30 @@ function tripal_feature_load_featureloc_sequences($feature_id, $featurelocs) {
   }
   return $floc_sequences;
 }
+
 /**
+ * This function is for features that align through an intermediate such
+ * as 'EST_match' or 'match'.  This occurs in the case where two sequences
+ * align but where one does not align perfectly.  Some ESTs may be in a contig
+ * but not all of the EST.  Portions may overhang and not be included in the
+ * consensus if quality is bad.
+ * For example:
+ *    Feature 1: Contig --------------------
+ *    Feature 2: EST_match           -------
+ *    Feature 3: EST                 ---------
  *
+ * The feature provided to the function will always be the feature 1.  The
+ * featureloc columns prefixed with 'right' (e.g. right_fmin) belong to the
+ * alignment of feature 3 with feature 2
+ *
+ * Features may align to more than one feature and are not matches. We do
+ * not want to include these, so we have to filter on the SO terms:
+ * match, or %_match
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_get_matched_alignments($feature) {
-  // This function is for features that align through an intermediate such
-  // as 'EST_match' or 'match'.  This occurs in the case where two sequences
-  // align but where one does not align perfectly.  Some ESTs may be in a contig
-  // but not all of the EST.  Portions may overhang and not be included in the
-  // consensus if quality is bad.
-  // For example:
-  //
-  //    Feature 1: Contig --------------------
-  //    Feature 2: EST_match           -------
-  //    Feature 3: EST                 ---------
-  //
-  // The feature provided to the function will always be the feature 1.  The
-  // featureloc columns prefixed with 'right' (e.g. right_fmin) belong to the
-  // alignment of feature 3 with feature 2
-  //
-  // Features may align to more than one feature and are not matches. We do
-  // not want to include these, so we have to filter on the SO terms:
-  // match, or %_match
-  //
+
    $sql = "
      SELECT
        FL1.featureloc_id    as left_featureloc_id,
@@ -668,8 +700,12 @@ function tripal_feature_get_matched_alignments($feature) {
    }
    return $featurelocs;
 }
+
 /**
+ * Load the arguments for the organism feature counts browser
  *
+ * @param $organism
+ *  The organism of interest
  *
  * @ingroup tripal_feature
  */
@@ -751,7 +787,7 @@ function tripal_feature_load_organism_feature_counts($organism) {
 }
 
 /**
- *  used to sort the list of relationship parts by start position
+ * Used to sort the list of relationship parts by start position
  *
  * @ingroup tripal_feature
  */
@@ -768,7 +804,7 @@ function tripal_feature_sort_rel_parts_by_start($a, $b) {
 }
 
 /**
- *  used to sort the list of relationship parts by start position
+ * Used to sort the list of relationship parts by start position
  *
  * @ingroup tripal_feature
  */
@@ -781,7 +817,11 @@ function tripal_feature_sort_rel_parts_by_end($a, $b) {
 }
 
 /**
+ * Returns the marked up fasta sequence for the described feature
  *
+ * @param $sequence
+ * @param $parts
+ * @param $defline
  *
  * @ingroup tripal_feature
  */
@@ -868,11 +908,12 @@ function tripal_feature_color_sequence($sequence, $parts, $defline) {
   return $newseq;
 }
 
-
-
-
 /**
- *
+ * The CV module will create the JSON array necessary for buillding a
+ * pie chart using jgChart and Google Charts.  We have to pass to it
+ * a table that contains count information, tell it which column
+ * contains the cvterm_id and provide a filter for getting the
+ * results we want from the table.
  *
  * @ingroup tripal_feature
  */
@@ -896,11 +937,6 @@ function tripal_feature_cv_chart($chart_id) {
 
   $organism_id = preg_replace("/^tripal_feature_cv_chart_(\d+)$/", "$1", $chart_id);
 
-  // The CV module will create the JSON array necessary for buillding a
-  // pie chart using jgChart and Google Charts.  We have to pass to it
-  // a table that contains count information, tell it which column
-  // contains the cvterm_id and provide a filter for getting the
-  // results we want from the table.
   $options = array(
     count_mview      => 'organism_feature_count',
     cvterm_id_column => 'cvterm_id',
@@ -912,17 +948,16 @@ function tripal_feature_cv_chart($chart_id) {
 }
 
 /**
- *
+ * The CV module will create the JSON array necessary for buillding a
+ * pie chart using jgChart and Google Charts.  We have to pass to it
+ * a table that contains count information, tell it which column
+ * contains the cvterm_id and provide a filter for getting the
+ * results we want from the table.
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_cv_tree($tree_id) {
 
-  // The CV module will create the JSON array necessary for buillding a
-  // pie chart using jgChart and Google Charts.  We have to pass to it
-  // a table that contains count information, tell it which column
-  // contains the cvterm_id and provide a filter for getting the
-  // results we want from the table.
   $organism_id = preg_replace("/^tripal_feature_cv_tree_(\d+)$/", "$1", $tree_id);
   $options = array(
     cv_id            => tripal_cv_get_cv_id('sequence'),
@@ -936,7 +971,7 @@ function tripal_feature_cv_tree($tree_id) {
 }
 
 /**
- *
+ * Delete the drupal taxonomy associated with our features
  *
  * @ingroup tripal_feature
  */
@@ -970,7 +1005,8 @@ function tripal_feature_del_vocabulary() {
 }
 
 /**
- *
+ * Implements hook_job_describe_args() in order to describe the various feature jobs
+ * to the tripal jobs interface.
  *
  * @ingroup tripal_feature
  */
@@ -1058,7 +1094,11 @@ function tripal_feature_job_describe_args($callback, $args) {
 
 /**
  * Implements hook_coder_ignore().
- * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for coder are stored
+ *
+ * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for
+ * coder are stored
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_coder_ignore() {
   return array(
@@ -1072,6 +1112,8 @@ function tripal_feature_coder_ignore() {
  * that ID by name, featurename or synonym.  If it matches uniquenly to a single
  * feature it will redirect to that feature page, otherwise, a list of matching
  * features is shown.
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_match_features_page($id) {
 
@@ -1152,6 +1194,8 @@ function tripal_feature_match_features_page($id) {
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == "tripal_feature_seq_extract_form") {
@@ -1164,4 +1208,4 @@ function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == "chado_feature_node_form") {
     $form['actions']['preview']['#access'] = FALSE;
   }
-}
+}

+ 4 - 7
tripal_feature/tripal_feature.views.inc

@@ -1,23 +1,20 @@
 <?php
-
 /**
  *  @file
  *  This file contains the basic functions for views integration of
- *  chado/tripal organism tables. Supplementary functions can be found in
- *  ./views/
- *
- *  Documentation on views integration can be found at
- *  http://views2.logrus.com/doc/html/index.html.
+ *  chado/tripal feature tables
  */
 
 /**
- * Implements hook_views_handlers()
+ * Implements hook_views_handlers().
  *
  * Purpose: Register all custom handlers with views
  *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  *
  * @return: An array of handler definitions
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_views_handlers() {
   return array(

+ 11 - 0
tripal_feature/tripal_feature.views_default.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Describe default feature views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
+ * @ingroup tripal_feature
  */
 function tripal_feature_views_default_views() {
   $views = array();
@@ -12,6 +18,11 @@ function tripal_feature_views_default_views() {
   return $views;
 }
 
+/**
+ * The default feature administration view
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_defaultview_admin_features() {
 
   $view = new view();

+ 10 - 1
tripal_feature/views_handlers/views_handler_field_residues.inc

@@ -1,7 +1,7 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Contains views_handler_field_residues field handler
  */
 
 /**
@@ -12,16 +12,25 @@
  */
 class views_handler_field_residues extends views_handler_field {
 
+  /**
+   * {@inheritdoc}
+   */
   function construct() {
     parent::construct();
       $this->additional_fields['residues'] = array('table' => 'feature', 'field' => 'residues');
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function query() {
     $this->ensure_my_table();
     $this->add_additional_fields();
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function render($values) {
     // add a <br> every 100 bp
     return ereg_replace("(.{100})", "\\1<br />", $values->feature_residues);

Some files were not shown because too many files changed in this diff