Przeglądaj źródła

ND module done... will need more testing with large dataset

Stephen Ficklin 11 lat temu
rodzic
commit
4b664d7114

+ 2 - 3
tripal_genetic/theme/tripal_feature/tripal_feature.genotypes.tpl.php

@@ -42,7 +42,6 @@ $feature_genotypes = $feature->feature_genotype->feature_id;
 // the total number of records for the paged query is stored in a session variable
 $total_records = $_SESSION['chado_pager'][$feature_pager_id]['total_records'];
 
-
 // now iterate through the feature genotypes and print a paged table.
 if (count($feature_genotypes) > 0) {?>
   <div id="tripal_feature-genotypes-box" class="tripal_feature-info-box tripal-info-box">
@@ -104,11 +103,11 @@ if (count($feature_genotypes) > 0) {?>
       if(count($stock_genotypes) > 0) { 
         foreach ($stock_genotypes as $stock_genotype){ 
           $stock = $stock_genotype->stock_id; 
-          $stock_name = $stock->name; 
+          $stock_name = $stock->name . ' (' . $stock->uniquename . ')'; 
           if(property_exists($stock, 'nid')) {
             $stock_name = l($stock_name, 'node/' . $stock->nid, array('attributes' => array('target' => '_blank')));
           }
-          $stock_names .= ucwords(preg_replace('/_/', ' ', $stock->type_id->name)) . ': ' . $stock_name . '<br>';
+          $stock_names .= $stock_name . '<br>';
         }
         $stock_names = substr($stock_names, 0, -4); // remove trailing <br>
       } 

+ 7 - 6
tripal_genetic/theme/tripal_stock/tripal_stock.genotypes.tpl.php

@@ -90,17 +90,18 @@ if (count($stock_genotypes) > 0) {?>
       }
       
       // build the list of marker features.
-      $markers = '';
+      $feature_names = 'N/A';
       if(count($feature_genotypes) > 0) {
+        $feature_names = '';
         foreach ($feature_genotypes as $feature_genotype){
           $feature = $feature_genotype->feature_id;
-          $fname = $feature->name;
+          $feature_name = $feature->name . ' (' . $feature->uniquename . ')';
           if(property_exists($feature, 'nid')) {
-            $fname = l($fname, 'node/' . $feature->nid, array('attributes' => array('target' => '_blank')));
+            $feature_name = l($feature_name, 'node/' . $feature->nid, array('attributes' => array('target' => '_blank')));
           }
-          $markers .= ucwords(preg_replace('/_/', ' ', $feature->type_id->name)) . ': ' . $fname . '<br>';
+          $feature_names .= $feature_name . '<br>';
         }
-        $markers = substr($markers, 0, -4); // remove trailing <br>
+        $feature_names = substr($feature_names, 0, -4); // remove trailing <br>
       }
         
       // add the fields to the table row
@@ -109,7 +110,7 @@ if (count($stock_genotypes) > 0) {?>
         $type,
         $genotype->description,
         $details,
-        $markers
+        $feature_names
       );
     } 
     

+ 8 - 10
tripal_genetic/tripal_genetic.module

@@ -106,12 +106,11 @@ function tripal_genetic_theme($existing, $type, $theme, $path) {
 function tripal_genetic_node_view($node, $view_mode, $langcode) {
   
   if ($node->type == 'chado_feature') {
-    // the tripal_natural_diversity module provides a tripal_feature_nd_genotype
-    // template.  The only difference between them is the addition of
-    // project information by the ND module's template.  Therefore,
-    // if the tripal_natural_diversity content is present then don't add the
-    // template from this module as the ND module would superceed this.
     if ($view_mode == 'full') {
+      // the tripal_natural_diversity module provides a tripal_feature_nd_genotype
+      // template.  The ND template superceeds this one. Therefore,
+      // if the tripal_natural_diversity content is present then don't add the
+      // template from this module as the ND module would superceed this.
       if (!array_key_exists('tripal_feature_nd_genotypes', $node->content)) {
         $node->content['tripal_feature_genotypes'] = array(
           '#value' => theme('tripal_feature_genotypes', array('node' => $node)),
@@ -120,12 +119,11 @@ function tripal_genetic_node_view($node, $view_mode, $langcode) {
     }
   }
   if ($node->type == 'chado_stock') {
-    // the tripal_natural_diversity module provides a tripal_stock_nd_genotype
-    // template.  The only difference between them is the addition of
-    // project information by the ND module's template.  Therefore,
-    // if the tripal_natural_diversity content is present then don't add the
-    // template from this module as the ND module would superceed this.
     if ($view_mode == 'full') {
+      // the tripal_natural_diversity module provides a tripal_stock_nd_genotype
+      // template.  The ND template superceeds this one. Therefore,
+      // if the tripal_natural_diversity content is present then don't add the
+      // template from this module as the ND module would superceed this.
       if (!array_key_exists('tripal_stock_nd_genotypes', $node->content)) {
         $node->content['tripal_stock_genotypes'] = array(
           '#value' => theme('tripal_stock_genotypes', array('node' => $node)),

+ 7 - 6
tripal_natural_diversity/theme/tripal_feature/tripal_feature.nd_genotypes.tpl.php

@@ -139,7 +139,7 @@ if (count($feature_genotypes) > 0) { ?>
             $stock = $nd_experiment_stock->stock_id;
             $stock_name = $stock->name . ' (' . $stock->uniquename . ')';
             if (property_exists($stock, 'nid')) {
-              $stock_name = l($stock_names, 'node/' . $stock->nid);
+              $stock_name = l($stock_name, 'node/' . $stock->nid);
             }
             $stock_names .= $stock_name . '<br>';
           }
@@ -152,15 +152,16 @@ if (count($feature_genotypes) > 0) { ?>
         $nd_experiment = tripal_core_expand_chado_vars($nd_experiment, 'table', 'nd_experiment_project', $options);
         $nd_experiment_projects = $nd_experiment->nd_experiment_project;
         if (count($nd_experiment_projects) > 0) {
+          $project_names = '';
           foreach ($nd_experiment_projects as $nd_experiment_project) {
             $project = $nd_experiment_project->project_id;
-            $name = $project->name;
+            $project_name = $project->name;
             if (property_exists($project, 'nid')) {
-              $name = l($name, "node/" . $project->nid, array('attributes' => array('target' => '_blank')));
+              $project_name = l($project_name, "node/" . $project->nid, array('attributes' => array('target' => '_blank')));
             }
-            $project_name .= $name . '<br>';
+            $project_names .= $project_name . '<br>';
           }
-          $project_name = substr($project_name, 0, -4); // remove trailing <br>
+          $project_names = substr($project_names, 0, -4); // remove trailing <br>
         }
       }
 
@@ -170,7 +171,7 @@ if (count($feature_genotypes) > 0) { ?>
         $genotype->description,
         $details,
         $stock_names,
-        $project_name,
+        $project_names,
       );
     } 
     

+ 15 - 14
tripal_natural_diversity/theme/tripal_stock/tripal_stock.nd_genotypes.tpl.php

@@ -52,21 +52,21 @@ $stock_pager_id = 15;
 
 // get all of the nd_experiment_stock records for this stock.
 $genotypes = array();
-$values = array('stock_id' => $stock->stock_id);
 $options = array(
-  'return_array' = 1;
+  'return_array' => 1,
   'include_fk' => array(
     'nd_experiment_id' => 1
   ),
 );
-$stock = tripal_core_expand_chado_vars($stock, 'table', 'nd_experiment_stock', $values, $options);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'nd_experiment_stock', $options);
 $nd_experiment_stocks = $stock->nd_experiment_stock;
-if ($nd_experiment_stocks) {
+dpm($stock);
+if (count($nd_experiment_stocks) > 0) {
   
   // iterate through the nd_experiment_stock records and look to see if there is
   // an nd_experiment_genotype record. If so, then add it out $genotypes array
-  foreach ($nd_experiment_stock as $nd_experiment_stock) {
-    $nd_experiment_id = $nd_experiment_stock->nd_experiment_id->nd_experiment_id
+  foreach ($nd_experiment_stocks as $nd_experiment_stock) {
+    $nd_experiment_id = $nd_experiment_stock->nd_experiment_id->nd_experiment_id;
     $nd_experiment    = $nd_experiment_stock->nd_experiment_id;
       
     // expand the nd_experiment record to include the nd_experiment_genotype table
@@ -85,7 +85,7 @@ if ($nd_experiment_stocks) {
       ),
     );
     $nd_experiment = tripal_core_expand_chado_vars($nd_experiment, 'table', 'nd_experiment_genotype', $options);
-    nd_experiment_genotypes = $nd_experiment->nd_experiment_genotype;
+    $nd_experiment_genotypes = $nd_experiment->nd_experiment_genotype;
     if ($nd_experiment_genotypes) {
       // for each of the genotypes, add them to our $genotypes array so we can 
       // display each one
@@ -166,12 +166,12 @@ if (count($genotypes) > 0) { ?>
       $genotype = tripal_core_expand_chado_vars($genotype, 'table', 'feature_genotype', $options);
       $feature_genotypes = $genotype->feature_genotype;
       if (count($feature_genotypes) > 0) {
+        $feature_names = '';
         foreach ($feature_genotypes as $feature_genotype) {
           $feature = $feature_genotype->feature_id;
-          $features[$feature->feature_id] = $feature;
           $feature_name = $feature->name . ' (' . $feature->uniquename . ')';
           if (property_exists($feature, 'nid')) {
-            $feature_name = l($feature_names, 'node/' . $feature->nid);
+            $feature_name = l($feature_name, 'node/' . $feature->nid);
           }
           $feature_names .= $feature_name . '<br>';
         }
@@ -184,15 +184,16 @@ if (count($genotypes) > 0) { ?>
       $nd_experiment = tripal_core_expand_chado_vars($nd_experiment, 'table', 'nd_experiment_project', $options);
       $nd_experiment_projects = $nd_experiment->nd_experiment_project;
       if (count($nd_experiment_projects) > 0) {
+        $project_names = '';
         foreach ($nd_experiment_projects as $nd_experiment_project) {
           $project = $nd_experiment_project->project_id;
-          $name = $project->name;
+          $project_name = $project->name;
           if (property_exists($project, 'nid')) {
-            $name = l($name, "node/" . $project->nid, array('attributes' => array('target' => '_blank')));
+            $project_name = l($project_name, "node/" . $project->nid, array('attributes' => array('target' => '_blank')));
           }
-          $project_name .= $name . '<br>';
+          $project_names .= $project_name . '<br>';
         }
-        $project_name = substr($project_name, 0, -4); // remove trailing <br>
+        $project_names = substr($project_names, 0, -4); // remove trailing <br>
       }
 
       $rows[] = array(
@@ -201,7 +202,7 @@ if (count($genotypes) > 0) { ?>
         $genotype->description,
         $details,
         $feature_names,
-        $project_name,
+        $project_names,
       );
     } 
     

+ 1 - 1
tripal_natural_diversity/theme/tripal_stock/tripal_stock.nd_phenotypes.tpl.php

@@ -94,7 +94,7 @@ if (count($phenotypes) > 0) {?>
       // add in the attribute type pheonotypes values are stored qualitatively or quantitatively. 
       // If qualitatively the cvalue_id will link to a type. If quantitative we
       // use the value column
-      $details . = ucwords(preg_replace('/_/', ' ', $phenotype->attr_id->name)) . ': ';
+      $details .= ucwords(preg_replace('/_/', ' ', $phenotype->attr_id->name)) . ': ';
       if ($phenotype->cvalue_id) { 
         $details .= ucwords(preg_replace('/_/', ' ', $phenotype->cvalue_id->name)) . '<br>';
       }

+ 28 - 23
tripal_natural_diversity/tripal_natural_diversity.module

@@ -132,19 +132,19 @@ function tripal_natural_diversity_block_view($delta = '') {
 
     $block = array();
     switch ($delta) {
-    	case 'ndfgenotype':
-    	  $block['subject'] = t('Genotypes');
-    	  $block['content'] = theme('tripal_feature_nd_genotypes', $node);
-    	  break;
-    	case 'ndsgenotype':
-    	  $block['subject'] = t('Stock Genotypes');
-    	  $block['content'] = theme('tripal_stock_nd_genotypes', $node);
-    	  break;
-    	case 'ndsphenotype':
-    	  $block['subject'] = t('Phenotypes');
-    	  $block['content'] = theme('tripal_stock_nd_phenotypes', $node);
-    	  break;
-    	default :
+      case 'ndfgenotype':
+        $block['subject'] = t('Genotypes');
+        $block['content'] = theme('tripal_feature_nd_genotypes', $node);
+        break;
+      case 'ndsgenotype':
+        $block['subject'] = t('Stock Genotypes');
+        $block['content'] = theme('tripal_stock_nd_genotypes', $node);
+        break;
+      case 'ndsphenotype':
+        $block['subject'] = t('Phenotypes');
+        $block['content'] = theme('tripal_stock_nd_phenotypes', $node);
+        break;
+      default :
     }
     return $block;
   }
@@ -154,13 +154,12 @@ function tripal_natural_diversity_block_view($delta = '') {
  * @ingroup tripal_natural_diversity
  */
 function tripal_natural_diversity_node_view($node, $view_mode, $langcode) {
-    if ($node->type == 'chado_feature') {
-      // the tripal_genetic module provides a tripal_feature_genotype
-      // template.  The only difference between them is the addition of
-      // project information by this module's template.  Therefore,
-      // if the tripal_genetic content is present get rid of it as this
-      // module superceeds it.
+  switch ($node->type) {
+    case 'chado_feature':
       if ($view_mode == 'full') {
+        // the tripal_genetic module provides a tripal_feature_genotype
+        // template. if the tripal_genetic content is present get rid of it as this
+        // module superceeds it.      
         if (array_key_exists('tripal_feature_genotypes', $node->content)) {
           unset($node->content['tripal_feature_genotypes']);
         }
@@ -168,9 +167,15 @@ function tripal_natural_diversity_node_view($node, $view_mode, $langcode) {
            '#value' => theme('tripal_feature_nd_genotypes', array('node' => $node)),
         );
       }
-    }
-    if ($node->type == 'chado_stock') {
+      break;
+    case 'chado_stock':
       if ($view_mode == 'full') {
+        // the tripal_genetic module provides a tripal_stock_genotype
+        // template. if the tripal_genetic content is present get rid of it as this
+        // module superceeds it.
+        if (array_key_exists('tripal_stock_genotypes', $node->content)) {
+          unset($node->content['tripal_stock_genotypes']);
+        }
         $node->content['tripal_stock_nd_genotypes'] = array(
            '#value' => theme('tripal_stock_nd_genotypes', array('node' => $node)),
         );
@@ -178,6 +183,6 @@ function tripal_natural_diversity_node_view($node, $view_mode, $langcode) {
            '#value' => theme('tripal_stock_nd_phenotypes', array('node' => $node)),
         );
       }
-    }
-    break;
+      break;
+  }
 }