on second though, remove post-only restriction on organism tree image cache flushing...
[sgn.git] / cgi-bin / phenome / qtl_form.pl
blobcefeb3b17e164365041fee3dba79cd91ba3cb1bb
1 =head1 DESCRIPTION
2 creates all the web forms for the qtl data submission
3 and sends the data to qtl_load.pl for processing
4 and loading it to the database.
6 =head1 AUTHOR
7 Isaak Y Tecle (iyt2@cornell.edu)
9 =cut
13 use strict;
14 my $qtl_form_detail_page = CXGN::Phenome::QtlFormDetailPage->new();
16 package CXGN::Phenome::QtlFormDetailPage;
20 use File::Spec;
21 use CXGN::VHost;
22 use CXGN::Page;
23 use CXGN::Scrap;
24 use CXGN::Scrap::AjaxPage;
25 use CXGN::Page::FormattingHelpers qw /info_section_html
26 page_title_html
27 columnar_table_html
28 html_optional_show
29 info_table_html
30 tooltipped_text
31 html_alternate_show
33 use CXGN::DB::Connection;
34 use CXGN::Phenome::Qtl;
35 use CXGN::Phenome::Qtl::Tools;
36 use CXGN::Phenome::Population;
37 use CXGN::Login;
40 sub new {
41 my $class = shift;
42 my $self = bless {}, $class;
43 $self->display();
45 return $self;
49 sub display {
50 my $self = shift;
51 my $dbh = CXGN::DB::Connection->new();
52 my $login = CXGN::Login->new($dbh);
54 my $sp_person_id = $login->verify_session();
57 my %args = {};
58 my $page = CXGN::Page->new("SGN", "isaak");
59 $page->jsan_use("CXGN.Phenome.Tools");
60 $page->jsan_use("CXGN.Phenome.Qtl");
61 $page->jsan_use("MochiKit.DOM");
62 $page->jsan_use("MochiKit.Async");
63 $page->jsan_use("Prototype");
64 $page->jsan_use("jquery");
66 %args = $page->get_all_encoded_arguments();
67 my $type = $args{type};
69 my $pop_id = $args{pop_id};
70 if ($sp_person_id) {
71 my $intro = $self->intro();
72 my ($org_submit, $pop_submit) = $self->org_pop_form();
73 my $traits_submit = $self->traits_form($pop_id);
74 my $pheno_submit = $self->pheno_form($pop_id);
75 my $geno_submit = $self->geno_form($pop_id);
76 my $stat_submit = $self->stat_form($pop_id);
77 my $conf_submit = $self->conf_form($pop_id);
80 if(!$type) {
81 $page->header("QTL Data Submission Page");
82 print page_title_html("Step 0: Introduction");
83 print $intro;
87 elsif($type eq 'pop_form') {
88 $page->header("QTL Data Submission Page");
89 print page_title_html("Step 1: Submit Population Details");
90 print $org_submit;
91 print $pop_submit;
95 elsif ($type eq 'trait_form') {
96 $page->header("QTL Data Submission Page");
97 print page_title_html("Step 2: Submit the List of Traits");
98 print $traits_submit;
103 elsif ($type eq 'pheno_form') {
104 $page->header("QTL Data Submission Page");
105 print page_title_html("Step 3: Submit the Phenotype Data");
106 print $pheno_submit;
110 elsif ($type eq 'geno_form') {
111 $page->header("QTL Data Submission Page");
112 print page_title_html("Step 4: Submit the Genotype Data");
113 print $geno_submit;
118 elsif ($type eq 'stat_form') {
119 $page->header("QTL Data Submission Page");
121 print page_title_html("Step 5: Set the Statistical Parameters
122 for the QTL Analysis"
124 print $stat_submit;
128 elsif ($type eq 'confirm') {
129 $page->header("Confirmation page");
130 print page_title_html("Step 6: Confirmation");
131 print $conf_submit;
135 $page->footer();
139 else {
140 print "To access the QTL data submission form and analysis, please login first.
141 <br/>If you don't have an account with SGN, you can create
142 one using this <a href= /solpeople/new-account.pl>form</a>.";
144 $page->footer();
146 exit();
153 sub org_pop_form {
154 my $self = shift;
156 my $taxon_subtitle = qq| <a href="javascript:Qtl.toggleAssociateTaxon()">[Select Organism]</a> |;
157 my $required = qq | <font color="red"><sup>*</sup></font>|;
158 my $organism_form = $self->associate_organism();
160 my $guide = $self->guideline();
162 my $org_sec = CXGN::Page::FormattingHelpers::info_section_html(
163 title =>"Select Organism",
164 subtitle =>$taxon_subtitle . " | " . $guide ,
165 contents => $organism_form,
166 id =>"organism_search",
168 my $pop_sec = CXGN::Page::FormattingHelpers::info_section_html(
169 title =>'Population Details',
170 contents =>"$required <i>must be filled.</i> ",
173 my $qtltools = CXGN::Phenome::Qtl::Tools->new();
174 my %cross_types = $qtltools->cross_types();
177 my $cross_options;
178 foreach my $key (keys %cross_types) {
179 $cross_options .= qq |<option value="$key">$cross_types{$key} |;
183 my $parent_m = tooltipped_text('Male parent', 'format eg. Solanum lycopersicum cv moneymaker');
185 my $parent_f = tooltipped_text('Female parent', 'format eg. Solanum lycopersicum cv micro tom');
187 my $pop_form = qq^
188 <form action="qtl_load.pl" method="POST" enctype="MULTIPART/FORM-DATA">
189 $pop_sec
190 <table>
191 <tr>
192 <td>Cross type$required</td>
193 <td> <select name="pop_type">
194 $cross_options
195 </select>
196 </td>
197 </tr>
198 <tr>
199 <td>Population name$required</td>
200 <td><input type="text" name="pop_name" size=42></td>
201 </tr>
202 <tr>
203 <td>Population description$required</td>
204 <td><textarea name="pop_desc" rows = 5 cols=44></textarea></td>
205 </tr>
206 <tr>
207 <td>$parent_f$required</td>
208 <td><input type="text" name="pop_female_parent" size=24></td>
209 <td>$parent_m$required</td>
210 <td><input type="text" name="pop_male_parent" size=24></td>
211 </tr>
212 <tr>
213 <td>Recurrent parent</td>
214 <td><input type="text" name="pop_recurrent_parent" size=24></td>
215 <td>Donor parent</td>
216 <td><input type="text" name="pop_donor_parent" size=24></td>
217 </tr>
218 <tr>
219 <td>Do you want to make the data public?</td>
220 <td><input type="radio" name="pop_is_public" value="true" checked />Yes</td>
221 <td><input type="radio" name="pop_is_public" value="false" />No</td>
222 </tr>
223 <tr>
224 <td>&nbsp;</td><td>&nbsp;</td>
225 <td><input type="hidden" name="type" value="pop_form"></td>
226 <td><input type="submit" value="Submit"></td>
227 </tr>
228 </table>
229 </form>
233 return $org_sec, $pop_form;
236 #########################
241 sub traits_form {
242 my $self = shift;
243 my $pop_id = shift;
245 my $guide = $self->guideline();
246 my $trait = tooltipped_text('Traits list', 'in tab delimited format');
248 my $traits_sec = CXGN::Page::FormattingHelpers::info_section_html(
249 title => 'Traits list',
250 subtitle => $guide,
251 contents => " ",
254 my $traits_form = qq^
255 <form action="qtl_load.pl" method="POST" enctype="MULTIPART/FORM-DATA">
256 $traits_sec
257 <table cellspacing=20>
258 <tr>
259 <td>$trait:</td>
260 <td><input type="file" name="trait_file" size=40>
261 <td> <input type="hidden" name="type" value="trait_form"></td>
262 <td> <input type="hidden" name="pop_id" value = $pop_id></td>
263 <td><input type="submit" value="Submit"> </td>
264 </tr>
265 </table>
266 </form>
269 return $traits_form;
273 sub pheno_form {
274 my $self = shift;
275 my $pop_id = shift;
276 my $guide= $self->guideline();
278 my $phenotype = tooltipped_text('Phenotype dataset', 'in tab delimited format');
280 my $pheno_sec = CXGN::Page::FormattingHelpers::info_section_html(
281 title => 'Phenotype dataset',
282 subtitle => "$guide",
283 contents => " ",
286 my $pheno_form = qq^
287 <form action="qtl_load.pl" method="POST" enctype="MULTIPART/FORM-DATA">
288 $pheno_sec
289 <table cellspacing=20>
290 <tr>
291 <td>$phenotype:</td>
292 <td><input type="file" name="pheno_file" size=40>
293 <td> <input type="hidden" name="type" value="pheno_form"></td>
294 <td> <input type="hidden" name="pop_id" value = $pop_id></td>
295 <td><input type="submit" value="Submit"> </td>
296 </tr>
297 </table>
298 </form>
301 return $pheno_form;
306 sub geno_form {
307 my $self = shift;
308 my $pop_id = shift;
309 my $guide= $self->guideline();
311 my $genotype = tooltipped_text('Genotype dataset', 'in tab delimited format');
312 my $geno_sec = CXGN::Page::FormattingHelpers::info_section_html(
313 title => 'Genotype dataset',
314 subtitle => $guide,
315 contents => " ",
317 my $geno_form = qq^
318 <form action="qtl_load.pl" method="POST" enctype="MULTIPART/FORM-DATA">
319 $geno_sec
320 <table cellspacing=20>
321 <tr>
322 <td>$genotype:</td>
323 <td><input type="file" name="geno_file" size=40>
324 <td> <input type="hidden" name="type" value="geno_form"></td>
325 <td> <input type="hidden" name="pop_id" value=$pop_id></td>
326 <td><input type="submit" value="Submit"> </td>
327 </tr>
328 </table>
329 </form>
332 return $geno_form;
337 sub stat_form {
338 my $self = shift;
339 my $pop_id = shift;
340 my $guide = $self->guideline();
341 my $no_draws = tooltipped_text('No. of imputations', 'required only if the
342 Simulate method is selected for the
343 calculation of QTL genotype probability method and Multiple Imputation');
344 my $permu_level = tooltipped_text('Significance level of permutation test',
345 'required only if permutation analysis
346 (LOD threshold) is run');
347 my $genome_scan = tooltipped_text('Genome scan size (cM):', 'not required for Marker Regression'
349 my $qtl_prob = tooltipped_text('QTL genotype probablity method:', 'not required for Marker Regression'
352 my $stat_sec =CXGN::Page::FormattingHelpers::info_section_html(
353 title => 'Statistical Parameters',
354 subtitle => $guide,
355 contents => " ",
359 my $stat_form = qq^
360 <form action="qtl_load.pl" method="POST" enctype="MULTIPART/FORM-DATA">
362 $stat_sec
364 <table cellspacing=20>
365 <tr><td>QTL model: </td>
366 <td> <select name="stat_qtl_model">
367 <option>
368 <option>Single-QTL Scan
369 <option style="color: #FF0000;text-decoration: line-through">Two-QTL Scan--currently not available
370 </select>
371 </td>
372 <td>QTL mapping method:</td>
373 <td><select name="stat_qtl_method">
374 <option>
375 <option>Marker Regression
376 <option>Maximum Likelihood
377 <option>Haley-Knott Regression
378 <option>Multiple Imputation
379 </select>
380 </td>
381 </tr>
382 <tr><td>$qtl_prob</td>
383 <td><select name="stat_prob_method">
384 <option>
385 <option>Calculate
386 <option>Simulate
387 </select>
388 </td>
389 <td>QTL genotype probability significance level:</td>
390 <td><select name="stat_prob_level">
391 <option>
392 <option>0.001
393 <option>0.05
394 <option>0.1
395 </select>
396 </td>
397 </tr>
398 <tr>
399 <td>$genome_scan</td>
400 <td><select name="stat_step_size">
401 <option>
402 <option>zero
403 <option>1
404 <option>2.5
405 <option>5
406 <option>10
407 </select>
408 </td>
409 <td>$no_draws</td>
410 <td><select name="stat_no_draws">
411 <option>
412 <option>5
413 <option>10
414 <option>15
415 <option>20
416 </select>
417 </td>
418 </tr>
419 <tr>
420 <td>No. of permutations:</td>
421 <td><select name="stat_permu_test">
422 <option>
423 <option>None
424 <option>100
425 <option>1000
426 </select>
427 </td>
428 <td>$permu_level:</td>
429 <td> <select name="stat_permu_level">
430 <option>
431 <option>0.05
432 <option>0.001
433 <option>0.1
434 </select>
435 </td>
436 </tr>
437 <tr>
438 <td> <input type="hidden" name="type" value="stat_form"></td>
439 <td> <input type="hidden" name="pop_id" value = $pop_id ></td>
440 </tr>
441 <tr>
442 <td></td>
443 <td><input type="submit" value="Submit"> </td>
444 <td></td>
445 <td> <input type="reset" value="Reset"></td>
446 </tr>
447 </table>
448 </form>
452 return $stat_form;
457 sub associate_organism {
458 my $self = shift;
460 my $associate = qq^
461 <div id= 'associateTaxonForm' style="display: none">
462 <div id= "organism_search">
463 Common name:
464 <input type="text"
465 style="width: 50%"
466 id="organism_name"
467 onkeyup="Qtl.getTaxons(this.value)">
468 <input type="button"
469 id="associate_taxon_button"
470 value="associate organism"
471 disabled="true"
472 onclick="Qtl.associateTaxon();this.disabled=false;">
473 <select id="taxon_select"
474 style="width: 100%"
475 onchange="Tools.enableButton('associate_taxon_button');"
476 size=10>
477 </select>
478 </div>
480 </div>
483 return $associate;
488 sub conf_form {
489 my $self = shift;
490 my $pop_id = shift;
491 my $guide = $self->guideline();
492 my $dbh = CXGN::DB::Connection->new();
494 my $conf_sec =CXGN::Page::FormattingHelpers::info_section_html(
495 title => ' ',
496 subtitle => "$guide",
497 contents => ' ',
500 my ($pop_link, $pop_name);
502 if ($pop_id) {
503 my $pop = CXGN::Phenome::Population->new($dbh, $pop_id);
504 $pop_name = $pop->get_name();
505 $pop_link = qq | <a href="/phenome/population.pl?population_id=$pop_id"><b>$pop_name</b></a> |;
508 my $conf_form = qq^
509 <form action=" " method="POST" enctype="MULTIPART/FORM-DATA">
510 $conf_sec
511 <table cellspacing=20>
512 <tr>
513 <td><b><p>You have successfully uploaded your QTL data.</p>
514 <p>On the next page you will see the population data summary.
515 The qtl analysis is performed on-the-fly and you need to click the
516 graph icon corresponding to the trait of your interest to proceed
517 with the QTL mapping analysis. The QTL analysis takes a few minutes,
518 so please be patient. </p>
519 <p>To continue to the QTL analysis page, follow the link below:</p>
520 $pop_link</b>
521 </td>
522 </tr>
523 </table>
524 </form>
528 return $conf_form;
533 sub intro {
534 my $self = shift;
535 my $guide = $self->guideline();
536 my $intro_sec =CXGN::Page::FormattingHelpers::info_section_html(
537 title => 'Introduction',
538 subtitle => $guide,
539 contents => ' ',
543 my $intro = qq^
544 <form action="qtl_load.pl" method="POST" enctype="MULTIPART/FORM-DATA">
545 $intro_sec
546 <table cellspacing=20>
547 <tr><td>
549 <p>The uploading of QTL data needs to be done in one session.
550 Therefore, have ready your data files before starting the
551 process.
552 </p>
554 <p>The data you need are:</p>
556 <ul>
557 <li>Some basic information about the population
558 <li>Traits file (tab delimited): List of traits,
559 definition, units of measurement.
560 <li>Phenotype data file (tab delimited):
561 <li>Genotype data file (tab delimited):
562 <li>Statistical parameters.
563 </ul>
565 <p>The QTL data uploading software is at Beta stage. If you have any problems
566 uploading your data or remarks, please send us your feedback.
567 </p>
568 </td>
569 </tr>
570 <tr>
571 <td> <input type="hidden" name = "type" value="begin"> </td>
572 <td> <input type="submit" value="Begin Uploading"> </td>
573 </tr>
574 </table>
575 </form>
578 return $intro;
583 sub guideline {
584 my $self = shift;
585 return my $guideline = qq |<a href="http://docs.google.com/View?id=dgvczrcd_1c479cgfb">Guidelines</a> |;