26 if (empty($accession)) {
27 $query = db_select(
'chado.plusgeno_view',
'pg');
28 $query->addExpression(
'count(distinct(accession))',
'count');
29 $query = $query->execute();
30 $num_studies = $query->fetchObject()->count;
32 $query = db_select(
'chado.plusgeno_view',
'pg');
33 $query->addExpression(
'count(distinct(species))',
'count');
34 $query = $query->execute();
35 $num_species = $query->fetchObject()->count;
37 $tpps_link =
"<b><a target=\"blank\" href=\"/tpps\">submit your study</a></b>";
38 $output .=
"This page reflects community submissions associated with published studies. Each submission is associated with a longterm identifier that connects the genotype, phenotype, and/or environmental metrics assessed. These studies represent diversity assessements, association mapping, and landscape genomics. We accept studies with a variety of marker types. We encourage you to $tpps_link to TreeGenes and utilize the provided accession in your publication. We currently have <b>$num_studies</b> studies representing <b>$num_species</b> species.";
39 if (module_exists(
'cartogratree')) {
40 $output .=
" Studies that have georeferenced accessions associated with them can be queried on <b><a href=\"cartogratree\">CartograPlant.</a></b>";
42 $form = drupal_get_form(
'tpps_details_search');
43 $output .= render($form);
46 drupal_add_css(drupal_get_path(
'module',
'tpps') .
TPPS_CSS_PATH);
47 drupal_add_js(drupal_get_path(
'module',
'tpps') .
TPPS_JS_PATH);
51 $output =
"<a href=\"$base_url/tpps/details\">Return to TPPS Details</a>$output";
54 if ($state[
'status'] !=
'Approved') {
55 drupal_set_message(t(
'This submission is still under construction. Some of the information may be available here, but please keep in mind that it may be incomplete or subject to change in the near future.'),
'warning');
56 if (function_exists(
'tpps_details_byaccession_page')) {
57 $output .= @tpps_details_byaccession_page()[
'raw_markup'][
'#markup'];
58 drupal_add_js(drupal_get_path(
'module',
'tpps') .
TPPS_JS_PATH);
63 if (empty($state[
'saved_values'][
TPPS_PAGE_3][
'skip_validation'])) {
64 $map_api_key = variable_get(
'tpps_maps_api_key', NULL);
65 $map_api_tools =
"<script src=\"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js\"></script><script src=\"https://maps.googleapis.com/maps/api/js?key=$map_api_key&callback=initMap\" 66 async defer></script>" 67 .
"<div id=\"_map_wrapper\"></div>";
69 if (!empty($state[
'tree_info'])) {
70 foreach ($state[
'tree_info'] as $name => $info) {
71 if (!empty($info[
'lat']) and !empty($info[
'lng'])) {
79 drupal_add_js(array(
'tpps' => array(
'tree_info' => $tree_info)),
'setting');
81 $output .= $map_api_tools;
83 drupal_add_js(drupal_get_path(
'module',
'tpps') .
TPPS_JS_PATH);
84 drupal_add_css(drupal_get_path(
'module',
'tpps') .
TPPS_CSS_PATH);
86 $pub_link = $state[
'title'];
87 $pub_id = db_select(
'chado.project_pub',
'p')
88 ->fields(
'p', array(
'pub_id'))
89 ->condition(
'project_id', $state[
'ids'][
'project_id'])
90 ->execute()->fetchObject()->pub_id;
91 if (!empty($pub_id)) {
92 $bundle = tripal_load_bundle_entity(array(
'label' =>
'Publication'));
93 $pub_id = chado_get_record_entity_by_bundle($bundle, $pub_id);
94 $pub_link =
"<a href='$base_url/Publication/$pub_id'>$pub_link</a>";
97 if (!empty($state[
'saved_values'][TPPS_PAGE_3][
'skip_validation'])) {
98 $image_path = drupal_get_path(
'module',
'tpps') .
'/images/';
99 $pub_link .=
"<img title=\"This submission contains no location information\" src=\"/{$image_path}no_location.png\">";
102 $output .=
"<h2>$pub_link</h2>";
104 $primary_author = $state[
'authors'][0];
105 if (preg_match(
'/,/', $primary_author)) {
106 $parts = explode(
',', $primary_author);
107 $lastname = trim($parts[0]);
110 $parts = explode(
' ', $primary_author);
111 $lastname = $parts[count($parts) - 1];
113 $output .=
"<h4>$lastname et al {$state['pyear']}";
114 if (!empty($state[
'journal'])) {
115 $output .=
" published in {$state['journal']}";
118 $output .=
"<div id=\"abstract\"><a href=\"#abstract\">Click to show abstract</a></div>" 119 .
"<script>jQuery(document).ready(jQuery('#abstract').on('click', function() { 120 jQuery('#abstract')[0].innerHTML = `{$state['abstract']}`; 122 if (empty($state[
'saved_values'][TPPS_PAGE_3][
'skip_validation']) and module_exists(
'cartogratree')) {
123 $output .=
"<a href=\"$base_url/cartogratree?accession=$accession\" target=\"blank\">View in CartograPlant</a><br>";
125 $output .=
"<a href=\"$base_url/tpps/api/files/$accession\">Download compressed raw files</a><br>";
127 $output .=
"<a href=\"$base_url/tpps/$accession/edit-publication\">Edit publication information</a>";
134 drupal_set_message(t(
'This submission is pending resubmission through the new TPPS pipeline. Some of the information may be available here, but please keep in mind that it may be incomplete or subject to change in the near future.'),
'warning');
136 if (function_exists(
'tpps_details_byaccession_page')) {
137 $output .= @tpps_details_byaccession_page()[
'raw_markup'][
'#markup'];
138 drupal_add_js(drupal_get_path(
'module',
'tpps') .
TPPS_JS_PATH);
153 $output =
'<ul class="nav nav-tabs" role="tablist"> 154 <li class="nav-item"><a class="nav-link active" role="tab" data-toggle="tab" href="#species">Species</a></li> 155 <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#study">Study Details</a></li> 156 <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#trees">Plants</a></li>';
159 $mass_spectro_exist = FALSE;
160 for ($i = 1; $i <= $state[
'stats'][
'species_count']; $i++) {
161 if (!empty($state[
'saved_values'][
TPPS_PAGE_4][
"organism-$i"][
'phenotype'])) {
164 if (!empty($state[
'saved_values'][TPPS_PAGE_4][
"organism-$i"][
'genotype'])) {
167 if ($state[
'saved_values'][TPPS_PAGE_4][
"organism-$i"][
'phenotype'][
'iso-check'] == TRUE) {
168 $mass_spectro_exist = TRUE;
172 $output .= $p_exist ?
'<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#phenotype">Phenotypes / Environments</a></li>' :
"";
173 $output .= $g_exist ?
'<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#genotype">Genotypes</a></li>' :
"";
174 $output .= $mass_spectro_exist ?
'<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#mass_spectrometry">Mass Spectrometry</a></li>' :
"";
175 $output .=
'</ul><div id="tab-content" class="tab-content">';
177 $output .=
"<div id=\"species\" role=\"tabpanel\" class=\"tab-pane fade in active\"></div>";
178 $output .=
"<div id=\"study\" role=\"tabpanel\" class=\"tab-pane fade\"></div>";
179 $output .=
"<div id=\"trees\" role=\"tabpanel\" class=\"tab-pane fade\"></div>";
181 $output .= $p_exist ?
"<div id=\"phenotype\" role=\"tabpanel\" class=\"tab-pane fade\"></div>" :
"";
182 $output .= $g_exist ?
"<div id=\"genotype\" role=\"tabpanel\" class=\"tab-pane fade\"></div>" :
"";
183 $output .= $mass_spectro_exist ?
"<div id=\"mass_spectrometry\" role=\"tabpanel\" class=\"tab-pane fade\"></div>" :
"";
198 $function =
"tpps_details_$type";
200 print($function($state));
211 $params = drupal_get_query_parameters($_POST);
213 if (empty($params)) {
214 $params = drupal_get_query_parameters();
216 if (!empty($params[
'page'])) {
217 $page = $params[
'page'];
221 $query = db_select(
'chado.plusgeno_view',
'pg');
222 $query->addExpression(
'count(distinct(pg.accession))',
'count');
223 if (!empty($params[
'type']) and !empty($params[
'value']) and !empty($params[
'op'])) {
224 switch ($params[
'type']) {
231 $query->condition($params[
'type'], $params[
'value'], $params[
'op']);
234 case 'phenotype_name':
235 $query->innerJoin(
'chado.project_stock',
'ps',
'ps.project_id = pg.project_id');
236 $query->innerJoin(
'chado.stock_phenotype',
'sp',
'sp.stock_id = ps.stock_id');
237 $query->innerJoin(
'chado.phenotype',
'ph',
'ph.phenotype_id = sp.phenotype_id');
238 $query->condition(
'ph.name', $params[
'value'], $params[
'op']);
241 case 'phenotype_ontology':
242 $query->innerJoin(
'chado.project_stock',
'ps',
'ps.project_id = pg.project_id');
243 $query->innerJoin(
'chado.stock_phenotype',
'sp',
'sp.stock_id = ps.stock_id');
244 $query->innerJoin(
'chado.phenotype',
'ph',
'ph.phenotype_id = sp.phenotype_id');
245 $query->innerJoin(
'chado.cvterm',
'cvt',
'cvt.cvterm_id = ph.attr_id');
246 $query->innerJoin(
'chado.cv',
'cv',
'cv.cv_id = cvt.cv_id');
247 $query->condition(
'cv.name', $params[
'value'], $params[
'op']);
250 case 'genotype_name':
251 $query->innerJoin(
'chado.tpps_search_genotype_name',
'g',
'g.project_id = pg.project_id');
252 $query->condition(
'g.name', $params[
'value'], $params[
'op']);
255 case 'genotype_marker':
256 $query->innerJoin(
'chado.tpps_search_genotype_marker',
'g',
'g.project_id = pg.project_id');
257 $query->condition(
'g.name', $params[
'value'], $params[
'op']);
261 $query->innerJoin(
'public.tpps_submission',
'ts',
'ts.accession = pg.accession');
262 $query->innerJoin(
'public.tpps_submission_tag',
'st',
'st.tpps_submission_id = ts.tpps_submission_id');
263 $query->innerJoin(
'public.tpps_tag',
'tt',
'tt.tpps_tag_id = st.tpps_tag_id');
264 $query->condition(
'tt.name', $params[
'value'], $params[
'op']);
271 $query = $query->execute();
272 $total = $query->fetchObject()->count;
274 $_GET[
'page'] = $page;
275 $page = pager_default_initialize($total, $per_page);
276 $start = $page * $per_page;
278 $submissions = db_select(
'chado.plusgeno_view',
'pg');
279 $submissions->distinct();
280 $submissions->innerJoin(
'chado.project',
'p',
'p.project_id = pg.project_id');
281 if (!empty($params[
'type']) and !empty($params[
'value']) and !empty($params[
'op'])) {
282 switch ($params[
'type']) {
289 $submissions->condition($params[
'type'], $params[
'value'], $params[
'op']);
292 case 'phenotype_name':
293 $submissions->innerJoin(
'chado.project_stock',
'ps',
'ps.project_id = pg.project_id');
294 $submissions->innerJoin(
'chado.stock_phenotype',
'sp',
'sp.stock_id = ps.stock_id');
295 $submissions->innerJoin(
'chado.phenotype',
'ph',
'ph.phenotype_id = sp.phenotype_id');
296 $submissions->condition(
'ph.name', $params[
'value'], $params[
'op']);
299 case 'phenotype_ontology':
300 $submissions->innerJoin(
'chado.project_stock',
'ps',
'ps.project_id = pg.project_id');
301 $submissions->innerJoin(
'chado.stock_phenotype',
'sp',
'sp.stock_id = ps.stock_id');
302 $submissions->innerJoin(
'chado.phenotype',
'ph',
'ph.phenotype_id = sp.phenotype_id');
303 $submissions->innerJoin(
'chado.cvterm',
'cvt',
'cvt.cvterm_id = ph.attr_id');
304 $submissions->innerJoin(
'chado.cv',
'cv',
'cv.cv_id = cvt.cv_id');
305 $submissions->condition(
'cv.name', $params[
'value'], $params[
'op']);
308 case 'genotype_name':
309 $submissions->innerJoin(
'chado.tpps_search_genotype_name',
'g',
'g.project_id = pg.project_id');
310 $submissions->condition(
'g.name', $params[
'value'], $params[
'op']);
313 case 'genotype_marker':
314 $submissions->innerJoin(
'chado.tpps_search_genotype_marker',
'g',
'g.project_id = pg.project_id');
315 $submissions->condition(
'g.name', $params[
'value'], $params[
'op']);
319 $submissions->innerJoin(
'public.tpps_submission',
'ts',
'ts.accession = pg.accession');
320 $submissions->innerJoin(
'public.tpps_submission_tag',
'st',
'st.tpps_submission_id = ts.tpps_submission_id');
321 $submissions->innerJoin(
'public.tpps_tag',
'tt',
'tt.tpps_tag_id = st.tpps_tag_id');
322 $submissions->condition(
'tt.name', $params[
'value'], $params[
'op']);
329 $submissions->fields(
'pg', array(
334 'phenotypes_assessed',
338 $submissions->range($start, $per_page);
339 $submissions->orderBy(
'pg.accession');
340 $submissions = $submissions->execute();
343 while (($sub = $submissions->fetchObject())) {
344 $proj_id = $sub->project_id;
346 $query = db_select(
'chado.organism',
'o');
347 $query->join(
'chado.pub_organism',
'po',
'o.organism_id = po.organism_id');
348 $query->join(
'chado.project_pub',
'pp',
'pp.pub_id = po.pub_id');
349 $query->fields(
'o', array(
'organism_id',
'genus',
'species'));
350 $query->condition(
'pp.project_id', $proj_id);
352 $query = $query->execute();
355 while (($result = $query->fetchObject())) {
356 $species[] =
tpps_entity_link($result->organism_id,
"{$result->genus} {$result->species}",
'Organism');
361 $warning =
"<img src='$base_url/misc/message-16-warning.png' title='This study has not yet been resubmitted through the new TPPS pipeline'> ";
365 "<a href=\"$base_url/tpps/details/{$sub->accession}\">{$sub->accession}</a>",
366 "$warning<a href=\"$base_url/tpps/details/{$sub->accession}\">{$sub->title}</a>",
368 implode(
'<br>', $species),
370 $sub->phenotypes_assessed,
374 $rows[$sub->accession] = $row;
386 'Phenotypes Assessed',
387 'Phenotypic Measures',
391 'attributes' => array(
392 'class' => array(
'view'),
393 'id' =>
'tpps_table_display',
401 $output = theme(
'table', $vars);
402 $pager = theme(
'pager', array(
'quantity', $total));
403 return $pager . $output;
425 $params = drupal_get_query_parameters();
426 $form[
'details_type'] = array(
429 'title' => t(
'Title'),
430 'species' => t(
'Species'),
431 'accession' => t(
'Accession'),
432 'author' => t(
'Primary Author'),
433 'year' => t(
'Publication Year'),
434 'phenotype_name' => t(
'Phenotype Name'),
435 'phenotype_ontology' => t(
'Phenotype Ontology Name'),
436 'genotype_name' => t(
'Genotype Name'),
437 'genotype_marker' => t(
'Genotype Marker Type'),
441 'wrapper' =>
'tpps-details-form',
442 'callback' =>
'tpps_details_form_callback',
444 '#prefix' =>
'<div id="tpps-details-form">',
445 '#default_value' => $params[
'type'] ?? NULL,
454 $form[
'details_op'] = array(
457 '#default_value' => $params[
'op'] ?? NULL,
460 $form[
'details_value'] = array(
461 '#type' =>
'textfield',
462 '#suffix' =>
'</div>',
463 '#autocomplete_path' =>
'tpps/autocomplete/project_title',
464 '#default_value' => $params[
'value'] ?? NULL,
467 if (empty($form_state[
'values'][
'details_type'])) {
468 $form_state[
'values'][
'details_type'] = $params[
'type'] ?? NULL;
471 if (!empty($form_state[
'values'][
'details_type'])) {
472 switch ($form_state[
'values'][
'details_type']) {
474 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/project_title';
478 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/species';
482 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/project_accession';
486 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/author';
489 case 'phenotype_name':
490 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/phenotype';
493 case 'phenotype_ontology':
494 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/phenotype_ontology';
497 case 'genotype_name':
498 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/genotype';
501 case 'genotype_marker':
502 $form[
'details_value'][
'#autocomplete_path'] =
'tpps/autocomplete/genotype_marker';
506 $form[
'details_value'][
'#autocomplete_path'] = NULL;
511 $form[
'details_search'] = array(
513 '#button_type' =>
'button',
514 '#value' => t(
'Search'),
517 $form[
'reset_button'] = array(
518 '#markup' =>
'<button class="btn btn-primary form-button" type="reset"/>Reset</button>',
521 $form[
'#attributes'] = array(
522 'style' =>
'text-align:center',
537 $query = db_select(
'tpps_tag',
't')
539 ->orderBy(
'static',
'DESC')
540 ->orderBy(
'tpps_tag_id')
543 while (($result = $query->fetchObject())) {
544 $tags[$result->tpps_tag_id] = array(
545 'id' => $result->tpps_tag_id,
546 'name' => $result->name,
547 'color' => $result->color,
548 'static' => $result->static,
554 return "<label for=\"tpps-tags-filter\">Sort by tags:</label><div id=\"tpps-tags-filter\">" . $output .
"</div>";
570 'details_type' => $form[
'details_type'],
571 'details_op' => $form[
'details_op'],
572 'details_value' => $form[
'details_value'],
586 $query = db_select(
'chado.organism',
'o');
587 $query->join(
'chado.pub_organism',
'po',
'o.organism_id = po.organism_id');
588 $query->join(
'chado.project_pub',
'pp',
'pp.pub_id = po.pub_id');
589 $query->fields(
'o', array(
'organism_id',
'genus',
'species',
'common_name'));
590 $query->condition(
'pp.project_id', $state[
'ids'][
'project_id']);
591 $query = $query->execute();
594 while (($result = $query->fetchObject())) {
595 $id = $result->organism_id;
596 $common_name = $result->common_name;
597 $family = $order =
"";
600 $family = db_select(
'chado.organismprop',
'o')
601 ->fields(
'o', array(
'value'))
602 ->condition(
'organism_id', $id)
604 ->execute()->fetchObject()->value;
608 $order = db_select(
'chado.organismprop',
'o')
609 ->fields(
'o', array(
'value'))
610 ->condition(
'organism_id', $id)
612 ->execute()->fetchObject()->value;
616 $common_name = db_select(
'chado.organismprop',
'o')
617 ->fields(
'o', array(
'value'))
618 ->condition(
'organism_id', $id)
620 ->execute()->fetchObject()->value;
623 $name =
"{$result->genus} {$result->species}";
625 $rows[$name] = array(
641 'attributes' => array(
642 'class' => array(
'view'),
643 'id' =>
'tpps_table_display',
650 return theme(
'table', $vars);
666 for ($i = 1; $i <= $state[
'stats'][
'species_count']; $i++) {
667 $id = $state[
'ids'][
'organism_ids'][$i];
668 $species_name = $state[
'saved_values'][
TPPS_PAGE_1][
'organism'][$i][
'name'];
672 $study_types = array(
673 1 =>
'Natural Population (Landscape)',
674 2 =>
'Growth Chamber',
676 4 =>
'Experimental/Common Garden',
683 foreach ($study_file_ids as $fid) {
684 $file = file_load($fid);
686 $file_url = check_plain(file_create_url($file->uri));
687 if(stripos($file_url,
'core/labs') === FALSE) {
688 $files[] =
"<a href='$file_url' target='blank'>$file->filename</a>";
694 $pub_link = $state[
'title'];
695 $pub_id = db_select(
'chado.project_pub',
'p')
696 ->fields(
'p', array(
'pub_id'))
697 ->condition(
'project_id', $state[
'ids'][
'project_id'])
698 ->execute()->fetchObject()->pub_id;
699 if (!empty($pub_id)) {
700 $bundle = tripal_load_bundle_entity(array(
'label' =>
'Publication'));
701 $pub_id = chado_get_record_entity_by_bundle($bundle, $pub_id);
702 $pub_link =
"<a href='$base_url/Publication/$pub_id'>$pub_link</a>";
704 $rows[] = array(
'Accession', $state[
'accession']);
705 $rows[] = array(
'Title', $pub_link);
706 $rows[] = array(
'Authors', implode(
', ', $state[
'authors']));
707 $rows[] = array(
'Species', implode(
'<br>', $species));
708 $rows[] = array(
'Data Type', $state[
'saved_values'][
TPPS_PAGE_2][
'data_type']);
711 $study_types[$state[
'saved_values'][TPPS_PAGE_2][
'study_type']],
713 $rows[] = array(
'File Downloads', implode(
'<br>', $files));
714 $rows[] = array(
'Population Size', $state[
'stats'][
'tree_count']);
715 if (!empty($state[
'stats'][
'phenotype_count'])) {
716 $rows[] = array(
'Phenotype Count', $state[
'stats'][
'phenotype_count']);
718 if (!empty($state[
'stats'][
'unique_phenotypes'])) {
719 $rows[] = array(
'Unique Phenotypes', $state[
'stats'][
'unique_phenotypes']);
726 'attributes' => array(
727 'class' => array(
'view'),
728 'id' =>
'tpps_table_display',
735 return theme(
'table', $vars);
739 $saved_values = $state[
'saved_values'];
741 $organism_count = $saved_values[
'1'][
'organism'][
'number'];
743 for($i=1; $i<=4; $i++) {
745 for($j=1; $j<=$organism_count; $j++) {
746 if(isset($saved_values[$i][
'tree-accession'][
'species-' . $j][
'file'])) {
747 array_push($file_ids, $saved_values[$i][
'tree-accession'][
'species-' . $j][
'file']);
753 for($j=1; $j<=$organism_count; $j++) {
754 if(isset($saved_values[$i][
'organism-' . $j][
'phenotype'][
'file'])) {
755 array_push($file_ids, $saved_values[$i][
'organism-' . $j][
'phenotype'][
'file']);
757 if(isset($saved_values[$i][
'organism-' . $j][
'phenotype'][
'metadata'])) {
758 array_push($file_ids, $saved_values[$i][
'organism-' . $j][
'phenotype'][
'metadata']);
761 for($j=1; $j<=$organism_count; $j++) {
762 if(isset($saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'snps-assay'])) {
763 array_push($file_ids, $saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'snps-assay']);
765 if(isset($saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'snps-association'])) {
766 array_push($file_ids, $saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'snps-association']);
768 if(isset($saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'vcf'])) {
769 array_push($file_ids, $saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'vcf']);
771 if(isset($saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'ssrs'])) {
772 array_push($file_ids, $saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'ssrs']);
774 if(isset($saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'ssrs_extra'])) {
775 array_push($file_ids, $saved_values[$i][
'organism-' . $j][
'genotype'][
'files'][
'ssrs_extra']);
781 if(count($saved_values[
'summarypage'][
'files']) > 2) {
782 $files = $saved_values[
'summarypage'][
'files'];
783 foreach ($files as $file_index => $file_id) {
784 if(is_numeric($file_id) && $file_id > 0) {
803 $path = current_path();
804 $args = explode(
'/', $path);
805 $params = drupal_get_query_parameters($_POST);
807 if (!empty($params[
'page'])) {
808 $page = $params[
'page'];
813 if (empty($state[
'tree_info'])) {
814 $output = t(
'The plant information for this study has not been properly updated. Please contact your site administrator.');
818 $skip = !empty($state[
'saved_values'][
TPPS_PAGE_3][
'skip_validation']);
820 $_GET[
'page'] = $page;
821 pager_default_initialize(count($state[
'tree_info']), $per_page);
822 $chunks = array_chunk($state[
'tree_info'], $per_page, TRUE);
824 foreach ($chunks[$page] as $name => $info) {
825 $id = $info[
'organism_id'];
826 $form_number = array_search($id, $state[
'ids'][
'organism_ids']);
827 $species_name = $state[
'saved_values'][
TPPS_PAGE_1][
'organism'][$form_number][
'name'];
832 strtoupper($args[2]) .
'-' . strip_tags($tree_id),
837 $row[] = $info[
'lat'];
838 $row[] = $info[
'lng'];
844 'TreeGenes Identifier',
849 $header[] =
'Latitude';
850 $header[] =
'Longitude';
856 'attributes' => array(
857 'class' => array(
'view'),
858 'id' =>
'tpps_table_display',
865 $table = theme(
'table', $vars);
866 $pager = theme(
'pager', array(
'quantity', count($state[
'tree_info'])));
867 return $pager . $table;
880 $params = drupal_get_query_parameters($_POST);
882 if (!empty($params[
'page'])) {
883 $page = $params[
'page'];
887 $start = $page * $per_page;
889 $query = db_select(
'chado.phenotype',
'p');
890 $query->join(
'chado.stock_phenotype',
'sp',
'sp.phenotype_id = p.phenotype_id');
891 $query->join(
'chado.project_stock',
'ps',
'ps.stock_id = sp.stock_id');
892 $query->join(
'chado.stock',
's',
's.stock_id = sp.stock_id');
893 $query->addExpression(
'count(p.phenotype_id)',
'count');
894 $query->condition(
'ps.project_id', $state[
'ids'][
'project_id']);
895 $query = $query->execute();
896 $total = $query->fetchObject()->count;
898 $_GET[
'page'] = $page;
899 pager_default_initialize($total, $per_page);
901 $query = db_select(
'chado.phenotype',
'p');
902 $query->join(
'chado.stock_phenotype',
'sp',
'sp.phenotype_id = p.phenotype_id');
903 $query->join(
'chado.project_stock',
'ps',
'ps.stock_id = sp.stock_id');
904 $query->join(
'chado.stock',
's',
's.stock_id = sp.stock_id');
905 $query->fields(
'p', array(
912 $query->fields(
's', array(
'uniquename',
'stock_id'));
913 $query->condition(
'ps.project_id', $state[
'ids'][
'project_id']);
914 $query->range($start, $per_page);
915 $query = $query->execute();
929 while (($result = $query->fetchObject())) {
931 preg_match(
'/^TGDR.{1,4}-(.*)$/', $result->uniquename, $matches);
933 $obs = chado_get_cvterm(array(
934 'cvterm_id' => $result->observable_id,
936 $attr = chado_get_cvterm(array(
937 'cvterm_id' => $result->attr_id,
958 'attributes' => array(
959 'class' => array(
'view'),
960 'id' =>
'tpps_table_display',
967 $table = theme(
'table', $vars);
968 $pager = theme(
'pager', array(
'quantity', $total));
969 return $pager . $table;
982 $params = drupal_get_query_parameters($_POST);
984 if (!empty($params[
'page'])) {
985 $page = $params[
'page'];
989 $start = $page * $per_page;
992 $total_check =
false;
995 $total_array = variable_get(
'tpps_tab_genotype_' + $state[
'ids'][
'project_id'] +
'_total');
996 if($total_array == NULL) {
1001 if($total_array[
'expire_time'] < time()) {
1002 $total_check =
true;
1005 $total = $total_array[
'total'];
1013 $total_check =
true;
1017 $query = db_select(
'chado.genotype',
'g');
1018 $query->join(
'chado.stock_genotype',
'sg',
'sg.genotype_id = g.genotype_id');
1019 $query->join(
'chado.project_stock',
'ps',
'ps.stock_id = sg.stock_id');
1020 $query->addExpression(
'count(g.genotype_id)',
'count');
1021 $query->condition(
'ps.project_id', $state[
'ids'][
'project_id']);
1022 $query = $query->execute();
1023 $total = $query->fetchObject()->count;
1025 $total_array = array(
1026 'expire_time' => time() + variable_get(
'tpps_tab_genotype_total_cache_time', 30*(24*60*60)),
1029 variable_set(
'tpps_tab_genotype_' + $state[
'ids'][
'project_id'] +
'_total', $total_array);
1032 $_GET[
'page'] = $page;
1033 pager_default_initialize($total, $per_page);
1035 $query = db_select(
'chado.genotype',
'g');
1036 $query->join(
'chado.stock_genotype',
'sg',
'sg.genotype_id = g.genotype_id');
1037 $query->join(
'chado.project_stock',
'ps',
'ps.stock_id = sg.stock_id');
1038 $query->join(
'chado.stock',
's',
's.stock_id = sg.stock_id');
1039 $query->fields(
'g', array(
1046 $query->fields(
's', array(
'uniquename',
'stock_id'));
1047 $query->condition(
'ps.project_id', $state[
'ids'][
'project_id']);
1048 $query->range($start, $per_page);
1049 $query = $query->execute();
1051 while (($result = $query->fetchObject())) {
1053 preg_match(
'/^TGDR.{1,4}-(.*)$/', $result->s_uniquename, $matches);
1054 $tree = $matches[1];
1055 $type = chado_get_cvterm(array(
1056 'cvterm_id' => $result->type_id,
1061 $result->description,
1074 'attributes' => array(
1075 'class' => array(
'view'),
1076 'id' =>
'tpps_table_display',
1079 'colgroups' => NULL,
1083 $table = theme(
'table', $vars);
1084 $pager = theme(
'pager', array(
'quantity', $total));
1085 return $pager . $table;
1099 $params = drupal_get_query_parameters($_POST);
1101 if (!empty($params[
'page'])) {
1102 $page = $params[
'page'];
1106 $start = $page * $per_page;
1108 $query = db_select(
'chado.phenotype',
'p');
1109 $query->join(
'chado.stock_phenotype',
'sp',
'sp.phenotype_id = p.phenotype_id');
1110 $query->join(
'chado.project_stock',
'ps',
'ps.stock_id = sp.stock_id');
1111 $query->join(
'chado.stock',
's',
's.stock_id = sp.stock_id');
1112 $query->addExpression(
'count(p.phenotype_id)',
'count');
1113 $query->condition(
'ps.project_id', $state[
'ids'][
'project_id']);
1114 $query = $query->execute();
1115 $total = $query->fetchObject()->count;
1117 $_GET[
'page'] = $page;
1118 pager_default_initialize($total, $per_page);
1120 $query = db_select(
'chado.phenotype',
'p');
1121 $query->join(
'chado.stock_phenotype',
'sp',
'sp.phenotype_id = p.phenotype_id');
1122 $query->join(
'chado.project_stock',
'ps',
'ps.stock_id = sp.stock_id');
1123 $query->join(
'chado.stock',
's',
's.stock_id = sp.stock_id');
1124 $query->fields(
'p', array(
1131 $query->fields(
's', array(
'uniquename',
'stock_id'));
1134 $query->range($start, $per_page);
1135 $query = $query->execute();
1137 while (($result = $query->fetchObject())) {
1138 preg_match(
'/^TGDR...-(.*)$/', $result->uniquename, $matches);
1139 $tree = $matches[1];
1140 $obs = chado_get_cvterm(array(
1141 'cvterm_id' => $result->observable_id,
1143 $attr = chado_get_cvterm(array(
1144 'cvterm_id' => $result->attr_id,
1165 'attributes' => array(
1166 'class' => array(
'view'),
1167 'id' =>
'tpps_table_display',
1170 'colgroups' => NULL,
1174 $table = theme(
'table', $vars);
1175 $pager = theme(
'pager', array(
'quantity', $total));
1176 return $pager . $table;
tpps_submission_get_tags($accession)
tpps_details($accession=NULL)
tpps_details_genotype(array &$state)
tpps_details_search(array $form, array $form_state)
tpps_details_mass_spectrometry(array &$state)
tpps_details_trees(array &$state)
tpps_show_tags(array $tags)
tpps_entity_link($id, $name, $label)
tpps_details_phenotype(array &$state)
tpps_details_tabs(array &$state)
tpps_details_species(array &$state)
tpps_load_submission($accession, $state=TRUE)
tpps_details_tab($accession, $type)
tpps_chado_prop_exists($base_table, $id, $name, array $options=array())
tpps_details_study(array &$state)
tpps_load_cvterm($term, array $options=array(), $version=NULL, $refresh_cache=FALSE)
tpps_details_top_callback()
tpps_details_get_study_file_ids($state)
tpps_details_form_callback(array $form, array $form_state)