Browse Source

Tripal Feature adheres to Drupal coding standards

Pubudu Basnayaka 12 years ago
parent
commit
688d511b07

+ 661 - 644
tripal_feature/fasta_loader.php

@@ -1,5 +1,11 @@
 <?php
 
+/**
+ * @file
+ * @todo Add file header description
+ */
+
+
 /**
  * @defgroup fasta_loader FASTA Feature Loader
  * @{
@@ -7,264 +13,264 @@
  * @}
  * @ingroup tripal_feature
  */
- 
+
 /**
  *
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form (){
-
-   $form['fasta_file']= array(
-      '#type'          => 'textfield',
-      '#title'         => t('FASTA File'),
-      '#description'   => t('Please enter the full system path for the FASTA file, or a path within the Drupal
-                             installation (e.g. /sites/default/files/xyz.obo).  The path must be accessible to the
-                             server on which this Drupal instance is running.'),
-      '#required' => TRUE,
-   );
-
-   // get the list of organisms
-   $sql = "SELECT * FROM {organism} ORDER BY genus, species";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $organisms = array();
-   $organisms[''] = '';
-   while($organism = db_fetch_object($org_rset)){
-      $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
-   }
-   $form['organism_id'] = array (
-     '#title'       => t('Organism'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the organism to which these sequences are associated "),
-     '#required'    => TRUE,
-     '#options'     => $organisms,
-   );
-
-   $form['seqtype']= array(
-      '#type' => 'textfield',
-      '#title' => t('Sequence Type'),
-      '#required' => TRUE,
-      '#description' => t('Please enter the Sequence Ontology term that describes the sequences in the FASTA file.'),
-   );
-
-
-   // get the list of organisms
-   $sql = "SELECT L.library_id, L.name, CVT.name as type
-           FROM {library} L
-              INNER JOIN {cvterm} CVT ON L.type_id = CVT.cvterm_id
-           ORDER BY name";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $lib_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $libraries = array();
-   $libraries[''] = '';
-   while($library = db_fetch_object($lib_rset)){
-      $libraries[$library->library_id] = "$library->name ($library->type)";
-   }
-//   $form['library_id'] = array (
-//     '#title'       => t('Library'),
-//     '#type'        => t('select'),
-//     '#description' => t("Choose the library to which these sequences are associated "),
-//     '#required'    => FALSE,
-//     '#options'     => $libraries,
-//     '#weight'      => 5,
-//   );
-   $form['method']= array(
-      '#type' => 'radios',
-      '#title' => 'Method',
-      '#required' => TRUE,
-      '#options' => array(
-         t('Insert only'),
-         t('Update only'),
-         t('Insert and update'),
-      ),
-      '#description' => t('Select how features in the FASTA file are handled.  
-         Select "Insert only" to insert the new features. If a feature already 
-         exists with the same name or unique name and type then it is skipped.
-         Select "Update only" to only update featues that already exist in the
-         database.  Select "Insert and Update" to insert features that do
-         not exist and upate those that do.'),
-      '#default_value' => 2,
-   );
-
-$form['match_type']= array(
-      '#type' => 'radios',
-      '#title' => 'Name Match Type',
-      '#required' => TRUE,
-      '#options' => array(
-         t('Name'),
-         t('Unique name'),
-      ),
-      '#description' => t('Feature data is stored in Chado with both a human-readable
-        name and a unique name. If the features in your FASTA file are identified using
-        a human-readable name then select the "Name" button. If your features are
-        identified using the unique name then select the "Unique name" button.  If you 
-        loaded your features first using the GFF loader then the unique name of each
-        features were indicated by the "ID=" attribute and the name by the "Name=" attribute.
-        By default, the FASTA loader will use the first word (character string
-        before the first space) as  the name for your feature. If 
-        this does not uniquely identify your feature consider specifying a regular expression in the advanced section below. 
-        Additionally, you may import both a name and a unique name for each sequence using the advanced options. 
-        When updating a sequence, the value selected here will be used to identify the sequence in the 
-        database in combination with any regular expression provided below.'),
-      '#default_value' => 1,
-   );
-
-   $form['analysis'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Analysis Used to Derive Features'),
-      '#collapsed' => TRUE
-   ); 
-   $form['analysis']['desc'] = array(
-      '#type' => 'markup',
-      '#value' => t("Why specify an analysis for a data load?  All data comes 
-         from some place, even if downloaded from Genbank. By specifying
-         analysis details for all data uploads, it allows an end user to reproduce the
-         data set, but at least indicates the source of the data."), 
-   );
-
-   // get the list of organisms
-   $sql = "SELECT * FROM {analysis} ORDER BY name";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $analyses = array();
-   $analyses[''] = '';
-   while($analysis = db_fetch_object($org_rset)){
-      $analyses[$analysis->analysis_id] = "$analysis->name ($analysis->program $analysis->programversion, $analysis->sourcename)";
-   }
-   $form['analysis']['analysis_id'] = array (
-     '#title'       => t('Analysis'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the analysis to which these features are associated "),
-     '#required'    => TRUE,
-     '#options'     => $analyses,
-   );
-
-   // Advanced Options
-   $form['advanced'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Advanced Options'),
-      '#collapsed' => TRUE
-   );
-   $form['advanced']['re_help']= array(
-      '#type' => 'item',
-      '#value' => t('A regular expression is an advanced method for extracting information from a string of text.  
-                     Your FASTA file may contain both a human-readable name and a unique name for each sequence.  
-                     If you want to import
-                     both the name and unique name for all sequences, then you must provide regular expressions 
-                     so that the loader knows how to separate them.  
-                     Otherwise the name and uniquename will be the same.  
-                     By default, this loader will use the first word in the definition 
-                     lines of the FASTA file
-                     as the name or unique name of the feature.'),
-   );
-   $form['advanced']['re_name']= array(
-      '#type' => 'textfield',
-      '#title' => t('Regular expression for the name'),
-      '#required' => FALSE,
-      '#description' => t('Enter the regular expression that will extract the 
-         feature name from the FASTA definition line. For example, for a 
-         defintion line with a name and unique name separated by a bar \'|\' (>seqname|uniquename), 
-         the regular expression for the name would be, "^(.*?)\|.*$".'),
-   );  
-   $form['advanced']['re_uname']= array(
-      '#type' => 'textfield',
-      '#title' => t('Regular expression for the unique name'),
-      '#required' => FALSE,
-      '#description' => t('Enter the regular expression that will extract the 
-         feature name from the FASTA definition line. For example, for a 
-         defintion line with a name and unique name separated by a bar \'|\' (>seqname|uniquename), 
-         the regular expression for the unique name would be "^.*?\|(.*)$").'),
-   );   
- 
-
-   // Advanced database cross-reference optoins
-   $form['advanced']['db'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('External Database Reference'),
-      '#weight'=> 6,
-      '#collapsed' => TRUE
-   );
-   $form['advanced']['db']['re_accession']= array(
-      '#type' => 'textfield',
-      '#title' => t('Regular expression for the accession'),
-      '#required' => FALSE,
-      '#description' => t('Enter the regular expression that will extract the accession for the external database for each feature from the FASTA definition line.'),
-      '#weight' => 2
-   ); 
+function tripal_feature_fasta_load_form( ) {
+
+  $form['fasta_file']= array(
+    '#type'          => 'textfield',
+    '#title'         => t('FASTA File'),
+    '#description'   => t('Please enter the full system path for the FASTA file, or a path within the Drupal
+                           installation (e.g. /sites/default/files/xyz.obo).  The path must be accessible to the
+                           server on which this Drupal instance is running.'),
+    '#required' => TRUE,
+  );
+
+  // get the list of organisms
+  $sql = "SELECT * FROM {organism} ORDER BY genus, species";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $org_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+  $organisms = array();
+  $organisms[''] = '';
+  while ($organism = db_fetch_object($org_rset)) {
+    $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
+  }
+  $form['organism_id'] = array(
+   '#title'       => t('Organism'),
+   '#type'        => t('select'),
+   '#description' => t("Choose the organism to which these sequences are associated"),
+   '#required'    => TRUE,
+   '#options'     => $organisms,
+  );
+
+  $form['seqtype']= array(
+    '#type' => 'textfield',
+    '#title' => t('Sequence Type'),
+    '#required' => TRUE,
+    '#description' => t('Please enter the Sequence Ontology term that describes the sequences in the FASTA file.'),
+  );
+
+
+  // get the list of organisms
+  $sql = "SELECT L.library_id, L.name, CVT.name as type
+         FROM {library} L
+            INNER JOIN {cvterm} CVT ON L.type_id = CVT.cvterm_id
+         ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $lib_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+  $libraries = array();
+  $libraries[''] = '';
+  while ($library = db_fetch_object($lib_rset)) {
+    $libraries[$library->library_id] = "$library->name ($library->type)";
+  }
+  //   $form['library_id'] = array (
+  //     '#title'       => t('Library'),
+  //     '#type'        => t('select'),
+  //     '#description' => t("Choose the library to which these sequences are associated "),
+  //     '#required'    => FALSE,
+  //     '#options'     => $libraries,
+  //     '#weight'      => 5,
+  //   );
+  $form['method']= array(
+    '#type' => 'radios',
+    '#title' => 'Method',
+    '#required' => TRUE,
+    '#options' => array(
+      t('Insert only'),
+      t('Update only'),
+      t('Insert and update'),
+    ),
+    '#description' => t('Select how features in the FASTA file are handled.
+       Select "Insert only" to insert the new features. If a feature already
+       exists with the same name or unique name and type then it is skipped.
+       Select "Update only" to only update featues that already exist in the
+       database.  Select "Insert and Update" to insert features that do
+       not exist and upate those that do.'),
+    '#default_value' => 2,
+  );
+
+  $form['match_type']= array(
+    '#type' => 'radios',
+    '#title' => 'Name Match Type',
+    '#required' => TRUE,
+    '#options' => array(
+      t('Name'),
+      t('Unique name'),
+    ),
+    '#description' => t('Feature data is stored in Chado with both a human-readable
+      name and a unique name. If the features in your FASTA file are identified using
+      a human-readable name then select the "Name" button. If your features are
+      identified using the unique name then select the "Unique name" button.  If you
+      loaded your features first using the GFF loader then the unique name of each
+      features were indicated by the "ID=" attribute and the name by the "Name=" attribute.
+      By default, the FASTA loader will use the first word (character string
+      before the first space) as  the name for your feature. If
+      this does not uniquely identify your feature consider specifying a regular expression in the advanced section below.
+      Additionally, you may import both a name and a unique name for each sequence using the advanced options.
+      When updating a sequence, the value selected here will be used to identify the sequence in the
+      database in combination with any regular expression provided below.'),
+    '#default_value' => 1,
+  );
+
+  $form['analysis'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Analysis Used to Derive Features'),
+    '#collapsed' => TRUE
+  );
+  $form['analysis']['desc'] = array(
+    '#type' => 'markup',
+    '#value' => t("Why specify an analysis for a data load?  All data comes
+       from some place, even if downloaded from Genbank. By specifying
+       analysis details for all data uploads, it allows an end user to reproduce the
+       data set, but at least indicates the source of the data."),
+  );
+
+  // get the list of organisms
+  $sql = "SELECT * FROM {analysis} ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $org_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+  $analyses = array();
+  $analyses[''] = '';
+  while ($analysis = db_fetch_object($org_rset)) {
+    $analyses[$analysis->analysis_id] = "$analysis->name ($analysis->program $analysis->programversion, $analysis->sourcename)";
+  }
+  $form['analysis']['analysis_id'] = array(
+    '#title'       => t('Analysis'),
+    '#type'        => t('select'),
+    '#description' => t("Choose the analysis to which these features are associated"),
+    '#required'    => TRUE,
+    '#options'     => $analyses,
+  );
+
+  // Advanced Options
+  $form['advanced'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Advanced Options'),
+    '#collapsed' => TRUE
+  );
+  $form['advanced']['re_help']= array(
+    '#type' => 'item',
+    '#value' => t('A regular expression is an advanced method for extracting information from a string of text.
+                   Your FASTA file may contain both a human-readable name and a unique name for each sequence.
+                   If you want to import
+                   both the name and unique name for all sequences, then you must provide regular expressions
+                   so that the loader knows how to separate them.
+                   Otherwise the name and uniquename will be the same.
+                   By default, this loader will use the first word in the definition
+                   lines of the FASTA file
+                   as the name or unique name of the feature.'),
+  );
+  $form['advanced']['re_name']= array(
+    '#type' => 'textfield',
+    '#title' => t('Regular expression for the name'),
+    '#required' => FALSE,
+    '#description' => t('Enter the regular expression that will extract the
+       feature name from the FASTA definition line. For example, for a
+       defintion line with a name and unique name separated by a bar \'|\' (>seqname|uniquename),
+       the regular expression for the name would be, "^(.*?)\|.*$".'),
+  );
+  $form['advanced']['re_uname']= array(
+    '#type' => 'textfield',
+    '#title' => t('Regular expression for the unique name'),
+    '#required' => FALSE,
+    '#description' => t('Enter the regular expression that will extract the
+       feature name from the FASTA definition line. For example, for a
+       defintion line with a name and unique name separated by a bar \'|\' (>seqname|uniquename),
+       the regular expression for the unique name would be "^.*?\|(.*)$").'),
+  );
+
+
+  // Advanced database cross-reference optoins
+  $form['advanced']['db'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('External Database Reference'),
+    '#weight' => 6,
+    '#collapsed' => TRUE
+  );
+  $form['advanced']['db']['re_accession']= array(
+    '#type' => 'textfield',
+    '#title' => t('Regular expression for the accession'),
+    '#required' => FALSE,
+    '#description' => t('Enter the regular expression that will extract the accession for the external database for each feature from the FASTA definition line.'),
+    '#weight' => 2
+  );
 
   // get the list of databases
-   $sql = "SELECT * FROM {db} ORDER BY name";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $db_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $dbs = array();
-   $dbs[''] = '';
-   while($db = db_fetch_object($db_rset)){
-      $dbs[$db->db_id] = "$db->name";
-   }
-   $form['advanced']['db']['db_id'] = array (
-     '#title'       => t('External Database'),
-     '#type'        => t('select'),
-     '#description' => t("Plese choose an external database for which these sequences have a cross reference."),
-     '#required'    => FALSE,
-     '#options'     => $dbs,
-     '#weight'      => 1,
-   );
-
-   $form['advanced']['relationship'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Relationships'),
-      '#weight'=> 6,
-      '#collapsed' => TRUE
-   );
-   $rels = array();
-   $rels[''] = '';
-   $rels['part_of'] = 'part of';
-   $rels['derives_from'] = 'produced by';
-
-
-   // Advanced references options
-   $form['advanced']['relationship']['rel_type']= array(
-     '#title'       => t('Relationship Type'),
-     '#type'        => t('select'),
-     '#description' => t("Use this option to create associations, or relationships between the 
-                          features of this FASTA file and existing features in the database. For 
-                          example, to associate a FASTA file of peptides to existing genes or transcript sequence, 
-                          select the type 'produced by'. For a CDS sequences select the type 'part of'"),
-     '#required'    => FALSE,
-     '#options'     => $rels,
-     '#weight'      => 5,
-   );
-   $form['advanced']['relationship']['re_subject']= array(
-      '#type' => 'textfield',
-      '#title' => t('Regular expression for the parent'),
-      '#required' => FALSE,
-      '#description' => t('Enter the regular expression that will extract the unique 
-                           name needed to identify the existing sequence for which the 
-                           relationship type selected above will apply.'),
-      '#weight' => 6
-   ); 
-   $form['advanced']['relationship']['parent_type']= array(
-      '#type' => 'textfield',
-      '#title' => t('Parent Type'),
-      '#required' => FALSE,
-      '#description' => t('Please enter the Sequence Ontology term for the parent.  For example
-                           if the FASTA file being loaded is a set of proteins that are 
-                           products of genes, then use the SO term \'gene\' or \'transcript\' or equivalent. However,
-                           this type must match the type for already loaded features.'),
-      '#weight' => 7
-   );
-
-   $form['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Import FASTA file'),
-      '#weight' => 10,
-   );
-   return $form;   
+  $sql = "SELECT * FROM {db} ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $db_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+  $dbs = array();
+  $dbs[''] = '';
+  while ($db = db_fetch_object($db_rset)) {
+    $dbs[$db->db_id] = "$db->name";
+  }
+  $form['advanced']['db']['db_id'] = array(
+   '#title'       => t('External Database'),
+   '#type'        => t('select'),
+   '#description' => t("Plese choose an external database for which these sequences have a cross reference."),
+   '#required'    => FALSE,
+   '#options'     => $dbs,
+   '#weight'      => 1,
+  );
+
+  $form['advanced']['relationship'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Relationships'),
+    '#weight' => 6,
+    '#collapsed' => TRUE
+  );
+  $rels = array();
+  $rels[''] = '';
+  $rels['part_of'] = 'part of';
+  $rels['derives_from'] = 'produced by';
+
+
+  // Advanced references options
+  $form['advanced']['relationship']['rel_type']= array(
+   '#title'       => t('Relationship Type'),
+   '#type'        => t('select'),
+   '#description' => t("Use this option to create associations, or relationships between the
+                        features of this FASTA file and existing features in the database. For
+                        example, to associate a FASTA file of peptides to existing genes or transcript sequence,
+                        select the type 'produced by'. For a CDS sequences select the type 'part of'"),
+   '#required'    => FALSE,
+   '#options'     => $rels,
+   '#weight'      => 5,
+  );
+  $form['advanced']['relationship']['re_subject']= array(
+    '#type' => 'textfield',
+    '#title' => t('Regular expression for the parent'),
+    '#required' => FALSE,
+    '#description' => t('Enter the regular expression that will extract the unique
+                         name needed to identify the existing sequence for which the
+                         relationship type selected above will apply.'),
+    '#weight' => 6
+  );
+  $form['advanced']['relationship']['parent_type']= array(
+    '#type' => 'textfield',
+    '#title' => t('Parent Type'),
+    '#required' => FALSE,
+    '#description' => t('Please enter the Sequence Ontology term for the parent.  For example
+                         if the FASTA file being loaded is a set of proteins that are
+                         products of genes, then use the SO term \'gene\' or \'transcript\' or equivalent. However,
+                         this type must match the type for already loaded features.'),
+    '#weight' => 7
+  );
+
+  $form['button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Import FASTA file'),
+    '#weight' => 10,
+  );
+  return $form;
 }
 
 /**
@@ -272,98 +278,98 @@ $form['match_type']= array(
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form_validate($form, &$form_state){
-   $fasta_file = trim($form_state['values']['fasta_file']);
-   $organism_id  = $form_state['values']['organism_id'];
-   $type         = trim($form_state['values']['seqtype']);
-   $method       = trim($form_state['values']['method']);
-   $match_type   = trim($form_state['values']['match_type']);
-   $library_id   = $form_state['values']['library_id'];
-   $re_name      = trim($form_state['values']['re_name']);
-   $re_uname     = trim($form_state['values']['re_uname']);
-   $re_accession = trim($form_state['values']['re_accession']);
-   $db_id        = $form_state['values']['db_id'];
-   $rel_type     = $form_state['values']['rel_type'];
-   $re_subject   = trim($form_state['values']['re_subject']);
-   $parent_type   = trim($form_state['values']['parent_type']);
-
-   if($method == 0){
-      $method = 'Insert only';
-   }
-   if($method == 1){
-      $method = 'Update only';
-   }
-   if($method == 2){
-      $method = 'Insert and update';
-   }
-
-   if($match_type == 0){
-      $match_type = 'Name';
-   }
-
-   if($match_type == 1){
-      $match_type = 'Unique name';
-   }
-
-
-   if ($re_name and !$re_uname and strcmp($match_type,'Unique name')==0){
-      form_set_error('re_uname',t("You must provide a regular expression to identify the sequence unique name"));     
-   }
-
-   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
-   $dfile = $_SERVER['DOCUMENT_ROOT'] . base_path() . $fasta_file; 
-   if(!file_exists($dfile)){
-      // if not local to Drupal, the file must be someplace else, just use
-      // the full path provided
-      $dfile = $fasta_file;
-   }
-   if(!file_exists($dfile)){
-      form_set_error('fasta_file',t("Cannot find the file on the system. Check that the file exists or that the web server has permissions to read the file."));
-   }
-
-   // make sure if a relationship is specified that all fields are provided.
-   if(($rel_type or $parent_type) and !$re_subject){
-      form_set_error('re_subject',t("Please provide a regular expression for the parent"));
-   }
-   if(($rel_type or $re_subject) and !$parent_type){
-      form_set_error('parent_type',t("Please provide a SO term for the parent"));
-   }
-   if(($parent_type or $re_subject) and !$rel_type){
-      form_set_error('rel_type',t("Please select a relationship type"));
-   }
-
-
-   // make sure if a database is specified that all fields are provided
-   if($db_id and !$re_accession){
-      form_set_error('re_accession',t("Please provide a regular expression for the accession"));
-   }
-   if($re_accession and !$db_id){
-      form_set_error('db_id',t("Please select a database"));
-   }
-
-   // check to make sure the types exists
-   $cvtermsql = "SELECT CVT.cvterm_id
-                 FROM {cvterm} CVT
-                    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 = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
-   $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$type,$type));
-   if(!$cvterm){
-      form_set_error('type',t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
-   }
-   if($rel_type){
-      $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$parent_type,$parent_type));
-      if(!$cvterm){
-         form_set_error('parent_type',t("The Sequence Ontology (SO) term selected for the parent relationship is not available in the database. Please check spelling or select another."));
-      }
-   }
-
-   // check to make sure the 'relationship' and 'sequence' ontologies are loaded
-   $form_state['storage']['dfile'] = $dfile;
+function tripal_feature_fasta_load_form_validate($form, &$form_state) {
+  $fasta_file = trim($form_state['values']['fasta_file']);
+  $organism_id  = $form_state['values']['organism_id'];
+  $type         = trim($form_state['values']['seqtype']);
+  $method       = trim($form_state['values']['method']);
+  $match_type   = trim($form_state['values']['match_type']);
+  $library_id   = $form_state['values']['library_id'];
+  $re_name      = trim($form_state['values']['re_name']);
+  $re_uname     = trim($form_state['values']['re_uname']);
+  $re_accession = trim($form_state['values']['re_accession']);
+  $db_id        = $form_state['values']['db_id'];
+  $rel_type     = $form_state['values']['rel_type'];
+  $re_subject   = trim($form_state['values']['re_subject']);
+  $parent_type   = trim($form_state['values']['parent_type']);
+
+  if ($method == 0) {
+    $method = 'Insert only';
+  }
+  if ($method == 1) {
+    $method = 'Update only';
+  }
+  if ($method == 2) {
+    $method = 'Insert and update';
+  }
+
+  if ($match_type == 0) {
+    $match_type = 'Name';
+  }
+
+  if ($match_type == 1) {
+    $match_type = 'Unique name';
+  }
+
+
+  if ($re_name and !$re_uname and strcmp($match_type, 'Unique name')==0) {
+    form_set_error('re_uname', t("You must provide a regular expression to identify the sequence unique name"));
+  }
+
+  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
+  $dfile = $_SERVER['DOCUMENT_ROOT'] . base_path() . $fasta_file;
+  if (!file_exists($dfile)) {
+    // if not local to Drupal, the file must be someplace else, just use
+    // the full path provided
+    $dfile = $fasta_file;
+  }
+  if (!file_exists($dfile)) {
+    form_set_error('fasta_file', t("Cannot find the file on the system. Check that the file exists or that the web server has permissions to read the file."));
+  }
+
+  // make sure if a relationship is specified that all fields are provided.
+  if (($rel_type or $parent_type) and !$re_subject) {
+    form_set_error('re_subject', t("Please provide a regular expression for the parent"));
+  }
+  if (($rel_type or $re_subject) and !$parent_type) {
+    form_set_error('parent_type', t("Please provide a SO term for the parent"));
+  }
+  if (($parent_type or $re_subject) and !$rel_type) {
+    form_set_error('rel_type', t("Please select a relationship type"));
+  }
+
+
+  // make sure if a database is specified that all fields are provided
+  if ($db_id and !$re_accession) {
+    form_set_error('re_accession', t("Please provide a regular expression for the accession"));
+  }
+  if ($re_accession and !$db_id) {
+    form_set_error('db_id', t("Please select a database"));
+  }
+
+  // check to make sure the types exists
+  $cvtermsql = "SELECT CVT.cvterm_id
+               FROM {cvterm} CVT
+                  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 = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
+  $cvterm = db_fetch_object(db_query($cvtermsql, 'sequence', $type, $type));
+  if (!$cvterm) {
+    form_set_error('type', t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
+  }
+  if ($rel_type) {
+    $cvterm = db_fetch_object(db_query($cvtermsql, 'sequence', $parent_type, $parent_type));
+    if (!$cvterm) {
+      form_set_error('parent_type', t("The Sequence Ontology (SO) term selected for the parent relationship is not available in the database. Please check spelling or select another."));
+    }
+  }
+
+  // check to make sure the 'relationship' and 'sequence' ontologies are loaded
+  $form_state['storage']['dfile'] = $dfile;
 }
 
 /**
@@ -371,48 +377,48 @@ function tripal_feature_fasta_load_form_validate($form, &$form_state){
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form_submit ($form, &$form_state){
-   global $user;
-
-   $dfile        = $form_state['storage']['dfile'];
-   $organism_id  = $form_state['values']['organism_id'];
-   $type         = trim($form_state['values']['seqtype']);
-   $method       = trim($form_state['values']['method']);
-   $match_type   = trim($form_state['values']['match_type']);
-   $library_id   = $form_state['values']['library_id'];
-   $re_name      = trim($form_state['values']['re_name']);
-   $re_uname     = trim($form_state['values']['re_uname']);
-   $re_accession = trim($form_state['values']['re_accession']);
-   $db_id        = $form_state['values']['db_id'];
-   $rel_type     = $form_state['values']['rel_type'];
-   $re_subject   = trim($form_state['values']['re_subject']);
-   $parent_type   = trim($form_state['values']['parent_type']);
-   $analysis_id = $form_state['values']['analysis_id'];
-
-   if($method == 0){
-      $method = 'Insert only';
-   }
-   if($method == 1){
-      $method = 'Update only';
-   }
-   if($method == 2){
-      $method = 'Insert and update';
-   }
-
-   if($match_type == 0){
-      $match_type = 'Name';
-   }
-
-   if($match_type == 1){
-      $match_type = 'Unique name';
-   }
-
-   $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);
-
-   tripal_add_job("Import FASTA file: $dfile",'tripal_feature',
-      'tripal_feature_load_fasta',$args,$user->uid);
+function tripal_feature_fasta_load_form_submit($form, &$form_state) {
+  global $user;
+
+  $dfile        = $form_state['storage']['dfile'];
+  $organism_id  = $form_state['values']['organism_id'];
+  $type         = trim($form_state['values']['seqtype']);
+  $method       = trim($form_state['values']['method']);
+  $match_type   = trim($form_state['values']['match_type']);
+  $library_id   = $form_state['values']['library_id'];
+  $re_name      = trim($form_state['values']['re_name']);
+  $re_uname     = trim($form_state['values']['re_uname']);
+  $re_accession = trim($form_state['values']['re_accession']);
+  $db_id        = $form_state['values']['db_id'];
+  $rel_type     = $form_state['values']['rel_type'];
+  $re_subject   = trim($form_state['values']['re_subject']);
+  $parent_type   = trim($form_state['values']['parent_type']);
+  $analysis_id = $form_state['values']['analysis_id'];
+
+  if ($method == 0) {
+    $method = 'Insert only';
+  }
+  if ($method == 1) {
+    $method = 'Update only';
+  }
+  if ($method == 2) {
+    $method = 'Insert and update';
+  }
+
+  if ($match_type == 0) {
+    $match_type = 'Name';
+  }
+
+  if ($match_type == 1) {
+    $match_type = 'Unique name';
+  }
+
+  $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);
+
+  tripal_add_job("Import FASTA file: $dfile", 'tripal_feature',
+    'tripal_feature_load_fasta', $args, $user->uid);
 }
 
 /**
@@ -421,94 +427,95 @@ function tripal_feature_fasta_load_form_submit ($form, &$form_state){
  * @ingroup fasta_loader
  */
 function tripal_feature_load_fasta($dfile, $organism_id, $type,
-   $library_id, $re_name, $re_uname, $re_accession, $db_id, $rel_type,
-   $re_subject, $parent_type, $method, $uid, $analysis_id, 
-   $match_type,$job = NULL)
-{
-
-   print "Opening FASTA file $dfile\n";
-
-    
-   $lines = file($dfile,FILE_SKIP_EMPTY_LINES);
-   $i = 0;
-
-   $name = '';
-   $uname = '';
-   $residues = '';
-   $num_lines = sizeof($lines);
-   $interval = intval($num_lines * 0.01);
-   if($interval == 0){
-      $interval = 1;
-   }
-
-   foreach ($lines as $line_num => $line) {
-      $i++;  // update the line count     
-
-      // update the job status every 1% features
-      if($job and $i % $interval == 0){
-         tripal_job_set_progress($job,intval(($i/$num_lines)*100));
+  $library_id, $re_name, $re_uname, $re_accession, $db_id, $rel_type,
+  $re_subject, $parent_type, $method, $uid, $analysis_id,
+  $match_type, $job = NULL) {
+
+  print "Opening FASTA file $dfile\n";
+
+
+  $lines = file($dfile, FILE_SKIP_EMPTY_LINES);
+  $i = 0;
+
+  $name = '';
+  $uname = '';
+  $residues = '';
+  $num_lines = sizeof($lines);
+  $interval = intval($num_lines * 0.01);
+  if ($interval == 0) {
+    $interval = 1;
+  }
+
+  foreach ($lines as $line_num => $line) {
+    $i++;  // update the line count
+
+    // update the job status every 1% features
+    if ($job and $i % $interval == 0) {
+      tripal_job_set_progress($job, intval(($i/$num_lines)*100));
+    }
+
+    // if we encounter a definition line then get the name, uniquename,
+    // accession and relationship subject from the definition line
+    if (preg_match('/^>/', $line)) {
+      // if we have a feature name then we are starting a new sequence
+      // so let's handle the previous one before moving on
+      if ($name or $uname) {
+        tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id,
+          $accession, $subject, $rel_type, $parent_type, $analysis_id, $organism_id, $type,
+          $source, $residues, $method, $re_name, $match_type);
+        $residues = '';
+        $name = '';
+        $uname = '';
       }
 
-      // if we encounter a definition line then get the name, uniquename, 
-      // accession and relationship subject from the definition line
-      if(preg_match('/^>/',$line)){
-         // if we have a feature name then we are starting a new sequence
-         // so let's handle the previous one before moving on
-         if($name or $uname){
-           tripal_feature_fasta_loader_handle_feature($name,$uname,$db_id,
-              $accession,$subject,$rel_type,$parent_type,$analysis_id,$organism_id,$type,
-              $source,$residues,$method,$re_name,$match_type);
-           $residues = '';
-           $name = '';
-           $uname = '';
-         }
-
-         $line = preg_replace("/^>/",'',$line);
-         // get the feature name
-         if($re_name){
-            if(!preg_match("/$re_name/",$line,$matches)){
-               print "WARNING: Regular expression for the feature name finds nothing\n";
-            }
-            $name = trim($matches[1]);
-         } else {
-            // if the match_type is name and no regular expression was provided
-            // then use the first word as the name, otherwise we don't set the name
-            if(strcmp($match_type,'Name')==0){
-               preg_match("/^\s*(.*?)[\s\|].*$/",$line,$matches);
-               $name = trim($matches[1]);
-            }
-         } 
-         // get the feature unique name
-         if($re_uname){
-            if(!preg_match("/$re_uname/",$line,$matches)){
-               print "WARNING: Regular expression for the feature unique name finds nothing\n";
-            }
-            $uname = trim($matches[1]);
-         } else {
-            // if the match_type is name and no regular expression was provided
-            // then use the first word as the name, otherwise, we don't set the unqiuename
-            if(strcmp($match_type,'Unique name')==0){
-               preg_match("/^\s*(.*?)[\s\|].*$/",$line,$matches);
-               $uname = trim($matches[1]);
-            }
-         } 
-         // get the accession    
-         preg_match("/$re_accession/",$line,$matches);
-         $accession = trim($matches[1]);
-
-         // get the relationship subject
-         preg_match("/$re_subject/",$line,$matches);
-         $subject = trim($matches[1]);
+      $line = preg_replace("/^>/", '', $line);
+      // get the feature name
+      if ($re_name) {
+        if (!preg_match("/$re_name/", $line, $matches)) {
+          print "WARNING: Regular expression for the feature name finds nothing\n";
+        }
+        $name = trim($matches[1]);
+      }
+      else {
+        // if the match_type is name and no regular expression was provided
+        // then use the first word as the name, otherwise we don't set the name
+        if (strcmp($match_type, 'Name')==0) {
+          preg_match("/^\s*(.*?)[\s\|].*$/", $line, $matches);
+          $name = trim($matches[1]);
+        }
+      }
+      // get the feature unique name
+      if ($re_uname) {
+        if (!preg_match("/$re_uname/", $line, $matches)) {
+          print "WARNING: Regular expression for the feature unique name finds nothing\n";
+        }
+        $uname = trim($matches[1]);
       }
       else {
-         $residues .= trim($line);
+        // if the match_type is name and no regular expression was provided
+        // then use the first word as the name, otherwise, we don't set the unqiuename
+        if (strcmp($match_type, 'Unique name')==0) {
+          preg_match("/^\s*(.*?)[\s\|].*$/", $line, $matches);
+          $uname = trim($matches[1]);
+        }
+      }
+      // get the accession
+      preg_match("/$re_accession/", $line, $matches);
+      $accession = trim($matches[1]);
+
+      // get the relationship subject
+      preg_match("/$re_subject/", $line, $matches);
+      $subject = trim($matches[1]);
       }
-   }
+    else {
+      $residues .= trim($line);
+    }
+  }
    // 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,$type,
-      $source,$residues,$method,$re_name,$match_type);
-   return '';
+  tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id,
+    $accession, $subject, $rel_type, $parent_type, $analysis_id, $organism_id, $type,
+    $source, $residues, $method, $re_name, $match_type);
+  return '';
 }
 
 /**
@@ -516,194 +523,204 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_loader_handle_feature($name,$uname,$db_id,$accession,
-              $parent,$rel_type,$parent_type,$analysis_id,$organism_id,$type, 
-              $source,$residues,$method,$re_name,$match_type) 
-{
-   $previous_db = tripal_db_set_active('chado');
-
-   // first get the type for this sequence
-   $cvtermsql = "SELECT CVT.cvterm_id
-                 FROM {cvterm} CVT
-                    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 = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
-   $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$type,$type));
-   if(!$cvterm){
-      print "ERROR: cannot find the term type: '$type'\n";
-      return 0;
-   }
+function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $accession,
+  $parent, $rel_type, $parent_type, $analysis_id, $organism_id, $type,
+  $source, $residues, $method, $re_name, $match_type) {
+
+  $previous_db = tripal_db_set_active('chado');
+
+  // first get the type for this sequence
+  $cvtermsql = "SELECT CVT.cvterm_id
+               FROM {cvterm} CVT
+                  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 = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
+  $cvterm = db_fetch_object(db_query($cvtermsql, 'sequence', $type, $type));
+  if (!$cvterm) {
+    print "ERROR: cannot find the term type: '$type'\n";
+    return 0;
+  }
 
    // check to see if this feature already exists
-   if(strcmp($match_type,'Name')==0){
-      $cnt_sql = "SELECT count(*) as cnt FROM {feature} 
-                      WHERE organism_id = %d and name = '%s' and type_id = %d";
-      $cnt = db_fetch_object(db_query($cnt_sql,$organism_id,$name,$cvterm->cvterm_id));
-      if($cnt->cnt > 1){
-         print "ERROR: multiple features exist with the name '$name' of type '$type' for the organism.  skipping\n";
-         return 0;
-      } else {
-         $feature_sql = "SELECT * FROM {feature} 
-                      WHERE organism_id = %d and name = '%s' and type_id = %d";
-         $feature = db_fetch_object(db_query($feature_sql,$organism_id,$name,$cvterm->cvterm_id));
-      }
-   }
-   if(strcmp($match_type,'Unique name')==0){
-      $feature_sql = "SELECT * FROM {feature} 
-                      WHERE organism_id = %d and uniquename = '%s' and type_id = %d";
-      $feature = db_fetch_object(db_query($feature_sql,$organism_id,$uname,$cvterm->cvterm_id));
-   }
-
-   if(!$feature and (strcmp($method,'Insert only')==0 or strcmp($method,'Insert and update')==0)){
-       // if we have a unique name but not a name then set them to be teh same 
-       // and vice versa
-       if(!$uname){
-          $uname = $name;
-       }
-       elseif(!$name){
-          $name = $uname;
-       }
-      // now insert the feature
-      $sql = "INSERT INTO {feature} 
-                 (organism_id, name, uniquename, residues, seqlen, 
-                  md5checksum,type_id,is_analysis,is_obsolete)
-              VALUES(%d,'%s','%s','%s',%d, '%s', %d, %s, %s)";
-      $result = db_query($sql,$organism_id,$name,$uname,$residues,strlen($residues),
-                  md5($residues),$cvterm->cvterm_id,'false','false');
-      if(!$result){
-         print "ERROR: failed to insert feature '$name ($uname)'\n";
-         return 0;
-      } else {
-         print "Inserted feature $name ($uname)\n";
-      }
-      $feature = db_fetch_object(db_query($feature_sql,$organism_id,$uname,$cvterm->cvterm_id));
-   } 
-   if(!$feature and (strcmp($method,'Update only')==0 or strcmp($method,'Insert and update')==0)){
-      print "WARNING: failed to find feature '$name' ('$uname') while matching on " . strtolower($match_type) . ". Skipping\n";
+  if (strcmp($match_type, 'Name')==0) {
+    $cnt_sql = "SELECT count(*) as cnt FROM {feature}
+                  WHERE organism_id = %d and name = '%s' and type_id = %d";
+    $cnt = db_fetch_object(db_query($cnt_sql, $organism_id, $name, $cvterm->cvterm_id));
+    if ($cnt->cnt > 1) {
+      print "ERROR: multiple features exist with the name '$name' of type '$type' for the organism.  skipping\n";
       return 0;
-   }
-
-   if($feature and (strcmp($method,'Update only')==0 or strcmp($method,'Insert and update')==0)){
-       if(strcmp($method,'Update only')==0 or strcmp($method,'Insert and update')==0){
-         if(strcmp($match_type,'Name')==0){
-            // if we're matching on the name but do not have a new unique name then we
-            // don't want to update the uniquename.  If we do have a uniquename then we 
-            // should update it.  We only get a uniquename if there was a regular expression
-            // provided for pulling it out
-            if($uname){
-               $sql = "UPDATE {feature} 
-                        SET uniquename = '%s', residues = '%s', seqlen = '%s', md5checksum = '%s'
-                        WHERE organism_id = %d and name = '%s' and type_id = %d";
-               $result = db_query($sql,$uname,$residues,strlen($residues),md5($residues),$organism_id,$name,$cvterm->cvterm_id);
-            } else {
-               $sql = "UPDATE {feature} 
-                        SET residues = '%s', seqlen = '%s', md5checksum = '%s'
-                        WHERE organism_id = %d and name = '%s' and type_id = %d";
-               $result = db_query($sql,$residues,strlen($residues),md5($residues),$organism_id,$name,$cvterm->cvterm_id);
-            }
-         } else {
-            // if we're matching on the unique name but do not have a new name then we
-            // don't want to update the name.  If we do have a name then we 
-            // should update it.  We only get a name if there was a regular expression
-            // provided for pulling it out
-            if($name){
-               $sql = "UPDATE {feature} 
-                        SET name = '%s', residues = '%s', seqlen = '%s', md5checksum = '%s'
-                        WHERE organism_id = %d and uniquename = '%s' and type_id = %d";
-               $result = db_query($sql,$name,$residues,strlen($residues),md5($residues),$organism_id,$uname,$cvterm->cvterm_id);
-            } else {
-               $sql = "UPDATE {feature} 
-                        SET residues = '%s', seqlen = '%s', md5checksum = '%s'
-                        WHERE organism_id = %d and uniquename = '%s' and type_id = %d";
-               $result = db_query($sql,$residues,strlen($residues),md5($residues),$organism_id,$uname,$cvterm->cvterm_id);
-            }
-         }
-         if(!$result){
-            print "ERROR: failed to update feature '$name ($uname)'\n";
-            return 0;
-         } else {
-            print "Updated feature $name ($uname)\n";
-         }
-      } else {
-         print "WARNING: feature already exists: '$name' ('$uname'). Skipping\n";
-      }
-   }
-   // now get the feature
-   $feature = db_fetch_object(db_query($feature_sql,$organism_id,$uname,$cvterm->cvterm_id));
-   if(!$feature){
-      print "Something bad has happened: $organism_id, $uname, $cvterm->cvterm_id\n";
+    }
+    else {
+      $feature_sql = "SELECT * FROM {feature}
+                  WHERE organism_id = %d and name = '%s' and type_id = %d";
+      $feature = db_fetch_object(db_query($feature_sql, $organism_id, $name, $cvterm->cvterm_id));
+    }
+  }
+  if (strcmp($match_type, 'Unique name')==0) {
+    $feature_sql = "SELECT * FROM {feature}
+                    WHERE organism_id = %d and uniquename = '%s' and type_id = %d";
+    $feature = db_fetch_object(db_query($feature_sql, $organism_id, $uname, $cvterm->cvterm_id));
+  }
+
+  if (!$feature and (strcmp($method, 'Insert only')==0 or strcmp($method, 'Insert and update')==0)) {
+    // if we have a unique name but not a name then set them to be teh same
+    // and vice versa
+    if (!$uname) {
+      $uname = $name;
+    }
+    elseif (!$name) {
+      $name = $uname;
+    }
+    // now insert the feature
+    $sql = "INSERT INTO {feature}
+           (organism_id, name, uniquename, residues, seqlen,
+            md5checksum,type_id,is_analysis,is_obsolete)
+        VALUES(%d,'%s','%s','%s',%d, '%s', %d, %s, %s)";
+    $result = db_query($sql, $organism_id, $name, $uname, $residues, drupal_strlen($residues),
+            md5($residues), $cvterm->cvterm_id, 'false', 'false');
+    if (!$result) {
+      print "ERROR: failed to insert feature '$name ($uname)'\n";
       return 0;
-   }
-
-	 // add in the analysis link
-	 if ($analysis_id) {
-	 	$analysis_link_sql = 'SELECT * FROM analysisfeature WHERE analysis_id=%d AND feature_id=%d';
-	 	$analysis_link = db_fetch_object(db_query($analysis_link_sql, $analysis_id, $feature->feature_id));
-	 	if (!$analysis_link) {
-	 		$sql = "INSERT INTO analysisfeature (analysis_id, feature_id) VALUES (%d, %d)";
-	 		$result = db_query($sql, $analysis_id, $feature->feature_id);
-		  if(!$result){
-			  print "WARNING: could not add link between analysis: ".$analysis_id." and feature: ".$feature->uniquename."\n";
-		  }
-		  $analysis_link = db_fetch_object(db_query($analysis_link_sql, $analysis_id, $feature->feature_id));
-	 	}
-	 }
-	 
-   // now add the database cross reference
-   if($db_id){
-      // check to see if this accession reference exists, if not add it
-      $dbxrefsql = "SELECT * FROM {dbxref} WHERE db_id = %s and accession = '%s'";
-      $dbxref = db_fetch_object(db_query($dbxrefsql,$db_id,$accession));
-      if(!$dbxref){
-         $sql = "INSERT INTO {dbxref} (db_id,accession) VALUES (%d,'%s')";
-         $result = db_query($sql,$db_id,$accession);
-         if(!$result){
-           print "WARNING: could not add external database acession: '$name accession: $accession'\n";
-         }
-         $dbxref = db_fetch_object(db_query($dbxrefsql,$db_id,$accession));
+    }
+    else {
+      print "Inserted feature $name ($uname)\n";
+    }
+    $feature = db_fetch_object(db_query($feature_sql, $organism_id, $uname, $cvterm->cvterm_id));
+    }
+  if (!$feature and (strcmp($method, 'Update only')==0 or drupal_strcmp($method, 'Insert and update')==0)) {
+    print "WARNING: failed to find feature '$name' ('$uname') while matching on " . drupal_strtolower($match_type) . ". Skipping\n";
+    return 0;
+  }
+
+  if ($feature and (strcmp($method, 'Update only')==0 or strcmp($method, 'Insert and update')==0)) {
+    if (strcmp($method, 'Update only')==0 or strcmp($method, 'Insert and update')==0) {
+      if (strcmp($match_type, 'Name')==0) {
+        // if we're matching on the name but do not have a new unique name then we
+        // don't want to update the uniquename.  If we do have a uniquename then we
+        // should update it.  We only get a uniquename if there was a regular expression
+        // provided for pulling it out
+        if ($uname) {
+          $sql = "UPDATE {feature}
+                SET uniquename = '%s', residues = '%s', seqlen = '%s', md5checksum = '%s'
+                WHERE organism_id = %d and name = '%s' and type_id = %d";
+          $result = db_query($sql, $uname, $residues, drupal_strlen($residues), md5($residues), $organism_id, $name, $cvterm->cvterm_id);
+        }
+        else {
+          $sql = "UPDATE {feature}
+                  SET residues = '%s', seqlen = '%s', md5checksum = '%s'
+                  WHERE organism_id = %d and name = '%s' and type_id = %d";
+          $result = db_query($sql, $residues, durpal_strlen($residues), md5($residues), $organism_id, $name, $cvterm->cvterm_id);
+        }
+        }
+        else {
+          // if we're matching on the unique name but do not have a new name then we
+          // don't want to update the name.  If we do have a name then we
+          // should update it.  We only get a name if there was a regular expression
+          // provided for pulling it out
+          if ($name) {
+            $sql = "UPDATE {feature}
+                    SET name = '%s', residues = '%s', seqlen = '%s', md5checksum = '%s'
+                    WHERE organism_id = %d and uniquename = '%s' and type_id = %d";
+            $result = db_query($sql, $name, $residues, drupal_strlen($residues), md5($residues), $organism_id, $uname, $cvterm->cvterm_id);
+          }
+          else {
+            $sql = "UPDATE {feature}
+                    SET residues = '%s', seqlen = '%s', md5checksum = '%s'
+                    WHERE organism_id = %d and uniquename = '%s' and type_id = %d";
+            $result = db_query($sql, $residues, drupal_strlen($residues), md5($residues), $organism_id, $uname, $cvterm->cvterm_id);
+          }
+    }
+    if (!$result) {
+      print "ERROR: failed to update feature '$name ($uname)'\n";
+      return 0;
+    }
+    else {
+      print "Updated feature $name ($uname)\n";
+    }
+    }
+    else {
+      print "WARNING: feature already exists: '$name' ('$uname'). Skipping\n";
+    }
+  }
+   // now get the feature
+  $feature = db_fetch_object(db_query($feature_sql, $organism_id, $uname, $cvterm->cvterm_id));
+  if (!$feature) {
+    print "Something bad has happened: $organism_id, $uname, $cvterm->cvterm_id\n";
+    return 0;
+  }
+
+  // add in the analysis link
+  if ($analysis_id) {
+    $analysis_link_sql = 'SELECT * FROM analysisfeature WHERE analysis_id=%d AND feature_id=%d';
+    $analysis_link = db_fetch_object(db_query($analysis_link_sql, $analysis_id, $feature->feature_id));
+    if (!$analysis_link) {
+      $sql = "INSERT INTO analysisfeature (analysis_id, feature_id) VALUES (%d, %d)";
+      $result = db_query($sql, $analysis_id, $feature->feature_id);
+      if (!$result) {
+        print "WARNING: could not add link between analysis: " . $analysis_id . " and feature: " . $feature->uniquename . "\n";
       }
+      $analysis_link = db_fetch_object(db_query($analysis_link_sql, $analysis_id, $feature->feature_id));
+    }
+  }
 
-      // check to see if the feature dbxref record exists if not, then add it 
-      $fdbxrefsql = "SELECT * FROM {feature_dbxref} WHERE feature_id = %d and dbxref_id = %d";
-      $fdbxref = db_fetch_object(db_query($fdbxrefsql,$feature->feature_id,$dbxref->dbxref_id));
-      if(!$fdbxref){
-         $sql = "INSERT INTO {feature_dbxref} (feature_id,dbxref_id) VALUES (%d,%d)";
-         $result = db_query($sql,$feature->feature_id,$dbxref->dbxref_id);
-         if(!$result){
-            print "WARNING: could not associate database cross reference with feature: '$name accession: $accession'\n";
-         } else {
-            print "Added database crossreference $name ($uname) -> $accession\n";
-         }
+   // now add the database cross reference
+  if ($db_id) {
+    // check to see if this accession reference exists, if not add it
+    $dbxrefsql = "SELECT * FROM dbxref WHERE db_id = %d and accession = '%s'";
+    $dbxref = db_fetch_object(db_query($dbxrefsql, $db_id, $accession));
+    if (!$dbxref) {
+      $sql = "INSERT INTO dbxref (db_id,accession) VALUES (%d, '%s')";
+      $result = db_query($sql, $db_id, $accession);
+      if (!$result) {
+        print "WARNING: could not add external database acession: '$name accession: $accession'\n";
+      }
+      $dbxref = db_fetch_object(db_query($dbxrefsql, $db_id, $accession));
+    }
+
+    // check to see if the feature dbxref record exists if not, then add it
+    $fdbxrefsql = "SELECT * FROM {feature_dbxref} WHERE feature_id = %d and dbxref_id = %d";
+    $fdbxref = db_fetch_object(db_query($fdbxrefsql, $feature->feature_id, $dbxref->dbxref_id));
+    if (!$fdbxref) {
+      $sql = "INSERT INTO {feature_dbxref} (feature_id,dbxref_id) VALUES (%d, %d)";
+      $result = db_query($sql, $feature->feature_id, $dbxref->dbxref_id);
+      if (!$result) {
+        print "WARNING: could not associate database cross reference with feature: '$name accession: $accession'\n";
+      }
+      else {
+        print "Added database crossreference $name ($uname) -> $accession\n";
       }
-   }
+    }
+    }
 
    // now add in the relationship if one exists.  First, get the parent type for the relationship
-   // then get the parent feature 
-   if($rel_type){
-      $parentcvterm = db_fetch_object(db_query($cvtermsql,'sequence',$parent_type,$parent_type));
-      $relcvterm = db_fetch_object(db_query($cvtermsql,'relationship',$rel_type,$rel_type));
-      $parent_feature = db_fetch_object(db_query($feature_sql,$organism_id,$parent,$parentcvterm->cvterm_id));
-      if($parent_feature){
-         // check to see if the relationship already exists
-         $sql = "SELECT * FROM {feature_relationship} WHERE subject_id = %d and object_id = %d and type_id = %d";
-         $rel = db_fetch_object(db_query($sql,$feature->feature_id,$parent_feature->feature_id,$relcvterm->cvterm_id));
-         if($rel){
-            print "WARNING: relationship already exists, skipping '$uname' ($type) $rel_type '$parent' ($parent_type)\n";
-         } else {      
-            $sql = "INSERT INTO {feature_relationship} (subject_id,object_id,type_id)
-                    VALUES (%d,%d,%d)";
-            $result = db_query($sql,$feature->feature_id,$parent_feature->feature_id,$relcvterm->cvterm_id);
-            if(!$result){
-               print "WARNING: failed to insert feature relationship '$uname' ($type) $rel_type '$parent' ($parent_type)\n";
-            } else {
-               print "Inserted relationship relationship: '$uname' ($type) $rel_type '$parent' ($parent_type)\n";
-            }
-         } 
+   // then get the parent feature
+  if ($rel_type) {
+    $parentcvterm = db_fetch_object(db_query($cvtermsql, 'sequence', $parent_type, $parent_type));
+    $relcvterm = db_fetch_object(db_query($cvtermsql, 'relationship', $rel_type, $rel_type));
+    $parent_feature = db_fetch_object(db_query($feature_sql, $organism_id, $parent, $parentcvterm->cvterm_id));
+    if ($parent_feature) {
+      // check to see if the relationship already exists
+      $sql = "SELECT * FROM {feature_relationship} WHERE subject_id = %d and object_id = %d and type_id = %d";
+      $rel = db_fetch_object(db_query($sql, $feature->feature_id, $parent_feature->feature_id, $relcvterm->cvterm_id));
+      if ($rel) {
+        print "WARNING: relationship already exists, skipping '$uname' ($type) $rel_type '$parent' ($parent_type)\n";
       }
       else {
-         print "WARNING: cannot establish relationship '$uname' ($type) $rel_type '$parent' ($parent_type): Cannot find the parent\n";
+        $sql = "INSERT INTO {feature_relationship} (subject_id,object_id,type_id)
+                VALUES (%d,%d,%d)";
+        $result = db_query($sql, $feature->feature_id, $parent_feature->feature_id, $relcvterm->cvterm_id);
+        if (!$result) {
+          print "WARNING: failed to insert feature relationship '$uname' ($type) $rel_type '$parent' ($parent_type)\n";
+        }
+        else {
+          print "Inserted relationship relationship: '$uname' ($type) $rel_type '$parent' ($parent_type)\n";
+        }
       }
-   }
-   tripal_db_set_active($previous_db);
+    }
+    else {
+      print "WARNING: cannot establish relationship '$uname' ($type) $rel_type '$parent' ($parent_type): Cannot find the parent\n";
+    }
+    }
+  tripal_db_set_active($previous_db);
 }
 

File diff suppressed because it is too large
+ 613 - 605
tripal_feature/gff_loader.php


+ 146 - 139
tripal_feature/indexFeatures.php

@@ -1,61 +1,41 @@
 <?php
+/**
+ * @file
+ * @todo Add file header description
+ */
+
 
 // This script can be run as a stand-alone script to sync all the features from chado to drupal
 //
 // To index a single feature
 // -i feature_id
