Merge branch 'master' of https://github.com/solgenomics/sgn
[sgn.git] / cgi-bin / tools / insilicopcr / index.pl
blobd831fab9cb29db31a8558579587bffe7892c69f8
1 =head1 NAME
3 index.pl - In Silico PCR web interface
5 =head1 DESCRIPTION
7 This interface shows a form that requires user input of the forward primer,
8 reverse primer, maximum product size, Allowed mismathces. Also, In Silico
9 PCR is dependent on the BLAST similarity search. Part of the blast code was
10 used here to get the database, program, matrix, e-value.
11 This page will forward the input to pcr_blast_result.pl and will then display
12 the results in view_result.pl.
15 =head1 DEPENDENCIES
17 Alot of the BLAST code in /sgn/cgi-bin/tool/blast was reused here
18 PCR is dependent on the BLAST search to find the primers in the databases
20 =head1 AUTHOR
22 Waleed Haso wh292@cornell.edu
23 Only added modifications to support the PCR part
24 Original code was aspired from BLAST.
26 =cut
30 use strict;
31 use warnings;
32 use POSIX;
34 use CXGN::DB::Connection;
35 use CXGN::Page;
36 use CXGN::BlastDB;
37 use CXGN::Page::FormattingHelpers qw/page_title_html info_table_html hierarchical_selectboxes_html /;
38 use CXGN::Page::UserPrefs;
39 use CXGN::Tools::List qw/evens distinct/;
41 my $page = CXGN::Page->new("In Silico PCR form","Waleed");
42 my $dbh = CXGN::DB::Connection->new;
43 our $prefs = CXGN::Page::UserPrefs->new( $dbh );
45 $page->header('In Silico PCR');
47 my ($databases,$programs,$programs_js) = blast_db_prog_selects();
49 ##############################################################################################################################
51 print page_title_html("In Silico PCR");
55 print <<EOF;
57 <HR></HR>
58 <form method="post" action="pcr_blast_result.pl" name="PCRform" enctype="multipart/form-data">
59 <input type="hidden" name="outformat" value="8" />
61 <table id="PCRinput" align="center" summary="" cellpadding="0" cellspacing="15" border="0">
62 <tr>
63 <td>
64 <H2><B> PCR Primers:</B></H2>
65 </td>
66 </tr>
67 <tr>
68 <td>
69 <B> Forward Primer</B>
70 </td>
71 <td>
72 <input type="text" size="65" value="" name="fprimer" />
73 </td>
74 </tr>
75 <tr>
76 <td>
77 <B>Reverse Complement Forward Primer</B>
78 </td>
79 <td>
80 <input type="checkbox" name="frevcom" />
81 </td>
82 </tr>
83 <tr>
84 <td>
85 <B> Reverse Primer</B>
86 </td>
87 <td>
88 <input type="text" size="65" value="" name="rprimer" />
89 </td>
90 </tr>
91 <tr>
92 <td>
93 <B>Reverse Complement Reverse Primer</B>
94 </td>
95 <td>
96 <input type="checkbox" name="rrevcom" />
97 </td>
98 </tr>
99 <tr>
100 <td>
101 <b>Product Maximum Length</b>
102 </td>
103 <td >
104 <input type="text" size="5" value="5000" name="productLength" />
105 </td>
106 </tr>
107 <tr>
108 <td>
109 <b>Allowed Mismatches</b>
110 </td>
111 <td >
112 <input type="text" size="5" value="0" name="allowedMismatches" />
113 </td>
114 </tr>
115 <tr>
116 <td>
117 <H2><B> BLAST Attributes:</B></H2>
118 </td>
119 </tr>
121 <tr>
122 <td>
123 <b>Database (<tt>-d</tt>)</b>
124 </td>
125 <td>
126 $databases <a style="font-size: 80%" title="View details of each database" href="/tools/blast/dbinfo.pl">db details</a>
127 </td>
128 </tr>
129 <tr>
130 <td>
131 <b>BLAST Program (<tt>-p</tt>)</b>
132 </td>
133 <td>
134 $programs
135 </td>
136 </tr>
137 <tr>
138 <td>
139 <b>Substitution Matrix (<tt>-M</tt>)</b>
140 </td>
141 <td >
142 <select name="matrix">
143 <option value="BLOSUM62">BLOSUM62 (default)</option>
144 <option value="BLOSUM80">BLOSUM80 (recent divergence)</option>
145 <option value="BLOSUM45">BLOSUM45 (ancient divergence)</option>
146 <option value="PAM30">PAM30</option>
147 <option value="PAM70">PAM70</option>
148 </select>
149 </td>
150 </tr>
151 <tr>
152 <td>
153 <b>Expectation value (<tt>-e</tt>)</b>
154 </td>
155 <td >
156 <input type="text" size="10" value="0.01" name="expect" />
157 </td>
158 </tr>
159 <tr><td><b>Filter query sequence (DUST with blastn, SEG with others) (<tt>-F</tt>)</b></td>
160 <td><input type="checkbox" checked="checked" name="filterq" /></td>
161 </tr>
162 <tr>
163 <td align="right"><input type="reset" value="Clear" /></td>
164 <td align="center"><input type="submit" name="search" value=" Run " style="background: yellow; font-size: 130%" /></td>
165 </tr>
166 </table>
167 </form>
168 <script language="JavaScript" type="text/javascript">
169 $programs_js
170 </script>
173 #}#end of the commented else
175 $page->footer();
177 ##########################################################################################################################
178 #This subroutine is copied exactly from the BLAST index.pl code
180 sub blast_db_prog_selects {
181 sub opt {
182 my $db = shift;
183 my $timestamp = $db->file_modtime
184 or return '';
185 $timestamp = strftime(' &nbsp;(%m-%d-%y)',gmtime $db->file_modtime);
186 my $seq_count = $db->sequences_count;
188 [$db->blast_db_id, $db->title.$timestamp]
191 my @db_choices = map {
192 my @dbs = map [$_,opt($_)], grep $_->file_modtime, $_->blast_dbs( web_interface_visible => 't');
193 @dbs ? ('__'.$_->name, @dbs) : ()
194 } CXGN::BlastDB::Group->search_like(name => '%',{order_by => 'ordinal, name'});
196 my @ungrouped_dbs = grep $_->file_modtime,CXGN::BlastDB->search( blast_db_group_id => undef, web_interface_visible => 't', {order_by => 'title'} );
197 if(@ungrouped_dbs) {
198 push @db_choices, '__Other', map [$_,opt($_)], @ungrouped_dbs;
201 @db_choices or return '<span class="ghosted">The BLAST service is temporarily unavailable, we apologize for the inconvenience</span>';
203 my $selected_db_file_base = $prefs->get_pref('last_blast_db_file_base');
204 #warn "got pref last_blast_db_file_base '$selected_db_file_base'\n";
206 my %prog_descs = ( blastn => 'BLASTN (nucleotide to nucleotide)',
207 blastx => 'BLASTX (nucleotide to protein; query translated to protein)',
208 blastp => 'BLASTP (protein to protein)',
209 tblastx => 'TBLASTX (protein to protein; both database and query are translated)',
210 tblastn => 'TBLASTN (protein to nucleotide; database translated to protein)',
213 my @program_choices = map {
214 my ($db) = @$_;
215 if($db->type eq 'protein') {
216 [map [$_,$prog_descs{$_}], 'blastx','blastp']
217 } else {
218 [map [$_,$prog_descs{$_}], 'blastn','tblastx','tblastn']
220 } grep ref, @db_choices;
222 @db_choices = map {ref($_) ? $_->[1] : $_} @db_choices;
224 return hierarchical_selectboxes_html( parentsel => { name => 'database',
225 choices =>
226 \@db_choices,
227 $selected_db_file_base ? (selected => $selected_db_file_base) : (),
229 childsel => { name => 'program',
231 childchoices => \@program_choices