ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/modelit/server/index.php
Revision: 1299
Committed: Tue Jan 11 17:38:33 2011 UTC (8 years, 9 months ago) by hstehr
File size: 7485 byte(s)
Log Message:
adding Model-It server files to repository
Line File contents
1 <?php
2 include_once("inc/settings.php");
3 session_start();
4
5 function is_valid_job_name($job_name) {
6 return ereg('^[-0-9a-zA-Z_]+$', $job_name);
7 }
8
9 function is_valid_sequence($sequence) {
10 return ereg('^[a-zA-Z]+$', $sequence);
11 }
12
13 function job_output_exists($job_name) {
14 return file_exists(get_output_dir($job_name));
15 }
16
17 if (array_key_exists('_submit_check',$_POST)) {
18
19 // save form input
20 $seq = trim($_POST['sequence']);
21 $seq = str_replace("\n", "", $seq);
22 $seq = str_replace("\r", "", $seq);
23 $_SESSION['sequence'] = $_POST['sequence'];
24 $_SESSION['job_name'] = substr($_POST['job_name'], 0, 50); # maximum job length is 50
25
26 // check that job name is given
27 if(!array_key_exists('job_name',$_POST) || $_POST['job_name'] == "") {
28 $form_errors['no_job_name'] = 1;
29 } else {
30 // check that job name is valid
31 if(!is_valid_job_name($_POST['job_name'])) {
32 $form_errors["wrong_job_name"] = 1;
33 } else {
34 // check that job name is not taken already
35 if(job_output_exists($_POST['job_name'])) {
36 $form_errors['job_name_exists'] = 1;
37 }
38 }
39 }
40
41 // check that sequence exists
42 if(!array_key_exists('sequence',$_POST) || $_POST['sequence'] == "") {
43 $form_errors["no_sequence"] = 1;
44 } else {
45 // check that sequence is valid
46 if(!is_valid_sequence($seq)) {
47 $form_errors['wrong_sequence'] = 1;
48 } else {
49 $seqlen = strlen($seq);
50 }
51 }
52
53 // check that sequence range is valid
54 $seq_from = 1;
55 $seq_to = $seqlen;
56 // if start or end key exists
57 if( (array_key_exists('seqfrom',$_POST) && $_POST['seqfrom'] != "") ||
58 (array_key_exists('seqto',$_POST) && $_POST['seqto'] != "") ){
59 // if start or end key is missing
60 if(!array_key_exists('seqfrom',$_POST) || $_POST['seqfrom'] == "" ||
61 !array_key_exists('seqto',$_POST) || $_POST['seqto'] == "") {
62 $form_errors['wrong_seq_range'] = 1;
63 } else {
64 $seq_from = (int) $_POST['seqfrom'];
65 $seq_to = (int) $_POST['seqto'];
66 if($seq_from < 1 || $seq_to > $seqlen || $seq_to < $seq_from) {
67 $form_errors['wrong_seq_range'] = 2;
68 }
69 }
70 }
71
72 // no errors -> redirect to template selection
73 if(!isset($form_errors)) {
74 $_SESSION['sequence'] = strtoupper($seq);
75 $_SESSION['seqfrom'] = $seq_from;
76 $_SESSION['seqto'] = $seq_to;
77 header("Location: run_template_selection.php");
78 }
79 }
80 ?>
81 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
82 <html xmlns="http://www.w3.org/1999/xhtml">
83
84 <head>
85 <title>Structure prediction server</title>
86 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
87 <link rel="stylesheet" type="text/css" href="css/default.css" />
88
89 <script type="text/javascript">
90
91 // performed if 'clear form' button is pressed
92 function clearForm() {
93 document.seqform.job_name.value='';
94 document.seqform.sequence.value='';
95 document.seqform.seqfrom.value='';
96 document.seqform.seqto.value='';
97 setSeqLen();
98 }
99
100 // show the current sequence length in the 'rescount' field
101 function setSeqLen() {
102 var seqLen = document.getElementById('sequence').value.length;
103 var span = document.getElementById('rescount');
104 span.innerHTML = seqLen;
105 }
106
107 // select part of text area
108 function selectInTextArea(id, start, end){
109
110 var textarea = document.getElementById(id);
111 if(textarea.setSelectionRange){
112 textarea.setSelectionRange(parseInt(start), parseInt(end));
113 }
114 else {
115 var range = textarea.createTextRange();
116 range.collapse(true);
117
118 range.moveStart('character',parseInt(start) );
119 range.moveEnd('character',(parseInt(end)-parseInt(start)+1));
120 range.select();
121 }
122 }
123
124 // highlight the subsequence chosen in the sequence range text fields
125 function selectSubSequence() {
126 var areaId='sequence';
127 var fromId = 'seqfrom';
128 var toId = 'seqto';
129
130 var start = document.getElementById(fromId).value;
131 var end = document.getElementById(toId).value;
132
133 selectInTextArea(areaId, start-1, end);
134 }
135
136 // show the start and end indices of the selected sub sequence to the sequence range text fields
137 function setRange() {
138 var textarea=document.getElementById('sequence');
139 document.getElementById('seqfrom').value=textarea.selectionStart+1;
140 document.getElementById('seqto').value=textarea.selectionEnd;
141 }
142
143 </script>
144
145
146 </head>
147 <body onload="setSeqLen();">
148 <?php include_once("inc/owl_header.inc.php") ?>
149 <h3>Protein Structure Prediction Server</h3>
150 <div style="width:800px">
151 <div class="roundedcornr_box_759934">
152 <div class="roundedcornr_top_759934"><div></div></div>
153 <div class="roundedcornr_content_759934">
154
155 <form name="seqform" action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" enctype="multipart/form-data">
156 <input type="hidden" name="_submit_check" value="1"/>
157 <table cellspacing=10>
158 <tbody>
159 <tr>
160 <td valign="top">Job name:</td>
161 <td><input type="text" name="job_name" size=30 maxlength="50" value="<? echo $_SESSION['job_name'] ?>">
162 <?php
163 if(isset($form_errors['no_job_name'])) {
164 echo '<br/><font color="red">Please provide a job name</font>';
165 }
166 if(isset($form_errors['wrong_job_name'])) {
167 echo '<br/><font color="red">Wrong job name: please use only letters, numbers and underscores</font>';
168 }
169 if(isset($form_errors['job_name_exists'])) {
170 echo '<br/><font color="red">This job name exists already. Please choose a different one.<font>';
171 }
172 ?>
173 </td>
174 </tr>
175 <tr>
176 <td valign="top">Protein sequence:</td>
177 <td><textarea style="width:600px; height:150px" id="sequence" name="sequence" wrap="soft" onselect="setRange();" onkeyup="setSeqLen();" onchange="setSeqLen();"><? echo $_SESSION['sequence'] ?></textarea>
178 <?php
179 if(isset($form_errors['no_sequence'])) {
180 echo '<br/><font color="red" size="2">Please provide a sequence</font>';
181 }
182 if(isset($form_errors['wrong_sequence'])) {
183 echo '<br/><font color="red" size="2">Illegal character in sequence: please provide a plain protein sequence without fasta header</font>';
184 }
185 ?>
186 </td>
187 </tr>
188 <tr>
189 <td>Sequence range:</td>
190 <td>
191 <input type="text" name="seqfrom" id="seqfrom" value="<? echo $_SESSION['seqfrom'] ?>" size="4" maxlength="4" onkeyup="selectSubSequence()" onchange="selectSubSequence()" />
192 to <input type="text" name="seqto" id="seqto" value="<? echo $_SESSION['seqto'] ?>" size="4" maxlength="4" onkeyup="selectSubSequence()" onchange="selectSubSequence()" />
193 out of <span id="rescount">0</span>
194 <?php
195 if(isset($form_errors['wrong_seq_range'])) {
196 echo '<br/><font color="red" size="2">Invalid sequence range</font>';
197 }
198 ?>
199 </td>
200
201 </tr>
202 <!-- tr>
203 <td>Or upload file:</td>
204 <td><INPUT type="file" name="seq_file"></td>
205 </tr -->
206 <tr>
207 <td></td>
208 <td><input type="submit" value="Submit" class="fancybutton"> <input type="button" class="fancybutton" value="Clear form" onClick="clearForm();"></td>
209 </tr>
210 </tbody>
211 </table>
212 </form>
213 </div>
214 </div>
215 <div class="roundedcornr_bottom_759934"><div></div></div>
216 </div>
217 <br/>
218 <div class="buttons">
219 <a href="results.php"><img src="images/application_view_list.png" alt="" /> View result list</a>
220 </div>
221 <div style="clear:both;"></div>
222 <p><b>Contact: </b>stehr@molgen.mpg.de</p>
223 </body>
224 </html>