spficklin преди 14 години
родител
ревизия
059818cc72

+ 9 - 14
theme_tripal/node-chado_feature.tpl.php

@@ -26,7 +26,7 @@
  //print '<pre>'.print_r($variables,TRUE).'</pre>';
 drupal_add_css('./tripal-node-templates.css');
 $feature  = $variables['node']->feature;
-dpm($feature);
+//dpm($feature);
 ?>
 
 <?php if ($teaser) { 
@@ -91,13 +91,11 @@ if (Drupal.jsEnabled) {
 
    <!-- Sequence -->
    <?php 
-   if($feature->type_id->name == 'scaffold' or 
-      $feature->type_id->name == 'chromosome' or
-      $feature->type_id->name == 'pseudomolecule')
+   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)
    {
-      // don't even try to load the sequence for really big feature types.
-   } 
-   else {
       include('tripal_feature/tripal_feature_sequence.tpl.php'); 
    }
    ?>
@@ -110,14 +108,11 @@ if (Drupal.jsEnabled) {
 
    <!-- Feature locations -->
    <?php 
-   if($feature->type_id->name == 'scaffold' or 
-      $feature->type_id->name == 'chromosome' or
-      $feature->type_id->name == 'pseudomolecule')
+   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)
    {
-      // don't even try to load the feature locations for features that are typically
-      // very large landmarks
-   } 
-   else {
       include('tripal_feature/tripal_feature_featurelocs.tpl.php'); 
    }
    ?>

+ 3 - 3
theme_tripal/node-chado_organism.tpl.php

@@ -25,8 +25,8 @@
  //uncomment this line to see a full listing of the fields avail. to $node
  //print '<pre>'.print_r($variables,TRUE).'</pre>';
 drupal_add_css('./tripal-node-templates.css');
-$node = $variables['node'];
 $organism = $variables['node']->organism;
+//dpm($organism);
 ?>
 
 <?php if ($teaser) { 
@@ -91,8 +91,8 @@ if (Drupal.jsEnabled) {
 
 <!-- Table of contents -->
 <div id="tripal_organism_toc" class="tripal_toc">
-   <div id="tripal_organism_toc_title" class="tripal_toc_title">Resources for <br><i><?php print $organism->genus ?> <?php print $organism->species ?></i></div>
-   <span id="tripal_organism_toc_desc" class="tripal_toc_desc">Select a link below for more information</span>
+   <div id="tripal_organism_toc_title" class="tripal_toc_title">Resources</i></div>
+   <span id="tripal_organism_toc_desc" class="tripal_toc_desc"></span>
    <ul id="tripal_organism_toc_list" class="tripal_toc_list">
 
    </ul>

+ 2 - 3
theme_tripal/tripal_feature/tripal_feature_base.tpl.php

@@ -34,9 +34,8 @@ $feature  = $variables['node']->feature;
       <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
         <th>Organism</th>
         <td>
-          <?php if ($node->org_nid) { ?>
-      	   <a href="<?php print url("node/$org_nid") ?>"><?php print $organism->genus ." " . $organism->species ." (" .$organism->common_name ." )"?></a>
-      	 <?php 
+          <?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 .")";
           } ?>

+ 20 - 2
theme_tripal/tripal_feature/tripal_feature_featureloc_sequences.tpl.php

@@ -1,10 +1,28 @@
 <?php
-$featureloc_sequences = $variables['tripal_feature']['featureloc_sequences'];
+// get the featurelocs for this feature. If the variable is not already 
+// expanded then do so
+$feature = $variables['node']->feature;
+$featurelocs = $feature->featureloc;
+if(!$featurelocs){
+   // expand the feature object to include the featureloc records.  there are
+   // two foreign key relationships with featureloc and feature (srcefeature_id and
+   // feature_id).  This will expand both
+   $feature = tripal_core_expand_chado_vars($feature,'table','featureloc');
+}
+// get the featurelocs. if only one featureloc exists then we want to convert
+// the object into an array, otherwise the value is an array
+$ffeaturelocs = $feature->featureloc->feature_id;
+if (!$ffeaturelocs) {
+   $ffeaturelocs = array();
+} elseif (!is_array($ffeaturelocs)) { 
+   $ffeaturelocs = array($ffeaturelocs); 
+}
+$featureloc_sequences = tripal_feature_load_featureloc_sequences ($feature->feature_id,$ffeaturelocs);
 
 if(count($featureloc_sequences) > 0){
    foreach($featureloc_sequences as $src => $attrs){ ?>
        <div id="tripal_feature-<?php print $attrs['type']?>-box" class="tripal_feature-info-box tripal-info-box">
-         <div class="tripal_feature-info-box-title tripal-info-box-title"><?php print $attrs['type']?> Formatted Sequence</div>
+         <div class="tripal_feature-info-box-title tripal-info-box-title"><?php print $attrs['type']?> Colored Sequence</div>
          <div class="tripal_feature-info-box-desc tripal-info-box-desc"></div>
             <?php print $attrs['formatted_seq'] ?>
        </div>       

+ 7 - 7
theme_tripal/tripal_feature/tripal_feature_featurelocs.tpl.php

@@ -2,6 +2,11 @@
 
 $feature = $variables['node']->feature;
 
+// expand the feature object to include the featureloc records.  there are
+// two foreign key relationships with featureloc and feature (srcefeature_id and
+// feature_id).  This will expand both
+$feature = tripal_core_expand_chado_vars($feature,'table','featureloc');
+
 // get the featurelocs. if only one featureloc exists then we want to convert
 // the object into an array, otherwise the value is an array
 $ffeaturelocs = $feature->featureloc->feature_id;
@@ -40,16 +45,11 @@ if (!$sfeaturelocs) {
          } 
          $location = $featureloc->srcfeature_id->name .":".$featureloc->fmin . ".." . $featureloc->fmax;
          if($location->srcfeature_id->nid){
-           $location = "<a href=\"" . url("node/$location->srcfeature_id->nid") . "\">".$featureloc->srcfeature_id->name .":".$featureloc->fmin . ".." . $featureloc->fmax ."</a> ";
+           $location = "<a href=\"" . url("node/".$location->srcfeature_id->nid) . "\">".$featureloc->srcfeature_id->name .":".$featureloc->fmin . ".." . $featureloc->fmax ."</a> ";
          }
          ?>
          <tr class="<?php print $class ?>">
-           <td><?php 
-              if($featureloc->feature_id->nid){
-                 print "<a href=\"" . url("node/".$featureloc->feature_id->name) . "\">".$featureloc->feature_id->name."</a>";
-              } else {
-                 print $featureloc->feature_id->name;
-              }?>
+           <td><?php print $featureloc->feature_id->name;?>
            </td>
            <td><?php print $featureloc->feature_id->type_id->name ?></td>
            <td><?php print $location ?></td>

+ 53 - 19
theme_tripal/tripal_feature/tripal_feature_libraries.tpl.php

@@ -1,19 +1,53 @@
-<!-- Add library information which this feature belongs to-->
-           	<?php if ($node->lib_additions) { ?>
-               <tr><th>Library</th><td>
-                  <?php
-                     $libraries = $node->lib_additions;
-                     foreach ($libraries as $lib_url => $lib_name) {
-                        // Check if library exists as a node in drupal
-                        if ($lib_url) {
-                  ?>
-                     <a href="<?php print $lib_url?>"><?php print $lib_name?></a><BR>
-                  <?php
-                        } else {
-                           print $lib_name;
-                        }
-                     }
-                  ?>
-               </td></tr>
-            <?php } ?>
-            <!-- End of library addition -->
+<?php
+$feature = $variables['node']->feature;
+
+// expand the feature object to include the libraries from the library_feature
+// table in chado.
+$feature = tripal_core_expand_chado_vars($feature,'table','library_feature');
+
+// get the references. if only one reference exists then we want to convert
+// the object into an array, otherwise the value is an array
+$library_features = $feature->library_feature;
+if (!$library_features) {
+   $library_features = array();
+} elseif (!is_array($library_features)) { 
+   $library_features = array($library_features); 
+}
+
+?>
+<div id="tripal_feature-libraries-box" class="tripal_feature-info-box tripal-info-box">
+  <div class="tripal_feature-info-box-title tripal-info-box-title">Libraries</div>
+  <div class="tripal_feature-info-box-desc tripal-info-box-desc">This <?php print $feature->type_id->name ?> is derived, or can be located in the following libraries</div>
+  <?php if(count($library_features) > 0){ ?>
+  <table id="tripal_feature-libraries-table" class="tripal_feature-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Library Name</th>
+      <th>Type</th>
+    </tr>
+    <?php
+    $i = 0; 
+    foreach ($library_features as $library_feature){
+      $class = 'tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal-table-even-row';
+      }
+      ?>
+      <tr class="<?php print $class ?>">
+        <td><?php 
+          if($library_feature->library_id->nid){
+             print "<a href=\"". url("node/".$library_feature->library_id->nid) . "\">".$library_feature->library_id->name."</a>";
+          } else {
+             print $library_feature->library_id->name;
+          }
+        ?>
+        </td>
+        <td><?php print $library_feature->library_id->type_id->name?></td>
+      </tr>
+      <?php
+      $i++;  
+    } ?>
+  </table>
+  <?php } else { ?>
+    <div class="tripal-no-results">There are no libraries</div> 
+  <?php }?>
+</div>

+ 4 - 0
theme_tripal/tripal_feature/tripal_feature_references.tpl.php

@@ -1,6 +1,10 @@
 <?php
 $feature = $variables['node']->feature;
 
+// expand the feature object to include the external references stored
+// in the feature_dbxref table
+$feature = tripal_core_expand_chado_vars($feature,'table','feature_dbxref');
+
 // get the references. if only one reference exists then we want to convert
 // the object into an array, otherwise the value is an array
 $references = $feature->feature_dbxref;

+ 6 - 0
theme_tripal/tripal_feature/tripal_feature_relationships.tpl.php

@@ -2,6 +2,12 @@
 
 $feature = $variables['node']->feature;
 
+// expand the feature object to include the feature relationships.
+// since there two foreign keys (object_id and subject_id) in the 
+// feature_relationship table, we will access each one separately 
+$feature = tripal_core_expand_chado_vars($feature,
+   'table','feature_relationship', array('order_by'=>array('rank' => 'ASC')));
+
 // get the featurelocs. if only one featureloc exists then we want to convert
 // the object into an array, otherwise the value is an array
 $orelationships = $feature->feature_relationship->object_id;

+ 5 - 0
theme_tripal/tripal_feature/tripal_feature_sequence.tpl.php

@@ -1,5 +1,10 @@
 <?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');
+
 ?>
 <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"><?php print $feature->type_id->name ?> Sequence</div>

+ 4 - 0
theme_tripal/tripal_feature/tripal_feature_synonyms.tpl.php

@@ -1,6 +1,10 @@
 <?php
 $feature = $variables['node']->feature;
 
+// expand the feature object to include the synonyms from the feature_synonym 
+// table in chado.
+$feature = tripal_core_expand_chado_vars($feature,'table','feature_synonym');
+
 // get the references. if only one reference exists then we want to convert
 // the object into an array, otherwise the value is an array
 $synonyms = $feature->feature_synonym;

+ 9 - 15
theme_tripal/tripal_feature/tripal_feature_teaser.tpl.php

@@ -1,24 +1,19 @@
 <?php
 
 $feature  = $variables['node']->feature;
-$accession = $variables['node']->accession;
-$organism = $variables['node']->organism;
-$org_nid = $variables['node']->org_nid;
 
 ?>
 <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">
-    <?php print l($feature->featurename, 'node/'.$node->nid); ?>
-  </div>
+  <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>
 
-   <?php if($feature->is_obsolete == 't'){ ?>
-      <div class="tripal_feature-obsolete">This feature is obsolete and no longer used in analysis, but is here for reference</div>
+   <?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-odd-row tripal-table-even-row">
         <th>Name</th>
-        <td><?php print $feature->featurename; ?></td>
+        <td><?php print $feature->name; ?></td>
       </tr>
       <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
         <th nowrap>Unique Name</th>
@@ -26,7 +21,7 @@ $org_nid = $variables['node']->org_nid;
       </tr>
       <tr class="tripal_feature-table-odd-row tripal-table-even-row">
         <th>Internal ID</th>
-        <td><?php print $accession; ?></td>
+        <td><?php print $feature->feature_id; ?></td>
       </tr>
       <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
         <th>Length</th>
@@ -34,16 +29,15 @@ $org_nid = $variables['node']->org_nid;
       </tr>
       <tr class="tripal_feature-table-odd-row tripal-table-even-row">
         <th>Type</th>
-        <td><?php print $feature->cvname; ?></td>
+        <td><?php print $feature->type_id->name; ?></td>
       </tr>
       <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
         <th>Organism</th>
         <td>
-          <?php if ($node->org_nid) { ?>
-      	   <a href="<?php print url("node/$org_nid") ?>"><?php print $organism->genus ." " . $organism->species ." (" .$organism->common_name ." )"?></a>
-      	 <?php 
+          <?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 $organism->genus ." " . $organism->species ." (" .$organism->common_name ." )";
+            print $feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")";
           } ?>
         </td>
      	</tr>           	                                

+ 30 - 6
theme_tripal/tripal_organism/tripal_organism_library_list.tpl.php → theme_tripal/tripal_organism/tripal_organism_libraries.tpl.php

@@ -1,6 +1,20 @@
 <?php
 $organism = $variables['node']->organism;
-$libraries = $variables['tripal_library']['libraries'];
+
+// expand the organism object to include the libraries from the library
+// table in chado.
+$organism = tripal_core_expand_chado_vars($organism,'table','library');
+
+
+// get the references. if only one reference exists then we want to convert
+// the object into an array, otherwise the value is an array
+$libraries = $organism->library;
+if (!$libraries) {
+   $libraries = array();
+} elseif (!is_array($libraries)) { 
+   $libraries = array($libraries); 
+}
+
 ?>
 <div id="tripal_organism-library_list-box" class="tripal_organism-info-box tripal-info-box">
   <div class="tripal_organism-info-box-title tripal-info-box-title">Libraries</div>
@@ -14,6 +28,10 @@ $libraries = $variables['tripal_library']['libraries'];
       </tr>
       <?php
       foreach ($libraries as $library){ 
+      // expand the library to include the properties.
+      $library = tripal_core_expand_chado_vars($library,'table','libraryprop');
+      $library = tripal_core_expand_chado_vars($library,'field','libraryprop.value');
+
       $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
       if($i % 2 == 0 ){
          $class = 'tripal_organism-table-odd-row tripal-table-even-row';
@@ -22,22 +40,28 @@ $libraries = $variables['tripal_library']['libraries'];
       <tr class="<?php print $class ?>">
         <td><?php 
            if($library->nid){    
-              $link =   url("node/$library->nid");        
+              $link =  url("node/$library->nid");        
               print "<a href=\"$link\">$library->name</a>";
            } else {
               print $library->name;
            }
            ?>
         </td>
-        <td><?php print $library->description?></td>
+        <td><?php 
+           // right now we only have one property for libraries. So we can just
+           // refernece it directly.  If we had more than one property
+           // we would need to convert this to an if statment and loop
+           // until we found the right one.
+           print $library->libraryprop->value?>
+        </td>
         <td>
           <?php 
-            if ($library->cvname == 'cdna_library') {
+            if ($library->type_id->name == 'cdna_library') {
                print 'cDNA';
-            } else if ($library->cvname == 'bac_library') {
+            } else if ($library->type_id->name == 'bac_library') {
                print 'BAC';
             } else {
-               print $library->cvname;
+               print $library->type_id->name;
             }
           ?>
         </td>

+ 11 - 114
tripal_feature/tripal_feature.module

@@ -685,6 +685,8 @@ function chado_feature_form ($node,$param){
 
    $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
@@ -909,8 +911,9 @@ function chado_feature_validate($node){
  * @ingroup tripal_feature
  */
 function chado_feature_load($node){
-   // find the organism and add in the details
+   // get the feature details from chado
    $feature_id = chado_get_id_for_node('feature',$node);
+
    $values = array('feature_id' => $feature_id);
    $feature = tripal_core_generate_chado_var('feature',$values);
 
@@ -1248,13 +1251,13 @@ function tripal_feature_load_featureloc_sequences($feature_id,$featurelocs){
       $rel_featurelocs = tripal_feature_load_featurelocs ($rel->subject_id,'as_child',0);   
       foreach($rel_featurelocs as $rfindex => $rel_featureloc){
          // keep track of this unique source feature
-         $src = $rel_featureloc->src_feature_id ."-". $rel_featureloc->src_type_id;
+         $src = $rel_featureloc->src_feature_id ."-". $rel_featureloc->src_cvterm_id;
 
          // copy over the results to the relationship object.  Since there can
          // be more than one feature location for each relationship feature we 
          // use the '$src' variable to keep track of these.
          $rel->featurelocs->$src->src_uniquename = $rel_featureloc->src_uniquename;
-         $rel->featurelocs->$src->src_type_id    = $rel_featureloc->src_type_id;
+         $rel->featurelocs->$src->src_cvterm_id  = $rel_featureloc->src_cvterm_id;
          $rel->featurelocs->$src->src_cvname     = $rel_featureloc->src_cvname;
          $rel->featurelocs->$src->fmin           = $rel_featureloc->fmin;
          $rel->featurelocs->$src->fmax           = $rel_featureloc->fmax;
@@ -1275,13 +1278,14 @@ function tripal_feature_load_featureloc_sequences($feature_id,$featurelocs){
    // locations determiend above. 
    $sql = "SELECT residues FROM {feature} WHERE feature_id = %d";
    $floc_sequences = array();
-   foreach ($featurelocs as $findex => $featureloc){
+   foreach ($featurelocs as $featureloc){
       // get the residues for this feature
       $previous_db = tripal_db_set_active('chado');  // use chado database
-      $feature = db_fetch_object(db_query($sql,$featureloc->src_feature_id));
+      $feature = db_fetch_object(db_query($sql,$featureloc->srcfeature_id->feature_id));
       tripal_db_set_active($previous_db);  // now use drupal database
 
-      $src = $featureloc->src_feature_id ."-". $featureloc->src_type_id;
+      $src = $featureloc->srcfeature_id->feature_id ."-". $featureloc->srcfeature_id->type_id->cvterm_id;
+
       // orient the parts to the beginning of the feature sequence
       $parts = $rel_locs[$src]['parts'];
       usort($parts, 'tripal_feature_sort_rel_parts');
@@ -1290,7 +1294,7 @@ function tripal_feature_load_featureloc_sequences($feature_id,$featurelocs){
          $parts[$start]['end']   = $parts[$start]['end'] - $featureloc->fmin;
       }      
       $floc_sequences[$src]['src'] = $src;
-      $floc_sequences[$src]['type'] = $featureloc->cvname;
+      $floc_sequences[$src]['type'] = $featureloc->feature_id->type_id->name;
       $sequence = substr($feature->residues,$featureloc->fmin-1,($featureloc->fmax - $featureloc->fmin)+1);
       $floc_sequences[$src]['formatted_seq'] =  tripal_feature_color_sequence (
           $sequence,$parts);
@@ -1604,33 +1608,6 @@ function tripal_feature_theme () {
    );
 }
 
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess(&$variables){
-
-   // if the template file is the default node template file then we want
-   // to add all of our variables.
-   if($variables['template_files'][0] == 'node-chado_feature'){
-      $feature = $variables['node']->feature;
-
-//      $variables['tripal_feature']['object_relationships'] = tripal_feature_get_aggregate_relationships($feature->feature_id,0);
-//      $variables['tripal_feature']['subject_relationships'] = tripal_feature_load_relationships($feature->feature_id,'as_subject');
-//      $variables['tripal_feature']['featurelocs_as_child'] = tripal_feature_load_featurelocs($feature->feature_id,'as_child',0);
-//      $variables['tripal_feature']['featurelocs_as_parent'] = tripal_feature_load_featurelocs($feature->feature_id,'as_parent');
-
-      $variables['node']->feature = tripal_core_expand_chado_vars($feature,'table','feature_dbxref');
-      $variables['node']->feature = tripal_core_expand_chado_vars($feature,'table','feature_synonym');
-      $variables['node']->feature = tripal_core_expand_chado_vars($feature,'table','featureloc');
-      $variables['node']->feature = tripal_core_expand_chado_vars($feature,'table','feature_relationship',
-         array('order_by'=>array('rank' => 'ASC')));
-
-      $featurelocs = $variables['tripal_feature']['featurelocs_as_child'];
-      $variables['tripal_feature']['featureloc_sequences'] = tripal_feature_load_featureloc_sequences ($feature->feature_id,$featurelocs);   
-   }
-}
 
 /**
  *
@@ -1652,86 +1629,6 @@ function tripal_feature_preprocess_tripal_organism_feature_browser(&$variables){
    $variables['tripal_feature']['browser'] = tripal_feature_load_organism_feature_browser($organism);
 }
 
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_properties(&$variables){
-   $feature = $variables['node']->feature;
-   $variables['tripal_feature']['properties'] = tripal_feature_load_properties($feature->feature_id);
-}
-
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_synonyms(&$variables){
-   $feature = $variables['node']->feature;
-   $variables['tripal_feature']['synonyms'] = tripal_feature_load_synonyms($feature->feature_id);
-}
-
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_relationships_as_object(&$variables){
-   $feature = $variables['node']->feature;
-   $variables['tripal_feature']['object_relationships'] = tripal_feature_get_aggregate_relationships($feature->feature_id,0);
-}
-
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_relationships_as_subject(&$variables){
-   $feature = $variables['node']->feature;
-   $variables['tripal_feature']['subject_relationships'] = tripal_feature_load_relationships($feature->feature_id,'as_subject');
-}
-
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_featurelocs_as_child(&$variables){
-   $feature = $variables['node']->feature;
-   $variables['tripal_feature']['featurelocs_as_child'] = tripal_feature_load_featurelocs($feature->feature_id,'as_child',0);
-}
-
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_featurelocs_as_parent(&$variables){
-   $feature = $variables['node']->feature;
-   $variables['tripal_feature']['featurelocs_as_parent'] = tripal_feature_load_featurelocs($feature->feature_id,'as_parent');
-}
-
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_references(&$variables){
-   $feature = $variables['node']->feature;
-   $variables['tripal_feature']['references'] = tripal_feature_load_references($feature->feature_id);
-}
-
-/**
- *  
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_preprocess_tripal_feature_featureloc_sequences(&$variables){
-   $feature = $variables['node']->feature;
-   $featurelocs = tripal_feature_load_featurelocs($feature->feature_id,'as_child',0);
-   $variables['tripal_feature']['featureloc_sequences'] = tripal_feature_load_featureloc_sequences ($feature->feature_id,$featurelocs);   
-}
 
 /**
  *

+ 32 - 1
tripal_library/tripal_library.api.inc

@@ -71,4 +71,35 @@ function tripal_library_chado_library_feature_schema() {
   );
   
   return $description;
-}
+}
+/**
+ * Implements hook_chado_libraryprop_schema()
+ * Purpose: To add descriptions and foreign keys to default table description
+ * Note: This array will be merged with the array from all other implementations
+ *
+ * @return
+ *    Array describing the libraryprop table
+ *
+ * @ingroup tripal_library
+ */
+function tripal_library_chado_libraryprop_schema() {
+  $description = array();
+  
+  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_library_feature_schema()
+
+  $description['foreign keys']['library'] = array(
+        'table' => 'library',
+        'columns' => array(
+          'library_id' => 'library_id',
+        ),
+  );  
+  
+  $description['foreign keys']['cvterm'] = array(
+        'table' => 'cvterm',
+        'columns' => array(
+          'type_id' => 'cvterm_id',
+        ),
+  );
+  
+  return $description;
+}

+ 14 - 81
tripal_library/tripal_library.module

@@ -213,8 +213,14 @@ function tripal_library_nodeapi(&$node, $op, $teaser, $page) {
             switch($node->type){
                case 'chado_organism':
                   // Show library if the organism/feature is not at teaser view
-                  $node->content['tripal_organism_library_list'] = array(
-					      '#value' => theme('tripal_organism_library_list', $node),
+                  $node->content['tripal_organism_libraries'] = array(
+					      '#value' => theme('tripal_organism_libraries', $node),
+                  );
+                  break;
+               case 'chado_feature':
+                  // Show library if the organism/feature is not at teaser view
+                  $node->content['tripal_feature_libraries'] = array(
+					      '#value' => theme('tripal_feature_libraries', $node),
                   );
                   break;
             }
@@ -239,89 +245,16 @@ function tripal_library_theme () {
       'tripal_library_search_result' => array (
          'arguments' => array('node'),
       ),
-      'tripal_organism_library_list' => array (
+      'tripal_organism_libraries' => array (
          'arguments' => array('node'=> null),
-         'template' => 'tripal_organism_library_list',
+         'template' => 'tripal_organism_libraries',
+      ),
+      'tripal_feature_libraries' => array (
+         'arguments' => array('node'=> null),
+         'template' => 'tripal_feature_libraries',
       )
    );
 }
-/*******************************************************************************
- *  
- */
-function tripal_library_preprocess_tripal_organism_library_list(&$variables){
-   $organism = $variables['node']->organism;
-   $variables['tripal_library']['libraries'] = tripal_library_load_organism_library_list($organism);
-}
-/************************************************************************
- * 
- */
-function tripal_library_load_organism_library_list ($organism) {
-
-   // get the libraries for the organism
-   $sql = "SELECT L.library_id, L.organism_id, L.name, L.uniquename, ".
-          "   L.type_id, CVT.name as cvname, CVT.definition ".
-          "FROM {library} L ".
-          "  INNER JOIN CVTerm CVT ON CVT.cvterm_id = L.type_id ".
-    	  	 "WHERE L.Organism_id = %d";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-
-   // iterate through all of the libraries and add in the node and 
-   // library description
-   $nsql = "SELECT nid FROM {chado_feature} ".
-           "WHERE feature_id = %d";
-   $dsql = "SELECT * FROM {libraryprop} LP ".
-     	    "  INNER JOIN CVTerm CVT ON CVT.cvterm_id = LP.type_id ".
-          "WHERE LP.library_id = %d ".
-          "  AND CVT.name = 'library_description'";
-   $i=0;
-   $libraries = array();
-   while($library = db_fetch_object($results)){
-      // get the description
-      $previous_db = tripal_db_set_active('chado');
-      $desc = db_fetch_object(db_query($dsql,$library->library_id));
-      tripal_db_set_active($previous_db);
-      // get the node
-      $node = db_fetch_object(db_query($nsql,$feature->feature_id));
-      // add the description and the node to the library
-      $library->nid = $node->nid;
-      $library->description = $desc->value;
-      $libraries[$i++] = $library;
-   }
-
-   return $libraries;           
-}
-/************************************************************************
- * 
- */
-function tripal_library_load_feature_library_list ($feature) {
-
-
-      $content = "";
-      $organism_id = $node->feature->organism_id;
-      $previous_db = tripal_db_set_active('chado');
-      $sql = "SELECT * FROM {library} L ".
-             "  INNER JOIN Library_feature LF ON L.library_id = LF.library_id ".
-       	  	 "WHERE LF.feature_id = " . $node->feature->feature_id;
-      $libraries = array();
-      $results = db_query($sql);
-      while($library = db_fetch_object($results)){
-         $libraries[] = $library;
-      }
-      tripal_db_set_active($previous_db);
-      if(count($libraries) > 0){
-         $lib_additions = array();
-         foreach ($libraries as $library){
-            $content .= "Library: ".$library->name;
-         };
-      }
-
-   return $content;
-
-
-}
 
 /************************************************************************
  * This function is an extension of the chado_feature_view and