Merge branch 'master' of https://github.com/solgenomics/sgn
[sgn.git] / cgi-bin / tools / align_viewer / index.pl
blob74fa40ae800b03bb3ce10a02e15f388d67c4ee5b
1 use CatalystX::GlobalContext qw( $c );
2 use strict;
4 use CXGN::Page;
5 use CXGN::Page::FormattingHelpers qw/ page_title_html
6 blue_section_html /;
7 use HTML::Entities;
8 #Get input, if this page is loaded from find_caps.pl
9 my $page = CXGN::Page->new( "Align Browser", "Chenwei");
10 my ($seq_data, $id_data, $format, $title, $type,
11 $show_prot_example, $show_cds_example, $show_id_example,
12 $temp_file, $maxiters) = $page->get_arguments(
13 qw/seq_data id_data format title type
14 show_prot_example show_cds_example show_id_example
15 temp_file maxiters/
18 my ($intro_content, $input_content);
20 my $HTML_ROOT = $c->get_conf('basepath');
21 my $DOC_PATH = $c->get_conf('tempfiles_subdir').'/align_viewer';
22 my $PATH = $HTML_ROOT . $DOC_PATH;
23 if( $temp_file ) {
24 $temp_file = $c->path_to( $c->generated_file_uri('align_viewer',$temp_file) );
25 if(-f $temp_file){
26 $seq_data = $temp_file->slurp;
31 #############################################################
32 #Create introduction content'
33 $intro_content = <<HTML;
34 <p>This tool analyzes sequence alignment. Please input <b>aligned sequences only</b>, in either fasta or clustal format.</p>
35 Its functionality includes:
36 <ol>
37 <li>Image display.</li>
38 <li>Calculation and output of pairwise similaity and putative splice variant or allelle pairs based on overlap and similarity between sequence pairs in an alignment.</li>
39 <li>Provides the user with options to hide some alignment sequences so that they are not included in the analysis.</li>
40 <li>Select a range of sequences to be analyzed.</li>
41 <li>Assess how an alignment member overlap with other members.</li>
42 <li>Calculate the non-gap mid point of each align sequence and group the sequences according to their overlap.</li>
43 </ol>
44 HTML
46 $title||="";
48 #############################################################
49 #Create input content
50 $input_content = <<HTML;
51 <form method="post" action="show_align.pl" name="aligninput" enctype="multipart/form-data">
53 <input type="submit" name="submit" value="Analyze Alignment" /><br /><br />
54 <b>Title (optional): </b>&nbsp;&nbsp;
55 <input type="textbox" name="title" size="16" value="$title">
56 <br /><br />
57 HTML
59 #Alignment type
60 if(!$type) { $type = "pep" }
61 my %type_checked = ( pep => "", nt => "", cds => "" );
62 $type_checked{$type} = "checked=\"checked\"";
63 my ($tcn, $tcp, $tcc) = map { $type_checked{$_} } qw/ nt pep cds /;
65 $input_content .= <<HTML;
66 <b>Type</b>&nbsp;&nbsp;
67 <input id="aligninput.radio.nt" type="radio" name="type" value="nt" $tcn/>nucleotide &nbsp;&nbsp;
68 <input id="aligninput.radio.pep" type="radio" name="type" value="pep" $tcp/>peptide &nbsp;&nbsp;
69 <input id="aligninput.radio.pep" type="radio" name="type" value="cds" $tcc/>CDS (most powerful)
70 <br /><br />
71 HTML
73 #############################
74 #Input format let it be unaligned by default
75 if (!$format) { $format="fasta_unaligned"; }
77 my %format_checked = ( clustalw => "",
78 fasta => "",
79 fasta_unaligned => "",
82 $format_checked{$format}="checked=\"checked\"";
83 $maxiters ||= 2;
84 my ($fcw, $fcf, $fcu) = map { $format_checked{$_} } qw/clustalw fasta fasta_unaligned/;
86 $input_content .= <<HTML;
87 <b>Input format</b><br />
88 You may specify the species of the sequence with a forward slash, e.g. "AT1G01010.1/Arabidopsis" <br />
89 Make sure all the spaces in the id and species are replaced by '_'.<br />
90 <input type="radio" name="format" value="clustalw" $fcw/>Clustal Alignment<a target="blank" href="/about/clustal_file.pl"> [What is this?]</a><br />
91 <input type="radio" name="format" value="fasta" $fcf/>Fasta Alignment (With Gaps)<br /><br />
92 <input type="radio" name="format" value="fasta_unaligned" $fcu/>Fasta Unaligned (Will be aligned with <a href="http://www.drive5.com/muscle/">Muscle 3.6</a>, Limited to 200 Sequences)<br />
94 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Max Iterations
95 <input type="text" name="maxiters" value=$maxiters>
96 Use more iterations for greater accuracy. The maximum is 1000.<br /><br />
97 <!--
98 <input type="radio" name="run" value="cluster" checked="1">run on cluster (preferred)<br />
99 <input type="radio" name="run" value="local">run on localhost<br /><br />
101 HTML
103 if($show_prot_example){
104 $seq_data = $page->path_to("cgi-bin/tools/align_viewer/data/prot_example.txt")->slurp;
106 elsif($show_cds_example){
107 $seq_data = $page->path_to("cgi-bin/tools/align_viewer/data/cds_example.txt")->slurp;
109 elsif($show_id_example){
110 $id_data = <<HEREDOC;
111 SGN-U282881 SGN-U228103 At1g09155.1 At1g56240.1 At1g56250.1 NP_178331.2 At2g02350.1 At2g02320.1 At2g02340.1 At2g02360.1 At2g02250.1 At2g02240.1 At2g02300.1 At2g02310.1 SGN-U211584 SGN-U219097 SGN-U219098 SGN-U311800 SGN-U218282 SGN-U218283 At5g24560.1 SGN-U204215 SGN-U221580 SGN-U282885 SGN-U234276 SGN-U220091 SGN-U305684 SGN-U219720
112 HEREDOC
115 $seq_data ||= '';
116 ###############################
117 #Text area for input sequences
118 $input_content .= <<HTML;
119 <b>Input fasta/clustal sequences</b>
120 &nbsp;&nbsp;
121 <a href="index.pl" onclick="
122 document.getElementById('textarea_seq_data').value = '';
123 return false">(x) Clear</a><br />
124 <textarea id="textarea_seq_data" name="seq_data" rows="12" cols="80">$seq_data</textarea><br /><br />
125 <b>Or use identifiers, separated by spaces</b><br />
126 Supports TAIR AGI [AT1G01010.1], SGN Unigene [SGN-U332332], or any NCBI/Entrez identifier<br />
127 <textarea id="textarea_id_data" name="id_data" rows="2" cols="80">$id_data</textarea><br /><br />
128 <b>Or upload a fasta/clustal file</b> <input type="file" name="upload" /><br />
129 <br /><br />
132 <input type="submit" name="submit" value="Analyze Alignment" />
133 </form>
135 HTML
138 # Print Page
140 $page->header();
143 my $example_link = <<HTML;
144 &nbsp;&nbsp;&nbsp;<span style="color:#669">
145 <a href="index.pl?&format=fasta&title=Alignment%20Example&type=pep&show_prot_example=1">
146 Aligned Example</a>
147 &nbsp;|&nbsp;
148 <a href="index.pl?&format=fasta_unaligned&maxiters=300&title=CDS%20Example&type=cds&show_cds_example=1">Unaligned Example</a>
149 &nbsp;|&nbsp;
150 <a href="index.pl?&maxiters=10&title=ID%20Input%20Example&&type=pep&format=fasta_unaligned&show_id_example=1">ID Input Example</a>
151 </span>
152 HTML
154 print page_title_html("Alignment Analyzer");
156 #print blue_section_html('Introduction','<table width="100%" cellpadding="5" cellspacing="0" border="0" summary=""><tr><td>' . $intro_content . '</td></tr></table>');
158 print blue_section_html(
159 "<span style=\"white-space:nowrap\">Query Input &nbsp;&nbsp;&nbsp;&nbsp;$example_link</span>",
160 '<table width="100%" cellpadding="5" cellspacing="0" border="0" summary=""><tr><td>' . $input_content . '</td></tr></table>');
163 $page->footer();