|
@@ -7,11 +7,11 @@
|
|
|
* stock => nd_experiment_stock => nd_experiment => nd_experiment_phenotype => phenotype.
|
|
|
*
|
|
|
* You can find ancillary information about data associated with a phenotype such as
|
|
|
- * a contact, pub, protocol, project, genotype, dbxref by using the
|
|
|
+ * a contact, pub, protocol, project, phenotype, dbxref by using the
|
|
|
* nd_experiment.nd_experiment_id value and traversing the other FK relationships
|
|
|
*
|
|
|
* stock => nd_experiment_stock => nd_experiment => nd_experiment_phenotype => phenotype
|
|
|
- * => nd_experiment_genotype => genotype
|
|
|
+ * => nd_experiment_phenotype => phenotype
|
|
|
* => nd_experiment_project => project
|
|
|
* => nd_experiment_pub => pub
|
|
|
* => nd_experiment_contact => contact
|
|
@@ -22,51 +22,69 @@
|
|
|
*
|
|
|
* In the FK relationships shown above, the nd_experiment_id value represents a single
|
|
|
* experimental value that may have all of the ancilliary data associated with it.
|
|
|
- * If the phenotype record shares an nd_experiment_id with a genotype, pub, contact,
|
|
|
+ * If the phenotype record shares an nd_experiment_id with a phenotype, pub, contact,
|
|
|
* protocol, etc then all of that data is associated with the phenotype and vice-versa.
|
|
|
*
|
|
|
* Techincally, we can skip including the 'nd_experiment' table when traversing the FK's
|
|
|
* because we have the nd_experiment_id value when we get the nd_experiment_stock record.
|
|
|
*
|
|
|
+ * When lots of phenotypes are associated with a stock (e.g. thousands) then traversing
|
|
|
+ * the FK relationships as described above can be very slow. Ideally, we only need to
|
|
|
+ * show a small subset with a pager. Therefore, a list of nd_experiment_phenotype_id's
|
|
|
+ * are provided to this template automatically within the stock object.
|
|
|
+ *
|
|
|
*/
|
|
|
|
|
|
|
|
|
$stock = $variables['node']->stock;
|
|
|
|
|
|
-
|
|
|
-$options = array('return_array' => 1);
|
|
|
-$stock = tripal_core_expand_chado_vars($stock, 'table', 'nd_experiment_stock', $options);
|
|
|
-$nd_experiment_stocks = $stock->nd_experiment_stock;
|
|
|
+
|
|
|
+$num_results_per_page = 25;
|
|
|
+$stock_pager_id = 10;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+$nd_experiment_phenotype_ids = $stock->nd_experiment_phenotype_ids;
|
|
|
+$total_records = count($nd_experiment_phenotype_ids);
|
|
|
+
|
|
|
+
|
|
|
+$current_page_num = pager_default_initialize($total_records, $num_results_per_page, $stock_pager_id);
|
|
|
+$offset = $num_results_per_page * $current_page_num;
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
$phenotypes = array();
|
|
|
-if (count($nd_experiment_stocks) > 0) {
|
|
|
+if ($total_records > 0) {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- foreach ($nd_experiment_stocks as $nd_experiment_stock){
|
|
|
-
|
|
|
-
|
|
|
- $nd_experiment_id = $nd_experiment_stock->nd_experiment_id->nd_experiment_id;
|
|
|
-
|
|
|
-
|
|
|
- $values = array('nd_experiment_id' => $nd_experiment_id);
|
|
|
- $nd_experiment_phenotypes = tripal_core_generate_chado_var('nd_experiment_phenotype', $values, $options);
|
|
|
-
|
|
|
-
|
|
|
- if ($nd_experiment_phenotypes) {
|
|
|
- foreach ($nd_experiment_phenotypes as $nd_experiment_phenotype){
|
|
|
- $phenotype = $nd_experiment_phenotype->phenotype_id;
|
|
|
- $phenotypes[$nd_experiment_id]['phenotype'] = $phenotype;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ for ($i = $offset ; $i < $offset + $num_results_per_page; $i++) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $options = array(
|
|
|
+ 'return_array' => 1,
|
|
|
+ 'include_fk' => array(
|
|
|
+ 'phenotype_id' => array(
|
|
|
+ 'type_id' => 1,
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ $values = array('nd_experiment_phenotype_id' => $nd_experiment_phenotype_id);
|
|
|
+ $nd_experiment_phenotype = chado_generate_var('nd_experiment_phenotype', $values);
|
|
|
+ $phenotype = $nd_experiment_phenotype->phenotype_id;
|
|
|
+ $phenotypes[$phenotype->phenotype_id]['phenotype'] = $phenotype;
|
|
|
+ $phenotypes[$phenotype->phenotype_id]['nd_experiment_id'] = $nd_experiment_phenotype->nd_experiment_id->nd_experiment_id;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (count($phenotypes) > 0) {?>
|
|
|
- <div class="tripal_stock-data-block-desc tripal-data-block-desc">This following phenotypes have been recorded for this stock.</div><?php
|
|
|
+ <div class="tripal_stock-data-block-desc tripal-data-block-desc">
|
|
|
+ The following <?php print number_format($total_records) ?> phenotypes(s) have been recorded.
|
|
|
+ </div><?php
|
|
|
|
|
|
|
|
|
|
|
@@ -81,8 +99,13 @@ if (count($phenotypes) > 0) {?>
|
|
|
|
|
|
|
|
|
|
|
|
- foreach ($phenotypes as $nd_experiment_id => $phenotype){
|
|
|
-
|
|
|
+ foreach ($phenotypes as $info){
|
|
|
+ $phenotype = $info['phenotype'];
|
|
|
+ $nd_experiment_id = $info['nd_experiment_id'];
|
|
|
+
|
|
|
+
|
|
|
+ $nd_experiment = chado_generate_var('nd_experiment', array('nd_experiment_id' => $nd_experiment_id));
|
|
|
+
|
|
|
$details = '';
|
|
|
|
|
|
if ($phenotype->name) {
|
|
@@ -154,4 +177,20 @@ if (count($phenotypes) > 0) {?>
|
|
|
|
|
|
|
|
|
print theme_table($table);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $pager = array(
|
|
|
+ 'tags' => array(),
|
|
|
+ 'element' => $stock_pager_id,
|
|
|
+ 'parameters' => array(
|
|
|
+ 'block' => 'genotypes'
|
|
|
+ ),
|
|
|
+ 'quantity' => $num_results_per_page,
|
|
|
+ );
|
|
|
+ print theme_pager($pager);
|
|
|
}
|