Pārlūkot izejas kodu

Working on feature module. Can now add features + synonyms manually

Stephen Ficklin 11 gadi atpakaļ
vecāks
revīzija
52c03fc8bf

+ 2 - 1
tripal_analysis/includes/tripal_analysis.form.inc

@@ -17,7 +17,7 @@ function chado_analysis_form($node, &$form_state) {
   //    form elements and the form is being rebuilt
   //
   // set form field defaults
-  $analysis_id = null;
+  $analysis_id    = null;
   $analysisname   = '';
   $program        = '';
   $programversion = '';
@@ -581,6 +581,7 @@ function chado_analysis_validate($node, &$form_state) {
  * @ingroup tripal_analysis
  */
 function tripal_analysis_validate($node, &$form_state) {
+  // remove surrounding white-space on submitted values
   $node->analysisname = trim($node->analysisname);
   $node->description = trim($node->description);
   $node->program = trim($node->program);

+ 4 - 3
tripal_analysis/theme/tripal_analysis/tripal_analysis_base.tpl.php

@@ -1,9 +1,10 @@
 <?php
 $analysis = $variables['node']->analysis;
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-?>
+$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description'); ?>
+
 <div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div><?php 
+  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
+  <div class="tripal__analysis-info-box-desc tripal-info-box-desc"></div><?php 
     
   // the $headers array is an array of fields to use as the colum headers. 
   // additional documentation can be found here 

+ 1 - 3
tripal_analysis/tripal_analysis.module

@@ -151,7 +151,6 @@ function tripal_analysis_permission() {
 function tripal_analysis_theme($existing, $type, $theme, $path) {
   $core_path = drupal_get_path('module', 'tripal_core');
 
-  $theme_path = drupal_get_path('module', 'tripal_analysis') . '/theme';
   $items = array(
     'node__chado_analysis' => array(
       'template' => 'node--chado-generic',
@@ -593,8 +592,7 @@ function chado_analysis_load($nodes) {
     // build the analysis variable
     $values = array('analysis_id' => $analysis_id);
     $analysis = tripal_core_generate_chado_var('analysis', $values);
-
-
+    
     // add in the description field
     $analysis = tripal_core_expand_chado_vars($analysis, 'field', 'analysis.description');
     $nodes[$nid]->analysis = $analysis;

+ 1 - 1
tripal_core/theme/css/tripal.css

@@ -75,7 +75,7 @@ table.tripal-table-horz .tripal-table-odd-row {
 }
 
 .tripal-info-box-desc {
-  padding-bottom: 15px;
+  /* padding-bottom: 15px; */
 }
 /* hide the title when inside of a block on a panel */
 .pane-block .tripal-info-box-title {

+ 3 - 3
tripal_feature/includes/tripal_feature.admin.inc

@@ -538,9 +538,9 @@ function tripal_feature_set_taxonomy($node, $feature_id) {
   // get the cvterm and the organism for this feature
   $sql = "
     SELECT CVT.name AS cvname, O.genus, O.species
-    FROM {CVTerm} CVT
-      INNER JOIN {Feature} F on F.type_id = CVT.cvterm_id
-      INNER JOIN {Organism} O ON F.organism_id = O.organism_id
+    FROM {cvterm} CVT
+      INNER JOIN {feature} F on F.type_id = CVT.cvterm_id
+      INNER JOIN {organism} O ON F.organism_id = O.organism_id
     WHERE F.feature_id = :feature_id
   ";
   $feature = chado_query($sql, array(':feature_id' => $feature_id))->fetchObject();

+ 6 - 6
tripal_feature/includes/tripal_feature.sync_features.inc

@@ -144,12 +144,12 @@ function tripal_feature_set_urls($na = NULL, $job = NULL) {
   // are not Chado tables we must manually prepare them 
   $psql = "
     PREPARE del_url_alias_by_src (text) AS
-    DELETE FROM {url_alias} WHERE src = \$1
+    DELETE FROM {url_alias} WHERE source = \$1
   ";
   db_query($psql);
   $psql = "
     PREPARE ins_url_alias_nisrds (text, text) AS
-    INSERT INTO url_alias (src, dst) VALUES (\$1, \$2)
+    INSERT INTO url_alias (source, alias) VALUES (\$1, \$2)
   ";
   db_query($psql);
   
@@ -183,20 +183,20 @@ function tripal_feature_set_urls($na = NULL, $job = NULL) {
     }
     
     // remove any previous alias and then add the new one
-    $success = db_query("EXECUTE del_url_alias_by_src(:src)", array(':src' => $src));    
+    $success = db_query("EXECUTE del_url_alias_by_src(:source)", array(':source' => $src));    
     if (!$success) {
       db_query('DEALLOCATE "del_url_alias_by_src"');
       db_query('DEALLOCATE "ins_url_alias_nisrds"');
       db_query("ROLLBACK");
-      watchdog('trp-seturl', "Failed Removing URL Alias: %src", array('%src' => $src), WATCHDOG_ERROR);
+      watchdog('trp-seturl', "Failed Removing URL Alias: %source", array('%source' => $src), WATCHDOG_ERROR);
       return;
     }
-    $success = db_query("EXECUTE ins_url_alias_nisrds(:src, :dst)", array(':src' => $src, ':dst' => $dst));
+    $success = db_query("EXECUTE ins_url_alias_nisrds(:source, :alias)", array(':source' => $src, ':alias' => $dst));
     if (!$success) {
       db_query('DEALLOCATE "del_url_alias_by_src"');
       db_query('DEALLOCATE "ins_url_alias_nisrds"');
       db_query("ROLLBACK");
-      watchdog('trp-seturl', "Failed Adding URL Alias: %dst", array('%dst' => $dst), WATCHDOG_ERROR);
+      watchdog('trp-seturl', "Failed Adding URL Alias: %alias", array('%alias' => $dst), WATCHDOG_ERROR);
       return;
     }
 

+ 3 - 0
tripal_feature/theme/css/tripal_feature.css

@@ -2,6 +2,9 @@
 #tripal_feature-sequence-residues {
   background-color: #FFFFFF;
   font-family: monospace;
+  margin: 10px 0 0 0;
+  padding: 0px;
+  font-size: medium;
 }
 
 pre#tripal_feature-featureloc_sequence {

+ 104 - 42
tripal_feature/theme/tripal_feature/tripal_feature_base.tpl.php

@@ -1,47 +1,109 @@
 <?php
+$feature  = $variables['node']->feature; ?>
 
-$feature  = $variables['node']->feature;
-
-?>
 <div id="tripal_feature-base-box" class="tripal_feature-info-box tripal-info-box">
-  <div class="tripal_feature-info-box-title tripal-info-box-title">Feature Details</div>
-  <div class="tripal_feature-info-box-desc tripal-info-box-desc"></div>
+  <div class="tripal_feature-info-box-title tripal-info-box-title">Details</div>
+  <div class="tripal_feature-info-box-desc tripal-info-box-desc"></div> <?php
+   
+  // the $headers array is an array of fields to use as the colum headers. 
+  // additional documentation can be found here 
+  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+  // This table for the analysis has a vertical header (down the first column)
+  // so we do not provide headers here, but specify them in the $rows array below.
+  $headers = array();
+  
+  // the $rows array contains an array of rows where each row is an array
+  // of values for each column of the table in that row.  Additional documentation
+  // can be found here:
+  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7 
+  $rows = array();
+
+  // Is Obsolete Row
+  if(strcmp($feature->is_obsolete,'t')==0){
+    $rows[] = array(
+      array(
+        'data' => '<div class="tripal_feature-obsolete">This feature is obsolete</div>',
+        'colspan' => 2
+      ),
+    );
+  }
+  // Name row
+  $rows[] = array(
+    array(
+      'data' => 'Name',
+      'header' => TRUE
+    ),
+    $feature->name
+  );
+  // Unique Name row
+  $rows[] = array(
+    array(
+      'data' => 'Unique Name',
+      'header' => TRUE
+    ),
+    $feature->uniquename
+  );
+  // Type row
+  $rows[] = array(
+    array(
+      'data' => 'Type',
+      'header' => TRUE
+    ),
+    $feature->type_id->name
+  );
+  // Organism row
+  if ($feature->organism_id->nid) {
+    $organism = l("<i>" . $feature->organism_id->genus . " " . $feature->organism_id->species . "</i> (" .$feature->organism_id->common_name .")", "node/".$feature->organism_id->nid, array('html' => TRUE));
+  } 
+  else {
+    $organism = $feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")";
+  }
+  $rows[] = array(
+    array(
+      'data' => 'Organism',
+      'header' => TRUE
+    ),
+    $organism
+  );
+  // Seqlen row
+  if($feature->seqlen > 0) {
+    $rows[] = array(
+      array(
+        'data' => 'Sequence length',
+        'header' => TRUE
+      ),
+      $feature->seqlen
+    );
+  }
+  // allow site admins to see the feature ID
+  if (user_access('access administration pages')) { 
+    // Feature ID
+    $rows[] = array(
+      array(
+        'data' => 'Feature ID',
+        'header' => TRUE
+      ),
+      $feature->feature_id
+    );
+  }
 
-   <?php if(strcmp($feature->is_obsolete,'t')==0){ ?>
-      <div class="tripal_feature-obsolete">This feature is obsolete</div>
-   <?php }?>
-   <table id="tripal_feature-base-table" class="tripal_feature-table tripal-table tripal-table-vert">
-      <tr class="tripal_feature-table-even-row tripal-table-even-row">
-        <th>Name</th>
-        <td><?php print $feature->name; ?></td>
-      </tr>
-      <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
-        <th nowrap>Unique Name</th>
-        <td><?php print $feature->uniquename; ?></td>
-      </tr>
-      <tr class="tripal_feature-table-even-row tripal-table-even-row">
-        <th>Internal ID</th>
-        <td><?php print $feature->feature_id; ?></td>
-      </tr>
-      <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
-        <th>Type</th>
-        <td><?php print $feature->type_id->name; ?></td>
-      </tr>
-      <tr class="tripal_feature-table-even-row tripal-table-even-row">
-        <th>Organism</th>
-        <td>
-          <?php if ($feature->organism_id->nid) { 
-      	   print "<a href=\"".url("node/".$feature->organism_id->nid)."\">".$feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")</a>";      	 
-          } else { 
-            print $feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")";
-          } ?>
-        </td>
-     	</tr> <?php   
-     	if ($feature->seqlen) { ?>
-        <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
-          <th>Length</th>
-          <td><?php print $feature->seqlen ?></td>
-        </tr> <?php 
-     	} ?>   	                                
-   </table>
+  // the $table array contains the headers and rows array as well as other
+  // options for controlling the display of the table.  Additional
+  // documentation can be found here:
+  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+  $table = array(
+    'header' => $headers,
+    'rows' => $rows,
+    'attributes' => array(
+      'id' => 'tripal_feature-table-base',
+    ),
+    'sticky' => FALSE,
+    'caption' => '',
+    'colgroups' => array(),
+    'empty' => '',
+  );
+  
+  // once we have our table array structure defined, we call Drupal's theme_table()
+  // function to generate the table.
+  print theme_table($table); ?>
 </div>

+ 15 - 7
tripal_feature/theme/tripal_feature/tripal_feature_sequence.tpl.php

@@ -1,18 +1,26 @@
 <?php
 $feature = $variables['node']->feature;
 
-// add the residues to the feature object.  Fields of type 'text' in Chado
-// are not automatically added, so we must add them manually
-$feature = tripal_core_expand_chado_vars($feature,'field','feature.residues');
+// we don't want to get the sequence for traditionally large types. They are
+// too big,  bog down the web browser, take longer to load and it's not
+// reasonable to print them on a page.
+$residues ='';
+if(strcmp($feature->type_id->name,'scaffold') !=0 and
+   strcmp($feature->type_id->name,'chromosome') !=0 and
+   strcmp($feature->type_id->name,'supercontig') !=0 and
+   strcmp($feature->type_id->name,'pseudomolecule') !=0) {
+  $feature = tripal_core_expand_chado_vars($feature,'field','feature.residues');
+  $residues = $feature->residues;
+} 
 
-if ($feature->residues) { ?>
+if ($residues) { ?>
   <div id="tripal_feature-sequence-box" class="tripal_feature-info-box tripal-info-box">
     <div class="tripal_feature-info-box-title tripal-info-box-title">Sequence</div>
     <div class="tripal_feature-info-box-desc tripal-info-box-desc">The sequence for this <?php print $feature->type_id->name; ?> </div>
     <pre id="tripal_feature-sequence-residues"><?php 
-      // format the sequence to break ever 100 residues
-      print ereg_replace("(.{60})","\\1<br>",$feature->residues); ?>  
+      // format the sequence to break every 100 residues
+      print preg_replace("/(.{50})/","\\1<br>",$feature->residues); ?>  
     </pre>
-  </div><?php
+  </div> <?php
 }
 

+ 39 - 19
tripal_feature/theme/tripal_feature/tripal_feature_synonyms.tpl.php

@@ -7,27 +7,47 @@ $options = array('return_array' => 1);
 $feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_synonym', $options);
 $synonyms = $feature->feature_synonym;
 
-
 if(count($synonyms) > 0){ ?>
   <div id="tripal_feature-synonyms-box" class="tripal_feature-info-box tripal-info-box">
     <div class="tripal_feature-info-box-title tripal-info-box-title">Synonyms</div>
-    <div class="tripal_feature-info-box-desc tripal-info-box-desc">The feature '<?php print $feature->name ?>' has the following synonyms</div>
-
-    <table id="tripal_feature-synonyms-table" class="tripal_feature-table tripal-table tripal-table-horz">
-      <tr>
-        <th>Synonym</th>
-      </tr> <?php
-      $i = 0; 
-      foreach ($synonyms as $feature_synonym){
-        $class = 'tripal-table-odd-row';
-        if($i % 2 == 0 ){
-           $class = 'tripal-table-even-row';
-        } ?>
-        <tr class="<?php print $class ?>">
-          <td><?php print $feature_synonym->synonym_id->name?></td>
-        </tr> <?php
-        $i++;  
-      } ?>
-    </table>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">The feature '<?php print $feature->name ?>' has the following synonyms</div><?php
+    
+    // the $headers array is an array of fields to use as the colum headers. 
+    // additional documentation can be found here 
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    // This table for the analysis has a vertical header (down the first column)
+    // so we do not provide headers here, but specify them in the $rows array below.
+    $headers = array('Synonym');
+    
+    // the $rows array contains an array of rows where each row is an array
+    // of values for each column of the table in that row.  Additional documentation
+    // can be found here:
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7 
+    $rows = array();
+    foreach ($synonyms as $feature_synonym){
+      $rows[] = array(
+        $feature_synonym->synonym_id->name
+      );
+    } 
+    
+    // the $table array contains the headers and rows array as well as other
+    // options for controlling the display of the table.  Additional
+    // documentation can be found here:
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    $table = array(
+      'header' => $headers,
+      'rows' => $rows,
+      'attributes' => array(
+        'id' => 'tripal_feature-table-synonyms',
+      ),
+      'sticky' => FALSE,
+      'caption' => '',
+      'colgroups' => array(),
+      'empty' => '',
+    );
+    
+    // once we have our table array structure defined, we call Drupal's theme_table()
+    // function to generate the table.
+      print theme_table($table); ?>
   </div><?php
 }

+ 113 - 297
tripal_feature/tripal_feature.module

@@ -20,6 +20,7 @@ require_once "includes/fasta_loader.inc";
 require_once "includes/gff_loader.inc";
 require_once "includes/seq_extract.inc";
 require_once "includes/tripal_feature-delete.inc";
+require_once "includes/tripal_feature.form.inc";
 
 /**
  *
@@ -288,12 +289,14 @@ function tripal_feature_menu() {
  * @ingroup tripal_feature
  */
 function tripal_feature_theme($existing, $type, $theme, $path) {
-  return array(
-    'tripal_feature_search_index' => array(
-      'variables' => array('node'),
-    ),
-    'tripal_feature_search_results' => array(
-       'variables' => array('node'),
+  $core_path = drupal_get_path('module', 'tripal_core');
+  
+  $items = array(
+    'node__chado_feature' => array(
+      'template' => 'node--chado-generic',
+      'render element' => 'node',
+      'base hook' => 'node',
+      'path' => "$core_path/theme",
     ),
     'tripal_organism_feature_browser' => array(
       'variables' => array('node' => NULL),
@@ -306,56 +309,64 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
       'path' => "$path/theme/tripal_organism",
     ),
     'tripal_feature_base' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_base',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_base',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_sequence' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_sequence',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_sequence',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_proteins' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_proteins',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_proteins',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_synonyms' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_synonyms',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_synonyms',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_phenotypes' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_phenotypes',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_phenotypes',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_featurepos' => array(
-       'arguments' => array('node' => NULL),
-       'template' => 'tripal_feature_featurepos',
+      'arguments' => array('node' => NULL),
+      'template' => 'tripal_feature_featurepos',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_featureloc_sequences' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_featureloc_sequences',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_featureloc_sequences',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_references' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_references',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_references',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_properties' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_properties',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_properties',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_terms' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_terms',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_terms',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_alignments' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_alignments',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_alignments',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_relationships' => array(
-       'variables' => array('node' => NULL),
-       'template' => 'tripal_feature_relationships',
-    ),
-    'tripal_feature_edit_ALL_properties_form' => array(
-      'arguments' => array('form' => NULL),
-      'function' => 'theme_tripal_feature_edit_ALL_properties_form',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_feature_relationships',
+      'path' => "$path/theme/tripal_feature",
     ),
     'tripal_feature_help' => array(
       'template' => 'tripal_feature_help',
@@ -368,6 +379,8 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
        'arguments' => array('form'),
     )
   );
+  
+  return $items;
 }
 /**
  *
@@ -665,7 +678,8 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
   // remove any old synonyms
   $feature_syn_dsql = "DELETE FROM {feature_synonym} WHERE feature_id = :feature_id";
   if (!chado_query($feature_syn_dsql, array(':feature_id' => $feature_id))) {
-    $error .= "Could not remove synonyms from feature. ";
+    watchdog('tripal_feature', "Could not remove synonyms from feature. ", array(), WATCHDOG_ERROR);
+    return;
   }
 
   // return if we don't have any synonmys to add
@@ -676,7 +690,8 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
   foreach ($syn_array as $syn) {
     // skip this item if it's empty
     if (!$syn) {
-    break; }
+      break; 
+    }
 
     // check to see if we have this accession number already in the database
     // if so then don't add it again. it messes up drupal if the insert fails.
@@ -688,13 +703,14 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
         INSERT INTO {synonym} (name, synonym_sgml, type_id)
         VALUES (:name, :synonym_sgml,
           (SELECT cvterm_id
-           FROM {CVTerm} CVT
-             INNER JOIN CV ON CVT.cv_id = CV.cv_id
+           FROM {cvterm} CVT
+             INNER JOIN {cv} ON CVT.cv_id = CV.cv_id
            WHERE CV.name = 'feature_property' and CVT.name = 'synonym')
           )
       ";
       if (!chado_query($synonym_isql, array(':name' => $syn, ':synonym_sgml' => $syn))) {
-        $error .= "Could not add synonym. ";
+        watchdog('tripal_feature', "Could not add synonym. ", array(), WATCHDOG_WARNING);
+        return;
       }
       // now get the synonym we just added
       $synonym_sql = "SELECT synonym_id FROM {synonym} WHERE name = :name";
@@ -707,13 +723,10 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
       VALUES (:synonym_id, :feature_id, :pub_id)";
     $args = array(':synonym_id' => $synonym->synonym_id, ':feature_id' => $feature_id, ':pub_id'=> 1);
     if (!chado_query($feature_syn_isql, $args)) {
-      $error .= "Could not add synonyms to feature. ";
+      watchdog('tripal_feature', "Could not associate synonym with feature. ", array(), WATCHDOG_WARNING);
+      return;
     }
   }
-
-  // return to the drupal database
-  return $error;
-
 }
 /**
  *
@@ -773,265 +786,47 @@ function chado_feature_add_gbaccession($accession, $feature_id) {
   return $error;
 }
 
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function chado_feature_form($node, $param) {
-
-  $form = array();
-
-  $feature = $node->feature;
-
-  // add the residues to the feature object
-  $feature = tripal_core_expand_chado_vars($feature, 'field', 'feature.residues');
-
-  // if the node has synonyms then use that as the form may be returning
-  // from an error.  Otherwise try to find synonyms from the database
-  $synonyms = $node->synonyms;
-  $feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_synonym');
-  $feature_synonyms = $feature->feature_synonym;
-  if (!$synonyms) {
-    if (!is_array($feature_synonyms)) {
-      $synonyms = $feature_synonyms->synonym_id->name;
-    }
-    elseif (is_array($feature_synonyms)) {
-      foreach ($feature_synonyms as $index => $synonym) {
-        $synonyms .= $synonym->synonym_id->name . "\n";
-      }
-    }
-  }
-
-  $analyses = $node->analyses;
-  $references = $node->references;
-
-  // We need to pass above variables for preview to show
-  $form['feature'] = array(
-    '#type' => 'value',
-    '#value' => $feature
-  );
-  // This field is read when previewing a node
-  $form['synonyms'] = array(
-    '#type' => 'value',
-    '#value' => $synonyms
-  );
-  // This field is read when previewing a node
-  $form['analyses'] = array(
-    '#type' => 'value',
-    '#value' => $analyses
-  );
-  // This field is read when previewing a node
-  $form['references'] = array(
-    '#type' => 'value',
-    '#value' => $references
-  );
-
-  // keep track of the feature id if we have one.  If we do have one then
-  // this would indicate an update as opposed to an insert.
-  $form['feature_id'] = array(
-    '#type' => 'value',
-    '#value' => $feature->feature_id,
-  );
-
-  /*
-  $form['title']= array(
-    '#type' => 'textfield',
-    '#title' => t('Title'),
-    '#required' => TRUE,
-    '#default_value' => $node->title,
-    '#description' => t('The title must be a unique identifier for this feature.  It is recommended to use a combination of uniquename, organism and feature type in the title as this is guranteed to be unique.'),
-    '#maxlength' => 255
-  );*/
-
-  $form['uniquename']= array(
-    '#type' => 'textfield',
-    '#title' => t('Unique Feature Name'),
-    '#required' => TRUE,
-    '#default_value' => $feature->uniquename,
-    '#description' => t('Enter a unique name for this feature.  This name must be unique for the organism and feature type.'),
-    '#maxlength' => 255
-  );
-
-  $form['fname']= array(
-    '#type' => 'textfield',
-    '#title' => t('Feature Name'),
-    '#required' => TRUE,
-    '#default_value' => $feature->name,
-    '#description' => t('Enter the name used by humans to refer to this feature.'),
-    '#maxlength' => 255
-  );
-
-  // get the sequence ontology CV ID
-  $values = array('name' => 'sequence');
-  $cv = tripal_core_chado_select('cv', array('cv_id'), $values);
-  $cv_id = $cv[0]->cv_id;
-
-  $form['feature_type'] = array(
-   '#title'       => t('Feature Type'),
-   '#type'        => 'textfield',
-   '#description' => t("Choose the feature type."),
-   '#required'    => TRUE,
-   '#default_value' => $feature->type_id->name,
-   '#autocomplete_path' => "admin/tripal/tripal_cv/cvterm/auto_name/$cv_id",
-  );
-
-  // get the list of organisms
-  $sql = "SELECT * FROM {Organism} ORDER BY genus, species";
-  $org_rset = chado_query($sql);
-  $organisms = array();
-  $organisms[''] = '';
-  while ($organism = $org_rset->fetchObject()) {
-    $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 with which this feature is associated"),
-    '#required'    => TRUE,
-    '#default_value' => $feature->organism_id->organism_id,
-    '#options'     => $organisms,
-  );
-
-  // Get synonyms
-  if ($synonyms) {
-    if (is_array($synonyms)) {
-      foreach ($synonyms as $synonym) {
-        $syn_text .= "$synonym->name\n";
-      }
-    }
-    else {
-      $syn_text = $synonyms;
-    }
-  }
-  $form['synonyms']= array(
-    '#type' => 'textarea',
-    '#title' => t('Synonyms'),
-    '#required' => FALSE,
-    '#default_value' => $syn_text,
-    '#description' => t('Enter alternate names (synonmys) for this feature to help in searching and identification. You may enter as many alternate names as needed each on different lines.'),
-  );
-
-  $form['residues']= array(
-    '#type' => 'textarea',
-    '#title' => t('Residues'),
-    '#required' => FALSE,
-    '#default_value' => $feature->residues,
-    '#description' => t('Enter the nucelotide sequences for this feature'),
-  );
-
-  $checked = '';
-  if ($feature->is_obsolete == 't') {
-    $checked = '1';
-  }
-  $form['is_obsolete']= array(
-    '#type' => 'checkbox',
-    '#title' => t('Is Obsolete'),
-    '#required' => FALSE,
-    '#default_value' => $checked,
-    '#description' => t('Check this box if this sequence should be retired and no longer included in further analysis.'),
-  );
-  return $form;
-}
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function chado_feature_validate($node) {
-  $result = 0;
-
-  // make sure the feature type is a real sequence ontology term
-  $type = tripal_cv_get_cvterm_by_name($node->feature_type, NULL, 'sequence');
-  if (!$type) {
-    form_set_error('feature_type', t("The feature type is not a valid name from the Sequence Ontology."));
-  }
-
-  // if this is an update, we want to make sure that a different feature for
-  // the organism doesn't already have this uniquename. We don't want to give
-  // two sequences the same uniquename
-  if ($node->feature_id) {
-    $sql = "
-      SELECT *
-      FROM {feature} F
-        INNER JOIN {cvterm} CVT ON F.type_id = CVT.cvterm_id
-      WHERE
-        F.uniquename     = :uname AND
-        F.organism_id    = :orgnism_id AND
-        CVT.name         = :cvtname AND
-        NOT f.feature_id = :feature_id
-    ";
-    $args = array(':uname' => $node->uniquename, ':organism_id' => $node->organism_id,
-      ':cvtname' => $node->feature_type, ':feature_id' => $node->feature_id);
-    $result = chado_query($sql, $args)->fetchObject();
-    if ($result) {
-      form_set_error('uniquename', t("Feature update cannot proceed. The feature name '$node->uniquename' is not unique for this organism. Please provide a unique name for this feature."));
-    }
-  }
-
-  // if this is an insert then we just need to make sure this name doesn't
-  // already exist for this organism if it does then we need to throw an error
-  else {
-    $sql = "
-      SELECT *
-      FROM {feature} F
-        INNER JOIN {cvterm} CVT ON F.type_id = CVT.cvterm_id
-      WHERE
-        F.uniquename  = :name AND
-        F.organism_id = :organism_id AND
-        CVT.name      = :cvtname
-    ";
-    $args = array(':name' => $node->uniquename, ':organism_id' => $node->organism_id, ':cvtname' => $node->feature_type);
-    $result = chado_query($sql, $args)->fetchObject();
-    if ($result) {
-      form_set_error('uniquename', t("Feature insert cannot proceed. The feature name '$node->uniquename' already exists for this organism. Please provide a unique name for this feature."));
-    }
-  }
 
-  // we don't allow a genbank accession number for a contig
-  if ($node->feature_type == 'contig' and $node->gbaccession) {
-    form_set_error('gbaccession', t("Contigs cannot have a genbank accession number.  Please change the feature type or remove the accession number"));
-  }
-}
 /**
  *  When a node is requested by the user this function is called to allow us
  *  to add auxiliary data to the node object.
  *
  * @ingroup tripal_feature
  */
-function chado_feature_load($node) {
-
-  // get the feature details from chado
-  $feature_id = chado_get_id_for_node('feature', $node->nid);
-
-  $values = array('feature_id' => $feature_id);
-  $feature = tripal_core_generate_chado_var('feature', $values);
-
-  // by default, the titles are saved using the unique constraint.  We will
-  // keep it the same, but remove the duplicate name if the unique name and name
-  // are identical
-  $title_type = variable_get('chado_feature_title', 'unique_constraint');
-  if ($title_type == 'unique_constraint') {
-    if (strcmp($feature->name, $feature->uniquename)==0) {
-      $node->title = $feature->name . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
+function chado_feature_load($nodes) {
+
+  foreach ($nodes as $nid => $node) {
+    // find the feature and add in the details
+    $feature_id = chado_get_id_for_node('feature', $nid);
+  
+    // build the feature variable
+    $values = array('feature_id' => $feature_id);
+    $feature = tripal_core_generate_chado_var('feature', $values);
+    $nodes[$nid]->feature = $feature;
+
+    // by default, the titles are saved using the unique constraint.  We will
+    // keep it the same, but remove the duplicate name if the unique name and name
+    // are identical. This doesn't change the title saved in the database, just what is shown
+    // to the user on the page
+    $title_type = variable_get('chado_feature_title', 'unique_constraint');
+    if ($title_type == 'unique_constraint') {
+      if (strcmp($feature->name, $feature->uniquename)==0) {
+        $node->title = $feature->name . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
+      }
+      // in previous version of Tripal, the feature title was simply the unique name.
+      // so, we recreate the title just to be sure all of our feature pages are consistent
+      else {
+        $node->title = $feature->name . ", " . $feature->uniquename . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
+      }
     }
-    // in previous version of Tripal, the feature title was simply the unique name.
-    // so, we recreate the title just to be sure all of our feature pages are consistent
-    else {
-      $node->title = $feature->name . ", " . $feature->uniquename . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species ;
+    // set the title to be the feature name or uniquename as configured
+    if ($title_type == 'feature_name') {
+      $node->title = $feature->name;
+    }
+    if ($title_type == 'feature_unique_name') {
+      $node->title = $feature->uniquename;
     }
   }
-  // set the title to be the feature name or uniquename as configured
-  if ($title_type == 'feature_name') {
-    $node->title = $feature->name;
-  }
-  if ($title_type == 'feature_unique_name') {
-    $node->title = $feature->uniquename;
-  }
-
-  $additions = new stdClass();
-  $additions->feature = $feature;
-  return $additions;
 }
 /**
  *
@@ -1895,11 +1690,12 @@ function tripal_feature_node_insert($node) {
       }
 
       // remove any previous alias
-      db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
+      db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "node/$node->nid"));
 
       // set the URL for this feature page
       $url_alias = tripal_feature_get_feature_url($node);
-      path_set_alias("node/$node->nid", $url_alias);
+      $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
+      path_save($path_alias);
       break;
   }
 }
@@ -1909,6 +1705,25 @@ function tripal_feature_node_insert($node) {
  */
 function tripal_feature_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
+    case 'chado_feature':
+      // Show feature browser and counts
+      if ($view_mode == 'full') {
+        $node->content['tripal_feature_base'] = array(
+          '#value' => theme('tripal_feature_base', array('node' => $node)),
+        );
+        $node->content['tripal_feature_seqence'] = array(
+          '#value' => theme('tripal_feature_sequence', array('node' => $node)),
+        );
+        $node->content['tripal_feature_synonyms'] = array(
+          '#value' => theme('tripal_feature_synonyms', array('node' => $node)),
+        );
+      }
+      if ($view_mode == 'teaser') {
+        $node->content['tripal_feature_teaser'] = array(
+          '#value' => theme('tripal_feature_teaser', array('node' => $node)),
+        );
+      }
+      break;
     case 'chado_organism':
       // Show feature browser and counts
       if ($view_mode == 'full') {
@@ -1939,11 +1754,12 @@ function tripal_feature_node_update($node) {
   switch ($node->type) {
     case 'chado_feature':
       // remove any previous alias
-      db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => "node/$node->nid"));
+      db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "node/$node->nid"));
 
       // set the URL for this feature page
       $url_alias = tripal_feature_get_feature_url($node);
-      path_set_alias("node/$node->nid", $url_alias);
+      $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
+      path_save($path_alias);
       break;
   }
 }

+ 1 - 1
tripal_organism/tripal_organism.module

@@ -224,7 +224,7 @@ function tripal_organism_node_view($node, $view_mode, $langcode) {
           '#value' => theme('tripal_organism_base', array('node' => $node)),
         );
       }
-      if ($view_mode == 'teaster') {
+      if ($view_mode == 'teaser') {
         $node->content['tripal_organism_teaser'] = array(
           '#value' => theme('tripal_organism_teaser', array('node' => $node)),
         );

+ 2 - 1
tripal_pub/includes/tripal_pub.admin.inc

@@ -228,7 +228,8 @@ function tripal_pub_set_pub_url($node, $pub_id) {
   // remove any previous alias
   db_query("DELETE FROM {url_alias} WHERE src = :src", array(':src' => $node_url));
   // add the new alias
-  path_set_alias($node_url, $url_alias);
+  $path_alias = array("source" => $node_url, "alias" => $url_alias);
+  path_save($path_alias);
 
   return $url_alias;
 }

+ 4 - 2
tripal_stock/tripal_stock.module

@@ -1144,7 +1144,8 @@ function tripal_stock_node_insert($node) {
       
       // set the URL for this stock page
       $url_alias = tripal_stock_get_stock_url($node);
-      path_set_alias("node/$node->nid", $url_alias);
+      $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
+      path_save($path_alias);
       break;
   }
 }
@@ -1161,7 +1162,8 @@ function tripal_stock_node_update($node) {
       
       // set the URL for this stock page
       $url_alias = tripal_stock_get_stock_url($node);
-      path_set_alias("node/$node->nid", $url_alias);
+      $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
+      path_save($path_alias);
       break;
   }
 }