Merge pull request #5177 from solgenomics/topic/solgs/refactor-solgs-pipeline
[sgn.git] / cgi-bin / phenotype / population.pl
blob5f657e8ff41d332d3db99584d41196ea0723791a
1 #!/usr/bin/perl -w
3 #Main Page for Phenotypic Database
5 use strict;
6 use CXGN::Page;
7 use CXGN::DB::PhenoPopulation;
8 use CGI;
10 #get parameters from form on previous page
11 use CatalystX::GlobalContext qw( $c );
12 my %params = %{$c->req->params};
13 my $pop_id = $params{pop_id};
15 my $page = CXGN::Page->new('phenotype', 'Adri');
17 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 transitional//EN\" \"http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd\">";
19 #-------------------------------------------------
20 my @populations = CXGN::DB::PhenoPopulation::get_all_populations;
21 my $current_pop_id;
22 my $current_pop_name;
24 #population selected
25 if ($pop_id) {
26 $current_pop_id = $pop_id;
27 $current_pop_name = CXGN::DB::PhenoPopulation::get_pop_name_from_pop_id($pop_id);
30 #no population selected, first one in DB is used as default
31 else {
32 $current_pop_id = $populations[0][0];
33 $current_pop_name = $populations[0][1];
36 my @genotypes = CXGN::DB::PhenoPopulation::get_all_gen_from_pop_id($current_pop_id);
37 my @gen_ids;
38 for my $i (0..$#genotypes) {
39 push @gen_ids, $genotypes[$i][0];
41 my @prop_info_by_organ = CXGN::DB::PhenoPopulation::get_all_prop_info_by_organ_from_pop_id($current_pop_id);
43 $page->header($current_pop_name." Population");
45 print <<EOF
47 <table summary="" width="100%" cellpadding="0" cellspacing="10" border="0">
49 <tr><td valign="top">
50 <center><h2><b><u>$current_pop_name Population</u></b></h2></center>
51 </td></tr>
52 EOF
55 #select box for populations
56 if ($#populations > 0) {
57 print "<tr><td valign=\"top\">";
58 print "<table summary=\"\"><tr><td colspan=\"2\">";
59 print "<form action=\"/phenotype/main_phenotype.pl\" method=\"get\">";
60 print "<br />";
61 print "<b><u>Change Population</u></b>\n<br />";
62 print "Below is the list of population(s) currently in the database. Select a population and click the button to search images and data in another population.";
63 print "</td></tr>";
64 print "<tr><td valign=\"top\" align=\"left\">";
65 print "All Populations: ";
66 print "<select name=\"pop_id\">\n";
67 for my $i (0..$#populations) {
68 print "<option value=\"$populations[$i][0]\"> $populations[$i][1]</option>";
70 print "</select>";
71 print "</td>";
72 print "<td valign=\"top\" align=\"right\">";
73 print "<input type=\"submit\" value=\"Change Population\" />";
74 print "<br />";
75 print "</form>";
76 print "</td></tr></table>";
77 print "</td></tr>";
79 #line
80 print "<tr><td><img src=\"/documents/img/dot_clear.gif\" width=\"1\" height=\"10\" alt=\"\" /></td></tr>";
81 print "<tr><td colspan=\"1\" bgcolor=\"#cccccc\"><img src=\"/documents/img/dot_clear.gif\" width=\"1\" height=\"1\" alt=\"\" /></td></tr>";
82 print "<tr><td><img src=\"/documents/img/dot_clear.gif\" width=\"1\" height=\"10\" alt=\"\" /></td></tr>";
85 print <<EOF
86 <tr><td valign="top">
88 <table summary="" width="100%" cellpadding="0" cellspacing="0" border="0">
90 <!--genotypes-->
91 <tr><td colspan="2">
92 <form action="/phenotype/display_plants_from_genotype.pl" method="get">
93 <table summary="" width="100%" cellpadding="0" cellspacing="0" border="0">
94 <tr><td>
95 <b><u>Search By GENOTYPES</u></b>
96 </td></tr>
97 <tr><td>
98 Below is a list of all <b>genotypes</b> in the selected population above - selecting a genotype will take you to a page of plants with the selected genotype. This new page will have links to all images and data of these plants:
99 </td></tr>
100 <tr><td valign="top" align="left">
101 Genotypes in <b>$current_pop_name</b>:
102 <select name="gen_id">
107 for my $i (0..$#genotypes) {
108 print "<option value = \"$genotypes[$i][0]\"> $genotypes[$i][1]</option>";
111 print <<EOF
112 </select>
113 <input type="hidden" name="pop_id" value="$current_pop_id" />
114 <input type="hidden" name="pop_name" value="$current_pop_name" />
115 </td>
116 <td valign="top" align="right">
117 <input type="submit" value="get Plants by Genotype" />
118 </td></tr>
119 </table>
120 </form>
121 </td></tr>
125 my $current_pop_name_2 = $current_pop_name;
126 $current_pop_name_2 =~ s/\s/%20/g;
128 print<<EOF
130 <!--properties-->
131 <tr><td colspan="2">
132 <form action="/phenotype/display_plants_from_property.pl" method="get">
133 <table summary="">
134 <tr><td>
135 <b><u>Search By PROPERTIES</u></b> (<a href="display_prop_list.pl?pop_id=$current_pop_id&amp;pop_name=$current_pop_name_2">Property Descriptions</a>)
136 </td></tr>
141 print "<tr><td>Below is a list of all <b>properties</b> measured in the selected population above - selecting a property will take you to a page of plants with the selected property measured. This new page will have links to each plant's sample data and images:</td></tr>";
143 print "<tr><td width=\"100%\" valign=\"top\" align=\"left\">";
144 print "Properties in <b>$current_pop_name</b>:";
145 print "<select name=\"prop_id\">";
147 for my $i (0..$#prop_info_by_organ) {
148 $prop_info_by_organ[$i] or next;
150 my $organ_name = $prop_info_by_organ[$i][0][2];
151 print "<optgroup label=\"$organ_name\">";
152 for my $j (0..$#{$prop_info_by_organ[$i]}) {
153 my $prop_id = $prop_info_by_organ[$i][$j][0];
154 my $prop_name = $prop_info_by_organ[$i][$j][1];
155 print "<option value=\"$prop_id\"> $prop_name</option>";
157 print "</optgroup>";
160 print <<EOF
161 </select>
162 <input type="hidden" name="pop_id" value="$current_pop_id" />
163 <input type="hidden" name="pop_name" value="$current_pop_name" />
164 </td>
165 <td width="100%" valign="top" align="right">
166 <input type="submit" value="get Plants by Property" />
167 </td></tr>
168 </table>
169 </form>
170 </td></tr>
172 <tr><td><img src="/documents/img/dot_clear.gif" width="1" height="10" alt="" /></td></tr>
173 <tr><td colspan="1" bgcolor="#cccccc"><img src="/documents/img/dot_clear.gif" width="1" height="1" alt="" /></td></tr>
174 <tr><td><img src="/documents/img/dot_clear.gif" width="1" height="10" alt="" /></td></tr>
176 <tr><td>
177 <center><h3><u>Terminology</u></h3></center>
178 </td></tr>
179 <tr><td>
180 <dl>
181 <dt><b>Population</b></dt>
182 <dd>all the organisms that constitute a specific group or occur in a specified location</dd>
183 <dt><br /><b>Genotype</b></dt>
184 <dd>a group of organisms sharing a specific genetic constitution</dd>
185 <dt><br /><b>Property/Phenotype</b></dt>
186 <dd>the observable physical or biochemical characteristics of an organism, as determined by both genetic makeup and environmental influences</dd>
187 </dl>
189 </td></tr>
190 </table>
191 </td></tr>
192 </table>
197 $page->footer();