-// -n node_id 
+// -n node_id
 //
 // To index all features
-// -i 0 
+// -i 0
 
 $arguments = getopt("i:n:");
 
-if(isset($arguments['i'])){
-   $drupal_base_url = parse_url('http://www.example.com');
-   $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
-   $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
-   $_SERVER['REMOTE_ADDR'] = NULL;
-   $_SERVER['REQUEST_METHOD'] = NULL;
-	
-   require_once 'includes/bootstrap.inc';
-   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-
-   $feature_id = $arguments['i'];
-   $nid        = $arguments['n'];
-
-   # print "\n";
-   # print "feature id is $feature_id\n";
-   # print "nid is $nid\n";
-   # print "\n";
-
-   if($feature_id > 0){ 
-      # print "indexing feature $feature_id\n";
-     // We register a shutdown function to ensure that the nodes
-     // that are indexed will have proper entries in the search_totals
-     // table.  Without these entries, the searching doesn't work
-     // properly. This function may run for quite a while since
-     // it must calculate the sum of the scores of all entries in
-     // the search_index table.  In the case of common words like
-     // 'contig', this will take quite a while
-      register_shutdown_function('search_update_totals');
-      tripal_feature_index_feature($feature_id, $nid); 
-   }
-   else{ 
-      print "indexing all features...\n";
-      tripal_features_reindex(0);
-   }
+if (isset($arguments['i'])) {
+  $drupal_base_url = parse_url('http://www.example.com');
+  $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
+  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
+  $_SERVER['REMOTE_ADDR'] = NULL;
+  $_SERVER['REQUEST_METHOD'] = NULL;
 
-}
+  require_once 'includes/bootstrap.inc';
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_features_reindex ($max_sync,$job_id = NULL){
-   $i = 0;
+  $feature_id = $arguments['i'];
+  $nid        = $arguments['n'];
 
+  # print "\n";
+  # print "feature id is $feature_id\n";
+  # print "nid is $nid\n";
+  # print "\n";
+
+  if ($feature_id > 0) {
+    # print "indexing feature $feature_id\n";
    // We register a shutdown function to ensure that the nodes
    // that are indexed will have proper entries in the search_totals
    // table.  Without these entries, the searching doesn't work
@@ -63,63 +43,90 @@ function tripal_features_reindex ($max_sync,$job_id = NULL){
    // it must calculate the sum of the scores of all entries in
    // the search_index table.  In the case of common words like
    // 'contig', this will take quite a while
-   register_shutdown_function('search_update_totals');
-
-   // use this SQL statement to get the features that we're going to index. This
-   // SQL statement is derived from the hook_search function in the Drupal API.
-   // Essentially, this is the SQL statement that finds all nodes that need
-   // reindexing, but adjusted to include the chado_feature
-   $sql = "SELECT N.nid, N.title, CF.feature_id ".
-          "FROM {node} N ".
-          "  INNER JOIN chado_feature CF ON CF.nid = N.nid ";
-   $results = db_query($sql);
-
-   // load into ids array
-   $count = 0;
-   $chado_features = array();
-   while($chado_feature = db_fetch_object($results)){
-      $chado_features[$count] = $chado_feature;
-      $count++;
-   }
-
-   // Iterate through features that need to be indexed 
-   $interval = intval($count * 0.01);
-   if($interval >= 0){
-      $interval = 1;
-   }
-   foreach($chado_features as $chado_feature){
-
-      // update the job status every 1% features
-      if($job_id and $i % $interval == 0){
-         $prog = intval(($i/$count)*100);
-         tripal_job_set_progress($job_id,$prog);
-         print "$prog%\n";
-      }
-
-      // sync only the max requested
-      if($max_sync and $i == $max_sync){
-         return '';
-      }
-      $i++;
-
-      # tripal_feature_index_feature ($chado_feature->feature_id,$chado_feature->nid);
-      # parsing all the features can cause memory overruns 
-      # we are not sure why PHP does not clean up the memory as it goes
-      # to avoid this problem we will call this script through an
-      # independent system call
-
-      $cmd = "php " . drupal_get_path('module', 'tripal_feature') . "/indexFeatures.php ";
-      $cmd .= "-i $chado_feature->feature_id -n $chado_feature->nid ";
-
-      # print "\t$cmd\n";
-      # print "\tfeature id is $chado_feature->feature_id\n";
-      # print "\tnid is $chado_feature->nid\n";
-      # print "\n";
-
-      system($cmd);
-   }
-
-   return '';
+    register_shutdown_function('search_update_totals');
+    tripal_feature_index_feature($feature_id, $nid);
+  }
+  else{
+    print "indexing all features...\n";
+    tripal_features_reindex(0);
+  }
+
+}
+
+/**
+ *
+ *
+ * @ingroup tripal_feature
+ */
+function tripal_features_reindex($max_sync, $job_id = NULL) {
+  $i = 0;
+
+  // We register a shutdown function to ensure that the nodes
+  // that are indexed will have proper entries in the search_totals
+  // table.  Without these entries, the searching doesn't work
+  // properly. This function may run for quite a while since
+  // it must calculate the sum of the scores of all entries in
+  // the search_index table.  In the case of common words like
+  // 'contig', this will take quite a while
+  register_shutdown_function('search_update_totals');
+
+  // use this SQL statement to get the features that we're going to index. This
+  // SQL statement is derived from the hook_search function in the Drupal API.
+  // Essentially, this is the SQL statement that finds all nodes that need
+  // reindexing, but adjusted to include the chado_feature
+  $sql = "SELECT N.nid, N.title, CF.feature_id ".
+        "FROM {node} N ".
+        "  INNER JOIN chado_feature CF ON CF.nid = N.nid ";
+  $results = db_query($sql);
+
+  // load into ids array
+  $count = 0;
+  $chado_features = array();
+  while ($chado_feature = db_fetch_object($results)) {
+    $chado_features[$count] = $chado_feature;
+    $count++;
+  }
+
+  // Iterate through features that need to be indexed
+  $interval = intval($count * 0.01);
+  if ($interval >= 0) {
+    $interval = 1;
+  }
+  foreach ($chado_features as $chado_feature) {
+
+    // update the job status every 1% features
+    if ($job_id and $i % $interval == 0) {
+      $prog = intval(($i/$count)*100);
+      tripal_job_set_progress($job_id, $prog);
+      print "$prog%\n";
+    }
+
+    // sync only the max requested
+    if ($max_sync and $i == $max_sync) {
+      return '';
+    }
+    $i++;
+
+  /**
+    * tripal_feature_index_feature ($chado_feature->feature_id,$chado_feature->nid);
+    * parsing all the features can cause memory overruns
+    * we are not sure why PHP does not clean up the memory as it goes
+    * to avoid this problem we will call this script through an
+    * independent system call
+    */
+
+    $cmd = "php " . drupal_get_path('module', 'tripal_feature') . "/indexFeatures.php ";
+    $cmd .= "-i $chado_feature->feature_id -n $chado_feature->nid ";
+
+    # print "\t$cmd\n";
+    # print "\tfeature id is $chado_feature->feature_id\n";
+    # print "\tnid is $chado_feature->nid\n";
+    # print "\n";
+
+    system($cmd);
+    }
+
+  return '';
 }
 
 /**
@@ -127,44 +134,44 @@ function tripal_features_reindex ($max_sync,$job_id = NULL){
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_index_feature ($feature_id,$nid){
-   #print "\tfeature $feature_id nid $nid\n";
-   // return if we haven't been provided with a feature_id
-   if(!$feature_id){
+function tripal_feature_index_feature($feature_id, $nid) {
+  #print "\tfeature $feature_id nid $nid\n";
+  // return if we haven't been provided with a feature_id
+  if (!$feature_id) {
+    return 0;
+  }
+
+  // if we only have a feature_id then let's find a corresponding
+  // node.  If we can't find a node then return.
+  if (!$nid) {
+    $nsql = "SELECT N.nid,N.title FROM {chado_feature} CF ".
+            "  INNER JOIN {node} N ON N.nid = CF.nid ".
+            "WHERE CF.feature_id = %d";
+    $node = db_fetch_object(db_query($nsql, $feature_id));
+    if (!$node) {
       return 0;
-   }
-
-   // if we only have a feature_id then let's find a corresponding
-   // node.  If we can't find a node then return.
-   if(!$nid){
-      $nsql = "SELECT N.nid,N.title FROM {chado_feature} CF ".
-              "  INNER JOIN {node} N ON N.nid = CF.nid ".
-              "WHERE CF.feature_id = %d";
-      $node = db_fetch_object(db_query($nsql,$feature_id));
-      if(!$node){
-         return 0;
-      }
-      $node = node_load($node->nid);
-   } else {
-      $node = node_load($nid);
-   }
-
-   // node load the noad, the comments and the taxonomy and
-   // index
-   $node->build_mode = NODE_BUILD_SEARCH_INDEX;
-   $node = node_build_content($node, FALSE, FALSE);
-   $node->body = drupal_render($node->content);
-   node_invoke_nodeapi($node, 'view', FALSE, FALSE);
-//   $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
-//   $node->body .= module_invoke('taxonomy','nodeapi', $node, 'update index');
-   //   print "$node->title: $node->body\n";
-   search_index($node->nid,'node',$node->body);
-
-   # $mem = memory_get_usage(TRUE);
-   # $mb = $mem/1048576;
-   # print "$mb mb\n";
-
-   return 1;
+    }
+    $node = node_load($node->nid);
+  }
+  else {
+    $node = node_load($nid);
+  }
+
+  // node load the noad, the comments and the taxonomy and
+  // index
+  $node->build_mode = NODE_BUILD_SEARCH_INDEX;
+  $node = node_build_content($node, FALSE, FALSE);
+  $node->body = drupal_render($node->content);
+  node_invoke_nodeapi($node, 'view', FALSE, FALSE);
+  //   $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
+  //   $node->body .= module_invoke('taxonomy','nodeapi', $node, 'update index');
+  //   print "$node->title: $node->body\n";
+  search_index($node->nid, 'node', $node->body);
+
+  # $mem = memory_get_usage(TRUE);
+  # $mb = $mem/1048576;
+  # print "$mb mb\n";
+
+  return 1;
 }
 
-?>

+ 378 - 370
tripal_feature/syncFeatures.php

@@ -1,268 +1,274 @@
 <?php
 
+/**
+ * @file
+ * @todo Add file header description
+ */
+
 
 # This script can be run as a stand-alone script to sync all the features from chado to drupal
 // Parameter f specifies the feature_id to sync
-// -f 0 will sync all features 
+// -f 0 will sync all features
 
 $arguments = getopt("f:");
 
-if(isset($arguments['f'])){
-   $drupal_base_url = parse_url('http://www.example.com');
-   $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
-   $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
-   $_SERVER['REMOTE_ADDR'] = NULL;
-   $_SERVER['REQUEST_METHOD'] = NULL;
-	
-   require_once 'includes/bootstrap.inc';
-   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-
-   $feature_id = $arguments['f'];
-
-   if($feature_id > 0 ){ 
-      tripal_feature_sync_feature($feature_id); 
-   }
-   else{ 
-      print "syncing all features...\n";
-      tripal_feature_sync_features();
-   }   
+if (isset($arguments['f'])) {
+  $drupal_base_url = parse_url('http://www.example.com');
+  $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
+  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
+  $_SERVER['REMOTE_ADDR'] = NULL;
+  $_SERVER['REQUEST_METHOD'] = NULL;
+
+  require_once 'includes/bootstrap.inc';
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
+  $feature_id = $arguments['f'];
+
+  if ($feature_id > 0 ) {
+    tripal_feature_sync_feature($feature_id);
+  }
+  else{
+    print "syncing all features...\n";
+    tripal_feature_sync_features();
+  }
 }
 /**
-*
-*/
-function tripal_feature_sync_form (){
-
-   $form['description'] = array(
-      '#type' => 'item',
-      '#value' => t("Add feature types, optionally select an organism and ".
-         "click the 'Sync all Features' button to create Drupal ".
-         "content for features in chado. Only features of the types listed ".
-         "below in the Feature Types box will be synced. You may limit the ".
-         "features to be synced by a specific organism. Depending on the ".
-         "number of features in the chado database this may take a long ".
-         "time to complete. "),
-   );
-
-   $form['feature_types'] = array(
-      '#title'       => t('Feature Types'),
-      '#type'        => 'textarea',
-      '#description' => t('Enter the names of the sequence types that the ".
-         "site will support with independent pages.  Pages for these data ".
-         "types will be built automatically for features that exist in the ".
-         "chado database.  The names listed here should be spearated by ".
-         "spaces or entered separately on new lines. The names must match ".
-         "exactly (spelling and case) with terms in the sequence ontology'),
-      '#required'    => TRUE,
-      '#default_value' => variable_get('chado_sync_feature_types','gene contig'),
-   );
-
-   // get the list of organisms
-   $sql = "SELECT * FROM {organism} ORDER BY genus, species";
-   $orgs = tripal_organism_get_synced(); 
-   $organisms[] = ''; 
-   foreach($orgs as $organism){
-      $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
-   }
-   $form['organism_id'] = array (
-     '#title'       => t('Organism'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the organism for which features will be deleted."),
-     '#options'     => $organisms,
-   );
-
-
-   $form['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Sync all Features'),
-      '#weight' => 3,
-   );
-
-   return $form;
+ *
+ */
+function tripal_feature_sync_form() {
+
+  $form['description'] = array(
+  '#type' => 'item',
+  '#value' => t("Add feature types, optionally select an organism and ".
+     "click the 'Sync all Features' button to create Drupal ".
+     "content for features in chado. Only features of the types listed ".
+     "below in the Feature Types box will be synced. You may limit the ".
+     "features to be synced by a specific organism. Depending on the ".
+     "number of features in the chado database this may take a long ".
+     "time to complete. "),
+  );
+
+  $form['feature_types'] = array(
+    '#title'       => t('Feature Types'),
+    '#type'        => 'textarea',
+    '#description' => t('Enter the names of the sequence types that the ".
+       "site will support with independent pages.  Pages for these data ".
+       "types will be built automatically for features that exist in the ".
+       "chado database.  The names listed here should be spearated by ".
+       "spaces or entered separately on new lines. The names must match ".
+       "exactly (spelling and case) with terms in the sequence ontology'),
+    '#required'    => TRUE,
+    '#default_value' => variable_get('chado_sync_feature_types', 'gene contig'),
+  );
+
+  // get the list of organisms
+  $sql = "SELECT * FROM {organism} ORDER BY genus, species";
+  $orgs = tripal_organism_get_synced();
+  $organisms[] = '';
+  foreach ($orgs as $organism) {
+    $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
+  }
+  $form['organism_id'] = array(
+    '#title'       => t('Organism'),
+    '#type'        => t('select'),
+    '#description' => t("Choose the organism for which features will be deleted."),
+    '#options'     => $organisms,
+  );
+
+
+  $form['button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Sync all Features'),
+    '#weight' => 3,
+  );
+
+  return $form;
 }
 /**
-*
-*/
-function tripal_feature_sync_form_validate ($form, &$form_state){
-   $organism_id   = $form_state['values']['organism_id'];
-   $feature_types = $form_state['values']['feature_types'];
+ *
+ */
+function tripal_feature_sync_form_validate($form, &$form_state) {
+  $organism_id   = $form_state['values']['organism_id'];
+  $feature_types = $form_state['values']['feature_types'];
 
-   // nothing to do
+  // nothing to do
 }
 /**
-*
-*/
-function tripal_feature_sync_form_submit ($form, &$form_state){
+ *
+ */
+function tripal_feature_sync_form_submit($form, &$form_state) {
 
-   global $user;
+  global $user;
 
-   $organism_id   = $form_state['values']['organism_id'];
-   $feature_types = $form_state['values']['feature_types'];
+  $organism_id   = $form_state['values']['organism_id'];
+  $feature_types = $form_state['values']['feature_types'];
 
-   $job_args = array(0,$organism_id,$feature_types);
+  $job_args = array(0, $organism_id, $feature_types);
 
-   if($organism_id){
-      $organism = tripal_core_chado_select('organism',array('genus','species'),array('organism_id' => $organism_id));
-      $title = "Sync all features for " .  $organism[0]->genus . " " . $organism[0]->species;
-   } else {
-      $title = t('Sync all features for all synced organisms');
-   }
+  if ($organism_id) {
+    $organism = tripal_core_chado_select('organism', array('genus', 'species'), array('organism_id' => $organism_id));
+    $title = "Sync all features for " .  $organism[0]->genus . " " . $organism[0]->species;
+  }
+  else {
+    $title = t('Sync all features for all synced organisms');
+  }
 
-   variable_set('chado_sync_feature_types',$feature_types);
+  variable_set('chado_sync_feature_types', $feature_types);
 
-   tripal_add_job($title,'tripal_feature',
-         'tripal_feature_sync_features',$job_args,$user->uid);
+  tripal_add_job($title, 'tripal_feature',
+    'tripal_feature_sync_features', $job_args, $user->uid);
 }
 /**
-*
-*/   
-function tripal_feature_set_urls($job_id = NULL){
-   // first get the list of features that have been synced
-   $sql = "SELECT * FROM {chado_feature}";
-   $nodes = db_query($sql);
-   while($node = db_fetch_object($nodes)){
-      // now get the feature details
-      $feature_arr = tripal_core_chado_select('feature',
-         array('feature_id','name','uniquename'),
-         array('feature_id' => $node->feature_id));
-      $feature = $feature_arr[0];
-
-      tripal_feature_set_feature_url($node,$feature);
-   }
+ *
+ */
+function tripal_feature_set_urls($job_id = NULL) {
+  // first get the list of features that have been synced
+  $sql = "SELECT * FROM {chado_feature}";
+  $nodes = db_query($sql);
+  while ($node = db_fetch_object($nodes)) {
+    // now get the feature details
+    $feature_arr = tripal_core_chado_select('feature',
+      array('feature_id', 'name', 'uniquename'),
+      array('feature_id' => $node->feature_id));
+    $feature = $feature_arr[0];
+
+    tripal_feature_set_feature_url($node, $feature);
+  }
 }
 /**
-*
-*/
-function tripal_feature_set_feature_url($node,$feature){
-
-   // determine which URL alias to use
-   $alias_type = variable_get('chado_feature_url','internal ID');
-   $aprefix = variable_get('chado_feature_accession_prefix','ID');
-   switch ($alias_type) {
-      case 'feature name':
-         $url_alias = $feature->name;
-         break;
-      case 'feature unique name':
-         $url_alias = $feature->uniquename;
-         break;
-      default:
-         $url_alias = "$aprefix$feature->feature_id";
-   }
-   print "Setting $alias_type as URL alias for $feature->name: node/$node->nid => $url_alias\n";
-   // remove any previous alias
-   db_query("DELETE FROM {url_alias} WHERE src = '%s'", "node/$node->nid");
-   // add the new alias
-   path_set_alias("node/$node->nid",$url_alias);
+ *
+ */
+function tripal_feature_set_feature_url($node, $feature) {
+
+  // determine which URL alias to use
+  $alias_type = variable_get('chado_feature_url', 'internal ID');
+  $aprefix = variable_get('chado_feature_accession_prefix', 'ID');
+  switch ($alias_type) {
+    case 'feature name':
+      $url_alias = $feature->name;
+      break;
+    case 'feature unique name':
+      $url_alias = $feature->uniquename;
+      break;
+    default:
+      $url_alias = "$aprefix$feature->feature_id";
+  }
+  print "Setting $alias_type as URL alias for $feature->name: node/$node->nid => $url_alias\n";
+  // remove any previous alias
+  db_query("DELETE FROM {url_alias} WHERE src = '%s'", "node/$node->nid");
+  // add the new alias
+  path_set_alias("node/$node->nid", $url_alias);
 }
 /**
  *
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_sync_features ($max_sync = 0, $organism_id = NULL, 
-   $feature_types = NULL, $job_id = NULL)
-{
-   //print "Syncing features (max of $max_sync)\n";
-   $i = 0;
-
-   // get the list of available sequence ontology terms for which
-   // we will build drupal pages from features in chado.  If a feature
-   // is not one of the specified typse we won't build a node for it.
-   if(!$feature_types){
-      $allowed_types = variable_get('chado_sync_feature_types','gene contig');
-   } else {
-      $allowed_types = $feature_types;
-   }
-   $allowed_types = preg_replace("/[\s\n\r]+/"," ",$allowed_types);
-
-   print "Looking for features of type: $allowed_types\n";
-
-   $so_terms = split(' ',$allowed_types);
-   $where_cvt = "";
-   foreach ($so_terms as $term){
-      $where_cvt .= "CVT.name = '$term' OR ";
-   }
-   $where_cvt = substr($where_cvt,0,strlen($where_cvt)-3);  # strip trailing 'OR'
-
-   // get the list of organisms that are synced and only include features from
-   // those organisms
-   $orgs = tripal_organism_get_synced();
-   $where_org = "";
-   foreach($orgs as $org){
-      if($organism_id){
-         if($org->organism_id and $org->organism_id == $organism_id){
-            $where_org .= "F.organism_id = $org->organism_id OR ";
-         }
-      } 
-      else {
-         if($org->organism_id){
-            $where_org .= "F.organism_id = $org->organism_id OR ";
-         }
-      }
-   }
-   $where_org = substr($where_org,0,strlen($where_org)-3);  # strip trailing 'OR'
-
-   // use this SQL statement to get the features that we're going to upload
-   $sql = "SELECT feature_id ".
-          "FROM {FEATURE} F ".
-          "  INNER JOIN Cvterm CVT ON F.type_id = CVT.cvterm_id ".
-          "  INNER JOIN CV on CV.cv_id = CVT.cv_id ".
-          "WHERE ($where_cvt) AND ($where_org) AND CV.name = 'sequence' ".
-          "ORDER BY feature_id";
-
-   // get the list of features
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $results = db_query($sql);
-
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   // load into ids array
-   $count = 0;
-   $ids = array();
-   while($id = db_fetch_object($results)){
-      $ids[$count] = $id->feature_id;
-      $count++;
-   }
-
-   // make sure our vocabularies are set before proceeding
-   tripal_feature_set_vocabulary();
-
-   // pre-create the SQL statement that will be used to check
-   // if a feature has already been synced.  We skip features
-   // that have been synced
-   $sql = "SELECT * FROM {chado_feature} WHERE feature_id = %d";
-
-   // Iterate through features that need to be synced
-   $interval = intval($count * 0.01);
-   if($interval > 1){
-      $interval = 1;
-   }
-   $num_ids = sizeof($ids);
-   $i = 0;
-   foreach($ids as $feature_id){
-      // update the job status every 1% features
-      if($job_id and $i % $interval == 0){
-         tripal_job_set_progress($job_id,intval(($i/$count)*100));
-      }
-      // if we have a maximum number to sync then stop when we get there
-      // if not then just continue on
-      if($max_sync and $i == $max_sync){
-         return '';
+function tripal_feature_sync_features($max_sync = 0, $organism_id = NULL,
+  $feature_types = NULL, $job_id = NULL) {
+  //print "Syncing features (max of $max_sync)\n";
+  $i = 0;
+
+  // get the list of available sequence ontology terms for which
+  // we will build drupal pages from features in chado.  If a feature
+  // is not one of the specified typse we won't build a node for it.
+  if (!$feature_types) {
+    $allowed_types = variable_get('chado_sync_feature_types', 'gene contig');
+  }
+  else {
+    $allowed_types = $feature_types;
+  }
+  $allowed_types = preg_replace("/[\s\n\r]+/", " ", $allowed_types);
+
+  print "Looking for features of type: $allowed_types\n";
+
+  $so_terms = split(' ', $allowed_types);
+  $where_cvt = "";
+  foreach ($so_terms as $term) {
+    $where_cvt .= "CVT.name = '$term' OR ";
+  }
+  $where_cvt = drupal_substr($where_cvt, 0, drupal_strlen($where_cvt)-3);  # strip trailing 'OR'
+
+  // get the list of organisms that are synced and only include features from
+  // those organisms
+  $orgs = tripal_organism_get_synced();
+  $where_org = "";
+  foreach ($orgs as $org) {
+    if ($organism_id) {
+      if ($org->organism_id and $org->organism_id == $organism_id) {
+        $where_org .= "F.organism_id = $org->organism_id OR ";
       }
-      if(!db_fetch_object(db_query($sql,$feature_id))){
-        
-         # parsing all the features can cause memory overruns 
-         # we are not sure why PHP does not clean up the memory as it goes
-         # to avoid this problem we will call this script through an
-         # independent system call
-         print "$i of $num_ids Syncing feature id: $feature_id\n";
-         $cmd = "php " . drupal_get_path('module', 'tripal_feature') . "/syncFeatures.php -f $feature_id ";
-         system($cmd);
-
-      }
-      $i++;
-   }
-
-   return '';
+    }
+    else {
+    if ($org->organism_id) {
+      $where_org .= "F.organism_id = $org->organism_id OR ";
+    }
+    }
+  }
+  $where_org = drupal_substr($where_org, 0, drupal_strlen($where_org)-3);  # strip trailing 'OR'
+
+  // use this SQL statement to get the features that we're going to upload
+  $sql = "SELECT feature_id ".
+        "FROM {FEATURE} F ".
+        "  INNER JOIN Cvterm CVT ON F.type_id = CVT.cvterm_id ".
+        "  INNER JOIN CV on CV.cv_id = CVT.cv_id ".
+        "WHERE ($where_cvt) AND ($where_org) AND CV.name = 'sequence' ".
+        "ORDER BY feature_id";
+
+  // get the list of features
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $results = db_query($sql);
+
+  tripal_db_set_active($previous_db);  // now use drupal database
+
+  // load into ids array
+  $count = 0;
+  $ids = array();
+  while ($id = db_fetch_object($results)) {
+    $ids[$count] = $id->feature_id;
+    $count++;
+  }
+
+  // make sure our vocabularies are set before proceeding
+  tripal_feature_set_vocabulary();
+
+  // pre-create the SQL statement that will be used to check
+  // if a feature has already been synced.  We skip features
+  // that have been synced
+  $sql = "SELECT * FROM {chado_feature} WHERE feature_id = %d";
+
+  // Iterate through features that need to be synced
+  $interval = intval($count * 0.01);
+  if ($interval > 1) {
+    $interval = 1;
+  }
+  $num_ids = sizeof($ids);
+  $i = 0;
+  foreach ($ids as $feature_id) {
+    // update the job status every 1% features
+    if ($job_id and $i % $interval == 0) {
+      tripal_job_set_progress($job_id, intval(($i/$count)*100));
+    }
+    // if we have a maximum number to sync then stop when we get there
+    // if not then just continue on
+    if ($max_sync and $i == $max_sync) {
+      return '';
+    }
+    if (!db_fetch_object(db_query($sql, $feature_id))) {
+
+      # parsing all the features can cause memory overruns
+      # we are not sure why PHP does not clean up the memory as it goes
+      # to avoid this problem we will call this script through an
+      # independent system call
+      print "$i of $num_ids Syncing feature id: $feature_id\n";
+      $cmd = "php " . drupal_get_path('module', 'tripal_feature') . "/syncFeatures.php -f $feature_id ";
+      system($cmd);
+
+    }
+    $i++;
+  }
+
+  return '';
 }
 
 /**
@@ -270,149 +276,151 @@ function tripal_feature_sync_features ($max_sync = 0, $organism_id = NULL,
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_sync_feature ($feature_id){
-//   print "\tSyncing feature $feature_id\n";
-
-   $mem = memory_get_usage(TRUE);
-   $mb = $mem/1048576;
-//   print "$mb mb\n";
-
-   global $user;
-   $create_node = 1;   // set to 0 if the node exists and we just sync and not create
-
-   // get the accession prefix
-   $aprefix = variable_get('chado_feature_accession_prefix','ID');
-
-   // if we don't have a feature_id then return
-   if(!$feature_id){
-      drupal_set_message(t("Please provide a feature_id to sync"));
-      return '';
-   }
-
-   // get information about this feature
-   $fsql = "SELECT F.feature_id, F.name, F.uniquename,O.genus, ".
-           "    O.species,CVT.name as cvname,F.residues,F.organism_id ".
-           "FROM {FEATURE} F ".
-           "  INNER JOIN Cvterm CVT ON F.type_id = CVT.cvterm_id ".
-           "  INNER JOIN Organism O ON F.organism_id = O.organism_ID ".
-           "WHERE F.feature_id = %d";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $feature = db_fetch_object(db_query($fsql,$feature_id));
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   // get the synonyms for this feature
-   $synsql = "SELECT S.name ".
-             "FROM {feature_synonym} FS ".
-             "  INNER JOIN {synonym} S on FS.synonym_id = S.synonym_id ".
-             "WHERE FS.feature_id = %d";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $synonyms = db_query($synsql,$feature_id);
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   // now add these synonyms to the feature object as a single string   
-   $synstring = '';
-   while($synonym = db_fetch_object($synonyms)){
-      $synstring .= "$synonym->name\n";
-   }        
-   $feature->synonyms = $synstring;
-
-   // check to make sure that we don't have any nodes with this feature name as a title
-   // but without a corresponding entry in the chado_feature table if so then we want to
-   // clean up that node.  (If a node is found we don't know if it belongs to our feature or
-   // not since features can have the same name/title.)
-   $tsql =  "SELECT * FROM {node} N ".
-            "WHERE title = '%s'";
-   $cnsql = "SELECT * FROM {chado_feature} ".
-            "WHERE nid = %d";
-   $nodes = db_query($tsql,$feature->name);
-   // cycle through all nodes that may have this title
-   while($node = db_fetch_object($nodes)){
-      $feature_nid = db_fetch_object(db_query($cnsql,$node->nid));
-      if(!$feature_nid){
-         drupal_set_message(t("$feature_id: A node is present but the chado_feature entry is missing... correcting"));
-         node_delete($node->nid);
+function tripal_feature_sync_feature($feature_id) {
+  //   print "\tSyncing feature $feature_id\n";
+
+  $mem = memory_get_usage(TRUE);
+  $mb = $mem/1048576;
+  //   print "$mb mb\n";
+
+  global $user;
+  $create_node = 1;   // set to 0 if the node exists and we just sync and not create
+
+  // get the accession prefix
+  $aprefix = variable_get('chado_feature_accession_prefix', 'ID');
+
+  // if we don't have a feature_id then return
+  if (!$feature_id) {
+    drupal_set_message(t("Please provide a feature_id to sync"));
+    return '';
+  }
+
+  // get information about this feature
+  $fsql = "SELECT F.feature_id, F.name, F.uniquename,O.genus, ".
+         "    O.species,CVT.name as cvname,F.residues,F.organism_id ".
+         "FROM {FEATURE} F ".
+         "  INNER JOIN Cvterm CVT ON F.type_id = CVT.cvterm_id ".
+         "  INNER JOIN Organism O ON F.organism_id = O.organism_ID ".
+         "WHERE F.feature_id = %d";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $feature = db_fetch_object(db_query($fsql, $feature_id));
+  tripal_db_set_active($previous_db);  // now use drupal database
+
+  // get the synonyms for this feature
+  $synsql = "SELECT S.name ".
+           "FROM {feature_synonym} FS ".
+           "  INNER JOIN {synonym} S on FS.synonym_id = S.synonym_id ".
+           "WHERE FS.feature_id = %d";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $synonyms = db_query($synsql, $feature_id);
+  tripal_db_set_active($previous_db);  // now use drupal database
+
+  // now add these synonyms to the feature object as a single string
+  $synstring = '';
+  while ($synonym = db_fetch_object($synonyms)) {
+    $synstring .= "$synonym->name\n";
+  }
+  $feature->synonyms = $synstring;
+
+  // check to make sure that we don't have any nodes with this feature name as a title
+  // but without a corresponding entry in the chado_feature table if so then we want to
+  // clean up that node.  (If a node is found we don't know if it belongs to our feature or
+  // not since features can have the same name/title.)
+  $tsql =  "SELECT * FROM {node} N ".
+          "WHERE title = '%s'";
+  $cnsql = "SELECT * FROM {chado_feature} ".
+          "WHERE nid = %d";
+  $nodes = db_query($tsql, $feature->name);
+  // cycle through all nodes that may have this title
+  while ($node = db_fetch_object($nodes)) {
+    $feature_nid = db_fetch_object(db_query($cnsql, $node->nid));
+    if (!$feature_nid) {
+      drupal_set_message(t("%feature_id: A node is present but the chado_feature entry is missing... correcting", array('%feature_id' => $feature_id)));
+      node_delete($node->nid);
+    }
+  }
+
+  // check if this feature already exists in the chado_feature table.
+  // if we have a chado feature, we want to check to see if we have a node
+  $cfsql = "SELECT * FROM {chado_feature} ".
+          "WHERE feature_id = %d";
+  $nsql =  "SELECT * FROM {node} ".
+          "WHERE nid = %d";
+  $chado_feature = db_fetch_object(db_query($cfsql, $feature->feature_id));
+  if ($chado_feature) {
+    drupal_set_message(t("%feature_id: A chado_feature entry exists", array('%feature_id' => $feature_id)));
+    $node = db_fetch_object(db_query($nsql, $chado_feature->nid));
+    if (!$node) {
+      // if we have a chado_feature but not a node then we have a problem and
+      // need to cleanup
+      drupal_set_message(t("%feature_id: The node is missing, but has a chado_feature entry... correcting", array('%feature_id' => $feature_id)));
+      $df_sql = "DELETE FROM {chado_feature} WHERE feature_id = %d";
+      db_query($df_sql, $feature_id);
+    }
+    else {
+      drupal_set_message(t("%feature_id: A corresponding node exists", array('%feature_id' => $feature_id)));
+      $create_node = 0;
+    }
+  }
+
+  // if we've encountered an error then just return.
+  if ($error_msg = db_error()) {
+    //print "$error_msg\n";
+    return '';
+  }
+
+  // if a drupal node does not exist for this feature then we want to
+  // create one.  Note that the node_save call in this block
+  // will call the hook_submit function which
+  if ($create_node) {
+    // get the organism for this feature
+    $sql = "SELECT * FROM {organism} WHERE organism_id = %d";
+    $organism = db_fetch_object(db_query($sql, $feature->organism_id));
+
+    drupal_set_message(t("%feature_id: Creating node $feature->name", array('%feature_id' => $feature_id)));
+    $new_node = new stdClass();
+    $new_node->type = 'chado_feature';
+    $new_node->uid = $user->uid;
+    $new_node->title = "$feature->name, $feature->uniquename ($feature->cvname) $organism->genus $organism->species";
+    $new_node->fname = "$feature->name";
+    $new_node->uniquename = "$feature->uniquename";
+    $new_node->feature_id = $feature->feature_id;
+    $new_node->residues = $feature->residues;
+    $new_node->organism_id = $feature->organism_id;
+    $new_node->feature_type = $feature->cvname;
+    $new_node->synonyms = $feature->synonyms;
+
+    // validate the node and if okay then submit
+    node_validate($new_node);
+    if ($errors = form_get_errors()) {
+      foreach ($errors as $key => $msg) {
+        drupal_set_message(t("%msg", array('%msg' => $msg)));
       }
-   }
-
-   // check if this feature already exists in the chado_feature table.
-   // if we have a chado feature, we want to check to see if we have a node
-   $cfsql = "SELECT * FROM {chado_feature} ".
-            "WHERE feature_id = %d";
-   $nsql =  "SELECT * FROM {node} ".
-            "WHERE nid = %d";
-   $chado_feature = db_fetch_object(db_query($cfsql,$feature->feature_id));
-   if($chado_feature){
-      drupal_set_message(t("$feature_id: A chado_feature entry exists"));
-      $node = db_fetch_object(db_query($nsql,$chado_feature->nid));
-      if(!$node){
-         // if we have a chado_feature but not a node then we have a problem and
-         // need to cleanup
-         drupal_set_message(t("$feature_id: The node is missing, but has a chado_feature entry... correcting"));
-         $df_sql = "DELETE FROM {chado_feature} WHERE feature_id = %d";
-         db_query($df_sql,$feature_id);
-      } else {
-         drupal_set_message(t("$feature_id: A corresponding node exists"));
-         $create_node = 0;
-      }
-   }
+      return $errors;
+    }
+    else {
+      $node = node_submit($new_node);
+      node_save($node);
+    }
 
-   // if we've encountered an error then just return.
-   if($error_msg = db_error()){
-      //print "$error_msg\n";
-      return '';
-   }
-
-   // if a drupal node does not exist for this feature then we want to
-   // create one.  Note that the node_save call in this block
-   // will call the hook_submit function which
-   if($create_node){
-      // get the organism for this feature
-      $sql = "SELECT * FROM {organism} WHERE organism_id = %d";
-      $organism = db_fetch_object(db_query($sql,$feature->organism_id));
-
-      drupal_set_message(t("$feature_id: Creating node $feature->name"));
-      $new_node = new stdClass();
-      $new_node->type = 'chado_feature';
-      $new_node->uid = $user->uid;
-      $new_node->title = "$feature->name, $feature->uniquename ($feature->cvname) $organism->genus $organism->species";
-      $new_node->fname = "$feature->name";
-      $new_node->uniquename = "$feature->uniquename";
-      $new_node->feature_id = $feature->feature_id;
-      $new_node->residues = $feature->residues;
-      $new_node->organism_id = $feature->organism_id;
-      $new_node->feature_type = $feature->cvname;
-      $new_node->synonyms = $feature->synonyms;
-
-      // validate the node and if okay then submit
-      node_validate($new_node);
-      if ($errors = form_get_errors()) {
-         foreach($errors as $key => $msg){
-            drupal_set_message($msg);
-         }
-         return $errors;
-      } else {
-         $node = node_submit($new_node);
-         node_save($node);
-      }
-
-   }
-   else {
-      $node = $chado_feature;
-   }
+  }
+  else {
+    $node = $chado_feature;
+  }
 
 
-   // set the taxonomy for this node
-   drupal_set_message(t("$feature_id ($node->nid): setting taxonomy"));
-   tripal_feature_set_taxonomy($node,$feature_id);
+  // set the taxonomy for this node
+  drupal_set_message(t("%feature_id ($node->nid): setting taxonomy", array('%feature_id' => $feature_id)));
+  tripal_feature_set_taxonomy($node, $feature_id);
 
-   // reindex the node
-   // drupal_set_message(t("$feature_id( $node->nid): indexing"));
-   // tripal_feature_index_feature ($feature_id,$node->nid);
+  // reindex the node
+  // drupal_set_message(t("$feature_id( $node->nid): indexing"));
+  // tripal_feature_index_feature ($feature_id,$node->nid);
 
-   // set the URL alias for this node
-   tripal_feature_set_feature_url($node,$feature);
+  // set the URL alias for this node
+  tripal_feature_set_feature_url($node, $feature);
 
 
-   return '';
+  return '';
 }
-?>
+

+ 116 - 116
tripal_feature/tripal_feature-db_references.inc

@@ -13,13 +13,13 @@
 function tripal_feature_add_ALL_dbreferences_page($node) {
   $output = '';
 
-  $output .= tripal_feature_implement_add_chado_properties_progress('db_references') . '<br>';
-  $output .= '<b>All Database References should strictly pertain to THE CURRENT Individual</b><br>';
-  $output .= '<br><b>Current Database References</b><br>';
+  $output .= tripal_feature_implement_add_chado_properties_progress('db_references') . '<br />';
+  $output .= '<b>All Database References should strictly pertain to THE CURRENT Individual</b><br />';
+  $output .= '<br /><b>Current Database References</b><br />';
   $output .= list_dbreferences_for_node($node->db_references);
-  $output .= '<br><br>';
+  $output .= '<br /><br />';
   $output .= drupal_get_form('tripal_feature_add_ONE_dbreference_form', $node);
-  $output .= '<br>';
+  $output .= '<br />';
   $output .= drupal_get_form('tripal_feature_implement_add_chado_properties_navigate', 'db_references', $node->nid);
   return $output;
 }
@@ -84,29 +84,29 @@ function tripal_feature_add_ONE_dbreference_form($form_state, $node) {
  */
 function tripal_feature_add_ONE_dbreference_form_validate($form, &$form_state) {
 
-   $db_id = $form_state['values']['db_id'];
-   $accession = $form_state['values']['accession'];
-   $description = $form_state['values']['description'];
-   $feature_id = $form_state['values']['feature_id'];
-   $nid = $form_state['values']['nid'];
-
-   // Check database is valid db_id in chado
-   $previous_db = tripal_db_set_active('chado');
-   $tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM {db} WHERE db_id=%d", $db_id));
-   tripal_db_set_active($previous_db);
-   if ($tmp_obj->count != 1) {
-      form_set_error('database', 'The database you selected is not valid. Please choose another one.');
-   }
-
-   // Check Accession is unique for database
-   $previous_db = tripal_db_set_active('chado');
-   $sql = "SELECT count(*) as count FROM {dbxref} WHERE accession='%s' and db_id = %d";
-   $tmp_obj = db_fetch_object(db_query($sql, $accession, $db_id));
-   tripal_db_set_active($previous_db);
-
-   if ($tmp_obj->count > 0) {
-      form_set_error('accession', 'This accession has already been assigned to another feature in the selected database.');
-   }
+  $db_id = $form_state['values']['db_id'];
+  $accession = $form_state['values']['accession'];
+  $description = $form_state['values']['description'];
+  $feature_id = $form_state['values']['feature_id'];
+  $nid = $form_state['values']['nid'];
+
+  // Check database is valid db_id in chado
+  $previous_db = tripal_db_set_active('chado');
+  $tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM {db} WHERE db_id=%d", $db_id));
+  tripal_db_set_active($previous_db);
+  if ($tmp_obj->count != 1) {
+    form_set_error('database', 'The database you selected is not valid. Please choose another one.');
+  }
+
+  // Check Accession is unique for database
+  $previous_db = tripal_db_set_active('chado');
+  $sql = "SELECT count(*) as count FROM {dbxref} WHERE accession='%s' and db_id = %d";
+  $tmp_obj = db_fetch_object(db_query($sql, $accession, $db_id));
+  tripal_db_set_active($previous_db);
+
+  if ($tmp_obj->count > 0) {
+    form_set_error('accession', 'This accession has already been assigned to another feature in the selected database.');
+  }
 
 }
 
@@ -117,33 +117,33 @@ function tripal_feature_add_ONE_dbreference_form_validate($form, &$form_state) {
  */
 function tripal_feature_add_ONE_dbreference_form_submit($form, &$form_state) {
 
-   $db_id = $form_state['values']['db_id'];
-   $accession = $form_state['values']['accession'];
-   $description = $form_state['values']['description'];
-   $feature_id = $form_state['values']['feature_id'];
-   $nid = $form_state['values']['nid'];
+  $db_id = $form_state['values']['db_id'];
+  $accession = $form_state['values']['accession'];
+  $description = $form_state['values']['description'];
+  $feature_id = $form_state['values']['feature_id'];
+  $nid = $form_state['values']['nid'];
 
-   // create dbxref
-   $previous_db = tripal_db_set_active('chado');
-   $isql =  "INSERT INTO {dbxref} (db_id, accession, description) VALUES (%d, '%s', '%s')";
-   db_query($isql, $db_id, $accession, $description);
-   tripal_db_set_active($previous_db);
+  // create dbxref
+  $previous_db = tripal_db_set_active('chado');
+  $isql =  "INSERT INTO {dbxref} (db_id, accession, description) VALUES (%d, '%s', '%s')";
+  db_query($isql, $db_id, $accession, $description);
+  tripal_db_set_active($previous_db);
 
-   //create feature_dbxref
-   $dbxref = tripal_db_get_dbxref( array('db_id' => array('type' => 'INT', 'value' => $form_state['values']['db_id']),
-                       'accession' => array('type' => 'STRING', 'exact' => TRUE, 'value' => $form_state['values']['accession']) ) );
+  //create feature_dbxref
+  $dbxref = tripal_db_get_dbxref( array('db_id' => array('type' => 'INT', 'value' => $form_state['values']['db_id']),
+                     'accession' => array('type' => 'STRING', 'exact' => TRUE, 'value' => $form_state['values']['accession']) ) );
 
   if (!empty($dbxref->dbxref_id)) {
     $previous_db = tripal_db_set_active('chado');
       $isql = "INSERT INTO {feature_dbxref} (feature_id, dbxref_id) VALUES (%d, %d)";
       db_query($isql, $feature_id, $dbxref->dbxref_id);
     tripal_db_set_active($previous_db);
-      drupal_set_message('Successfully Added Database Reference');
+      drupal_set_message(t('Successfully Added Database Reference'));
       drupal_goto('node/' . $nid);
-   }
-   else {
-      drupal_set_message('Database reference NOT successfully created...', 'error');
-   } //end of if dbxref was created successfully
+  }
+  else {
+    drupal_set_message(t('Database reference NOT successfully created...'), 'error');
+  } //end of if dbxref was created successfully
 
 }
 
@@ -157,9 +157,9 @@ function tripal_feature_edit_ALL_dbreferences_page($node) {
   $output = '';
 
   $output .= drupal_get_form('tripal_feature_edit_ALL_db_references_form', $node);
-  $output .= '<br>';
+  $output .= '<br />';
   $output .= drupal_get_form('tripal_feature_add_ONE_dbreference_form', $node);
-  $output .= '<br>';
+  $output .= '<br />';
   $output .= drupal_get_form('tripal_feature_implement_back_to_feature_button', $node->nid);
 
   return $output;
@@ -190,52 +190,52 @@ function tripal_feature_edit_ALL_db_references_form($form_state, $node) {
   ksort($db_options);
 
   if (sizeof($references) != 0) {
-     foreach ($references as $ref) {
-       $i++;
-       $form["num-$i"] = array(
-         '#type' => 'fieldset',
-         '#title' => t("Database Reference") . " $i"
-       );
-
-       $form["num-$i"]["accession-$i"] = array(
-         '#type' => 'textfield',
-         '#title' => t('Accession'),
-         '#size' => 30,
-         '#required' => TRUE,
-         '#default_value' => $ref->accession
-       );
-
-       $form["num-$i"]["db_id-$i"] = array(
-         '#type' => 'select',
-         '#title' => t('Database'),
-         '#options' => $db_options,
-         '#required' => TRUE,
-         '#default_value' => $ref->db_id
-       );
-
-
-       $form["num-$i"]["dbxref_id-$i"] = array(
-         '#type' => 'hidden',
-         '#value' => $ref->dbxref_id
-       );
-
-       $form["num-$i"]["delete-$i"] = array(
-         '#type' => 'submit',
-         '#value' => t("Delete"),
-         '#name' => "delete-$i",
-       );
-
-     }
-
-     $form['num_db_references'] = array(
-       '#type' => 'hidden',
-       '#value' => $i
-     );
-
-     $form["submit-edits"] = array(
-       '#type' => 'submit',
-       '#value' => t('Update All References')
-     );
+    foreach ($references as $ref) {
+      $i++;
+      $form["num-$i"] = array(
+        '#type' => 'fieldset',
+        '#title' => t("Database Reference") . " $i"
+      );
+
+      $form["num-$i"]["accession-$i"] = array(
+        '#type' => 'textfield',
+        '#title' => t('Accession'),
+        '#size' => 30,
+        '#required' => TRUE,
+        '#default_value' => $ref->accession
+      );
+
+      $form["num-$i"]["db_id-$i"] = array(
+        '#type' => 'select',
+        '#title' => t('Database'),
+        '#options' => $db_options,
+        '#required' => TRUE,
+        '#default_value' => $ref->db_id
+      );
+
+
+      $form["num-$i"]["dbxref_id-$i"] = array(
+        '#type' => 'hidden',
+        '#value' => $ref->dbxref_id
+      );
+
+      $form["num-$i"]["delete-$i"] = array(
+        '#type' => 'submit',
+        '#value' => t("Delete"),
+        '#name' => "delete-$i",
+      );
+
+      }
+
+      $form['num_db_references'] = array(
+        '#type' => 'hidden',
+        '#value' => $i
+      );
+
+      $form["submit-edits"] = array(
+        '#type' => 'submit',
+        '#value' => t('Update All References')
+      );
   } //end of foreach db ref
   return $form;
 }
@@ -253,29 +253,29 @@ function tripal_feature_edit_ALL_db_references_form_submit($form, &$form_state)
   $nid = $form_state['values']['nid'];
 
   if (strcmp($action, 'Update All References')==0) {
-     for ($i=1; $i<=$num_refs; $i++) {
-     $dbxref_id = $form_state['values']["dbxref_id-$i"];
-     $db_id = $form_state['values']["db_id-$i"];
-     $accession = $form_state['values']["accession-$i"];
-       tripal_feature_update_db_reference($dbxref_id, $db_id, $accession);
-     }
-     drupal_set_message("Updated all Database References");
-     drupal_goto('node/' . $nid);
+    for ($i=1; $i<=$num_refs; $i++) {
+    $dbxref_id = $form_state['values']["dbxref_id-$i"];
+    $db_id = $form_state['values']["db_id-$i"];
+    $accession = $form_state['values']["accession-$i"];
+      tripal_feature_update_db_reference($dbxref_id, $db_id, $accession);
+    }
+    drupal_set_message(t("Updated all Database References"));
+    drupal_goto('node/' . $nid);
   }
   elseif (strcmp($action, 'Delete')==0) {
-     if (preg_match('/delete-(\d+)/', $button, $matches) ) {
-        $i = $matches[1];
-       $dbxref_id = $form_state['values']["dbxref_id-$i"];
-        tripal_feature_delete_db_reference($dbxref_id);
-        drupal_set_message("Deleted Database Reference");
-        drupal_goto('node/' . $nid);
-     }
-     else {
-        drupal_set_message("Could not remove database reference: ", 'error');
-     }
-  }
+    if (preg_match('/delete-(\d+)/', $button, $matches) ) {
+      $i = $matches[1];
+      $dbxref_id = $form_state['values']["dbxref_id-$i"];
+      tripal_feature_delete_db_reference($dbxref_id);
+      drupal_set_message(t("Deleted Database Reference"));
+      drupal_goto('node/' . $nid);
+    }
+    else {
+      drupal_set_message(t("Could not remove database reference:"), 'error');
+    }
+    }
   else {
-    drupal_set_message("Unrecognized Button Pressed", 'error');
+    drupal_set_message(t("Unrecognized Button Pressed"), 'error');
   }
 
 }
@@ -323,7 +323,7 @@ function tripal_feature_delete_db_reference($dbxref_id) {
 function theme_tripal_feature_edit_ALL_db_references_form($form) {
   $output = '';
 
-  $output .= '<br><fieldset>';
+  $output .= '<br /><fieldset>';
   $output .= '<legend>Edit Existing Database References<span class="form-optional" title="This field is optional">(optional)</span></legend>';
   $output .= '<p>Below is a list of already existing database references, one per line. When entering a database reference, the accession '
          .'is a unique identifier for this feature in the specified database.</p>';
@@ -337,7 +337,7 @@ function theme_tripal_feature_edit_ALL_db_references_form($form) {
          . drupal_render($form["submit-$i"]) . '</td></tr>';
   }
 
-  $output .= '</table><br>';
+  $output .= '</table><br />';
   $output .= drupal_render($form);
   $output .= '</fieldset>';
 

+ 142 - 143
tripal_feature/tripal_feature-delete.inc

@@ -5,167 +5,166 @@
  */
 
 function tripal_feature_delete_form() {
-   // get the list of organisms
-   $sql = "SELECT * FROM {organism} ORDER BY genus, species";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $organisms = array();
-   $organisms[''] = '';
-   while ($organism = db_fetch_object($org_rset)) {
-      $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
-   }
-   $form['desc'] = array(
-      '#type' => 'markup',
-      '#value' => t("Use one or more of the following fields to identify sets of features to be deleted."),
-   );
-
-   $form['feature_names']= array(
-      '#type' => 'textarea',
-      '#title' => t('Feature Names'),
-      '#description' => t('Please provide a list of feature names or unique names,
-         separated by spaces or by new lines to be delete. If you specify feature names then
-         all other options below will be ignored (except the unique checkbox).'),
-   );
+  // get the list of organisms
+  $sql = "SELECT * FROM {organism} ORDER BY genus, species";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $org_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+  $organisms = array();
+  $organisms[''] = '';
+  while ($organism = db_fetch_object($org_rset)) {
+    $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
+  }
+  $form['desc'] = array(
+    '#type' => 'markup',
+    '#value' => t("Use one or more of the following fields to identify sets of features to be deleted."),
+  );
+
+  $form['feature_names']= array(
+    '#type' => 'textarea',
+    '#title' => t('Feature Names'),
+    '#description' => t('Please provide a list of feature names or unique names,
+       separated by spaces or by new lines to be delete. If you specify feature names then
+       all other options below will be ignored (except the unique checkbox).'),
+  );
   $form['is_unique'] = array(
-      '#title' => t('Names are Unique Names'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checbox if the names listed in the feature
-        names box above are the unique name of the feature rather than the human readable names.'),
+    '#title' => t('Names are Unique Names'),
+    '#type' => 'checkbox',
+    '#description' => t('Select this checbox if the names listed in the feature
+      names box above are the unique name of the feature rather than the human readable names.'),
+  );
+  $form['seq_type']= array(
+    '#type' => 'textfield',
+    '#title' => t('Sequence Type'),
+    '#description' => t('Please enter the Sequence Ontology term that describes the features to be deleted. Use in conjunction with an organism or anaylysis.'),
+  );
+
+  $form['organism_id'] = array(
+   '#title'       => t('Organism'),
+   '#type'        => t('select'),
+   '#description' => t("Choose the organism for which features will be deleted."),
+   '#options'     => $organisms,
+  );
+
+
+  // get the list of analyses
+  $sql = "SELECT * FROM {analysis} ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $org_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+  $analyses = array();
+  $analyses[''] = '';
+  while ($analysis = db_fetch_object($org_rset)) {
+    $analyses[$analysis->analysis_id] = "$analysis->name ($analysis->program $analysis->programversion, $analysis->sourcename)";
+  }
+  //  TODO: ADD THIS BACK IN LATER
+  //
+  //   $form['analysis']['analysis_id'] = array (
+  //     '#title'       => t('Analysis'),
+  //     '#type'        => t('select'),
+  //     '#description' => t("Choose the analysis for which associated features will be deleted."),
+  //     '#options'     => $analyses,
+  //   );
+
+  $form['button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Delete Features'),
   );
-   $form['seq_type']= array(
-      '#type' => 'textfield',
-      '#title' => t('Sequence Type'),
-      '#description' => t('Please enter the Sequence Ontology term that describes the features to be deleted. Use in conjunction with an organism or anaylysis.'),
-   );
-
-   $form['organism_id'] = array(
-     '#title'       => t('Organism'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the organism for which features will be deleted."),
-     '#options'     => $organisms,
-   );
-
-
-   // get the list of analyses
-   $sql = "SELECT * FROM {analysis} ORDER BY name";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $analyses = array();
-   $analyses[''] = '';
-   while ($analysis = db_fetch_object($org_rset)) {
-      $analyses[$analysis->analysis_id] = "$analysis->name ($analysis->program $analysis->programversion, $analysis->sourcename)";
-   }
-//  TODO: ADD THIS BACK IN LATER
-//
-//   $form['analysis']['analysis_id'] = array (
-//     '#title'       => t('Analysis'),
-//     '#type'        => t('select'),
-//     '#description' => t("Choose the analysis for which associated features will be deleted."),
-//     '#options'     => $analyses,
-//   );
-
-   $form['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Delete Features'),
-   );
-   return $form;
+  return $form;
 }
 
 function tripal_feature_delete_form_validate($form, &$form_state) {
-   $organism_id   = $form_state['values']['organism_id'];
-   $seq_type      = trim($form_state['values']['seq_type']);
-   $analysis_id   = $form_state['values']['analysis_id'];
-   $is_unique     = $form_state['values']['is_unique'];
-   $feature_names = $form_state['values']['feature_names'];
-
-   if (!$organism_id and !$anaysis_id and !$seq_type and !$feature_names) {
-      form_set_error('feature_names', t("Please select at least one option"));
-   }
-
-   // check to make sure the types exists
-   if ($seq_type) {
-      $cvtermsql = "SELECT CVT.cvterm_id
-                    FROM {cvterm} CVT
-                       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 = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
-      $cvterm = db_fetch_object(db_query($cvtermsql, 'sequence', $seq_type, $seq_type));
-      if (!$cvterm) {
-         form_set_error('seq_type', t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
-      }
-   }
+  $organism_id   = $form_state['values']['organism_id'];
+  $seq_type      = trim($form_state['values']['seq_type']);
+  $analysis_id   = $form_state['values']['analysis_id'];
+  $is_unique     = $form_state['values']['is_unique'];
+  $feature_names = $form_state['values']['feature_names'];
+
+  if (!$organism_id and !$anaysis_id and !$seq_type and !$feature_names) {
+    form_set_error('feature_names', t("Please select at least one option"));
+  }
+
+  // check to make sure the types exists
+  if ($seq_type) {
+    $cvtermsql = "SELECT CVT.cvterm_id
+                  FROM {cvterm} CVT
+                     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 = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
+    $cvterm = db_fetch_object(db_query($cvtermsql, 'sequence', $seq_type, $seq_type));
+    if (!$cvterm) {
+      form_set_error('seq_type', t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
+    }
+  }
 }
 
 function tripal_feature_delete_form_submit($form, &$form_state) {
-   global $user;
+  global $user;
 
-   $organism_id   = $form_state['values']['organism_id'];
-   $seq_type      = trim($form_state['values']['seq_type']);
-   $analysis_id   = $form_state['values']['analysis_id'];
-   $is_unique     = $form_state['values']['is_unique'];
-   $feature_names = $form_state['values']['feature_names'];
+  $organism_id   = $form_state['values']['organism_id'];
+  $seq_type      = trim($form_state['values']['seq_type']);
+  $analysis_id   = $form_state['values']['analysis_id'];
+  $is_unique     = $form_state['values']['is_unique'];
+  $feature_names = $form_state['values']['feature_names'];
 
-   $args = array($organism_id, $analysis_id, $seq_type, $is_unique, $feature_names);
+  $args = array($organism_id, $analysis_id, $seq_type, $is_unique, $feature_names);
 
-   tripal_add_job("Delete features", 'tripal_feature',
-      'tripal_feature_delete_features', $args, $user->uid);
+  tripal_add_job("Delete features", 'tripal_feature',
+    'tripal_feature_delete_features', $args, $user->uid);
 }
 
 
 function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
-   $is_unique, $feature_names, $job = NULL) {
-
-   global $user;
-   $match = array();
-
-   // if feature names have been provided then handle that separately
-   if ($feature_names) {
-      $names = preg_split('/\s+/', $feature_names);
-      if (sizeof($names) == 1) {
-         $names = $names[0];
-      }
-      if ($is_unique) {
-         $match['uniquename'] = $names;
-      }
-      else {
-         $match['name'] = $names;
-      }
-      $num_deletes = tripal_core_chado_select('feature', array('count(*) as cnt'), $match);
-      print "Deleting " . $num_deletes[0]->cnt . " features\n";
-      tripal_core_chado_delete('feature', $match);
-   }
-
-   // if the user has provided an analysis_id then handle that separately
-   elseif ($analysis_id) {
-      tripal_feature_delete_by_analysis();
-   }
-   else {
-
-
-      if ($organism_id) {
-         $match['organism_id'] = $organism_id;
-      }
-      if ($seq_type) {
-         $match['type_id'] = array(
-            'name' => $seq_type,
-            'cv_id' => array(
-               'name' => 'sequence'
-            ),
-         );
-      }
-      $num_deletes = tripal_core_chado_select('feature', array('count(*) as cnt'), $match);
-      print "Deleting " . $num_deletes[0]->cnt . " features\n";
-      tripal_core_chado_delete('feature', $match);
-   }
-
-   print "Removing orphaned feature pages\n";
-   tripal_features_cleanup(array(), $user->uid);
+  $is_unique, $feature_names, $job = NULL) {
+
+  global $user;
+  $match = array();
+
+  // if feature names have been provided then handle that separately
+  if ($feature_names) {
+    $names = preg_split('/\s+/', $feature_names);
+    if (sizeof($names) == 1) {
+      $names = $names[0];
+    }
+    if ($is_unique) {
+      $match['uniquename'] = $names;
+    }
+    else {
+      $match['name'] = $names;
+    }
+    $num_deletes = tripal_core_chado_select('feature', array('count(*) as cnt'), $match);
+    print "Deleting " . $num_deletes[0]->cnt . " features\n";
+    tripal_core_chado_delete('feature', $match);
+  }
+
+  // if the user has provided an analysis_id then handle that separately
+  elseif ($analysis_id) {
+    tripal_feature_delete_by_analysis();
+  }
+  else {
+
+    if ($organism_id) {
+      $match['organism_id'] = $organism_id;
+    }
+    if ($seq_type) {
+      $match['type_id'] = array(
+        'name' => $seq_type,
+        'cv_id' => array(
+          'name' => 'sequence'
+        ),
+      );
+    }
+    $num_deletes = tripal_core_chado_select('feature', array('count(*) as cnt'), $match);
+    print "Deleting " . $num_deletes[0]->cnt . " features\n";
+    tripal_core_chado_delete('feature', $match);
+  }
+
+  print "Removing orphaned feature pages\n";
+  tripal_features_cleanup(array(), $user->uid);
 }
 
 function tripal_feature_delete_by_analysis($organism_id, $analysis_id, $seq_type,
-   $is_unique, $feature_names, $job = NULL) {
+  $is_unique, $feature_names, $job = NULL) {
 
 }
 

+ 79 - 79
tripal_feature/tripal_feature-properties.inc

@@ -101,19 +101,19 @@ function tripal_feature_add_ONE_property_form($form_state, $node, $expand) {
  */
 function tripal_feature_add_ONE_property_form_validate($form, &$form_state) {
 
-   // Only Require if Adding Property
-   if ($form_state['clicked_button']['#value'] == t('Add Property') ) {
+  // Only Require if Adding Property
+  if ($form_state['clicked_button']['#value'] == t('Add Property') ) {
 
-      // Check that there is a feature
-      if ( $form_state['values']['feature_id'] <= 0 ) {
-         form_set_error('feature_id', 'There is no associated feature.');
-      }
+    // Check that there is a feature
+    if ( $form_state['values']['feature_id'] <= 0 ) {
+      form_set_error('feature_id', 'There is no associated feature.');
+    }
 
-      // Check that Selected a type
-      if ( !$form_state['values']['property']) {
-         form_set_error('property', 'Please select a type of property.');
-      }
-   }
+    // Check that Selected a type
+    if ( !$form_state['values']['property']) {
+      form_set_error('property', 'Please select a type of property.');
+    }
+  }
 }
 
 /**
@@ -122,18 +122,18 @@ function tripal_feature_add_ONE_property_form_validate($form, &$form_state) {
  * @ingroup tripal_feature
  */
 function tripal_feature_add_ONE_property_form_submit($form, &$form_state) {
-   $feature_id = $form_state['values']['feature_id'];
-   $property = $form_state['values']['property'];
-   $value = $form_state['values']['prop_value'];
-   $cv_name = $form_state['values']['cv_name'];
-
-   $succes = tripal_feature_insert_property($feature_id, $property, $value, 0, $cv_name);
-   if ($succes) {
-      drupal_set_message(t("Successfully Added Property: %property => %value", array('%property' => $property), array('%value' => $value)));
-   }
-   else {
-      drupal_set_message(t("Failed to Add Property: %property => %value", array('%property' => $property), array('%value' => $value)));
-   }
+  $feature_id = $form_state['values']['feature_id'];
+  $property = $form_state['values']['property'];
+  $value = $form_state['values']['prop_value'];
+  $cv_name = $form_state['values']['cv_name'];
+
+  $succes = tripal_feature_insert_property($feature_id, $property, $value, 0, $cv_name);
+  if ($succes) {
+    drupal_set_message(t("Successfully Added Property: %property => %value", array('%property' => $property), array('%value' => $value)));
+  }
+  else {
+    drupal_set_message(t("Failed to Add Property: %property => %value", array('%property' => $property), array('%value' => $value)));
+  }
 }
 
 /**
@@ -170,9 +170,9 @@ function tripal_feature_edit_ALL_properties_form($form_state, $node, $properties
     $prop_type_options = array();
     $columns = array('cvterm_id', 'name');
     $values = array(
-       'cv_id' => array(
-          'name' => $form['cv_name']['#value']
-       )
+      'cv_id' => array(
+        'name' => $form['cv_name']['#value']
+      )
     );
     $results = tripal_core_chado_select('cvterm', $columns, $values);
     foreach ($results as $r) {
@@ -180,30 +180,30 @@ function tripal_feature_edit_ALL_properties_form($form_state, $node, $properties
     }
 
     // iterate through all of the properties and create a set of form elements
-    foreach ($properties as $i => $property) {
-       $form["num-$i"] = array(
-          '#type' => 'fieldset',
-          '#value' => "Property $i"
-       );
-       $form["num-$i"]["id-$i"] = array(
-          '#type' => 'hidden',
-          '#value' => $property->featureprop_id
-       );
-       $default = array_search($property->type, $prop_type_options);
-       $form["num-$i"]["type-$i"] = array(
-          '#type' => 'select',
-          '#options' => $prop_type_options,
-          '#default_value' => $property->type_id->name
-       );
-       $form["num-$i"]["value-$i"] = array(
-          '#type' => 'textfield',
-          '#default_value' => $property->value
-       );
-       $form["num-$i"]["delete-$i"] = array(
-          '#type' => 'submit',
-          '#value' => t("Delete"),
-         '#name' => "delete-$i",
-       );
+  foreach ($properties as $i => $property) {
+    $form["num-$i"] = array(
+      '#type' => 'fieldset',
+      '#value' => "Property $i"
+    );
+    $form["num-$i"]["id-$i"] = array(
+      '#type' => 'hidden',
+      '#value' => $property->featureprop_id
+    );
+    $default = array_search($property->type, $prop_type_options);
+    $form["num-$i"]["type-$i"] = array(
+      '#type' => 'select',
+      '#options' => $prop_type_options,
+      '#default_value' => $property->type_id->name
+    );
+    $form["num-$i"]["value-$i"] = array(
+      '#type' => 'textfield',
+      '#default_value' => $property->value
+    );
+    $form["num-$i"]["delete-$i"] = array(
+      '#type' => 'submit',
+      '#value' => t("Delete"),
+      '#name' => "delete-$i",
+    );
     } //end of foreach property
 
     $form['num_properties'] = array(
@@ -233,38 +233,38 @@ function tripal_feature_edit_ALL_properties_form_submit($form, &$form_state) {
 
   // if the update button was clicked then do the update
   if ($form_state['clicked_button']['#value'] == t('Update All Properties') ) {
-     // iterate through each of the properties and set each one
-     for ($i=1; $i<=$form_state['values']['num_properties']; $i++) {
-       $featureprop_id = $form_state['values']["id-$i"];
-       $property = $form_state['values']["type-$i"];
-       $value = $form_state['values']["value-$i"];
-       $success = tripal_feature_update_property_by_id($featureprop_id, $property, $value, $cv_name);
-       if (!$success) {
-          drupal_set_message(t("Failed to Update Property: %property => %value", array('%property' => $property), array('%value' => $value)));
-          $all_good = 0;
-       }
-     }
-     if ($all_good) {
-        drupal_set_message("Updated all Properties");
-     }
-     drupal_goto('node/' . $form_state['values']['nid']);
+    // iterate through each of the properties and set each one
+    for ($i=1; $i<=$form_state['values']['num_properties']; $i++) {
+      $featureprop_id = $form_state['values']["id-$i"];
+      $property = $form_state['values']["type-$i"];
+      $value = $form_state['values']["value-$i"];
+      $success = tripal_feature_update_property_by_id($featureprop_id, $property, $value, $cv_name);
+      if (!$success) {
+        drupal_set_message(t("Failed to Update Property: %property => %value", array('%property' => $property), array('%value' => $value)));
+        $all_good = 0;
+      }
+    }
+    if ($all_good) {
+      drupal_set_message(t("Updated all Properties"));
+    }
+    drupal_goto('node/' . $form_state['values']['nid']);
   }
   // if the delete button was clicked then remove the property
   elseif (preg_match('/delete-(\d+)/', $form_state['clicked_button']['#name'], $matches) ) {
-     $i = $matches[1];
-     $featureprop_id = $form_state['values']["id-$i"];
-     $property = $form_state['values']["type-$i"];
-     $value = $form_state['values']["value-$i"];
-     $success = tripal_feature_delete_property_by_id($featureprop_id);
-     if ($success) {
-        drupal_set_message("Deleted Property");
-     }
-     else {
-        drupal_set_message("Unable to Delete Property");
-     }
+    $i = $matches[1];
+    $featureprop_id = $form_state['values']["id-$i"];
+    $property = $form_state['values']["type-$i"];
+    $value = $form_state['values']["value-$i"];
+    $success = tripal_feature_delete_property_by_id($featureprop_id);
+    if ($success) {
+      drupal_set_message(t("Deleted Property"));
+    }
+    else {
+      drupal_set_message(t("Unable to Delete Property"));
+    }
   }
   else {
-    drupal_set_message("Unrecognized Button Pressed", 'error');
+    drupal_set_message(t("Unrecognized Button Pressed"), 'error');
   }
 }
 /**
@@ -275,7 +275,7 @@ function tripal_feature_edit_ALL_properties_form_submit($form, &$form_state) {
 function theme_tripal_feature_edit_ALL_properties_form($form) {
   $output = '';
 
-  $output .= '<br><fieldset>';
+  $output .= '<br /><fieldset>';
   $output .= '<legend>Edit Already Existing Properties<span class="form-optional" title="This field is optional">(optional)</span></legend>';
   $output .= '<p>Below is a list of already existing properties for this feature, one property per line. The type refers to the type of '
          .'property and the value is the value for that property. </p>';
@@ -289,7 +289,7 @@ function theme_tripal_feature_edit_ALL_properties_form($form) {
     }
   }
 
-  $output .= '</table><br>';
+  $output .= '</table><br />';
   $output .= drupal_render($form);
   $output .= '</fieldset>';
 

+ 110 - 112
tripal_feature/tripal_feature-relationships.inc

@@ -12,13 +12,13 @@
 function tripal_feature_add_ALL_relationships_page($node) {
   $output = '';
 
-  $output .= tripal_feature_implement_add_chado_properties_progress('relationships') . '<br>';
-  $output .= '<b>All Relationships should include the CURRENT Individual (' . $node->uniquename . ')</b><br>';
-  $output .= '<br><b>Current Relationships</b><br>';
+  $output .= tripal_feature_implement_add_chado_properties_progress('relationships') . '<br />';
+  $output .= '<b>All Relationships should include the CURRENT Individual (' . $node->uniquename . ')</b><br />';
+  $output .= '<br /><b>Current Relationships</b><br />';
   $output .= list_relationships_for_node($node->uniquename, $node->subject_relationships, $node->object_relationships);
-  $output .= '<br><br>';
+  $output .= '<br /><br />';
   $output .= drupal_get_form('tripal_feature_add_ONE_relationship_form', $node);
-  $output .= '<br>';
+  $output .= '<br />';
   $output .= drupal_get_form('tripal_feature_implement_add_chado_properties_navigate', 'relationships', $node->nid);
   return $output;
 }
@@ -120,13 +120,13 @@ function tripal_feature_add_ONE_relationship_form_validate($form, &$form_state)
       for ($i=0; $i<sizeof($subject_results); $i++) {
       $links[] = l($i+1, "node/" . $subject_results[$i]->nid); }
       $message = "Too many stocks match '" . $form_state['values']['subject_id'] . "'! "
-                  . " Please refine your input to match ONLY ONE stock. <br>"
+                  . " Please refine your input to match ONLY ONE stock. <br />"
      . "To aid in this process, here are the stocks that match your initial input: "
      . join(', ', $links);
       form_set_error('subject_id', $message);
     }
     elseif (sizeof($subject_results) < 1) {
-      form_set_error('subject_id', "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+      form_set_error('subject_id', t("There are no stocks matching your input. Please check your input for typos and/or lookup the stock %link", array('%link' => l(t('here'), 'stocks'))));
     }
     elseif (sizeof($subject_results) == 1) {
       $form_state['values']['subject_id'] = $subject_results[0]->stock_id;
@@ -141,13 +141,13 @@ function tripal_feature_add_ONE_relationship_form_validate($form, &$form_state)
       for ($i=0; $i<sizeof($object_results); $i++) {
       $links[] = l($i+1, "node/" . $object_results[$i]->nid); }
       $message = "Too many stocks match '" . $form_state['values']['object_id'] . "'! "
-                 . "Please refine your input to match ONLY ONE stock. <br>"
+                 . "Please refine your input to match ONLY ONE stock. <br />"
                  . "To aid in this process, here are the stocks that match your initial input: "
                  . join(', ', $links);
       form_set_error('object_id', $message);
     }
     elseif (sizeof($object_results) < 1) {
-      form_set_error('object_id', "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+      form_set_error('object_id', t("There are no stocks matching your input. Please check your input for typos and/or lookup the stock %link", array('%link' => l(t('here'), 'stocks'))));
     }
     elseif (sizeof($object_results) == 1) {
       $form_state['values']['object_id'] = $object_results[0]->stock_id;
@@ -194,7 +194,7 @@ function tripal_feature_add_ONE_relationship_form_submit($form, &$form_state) {
     );
     db_set_active($previous_db);
 
-    drupal_set_message('Successfully Added Relationship.');
+    drupal_set_message(t('Successfully Added Relationship.'));
   } //end of insert relationship
 
 }
@@ -208,9 +208,9 @@ function tripal_feature_edit_ALL_relationships_page($node) {
   $output = '';
 
   $output .= drupal_get_form('tripal_feature_edit_ALL_relationships_form', $node);
-  $output .= '<br>';
+  $output .= '<br />';
   $output .= drupal_get_form('tripal_feature_add_ONE_relationship_form', $node);
-  $output .= '<br>';
+  $output .= '<br />';
   $output .= drupal_get_form('tripal_feature_implement_back_to_feature_button', $node->nid);
 
   return $output;
@@ -243,93 +243,91 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
   $relationships = array_merge($orelationships, $srelationships);
 
   if (sizeof($relationships) != 0) {
-     foreach ($relationships as $r) {
-
-       $i++;
-       $form["num-$i"] = array(
-         '#type' => 'fieldset',
-         '#title' => t("Relationship %i", array('%i' => $i)),
-       );
-
-       $form["num-$i"]["id-$i"] = array(
-         '#type' => 'hidden',
-         '#value' => $r->stock_relationship_id
-       );
-
-       //Enter relationship specific fields
-       if ( !empty($r->subject_id) ) {
-         $default = $r->subject_uniquename;
-         $description = l($r->subject_name, 'node/' . $r->subject_nid);
-       }
-       else {
-          $default = $node->uniquename;
-          $description = "Current Feature";
-       }
-       $description .= " (" . $r->subject_type . ")";
-       $form["num-$i"]["subject_id-$i"] = array(
-         '#type' => 'textfield',
-         //'#title' => t('Subject'),
-         '#required'   => TRUE,
-         '#size' => 30,
-         '#default_value' => $default,
-         '#description' => t('%description', array('%description' => $description)),
-       );
-
-       $cv = tripal_cv_get_cv_by_name('relationship');
-       $type_options = tripal_cv_get_cvterm_options($cv->cv_id);
-       ksort($type_options);
-       $form["num-$i"]["type_id-$i"] = array(
-         '#type' => 'select',
-         //'#title' => t('Type of Relationship'),
-         '#options' => $type_options,
-         '#required' => TRUE,
-         '#default_value' => $r->relationship_type_id
-       );
-
-       if (!empty($r->object_id) ) {
-         $default = $r->object_uniquename;
-         $description = l($r->object_name, 'node/' . $r->object_nid);
-       }
-       else {
-         $default = $node->uniquename;
-         $description = 'Current Feature';
-       }
-       $description .= " (" . $r->object_type . ")";
-       $form["num-$i"]["object_id-$i"] = array(
-         '#type' => 'textfield',
-         //'#title' => t('Object'),
-         '#required'   => TRUE,
-         '#size' => 30,
-         '#default_value' => $default,
-         '#description' => $description
-       );
-
-       $form["num-$i"]["delete-$i"] = array(
-         '#type' => 'submit',
-         '#value' => t("Delete"),
-         '#name' => "delete-$i",
-       );
-
-     } //end of foreach relationship
-     $form['num_relationships'] = array(
-       '#type' => 'hidden',
-       '#value' => $i
-     );
-
-     $form["submit-edits"] = array(
-       '#type' => 'submit',
-       '#value' => t('Update All Relationships')
-     );
+    foreach ($relationships as $r) {
+
+      $i++;
+      $form["num-$i"] = array(
+        '#type' => 'fieldset',
+        '#title' => t("Relationship %i", array('%i' => $i)),
+      );
+
+      $form["num-$i"]["id-$i"] = array(
+        '#type' => 'hidden',
+        '#value' => $r->stock_relationship_id
+      );
+
+      //Enter relationship specific fields
+      if ( !empty($r->subject_id) ) {
+        $default = $r->subject_uniquename;
+        $description = l($r->subject_name, 'node/' . $r->subject_nid);
+      }
+      else {
+        $default = $node->uniquename;
+        $description = "Current Feature";
+      }
+      $description .= " (" . $r->subject_type . ")";
+      $form["num-$i"]["subject_id-$i"] = array(
+        '#type' => 'textfield',
+        //'#title' => t('Subject'),
+        '#required'   => TRUE,
+        '#size' => 30,
+        '#default_value' => $default,
+        '#description' => t('%description', array('%description' => $description)),
+      );
+
+      $cv = tripal_cv_get_cv_by_name('relationship');
+      $type_options = tripal_cv_get_cvterm_options($cv->cv_id);
+      ksort($type_options);
+      $form["num-$i"]["type_id-$i"] = array(
+        '#type' => 'select',
+        //'#title' => t('Type of Relationship'),
+        '#options' => $type_options,
+        '#required' => TRUE,
+        '#default_value' => $r->relationship_type_id
+      );
+
+      if (!empty($r->object_id) ) {
+        $default = $r->object_uniquename;
+        $description = l($r->object_name, 'node/' . $r->object_nid);
+      }
+      else {
+        $default = $node->uniquename;
+        $description = 'Current Feature';
+      }
+      $description .= " (" . $r->object_type . ")";
+      $form["num-$i"]["object_id-$i"] = array(
+        '#type' => 'textfield',
+        //'#title' => t('Object'),
+        '#required'   => TRUE,
+        '#size' => 30,
+        '#default_value' => $default,
+        '#description' => $description
+      );
+
+      $form["num-$i"]["delete-$i"] = array(
+        '#type' => 'submit',
+        '#value' => t("Delete"),
+        '#name' => "delete-$i",
+      );
+
+    } //end of foreach relationship
+    $form['num_relationships'] = array(
+      '#type' => 'hidden',
+      '#value' => $i
+    );
+
+    $form["submit-edits"] = array(
+      '#type' => 'submit',
+      '#value' => t('Update All Relationships')
+    );
   }
   else {
-     $form["info"] = array(
-       '#type' => 'markup',
-       '#value' => t('No relationships currently exist for this feature.')
-     );
+    $form["info"] = array(
+      '#type' => 'markup',
+      '#value' => t('No relationships currently exist for this feature.')
+    );
   }
 
-
-
   return $form;
 }
 
@@ -354,13 +352,13 @@ function tripal_feature_edit_ALL_relationships_form_validate($form, &$form_state
         for ($j=0; $j<sizeof($subject_results); $j++) {
         $links[] = l($j+1, "node/" . $subject_results[$j]->nid); }
         $message = "Too many stocks match '" . $form_state['values']["subject_id-$i"] . "'! "
-                 . "Please refine your input to match ONLY ONE stock. <br>"
+                 . "Please refine your input to match ONLY ONE stock. <br />"
                  . "To aid in this process, here are the stocks that match your initial input: "
                  . join(', ', $links);
         form_set_error("subject_id-$i", $message);
       }
       elseif (sizeof($subject_results) < 1) {
-        form_set_error("subject_id-$i", "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+        form_set_error("subject_id-$i", t("There are no stocks matching your input. Please check your input for typos and/or lookup the stock %link", array('%link' => l(t('here'), 'stocks'))));
       }
       elseif (sizeof($subject_results) == 1) {
         $form_state['values']["subject_id-$i"] = $subject_results[0]->stock_id;
@@ -375,13 +373,13 @@ function tripal_feature_edit_ALL_relationships_form_validate($form, &$form_state
         for ($j=0; $j<sizeof($object_results); $j++) {
         $links[] = l($j+1, "node/" . $object_results[$j]->nid); }
         $message = "Too many stocks match '" . $form_state['values']["object_id-$i"] . "'! "
-                 . "Please refine your input to match ONLY ONE stock. <br>"
+                 . "Please refine your input to match ONLY ONE stock. <br />"
                  . "To aid in this process, here are the stocks that match your initial input: "
                  . join(', ', $links);
         form_set_error("object_id-$i", $message);
       }
       elseif (sizeof($object_results) < 1) {
-        form_set_error("object_id-$i", "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+        form_set_error("object_id-$i", t("There are no stocks matching your input. Please check your input for typos and/or lookup the stock %link", array('%link' => l(t('here'), 'stocks'))));
       }
       elseif (sizeof($object_results) == 1) {
         $form_state['values']["object_id-$i"] = $object_results[0]->stock_id;
@@ -421,33 +419,33 @@ function tripal_feature_edit_ALL_relationships_form_validate($form, &$form_state
 function tripal_feature_edit_ALL_relationships_form_submit($form, &$form_state) {
 
   if ($form_state['clicked_button']['#value'] == t('Update Relationships') ) {
-     //Update all
-     for ($i=1; $i<=$form_state['values']['num_relationships']; $i++) {
+    //Update all
+    for ($i=1; $i<=$form_state['values']['num_relationships']; $i++) {
 
-       //process stock textfields
-       tripal_feature_update_relationship(
+      //process stock textfields
+      tripal_feature_update_relationship(
         $form_state['values']["id-$i"],
         $form_state['values']["subject_id-$i"],
         $form_state['values']["type_id-$i"],
         $form_state['values']["object_id-$i"]
       );
-     }
-     drupal_set_message("Updated all Relationships");
-     drupal_goto('node/' . $form_state['values']['nid']);
+    }
+    drupal_set_message(t("Updated all Relationships"));
+    drupal_goto('node/' . $form_state['values']['nid']);
 
   }
   elseif ( preg_match('/Delete #(\d+)/', $form_state['clicked_button']['#value'], $matches) ) {
 
-     $i = $matches[1];
-     tripal_feature_delete_relationship($form_state['values']["id-$i"]);
-     drupal_set_message("Deleted Relationship");
+    $i = $matches[1];
+    tripal_feature_delete_relationship($form_state['values']["id-$i"]);
+    drupal_set_message(t("Deleted Relationship"));
 
   }
   elseif ($form_state['clicked_button']['#value'] == t('Back to Stock') ) {
     drupal_goto('node/' . $form_state['values']['nid']);
   }
   else {
-    drupal_set_message("Unrecognized Button Pressed", 'error');
+    drupal_set_message(t("Unrecognized Button Pressed"), 'error');
   }
 
 }
@@ -495,7 +493,7 @@ function tripal_feature_delete_relationship($stock_relationship_id) {
 function theme_tripal_feature_edit_ALL_relationships_form($form) {
   $output = '';
 
-  $output .= '<br><fieldset>';
+  $output .= '<br /><fieldset>';
   $output .= '<legend>Edit Already Existing Relationships<span class="form-optional" title="This field is optional">(optional)</span></legend>';
   $output .= '<p>Each relationship for this stock is listed below, one per line. The textboxes indicating '
         .'the subject and object of the relationship can contain the uniquename, name, database '
@@ -511,7 +509,7 @@ function theme_tripal_feature_edit_ALL_relationships_form($form) {
               '<td>' . drupal_render($form["submit-$i"]) . '</td></tr>';
   }
 
-  $output .= '</table><br>';
+  $output .= '</table><br />';
   $output .= drupal_render($form);
   $output .= '</fieldset>';
 

File diff suppressed because it is too large
+ 461 - 462
tripal_feature/tripal_feature.admin.inc


+ 99 - 99
tripal_feature/tripal_feature.api.inc

@@ -225,13 +225,13 @@ function tripal_feature_chado_feature_cvterm_schema() {
           'pub_id' => 'pub_id',
         ),
   );
-  
+
   return $description;
 }
 /**
-*
-* @ingroup tripal_schema_api
-*/
+ *
+ * @ingroup tripal_schema_api
+ */
 function tripal_feature_chado_feature_synonym_schema() {
   $description = array();
 
@@ -286,26 +286,26 @@ function tripal_feature_chado_feature_synonym_schema() {
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id = NUll,
-   $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
-
-   // check that the incoming arguments are correct
-   if (($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)) {
-       watchdog('tripal_feature',
-          'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified',
-           array(), WATCHDOG_WARNING);
-   }
-
-   // get the analysisfeature_id if one is not provided
-   if (!$analysisfeature_id) {
-      $columns = array('analysisfeature_id');
-      $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
-      $analysisfeature_id = $result[0]->analysisfeature_id;
-   }
-
-   // get the property.
-   return tripal_core_get_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
+  $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
+
+  // check that the incoming arguments are correct
+  if (($analysis_id and !$feature_id) or
+    (!$analysis_id and $feature_id)) {
+      watchdog('tripal_feature',
+      'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified',
+      array(), WATCHDOG_WARNING);
+  }
+
+  // get the analysisfeature_id if one is not provided
+  if (!$analysisfeature_id) {
+    $columns = array('analysisfeature_id');
+    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $result = tripal_core_chado_select('analysisfeature', $columns, $values);
+    $analysisfeature_id = $result[0]->analysisfeature_id;
+  }
+
+  // get the property.
+  return tripal_core_get_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
 }
 
 /**
@@ -339,28 +339,28 @@ function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id =
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_id = NUll,
-   $analysisfeature_id = NULL, $property, $value, $update_if_present = 0,
-   $cv_name = 'tripal') {
-
-   // check that the incoming arguments are correct
-   if (($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)) {
-       watchdog('tripal_feature',
-          'tripal_feature_analysis_insert_property: Both an analysis ID and feature ID should be specified',
-           array(), WATCHDOG_WARNING);
-   }
-
-   // get the analysisfeature_id if one is not provided
-   if (!$analysisfeature_id) {
-      $columns = array('analysisfeature_id');
-      $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
-      $analysisfeature_id = $result[0]->analysisfeature_id;
-   }
-
-   // insert the property.
-   return tripal_core_insert_property('analysisfeature', $analysisfeature_id,
-      $property, $cv_name, $value, $update_if_present);
+  $analysisfeature_id = NULL, $property, $value, $update_if_present = 0,
+  $cv_name = 'tripal') {
+
+  // check that the incoming arguments are correct
+  if (($analysis_id and !$feature_id) or
+    (!$analysis_id and $feature_id)) {
+    watchdog('tripal_feature',
+      'tripal_feature_analysis_insert_property: Both an analysis ID and feature ID should be specified',
+      array(), WATCHDOG_WARNING);
+  }
+
+  // get the analysisfeature_id if one is not provided
+  if (!$analysisfeature_id) {
+    $columns = array('analysisfeature_id');
+    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $result = tripal_core_chado_select('analysisfeature', $columns, $values);
+    $analysisfeature_id = $result[0]->analysisfeature_id;
+  }
+
+  // insert the property.
+  return tripal_core_insert_property('analysisfeature', $analysisfeature_id,
+    $property, $cv_name, $value, $update_if_present);
 }
 
 /**
@@ -400,27 +400,27 @@ function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_i
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_id = NUll,
-   $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0,
-   $cv_name = 'tripal') {
-
-   // check that the incoming arguments are correct
-   if (($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)) {
-       watchdog('tripal_feature',
-          'tripal_feature_analysis_update_property: Both an analysis ID and feature ID should be specified',
-           array(), WATCHDOG_WARNING);
-   }
-
-   // get the analysisfeature_id if one is not provided
-   if (!$analysisfeature_id) {
-      $columns = array('analysisfeature_id');
-      $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
-      $analysisfeature_id = $result[0]->analysisfeature_id;
-   }
-
-   // update the property.
-   return tripal_core_update_property('analysisfeature', $analysisfeature_id, $property, $cv_name, $value, $insert_if_missing);
+  $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0,
+  $cv_name = 'tripal') {
+
+  // check that the incoming arguments are correct
+  if (($analysis_id and !$feature_id) or
+    (!$analysis_id and $feature_id)) {
+      watchdog('tripal_feature',
+      'tripal_feature_analysis_update_property: Both an analysis ID and feature ID should be specified',
+      array(), WATCHDOG_WARNING);
+  }
+
+  // get the analysisfeature_id if one is not provided
+  if (!$analysisfeature_id) {
+    $columns = array('analysisfeature_id');
+    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $result = tripal_core_chado_select('analysisfeature', $columns, $values);
+    $analysisfeature_id = $result[0]->analysisfeature_id;
+  }
+
+  // update the property.
+  return tripal_core_update_property('analysisfeature', $analysisfeature_id, $property, $cv_name, $value, $insert_if_missing);
 }
 
 /**
@@ -442,10 +442,10 @@ function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_i
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
-   $property, $value, $cv_name = 'tripal') {
+  $property, $value, $cv_name = 'tripal') {
 
-   // update the property.
-   return tripal_core_update_property_by_id('analysisfeature',
+    // update the property.
+    return tripal_core_update_property_by_id('analysisfeature',
       $analysisfeatureprop_id, $property, $cv_name, $value);
 }
 /**
@@ -481,25 +481,25 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NUll,
-   $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
-   // check that the incoming arguments are correct
-   if (($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)) {
-       watchdog('tripal_feature',
-          'tripal_feature_analysis_delete_property: Both an analysis ID and feature ID should be specified',
-           array(), WATCHDOG_WARNING);
-   }
-
-   // get the analysisfeature_id if one is not provided
-   if (!$analysisfeature_id) {
-      $columns = array('analysisfeature_id');
-      $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
-      $analysisfeature_id = $result[0]->analysisfeature_id;
-   }
-
-   // get the property.
-   return tripal_core_delete_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
+  $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
+  // check that the incoming arguments are correct
+  if (($analysis_id and !$feature_id) or
+    (!$analysis_id and $feature_id)) {
+      watchdog('tripal_feature',
+      'tripal_feature_analysis_delete_property: Both an analysis ID and feature ID should be specified',
+        array(), WATCHDOG_WARNING);
+  }
+
+  // get the analysisfeature_id if one is not provided
+  if (!$analysisfeature_id) {
+    $columns = array('analysisfeature_id');
+    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $result = tripal_core_chado_select('analysisfeature', $columns, $values);
+    $analysisfeature_id = $result[0]->analysisfeature_id;
+  }
+
+  // get the property.
+  return tripal_core_delete_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
 }
 /**
  * Delete a property using the analysisfeatureprop_id
@@ -513,8 +513,8 @@ function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_i
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id) {
-   // get the property.
-   return tripal_core_delete_property_by_id('analysisfeature', $analysisfeatureprop_id);
+  // get the property.
+  return tripal_core_delete_property_by_id('analysisfeature', $analysisfeatureprop_id);
 }
 /**
  * Retrieve properties of a given type for a given feature
@@ -533,7 +533,7 @@ function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id)
  * @ingroup tripal_feature_api
  */
 function tripal_feature_get_property($feature_id, $property, $cv_name='tripal') {
-   return tripal_core_get_property('feature', $feature_id, $property, $cv_name);
+  return tripal_core_get_property('feature', $feature_id, $property, $cv_name);
 }
 
 /**
@@ -557,9 +557,9 @@ function tripal_feature_get_property($feature_id, $property, $cv_name='tripal')
  * @ingroup tripal_feature_api
  */
 function tripal_feature_insert_property($feature_id, $property, $value,
-   $update_if_present = 0, $cv_name = 'tripal') {
-    return tripal_core_insert_property('feature', $feature_id, $property,
-       $cv_name, $value, $update_if_present);
+  $update_if_present = 0, $cv_name = 'tripal') {
+  return tripal_core_insert_property('feature', $feature_id, $property,
+    $cv_name, $value, $update_if_present);
 }
 /**
  * Update a feature property using the property name. Only use this
@@ -587,7 +587,7 @@ function tripal_feature_insert_property($feature_id, $property, $value,
  */
 function tripal_feature_update_property($feature_id, $property,
   $value, $insert_if_missing = 0, $cv_name = 'tripal') {
-   return tripal_core_update_property('feature', $feature_id, $property, $cv_name, $value, $insert_if_missing);
+    return tripal_core_update_property('feature', $feature_id, $property, $cv_name, $value, $insert_if_missing);
 }
 
 /**
@@ -610,7 +610,7 @@ function tripal_feature_update_property($feature_id, $property,
  */
 function tripal_feature_update_property_by_id($featureprop_id, $property,
   $value, $cv_name = 'tripal') {
-   return tripal_core_update_property_by_id('feature', $featureprop_id, $property, $cv_name, $value);
+    return tripal_core_update_property_by_id('feature', $featureprop_id, $property, $cv_name, $value);
 }
 
 /**
@@ -634,7 +634,7 @@ function tripal_feature_update_property_by_id($featureprop_id, $property,
  * @ingroup tripal_feature_api
  */
 function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal') {
-   return tripal_core_delete_property('feature', $feature_id, $property, $cv_name);
+  return tripal_core_delete_property('feature', $feature_id, $property, $cv_name);
 }
 /**
  * Delete a given feature property using the featureprop_id
@@ -648,5 +648,5 @@ function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal
  * @ingroup tripal_feature_api
  */
 function tripal_feature_delete_property_by_id($featureprop_id) {
-   return tripal_core_delete_property_by_id('feature', $featureprop_id);
+  return tripal_core_delete_property_by_id('feature', $featureprop_id);
 }

+ 146 - 146
tripal_feature/tripal_feature.install

@@ -5,173 +5,173 @@
  */
 
 /**
-*  Implementation of hook_install();
-*
-* @ingroup tripal_feature
-*/
+ * Implementation of hook_install().
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_install() {
-   // create the module's data directory
-   tripal_create_moddir('tripal_feature');
+  // create the module's data directory
+  tripal_create_moddir('tripal_feature');
 
-   // create the tables that correlate drupal nodes with chado
-   // features, organisms, etc....
-   drupal_install_schema('tripal_feature');
+  // create the tables that correlate drupal nodes with chado
+  // features, organisms, etc....
+  drupal_install_schema('tripal_feature');
 
-   // add the materialized view
-   tripal_feature_add_organism_count_mview();
+  // add the materialized view
+  tripal_feature_add_organism_count_mview();
 
 }
 /**
-*  Update for Drupal 6.x, Tripal 0.2b, Feature Module 0.2
-*  This update adjusts the materialized view by adding a 'cvterm_id' column
-*
-* @ingroup tripal_feature
-*/
+ *  Update for Drupal 6.x, Tripal 0.2b, Feature Module 0.2
+ *  This update adjusts the materialized view by adding a 'cvterm_id' column
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_update_6000() {
-   // recreate the materialized view
-   tripal_feature_add_organism_count_mview();
-   $ret = array(
-      '#finished' => 1,
-   );
+  // recreate the materialized view
+  tripal_feature_add_organism_count_mview();
+  $ret = array(
+    '#finished' => 1,
+  );
 
-   return $ret;
+  return $ret;
 }
 
 /**
-*
-* @ingroup tripal_feature
-*/
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_update_6300() {
-   // add the relationship aggregator table to the database
-   $schema = tripal_feature_get_schemas('tripal_feature_relagg');
-   $ret = array();
-   db_create_table($ret, 'tripal_feature_relagg', $schema['tripal_feature_relagg']);
+  // add the relationship aggregator table to the database
+  $schema = tripal_feature_get_schemas('tripal_feature_relagg');
+  $ret = array();
+  db_create_table($ret, 'tripal_feature_relagg', $schema['tripal_feature_relagg']);
 
-   return $ret;
+  return $ret;
 }
 /**
-*
-* @ingroup tripal_feature
-*/
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_add_organism_count_mview() {
-   $view_name = 'organism_feature_count';
-
-   // Drop the MView table if it exists
-   $mview_id = tripal_mviews_get_mview_id($view_name);
-   if ($mview_id) {
-      tripal_mviews_action("delete", $mview_id);
-   }
-
-   // Create the MView
-   tripal_add_mview(
-      // view name
-      $view_name,
-      // tripal module name
-      'tripal_feature',
-      // table name
-      $view_name,
-      // table schema definition
-      'organism_id integer, genus character varying(255), '.
-      '  species character varying(255), '.
-      '  common_name character varying(255), '.
-      '  num_features integer, cvterm_id integer, '.
-      '  feature_type character varying(255)',
-      // columns for indexing
-      'organism_id,cvterm_id,feature_type',
-      // SQL statement to populate the view
-      'SELECT O.organism_id, O.genus, O.species, O.common_name,
-          count(F.feature_id) as num_features,
-          CVT.cvterm_id, CVT.name as feature_type
-       FROM {Organism} O
-          INNER JOIN Feature F           ON O.Organism_id = F.organism_id
-          INNER JOIN Cvterm CVT          ON F.type_id = CVT.cvterm_id
-       GROUP BY O.Organism_id, O.genus, O.species, O.common_name,
-          CVT.cvterm_id, CVT.name',
-      // special index
-      ''
-   );
-
-   // add a job to the job queue so this view gets updated automatically next
-   // time the job facility is run
-   $mview_id = tripal_mviews_get_mview_id($view_name);
-   if ($mview_id) {
-      tripal_mviews_action('update', $mview_id);
-   }
+  $view_name = 'organism_feature_count';
+
+  // Drop the MView table if it exists
+  $mview_id = tripal_mviews_get_mview_id($view_name);
+  if ($mview_id) {
+    tripal_mviews_action("delete", $mview_id);
+  }
+
+  // Create the MView
+  tripal_add_mview(
+    // view name
+    $view_name,
+    // tripal module name
+    'tripal_feature',
+    // table name
+    $view_name,
+    // table schema definition
+    'organism_id integer, genus character varying(255), '.
+    '  species character varying(255), '.
+    '  common_name character varying(255), '.
+    '  num_features integer, cvterm_id integer, '.
+    '  feature_type character varying(255)',
+    // columns for indexing
+    'organism_id,cvterm_id,feature_type',
+    // SQL statement to populate the view
+    'SELECT O.organism_id, O.genus, O.species, O.common_name,
+        count(F.feature_id) as num_features,
+        CVT.cvterm_id, CVT.name as feature_type
+     FROM {Organism} O
+        INNER JOIN Feature F           ON O.Organism_id = F.organism_id
+        INNER JOIN Cvterm CVT          ON F.type_id = CVT.cvterm_id
+     GROUP BY O.Organism_id, O.genus, O.species, O.common_name,
+        CVT.cvterm_id, CVT.name',
+    // special index
+    ''
+  );
+
+  // add a job to the job queue so this view gets updated automatically next
+  // time the job facility is run
+  $mview_id = tripal_mviews_get_mview_id($view_name);
+  if ($mview_id) {
+    tripal_mviews_action('update', $mview_id);
+  }
 }
 /**
-* Implementation of hook_schema().
-*
-* @ingroup tripal_feature
-*/
+ * Implementation of hook_schema().
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_schema() {
-   $schema = tripal_feature_get_schemas();
-   return $schema;
+  $schema = tripal_feature_get_schemas();
+  return $schema;
 }
 /**
-* Implementation of hook_uninstall()
-*
-* @ingroup tripal_feature
-*/
+ * Implementation of hook_uninstall().
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_uninstall() {
 
-   // Drop the MView table if it exists
-   $mview_id = tripal_mviews_get_mview_id('organism_feature_count');
-   if ($mview_id) {
-      tripal_mviews_action("delete", $mview_id);
-   }
-
-   drupal_uninstall_schema('tripal_feature');
-
-   // Get the list of nodes to remove
-   $sql_feature_id = "SELECT nid, vid " .
-                 "FROM {node} " .
-                 "WHERE type='chado_feature'";
-   $result = db_query($sql_feature_id);
-   while ($node = db_fetch_object($result)) {
-      node_delete($node->nid);
-   }
+  // Drop the MView table if it exists
+  $mview_id = tripal_mviews_get_mview_id('organism_feature_count');
+  if ($mview_id) {
+    tripal_mviews_action("delete", $mview_id);
+  }
+
+  drupal_uninstall_schema('tripal_feature');
+
+  // Get the list of nodes to remove
+  $sql_feature_id = "SELECT nid, vid " .
+               "FROM {node} " .
+               "WHERE type='chado_feature'";
+  $result = db_query($sql_feature_id);
+  while ($node = db_fetch_object($result)) {
+    node_delete($node->nid);
+  }
 }
 
 /**
-* This function simply defines all tables needed for the module to work
-* correctly.  By putting the table definitions in a separate function we
-* can easily provide the entire list for hook_install or individual
-* tables for an update.
-*
-* @ingroup tripal_feature
-*/
+ * This function simply defines all tables needed for the module to work
+ * correctly.  By putting the table definitions in a separate function we
+ * can easily provide the entire list for hook_install or individual
+ * tables for an update.
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_get_schemas($table = NULL) {
   $schema = array();
 
 
   if (!$table or strcmp($table, 'chado_feature')==0) {
-     $schema['chado_feature'] = array(
-         'fields' => array(
-            'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-            'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-            'feature_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
-            'sync_date' => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer sync date/time'),
-         ),
-         'indexes' => array(
-            'feature_id' => array('feature_id')
-          ),
-         'unique keys' => array(
-            'nid_vid' => array('nid', 'vid'),
-            'vid' => array('vid')
-         ),
-         'primary key' => array('nid'),
-     );
+    $schema['chado_feature'] = array(
+      'fields' => array(
+        'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'feature_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+        'sync_date' => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer sync date/time'),
+      ),
+      'indexes' => array(
+        'feature_id' => array('feature_id')
+      ),
+      'unique keys' => array(
+        'nid_vid' => array('nid', 'vid'),
+        'vid' => array('vid')
+      ),
+      'primary key' => array('nid'),
+    );
   }
   if (!$table or strcmp($table, 'tripal_feature_relagg')==0) {
-     $schema['tripal_feature_relagg'] = array(
-        'fields' => array(
-           'type_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-           'rel_type_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-        ),
-        'indexes' => array(
-           'type_id' => array('type_id')
-        ),
-     );
+    $schema['tripal_feature_relagg'] = array(
+      'fields' => array(
+        'type_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'rel_type_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      ),
+      'indexes' => array(
+        'type_id' => array('type_id')
+      ),
+    );
   }
 
   return $schema;
@@ -184,16 +184,16 @@ function tripal_feature_get_schemas($table = NULL) {
  * @ingroup tripal_feature
  */
 function tripal_feature_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      // make sure the core module is installed...
-      if (!function_exists('tripal_create_moddir')) {
-         $requirements ['tripal_feature'] = array(
-            'title' => "tripal_feature",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
+  $requirements = array();
+  if ($phase == 'install') {
+    // make sure the core module is installed...
+    if (!function_exists('tripal_create_moddir')) {
+      $requirements ['tripal_feature'] = array(
+        'title' => "tripal_feature",
+        'value' => "error. Some required modules are just being installed. Please try again.",
+        'severity' => REQUIREMENT_ERROR,
+      );
+    }
+  }
+  return $requirements;
 }

File diff suppressed because it is too large
+ 435 - 436
tripal_feature/tripal_feature.module


+ 12 - 12
tripal_feature/tripal_feature.views.inc

@@ -38,7 +38,7 @@ function tripal_feature_views_data()  {
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }
@@ -67,7 +67,7 @@ function tripal_feature_views_data()  {
     );
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
         tripal_views_integration_add_entry($table_integration_array);
       }
     }
@@ -88,16 +88,16 @@ function tripal_feature_views_data()  {
  * @ingroup tripal_feature_views
  */
 function tripal_feature_views_handlers() {
- return array(
-   'info' => array(
-     'path' => drupal_get_path('module', 'tripal_feature') . '/views_handlers',
-   ),
-   'handlers' => array(
-     'views_handler_field_residues' => array(
-       'parent' => 'views_handler_field',
-     ),
-   ),
- );
+  return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'tripal_feature') . '/views_handlers',
+    ),
+    'handlers' => array(
+    'views_handler_field_residues' => array(
+      'parent' => 'views_handler_field',
+    ),
+    ),
+  );
 }
 
 /**

+ 1 - 1
tripal_feature/views_handlers/views_handler_field_residues.inc

@@ -24,7 +24,7 @@ class views_handler_field_residues extends views_handler_field {
 
   function render($values) {
     // add a <br> every 100 bp
-    return ereg_replace("(.{100})", "\\1<br>", $values->feature_residues);
+    return ereg_replace("(.{100})", "\\1<br />", $values->feature_residues);
 
   }
 }

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