upload fieldbook from manage phenotyping
[sgn.git] / cgi-bin / solpeople / cosii_submission.pl
blob5dd1d026034397724619003bcb27dc1809282e05
1 use Modern::Perl;
2 use CXGN::Page;
3 use CXGN::DB::Connection;
4 use CXGN::Marker::Tools;
5 use CXGN::Accession;
6 use CXGN::Accession::Tools;
7 use CXGN::Login;
8 use CXGN::Tools::Text;
10 my $dbh=CXGN::DB::Connection->new();
12 my $login=CXGN::Login->new($dbh);
13 $login->verify_session();
15 my $page=CXGN::Page->new('cosii_submission.pl','john');
17 $page->header('Submit COSII primer experiment');
18 my($action,$marker_name,$accession_id,$primer_type,$temp,$mg,$bands)=$page->get_encoded_arguments('action','marker_name','accession_id','primer_type','temp','mg','bands');
19 my $marker_id;
20 my $accession_name;
22 if($action eq 'verify' or $action eq 'insert') {
23 my @marker_ids=CXGN::Marker::Tools::marker_name_to_ids($dbh,$marker_name);
25 unless(@marker_ids) {
26 $page->message_page("Marker '$marker_name' not found.");
29 #i don't want to write any error handling here, because all cosii marker names (currently) refer to one marker each
30 if(@marker_ids>1) {
31 $page->message_page("Multiple markers found with name '$marker_name'. Please contact us to resolve this issue.");
34 ($marker_id)=@marker_ids;
36 #test accession
37 my $accession=CXGN::Accession->new($dbh,$accession_id);
38 unless($accession) {
39 $page->message_page("Accession ID '$accession_id' not found in database");
41 $accession_name=$accession->verbose_name();
43 #test primer type
44 unless($primer_type eq 'iUPA' or $primer_type eq 'eUPA') {
45 $page->message_page("Primer type '$primer_type' is unknown");
48 #test temp
49 unless($temp=~/^\d+$/) {
50 $page->message_page("Temperature '$temp' is unrecognized, please submit a whole number only");
52 if($temp>500) {
53 $page->message_page("Temperature '$temp' is invalid");
56 #test mg
57 unless(CXGN::Tools::Text::is_number($mg)) {
58 $page->message_page("Mg concentration is unrecognized, please submit a number or a number including one decimal point only");
61 #test bands
62 unless($bands eq 'M' or $bands eq 'm' or $bands=~/^\d+$/ or $bands=~/^\d+\+\d+$/) {
63 $page->message_page("Band sizes are unrecognized, please see examples and be sure not to include any spaces in your input");
65 if($bands eq 'm') {
66 $bands='M';
74 if($action eq 'verify')
76 print CXGN::Page::FormattingHelpers::page_title_html('Verify data');
77 print"<b>Marker name:</b> $marker_name (SGN-M$marker_id)<br />";
78 print"<b>Accession:</b> $accession_name (SGN accession ID:</b> $accession_id)<br />";
79 print"<b>Primer type:</b> $primer_type<br />";
80 print"<b>Temperature:</b> $temp<br />";
81 print"<b>Mg concentration:</b> $mg<br />";
82 print"<b>Bands:</b> $bands<br /><br />";
83 print <<END_HTML;
84 <form method="post" action="">
85 <input type="hidden" name="marker_id" value="$marker_id" />
86 <input type="hidden" name="marker_name" value="$marker_name" />
87 <input type="hidden" name="accession_id" value="$accession_id" />
88 <input type="hidden" name="primer_type" value="$primer_type" />
89 <input type="hidden" name="temp" value="$temp" />
90 <input type="hidden" name="mg" value="$mg" />
91 <input type="hidden" name="bands" value="$bands" />
92 <input type="hidden" name="action" value="insert" />
93 <input type="submit" value="Add new data" />
94 END_HTML
95 exit(0);
102 if($action eq 'insert')
104 print CXGN::Page::FormattingHelpers::page_title_html('Pretended to add this data');
105 print"<a href=\"/search/markers/markerinfo.pl?marker_id=$marker_id\">[View marker with new data]</a><br /><br />";
106 print"<b>Marker name:</b> $marker_name (SGN-M$marker_id)<br />";
107 print"<b>Accession:</b> $accession_name (SGN accession ID:</b> $accession_id)<br />";
108 print"<b>Primer type:</b> $primer_type<br />";
109 print"<b>Temperature:</b> $temp<br />";
110 print"<b>Mg concentration:</b> $mg<br />";
111 print"<b>Bands:</b> $bands<br />";
112 print"<hr />"
119 my $marker_name_filled_in='C2_At';
120 if($marker_name)
122 $marker_name_filled_in=$marker_name;
124 my $temp_filled_in='55';
125 if($temp)
127 $temp_filled_in=$temp;
129 my $mg_filled_in='1.5';
130 if($mg)
132 $mg_filled_in=$mg;
134 my $bands_filled_in='';
135 if($bands)
137 $bands_filled_in=$bands;
139 my @accessions=CXGN::Accession::Tools::all_accessions($dbh);
140 my $accessions_selector='<select name="accession_id">';
141 for my $accession_hash(sort {$a->{verbose_name} cmp $b->{verbose_name}} @accessions)
143 my $each_accession_id=$accession_hash->{accession_id};
144 my $each_accession_name=$accession_hash->{verbose_name};
145 #warn"$each_accession_id\n";
146 my $selected='';
147 if($each_accession_id==$accession_id)
149 $selected=' selected="selected" ';
151 $accessions_selector.="<option value=\"$each_accession_id\" $selected>$each_accession_name</option>";
153 $accessions_selector.='</select>';
154 my $iupa_selected='checked="checked"';
155 my $eupa_selected='';
156 if($primer_type and $primer_type eq 'eUPA')
158 $iupa_selected='';
159 $eupa_selected='checked="checked"';
161 print <<END_HTML;
162 <center>
163 <form method="post" action="">
164 <table cellspacing="10" cellpadding="10" border="0">
166 <tr>
167 <td>
168 Marker name<br />
169 <input type="text" name="marker_name" value="$marker_name_filled_in" /><br />
170 </td>
171 <td>
172 Primer type<br />
173 <input type="radio" name="primer_type" value="iUPA" $iupa_selected />iUPA<br />
174 <input type="radio" name="primer_type" value="eUPA" $eupa_selected />eUPA
175 </td>
176 </tr>
178 <tr>
179 <td colspan="2">
180 Accession<br />
181 $accessions_selector
182 <br />To add an accession to this list, <a href="/contact/form">contact SGN</a>.
183 </td>
184 </tr>
186 <tr>
187 <td>
188 Temperature (C)<br />
189 <input type="text" name="temp" value="$temp_filled_in" /><br />
190 </td>
191 <td>
192 Mg concentration<br />
193 <input type="text" name="mg" value="$mg_filled_in" /><br /><br />
194 </td>
195 </tr>
197 <tr>
198 <td>
199 Band sizes<br />
200 <input type="text" name="bands" value="$bands_filled_in" />
201 </td>
202 <td>
203 Band size examples:<br />
204 1 band: <b>300</b><br />
205 2 bands separated by a '+' sign: <b>300+500</b><br />
206 'M' for more than 2: <b>M</b>
207 </td>
208 </tr>
210 <tr>
211 <td colspan="2">
212 <input type="hidden" name="action" value="verify" />
213 <input type="submit" value="Verify" />
214 </td>
215 </tr>
217 </table>
218 </form>
219 </center>
220 END_HTML
221 $page->footer();