ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/mfoldinterface/obtainmfold.pl
Revision: 1.18
Committed: Mon Apr 10 16:39:37 2006 UTC (10 years, 3 months ago) by schu1321
Branch: MAIN
CVS Tags: HEAD
Changes since 1.17: +5 -1 lines
Log Message:
Fixed output path bug (was adding a \n to path). Also added a line to remove temp file after folding finishes.

Line File contents
1 #!/usr/bin/perl
2
3 # MFold Submission/Result Retrieval Script
4 # Created by Wade Schulz (schu1321@umn.edu)
5 # University of Minnesota, Department of Medicine
6 # Division of Rheumatic and Autoimmune Disease
7
8 # MFold Created by Dr. Michael Zuker
9 # "Mfold web server for nucleic acid folding and hybridization prediction. Nucleic Acids Res. 31 (13), 3406-15, (2003)"
10
11 use strict;
12 use Bio::Perl;
13 use IO::Socket;
14 use Cwd;
15 use Tk;
16 require Tk::DirTree;
17
18 # Print out program info
19 print_version();
20 get_data();
21
22 MainLoop;
23
24 sub get_data{
25 my $accession;
26 my $name;
27 my $desc;
28 my $seq;
29 my $start;
30 my $end;
31 my $cwd = getcwd;
32
33 open(SEQDATA, ">seqdata.tmp");
34
35 my $data_win = MainWindow->new;
36 $data_win->title("MFold Interface");
37 my $acc_frame = $data_win->Frame(-borderwidth => 3, -relief => "raised", -label=>"GI Number: ",
38 -labelPack => [-side => 'left', -anchor => 'w' ]);
39 my $name_frame = $data_win->Frame(-label=>"Sequence Name: ",
40 -labelPack => [ -side => 'left', -anchor => 'w' ]);
41 my $desc_frame = $data_win->Frame(-label=>"Sequence Description: ",
42 -labelPack => [ -side => 'left', -anchor => 'w' ]);
43 my $start_frame = $data_win->Frame(-label=>"Fold Start: ",
44 -labelPack => [ -side => 'left', -anchor => 'w' ]);
45 my $end_frame = $data_win->Frame(-label=>"Fold End: ",
46 -labelPack => [ -side => 'left', -anchor => 'w' ]);
47 my $seq_frame = $data_win->Frame(-label=>"Sequence: ",
48 -labelPack => [ -side => 'left', -anchor => 'w' ]);
49 my $added_frame = $data_win->Frame(-label=>"Added Sequences: ", -labelPack => [ -side => 'left', -anchor =>'w']);
50
51 $acc_frame->Entry(-relief => "groove",
52 -textvariable => \$accession)->pack(-side => 'left');
53
54 $name_frame->Entry(-relief => "groove",
55 -textvariable => \$name)->pack;
56 $desc_frame->Entry(-relief => "groove", -width => 100,
57 -textvariable => \$desc)->pack;
58 $start_frame->Entry(-relief => "groove",
59 -textvariable => \$start)->pack;
60 $end_frame->Entry(-relief => "groove",
61 -textvariable => \$end)->pack;
62 my $seqtext = $seq_frame->Scrolled("Text", -height => 24)->pack;
63
64 my $list = $added_frame->Scrolled("Listbox", -scrollbars => "e", -width => 40,
65 -selectmode => "single")->pack();
66
67 $list->insert('end', "Seq Name Start End");
68
69 my $dir_frame = $data_win->Frame(-borderwidth => 3, -relief => "raised", -label =>"Directory for Output: ", -labelPack => [ -side => 'left', -anchor => 'w']);
70 $dir_frame->Label(-relief => "groove",
71 -textvariable => \$cwd)->pack(-anchor => 'w');
72 $dir_frame->Button(-text => "Change Directory", -command => sub{
73 $data_win->withdraw;
74 my $top = new MainWindow;
75 $top->withdraw;
76
77 my $t = $top->Toplevel;
78 $t->title("Choose directory:");
79 my $ok = 0; # flag: "1" means OK, "-1" means cancelled
80
81 # Create Frame widget before the DirTree widget, so it's always visible
82 # if the window gets resized.
83 my $f = $t->Frame->pack(-fill => "x", -side => "bottom");
84
85 my $curr_dir = Cwd::cwd();
86
87 my $d;
88 $d = $t->Scrolled('DirTree',
89 -scrollbars => 'osoe',
90 -width => 35,
91 -height => 20,
92 -selectmode => 'browse',
93 -exportselection => 1,
94 -browsecmd => sub { $curr_dir = shift },
95
96 # With this version of -command a double-click will
97 # select the directory
98 -command => sub { $ok = 1 },
99
100 # With this version of -command a double-click will
101 # open a directory. Selection is only possible with
102 # the Ok button.
103 #-command => sub { $d->opencmd($_[0]) },
104 )->pack(-fill => "both", -expand => 1);
105 # Set the initial directory
106 $d->chdir($curr_dir);
107
108 $f->Button(-text => 'Ok',
109 -command => sub { $ok = 1 })->pack(-side => 'left');
110 $f->Button(-text => 'Cancel',
111 -command => sub { $ok = -1 })->pack(-side => 'left');
112
113 # You probably want to set a grab. See the Tk::FBox source code for
114 # more information (search for grabCurrent, waitVariable and
115 # grabRelease).
116 $f->waitVariable(\$ok);
117
118 if ($ok == 1) {
119 $cwd = $curr_dir;
120 $data_win->deiconify();
121 $top->destroy();
122 }
123 })->pack(-side => 'top', -anchor => 'w');
124
125 $dir_frame->pack(-side => 'top', -anchor => 'w', -fill => 'x');
126 $acc_frame->pack(-side => 'top', -anchor => 'w', -fill => 'x');
127
128 $acc_frame->Button(-text => "Get Sequence Data", -command => sub{
129 my $db_obj = Bio::DB::GenBank->new;
130 my $seq_obj = $db_obj->get_Seq_by_acc($accession);
131 $seq = $seq_obj->seq;
132 $seqtext->insert('end', $seq);
133 $desc = $seq_obj->desc;
134 })->pack(-side => 'top', -anchor => 'w');
135
136 my $options_frame = $data_win->Frame(-label=>"Download Options: ",
137 -labelPack => [-side => 'left', -anchor => 'w' ]);
138 my @downloads;
139 $options_frame->Checkbutton(-text => "CT Files",
140 -variable => \$downloads[0])->pack(-side => 'left');
141 $options_frame->Checkbutton(-text => "JPG Files",
142 -variable => \$downloads[1])->pack(-side => 'left');
143 $options_frame->Checkbutton(-text => "SS Count",
144 -variable => \$downloads[2])->pack(-side => 'left');
145 $options_frame->Checkbutton(-text => "Vienna Files",
146 -variable => \$downloads[3])->pack(-side => 'left');
147 $options_frame->Checkbutton(-text => "H-Num",
148 -variable => \$downloads[4])->pack(-side => 'left');
149 $options_frame->Checkbutton(-text => "P-Num",
150 -variable => \$downloads[5])->pack(-side => 'left');
151 foreach(@downloads){
152 $_ = 0;
153 }
154 $name_frame->pack(-side => 'top', -anchor => 'w');
155 $desc_frame->pack(-side => 'top', -anchor => 'w');
156 $start_frame->pack(-side => 'top', -anchor => 'w');
157 $end_frame->pack(-side => 'top', -anchor => 'w');
158 $seq_frame->pack(-side => 'top', -anchor => 'w');
159 $options_frame->pack(-side => 'top', -anchor => 'w');
160 $added_frame->pack(-side => 'right', -anchor => 'n');
161
162 $data_win->Button(-text => "Add to List", -command => sub{
163 $seq = $seqtext->get('0.0', 'end');
164 $accession =~ s/\t//ig;
165 $start =~ s/\t//ig;
166 $end =~ s/\t//ig;
167 $name =~ s/\t//ig;
168 $desc =~ s/\t//ig;
169 $seq =~ s/\t//ig;
170 $accession =~ s/\n//ig;
171 $start =~ s/\n//ig;
172 $end =~ s/\n//ig;
173 $name =~ s/\n//ig;
174 $desc =~ s/\n//ig;
175 $seq =~ s/\n//ig;
176 $seq =~ s/ //ig;
177 $seq =~ s/[^acgtACGTuU]//ig;
178 $name =~ s/[^A-Za-z0-9_-]//ig;
179
180
181 print SEQDATA "$accession\t$start\t$end\t$name\t$desc\t$seq";
182 foreach(@downloads){
183 print SEQDATA "\t$_";
184 }
185 print SEQDATA "\t$cwd\n";
186 $list->insert('end', "$name $start $end");
187 $accession = '';
188 $start = '';
189 $end = '';
190 $name = '';
191 $desc = '';
192 $seqtext->delete('0.0', 'end');
193 })->pack(-side => 'bottom', -anchor => 'w');
194
195 $data_win->Button(-text => "Fold!", -command => sub{
196 close(SEQDATA);
197 $data_win->withdraw();
198 foldit();
199 })->pack(-side => 'bottom', -anchor => 'w');
200
201 }
202
203 # Loop to get data from file created by GUI
204 sub foldit{
205 # Get Accession Number from User
206 open(DATA, "seqdata.tmp") || die "Could not open temp file for input\n";
207 my $i = 0;
208 while(my $line = <DATA>){
209 $i++;
210 my @data = split(/\t/, $line);
211
212 my $start = $data[1];
213 my $end = $data[2];
214 my $name = $data[3];
215 my $seq = $data[5];
216 my @downloads;
217 $downloads[0] = $data[6];
218 $downloads[1] = $data[7];
219 $downloads[2] = $data[8];
220 $downloads[3] = $data[9];
221 $downloads[4] = $data[10];
222 $downloads[5] = $data[11];
223 my $cwd = $data[12];
224 # Fold Sequence, Download Data
225 get_seqs($start, $end, $name, $seq, $cwd, @downloads);
226 print "**************************\n";
227 print "Fold #$i complete!\n\n";
228 }
229 close(DATA);
230 unlink("seqdata.tmp");
231 exit(0);
232 }
233 # Main program function - gets sequence and drives other functions to fold/download data
234 sub get_seqs{
235 my ($start, $end, $seqname, $seq, $cwd, @downloads) = @_;
236 $cwd =~ s/\n//ig;
237
238 # Determine sequence length, start and end nucelotides for folding
239 my $length = length($seq);
240 print "Sequence is $length nucleotides long.\n";
241
242 if($end - $start > 800){
243 $end = $start + 799;
244 print "Selected sequence too long for immediate job (Limit 800 bases). End nt changed to $end.\n";
245 }
246 if($end>$length){
247 $end = $length;
248 print "Source sequence not long enough. End nt changed to $end.\n";
249 }
250
251
252 $seqname =~ s/\n//ig;
253 $seqname .= "_$start-$end";
254
255 # Print Status
256 print "Folding \"", $seqname, "\" from nucleotide $start to $end of total $length\n";
257 # Fold sequence, obtain address for results
258 my $address = fold($seqname, $start, $end, $seq);
259
260
261 my $filename;
262 if($address =~ /^.*old\/mfold\/(\d.*\/.*)\/.*/){
263 $filename = $1;
264 }
265
266 # Create directory for results
267 my $download;
268
269 my $type;
270 my $path;
271 my $param;
272
273 mkdir("$cwd/$seqname/");
274 my $success=0;
275 my $fails=0;
276 if($downloads[2] == 1){
277 ########################
278 # Download SS file -- add ending to $address, pass info to sub socket_download
279 ########################
280 $success = $fails = 0;
281 $path = ">$cwd/$seqname/$seqname.ss-count";
282 $download = $address . ".ss-count";
283 $type = "SS Count";
284 $success = socket_download(0, $download, $path, $type);
285 while($success == 1 && $fails < 5){
286 print "SS Count Not Complete. Pausing for 20 seconds.\n";
287 my $count = 0;
288 while($count<20){
289 sleep(1);
290 $count++;
291 print ".";
292 }
293 print "\n";
294 $success = socket_download(0, $download, $path, $type);
295 $fails += $success;
296 }
297 }
298 if($downloads[4] == 1){
299 ########################
300 # Download h-num file -- add ending to $address, pass info to sub socket_download
301 ########################
302 $success = $fails = 0;
303 $path = ">$cwd/$seqname/$seqname.h-num";
304 $download = $address . ".h-num";
305 $type = "H-Num";
306 $success = socket_download(0, $download, $path, $type);
307 while($success == 1 && $fails < 5){
308 print "H-num Not Complete. Pausing for 20 seconds.\n";
309 my $count = 0;
310 while($count<20){
311 sleep(1);
312 $count++;
313 print ".";
314 }
315 print "\n";
316 $success = socket_download(0, $download, $path, $type);
317 $fails += $success;
318 }
319 }
320 if($downloads[5] == 1){
321 ########################
322 # Download P-num file -- add ending to $address, pass info to sub socket_download
323 ########################
324 $success = $fails = 0;
325 $path = ">$cwd/$seqname/$seqname.ann";
326 $download = $address . ".ann";
327 $type = "P-num";
328 $success = socket_download(0, $download, $path, $type);
329 while($success == 1 && $fails < 5){
330 print "P-num Not Complete. Pausing for 20 seconds.\n";
331 my $count = 0;
332 while($count<20){
333 sleep(1);
334 $count++;
335 print ".";
336 }
337 print "\n";
338 $success = socket_download(0, $download, $path, $type);
339 $fails += $success;
340 }
341 }
342 if($downloads[0] == 1){
343 ########################
344 # Compress, download CT files
345 ########################
346 $success = $fails = 0;
347 $path = ">$cwd/$seqname/$seqname.ct.zip";
348 $param = "FILE_NAME=$filename/1&MODE=zip&STYPE=ct&SUB_DIR=$filename";
349 $param =~ s/\//\%2F/ig;
350 sock_compress($param);
351 $download = $address . ".ct.zip";
352 $type = "CT Zip";
353 $success += socket_download(1, $download, $path, $type);
354 while($success == 1 && $fails < 5){
355 print "CT Zip file not complete. Pausing for 20 seconds.\n";
356 my $count = 0;
357 while($count<20){
358 sleep(1);
359 $count++;
360 print ".";
361 }
362 print "\n";
363 $success = socket_download(1, $download, $path, $type);
364 $fails += $success
365 }
366 }
367 if($downloads[1] == 1){
368 ########################
369 # Compress, download JPG files
370 ########################
371 $success = $fails = 0;
372 $path = ">$cwd/$seqname/$seqname.jpg.zip";
373 $param = "FILE_NAME=$filename/1&MODE=zip&STYPE=jpg&SUB_DIR=$filename";
374 $param =~ s/\//\%2F/ig;
375 sock_compress($param);
376 $download = $address . ".jpg.zip";
377 $type = "JPG Zip";
378 $success += socket_download(1, $download, $path, $type);
379 while($success == 1 && $fails < 5){
380 print "JPG Zip file not complete. Pausing for 20 seconds.\n";
381 my $count = 0;
382 while($count<20){
383 sleep(1);
384 $count++;
385 print ".";
386 }
387 print "\n";
388 $success = socket_download(1, $download, $path, $type);
389 $fails += $success
390 }
391 }
392 if($downloads[3] == 1){
393 ########################
394 # Compress, download Vienna files
395 ########################
396 $success = $fails = 0;
397 $path = ">$cwd/$seqname/$seqname.b.zip";
398 $param = "FILE_NAME=$filename/1&MODE=zip&STYPE=Vienna&SUB_DIR=$filename";
399 $param =~ s/\//\%2F/ig;
400 sock_compress($param);
401 $download = $address . ".b.zip";
402 $type = "Vienna Zip";
403 $success += socket_download(1, $download, $path, $type);
404 while($success == 1 && $fails < 5){
405 print "Vienna Zip file not complete. Pausing for 20 seconds.\n";
406 my $count = 0;
407 while($count<20){
408 sleep(1);
409 $count++;
410 print ".";
411 }
412 print "\n";
413 $success = socket_download(1, $download, $path, $type);
414 $fails += $success
415 }
416 }
417
418 print "Finished! Files can be found at: \n$cwd/$seqname\n";
419
420
421
422 # Compress files (ex. CT, jpg, etc)
423 sub sock_compress{
424 my ($param) = @_;
425 ######################################
426 # Open the socket
427 ######################################
428 my $sock = new IO::Socket::INET(
429 PeerAddr=>'www.bioinfo.rpi.edu',
430 PeerPort=>'80',
431 Proto=>'tcp'
432 );
433 die "Could not create socket: $!\n" unless $sock;
434
435 ######################################
436 # Send information
437 ######################################
438 print $sock "GET /applications/mfold/old/cgi-bin/mfold-compress_img.cgi?" . $param . " HTTP/1.1\n" .
439 "Host: www.bioinfo.rpi.edu\n" .
440 "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1\n" .
441 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\n" .
442 "Accept-Language: en-us,en;q=0.5\n" .
443 "Accept-Encoding: gzip,deflate\n" .
444 "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\n" .
445 "Keep-Alive: 300\n" .
446 "Connection: keep-alive\n" .
447 "Referer: http://www.bioinfo.rpi.edu/\n\n";
448
449
450 print "Compressing files...\n";
451 ########################################
452 # Receive Information
453 ########################################
454 my $temp = 0;
455 while( my $line = <$sock> && $temp < 5){
456 #print $line, "\n";
457 $temp++;
458 }
459
460 ########################
461 # Close Socket
462 ########################
463 close($sock);
464 }
465
466 }
467
468 # Function to open socket, fold sequence, and obtain page data to search for path
469 sub fold{
470 my ($seqname, $start, $end, $sequence) = @_;
471 ########################
472 # Set folding parameters
473 ########################
474 my $constraints = "";
475 my $LorC = "linear";
476 my $percent = "5";
477 my $maxfolds = "50";
478 my $window = "default";
479 my $max_lp = "30";
480 my $max_as = "30";
481 my $maxbp = "no+limit";
482 my $batch = "An+Immediate";
483 my $email_addr = "schu1321\@umn.edu";
484 my $gifres = "72x72";
485 my $mode = "auto";
486 my $grid = "ON";
487 my $lab_fr = "default";
488 ## Offset may change -- see in do not edit section
489 my $offset = 0;
490 my $rot_ang = "0";
491 my $ann = "None";
492 my $max_length1 = "800";
493 my $max_length2 = "6000";
494 my $na = "RNA";
495 my $rh = "schu1321\@umn.edu";
496
497 ######################################
498 # MFold Page information (If changed)
499 ######################################
500 my $page = '/applications/mfold/old/cgi-bin/nph-mfold-3.1.cgi';
501
502 ###################################################
503 ## DO EDIT THESE
504 ## NOT BELOW LINES
505 ###################################################
506
507 # Create sequence from start-end
508 my @fullseq;
509 my $nt=$start-1;
510 my @sequence = split('', $sequence);
511 while($nt<$end-1){
512 $fullseq[$nt] = $sequence[$nt];
513 $nt++;
514 }
515 my $fullseq = join('', @fullseq);
516
517 ######################################
518 # Build the parameter list
519 ######################################
520 my $param = 'SEQ_NAME='.$seqname.
521 '&SEQUENCE='.$fullseq.
522 '&CONSTRAINTS='.$constraints.
523 '&LorC='.$LorC.
524 '&PERCENT='.$percent.
525 '&MAXFOLDS='.$maxfolds.
526 '&WINDOW='.$window.
527 '&MAX_LP='.$max_lp.
528 '&MAX_AS='.$max_as.
529 '&MAXBP='.$maxbp.
530 '&BATCH='.$batch.
531 '&EMAIL_ADDR='.$email_addr.
532 '&GIFRES='.$gifres.
533 '&MODE='.$mode.
534 '&GRID='.$grid.
535 '&LAB_FR='.$lab_fr.
536 '&OFFSET='.$offset.
537 '&ROT_ANG='.$rot_ang.
538 '&ANN='.$ann.
539 '&MAX_LENGTH1='.$max_length1.
540 '&MAX_LENGTH2='.$max_length2.
541 '&NA='.$na.
542 '&RH='.$rh
543 ;
544 print "Opening Socket...\n";
545 ######################################
546 # Open the socket
547 ######################################
548 my $sock = new IO::Socket::INET(
549 PeerAddr=>'www.bioinfo.rpi.edu',
550 PeerPort=>'80',
551 Proto=>'tcp'
552 );
553 die "Could not create socket: $!\n" unless $sock;
554
555 ######################################
556 # Send information
557 ######################################
558 print $sock "POST " . $page . " HTTP/1.1\n" .
559 "Host: www.bioinfo.rpi.edu\n" .
560 "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1\n" .
561 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\n" .
562 "Accept-Language: en-us,en;q=0.5\n" .
563 "Accept-Encoding: gzip,deflate\n" .
564 "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\n" .
565 "Keep-Alive: 300\n" .
566 "Connection: keep-alive\n" .
567 "Referer: http://www.bioinfo.rpi.edu/applications/mfold/old/rna/form1.cgi\n" .
568 "Content-Type: application/x-www-form-urlencoded\n" .
569 "Content-Length: " . length($param) . "\n\n" .
570 $param . "\n";
571
572 print "Receiving Confirmation...\n";
573 ########################################
574 # Receive Information, store in array
575 ########################################
576 my $line;
577 my @store;
578 my $z=0;
579 while( $line = <$sock> ){
580 $store[$z] = $line;
581 $z++;
582 }
583
584 ########################
585 # Close Socket
586 ########################
587 close($sock);
588 my $address = get_url(@store);
589
590 return $address;
591
592 }
593
594 # Search @store for URL to download info
595 sub get_url{
596 my @store = @_;
597 ########################
598 # Search for link, set up address for download ($address2)
599 ########################
600 print "Searching for link...\n";
601 my $last = join('', @store);
602 my @new_url = split(/url=http:\/\/www.bioinfo.rpi.edu\/applications\/mfold\/old\/mfold\//, $last);
603 my $new2 = $new_url[1];
604 @new_url = ();
605 @new_url = split(/\/\"><\//, $new2);
606 my $address = '/applications/mfold/old/mfold/' . $new_url[0];
607 $new2 = $new_url[0];
608 @new_url = ();
609 @new_url = split(/\//, $new2);
610 $address = $address . '/' . $new_url[1];
611 return $address;
612 }
613
614 # Function to open socket, download info to file
615 sub socket_download{
616 my ($mode, $download, $finalpath, $type) = @_;
617
618 print "Opening Socket for $type Download...\n";
619 ######################################
620 # Open the socket
621 ######################################
622 my $sock = new IO::Socket::INET(
623 PeerAddr=>'www.bioinfo.rpi.edu',
624 PeerPort=>'80',
625 Proto=>'tcp'
626 );
627 die "Could not create socket: $!\n" unless $sock;
628
629 ######################################
630 # Send information
631 ######################################
632 print $sock "GET /" . $download . " HTTP/1.1\n" .
633 "Host: www.bioinfo.rpi.edu\n" .
634 "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1\n" .
635 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\n" .
636 "Accept-Language: en-us,en;q=0.5\n" .
637 "Accept-Encoding: gzip,deflate\n" .
638 "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\n" .
639 "Keep-Alive: 300\n" .
640 "Connection: keep-alive\n\n";
641
642 print "Receiving $type File...\n";
643 ########################################
644 # Receive Information, print to terminal and store in array
645 ########################################
646
647 open(DATAOUT, $finalpath) || die;
648 my $print = 0;
649 if($mode == 1){
650 binmode $sock;
651 binmode DATAOUT;
652 my $buffer;
653 while ($buffer = readline($sock)){
654 if($buffer =~ /Error/ || $buffer =~ /error/){
655 return 1;
656 }
657 if($print == 2){
658 print DATAOUT $buffer;
659 }
660 if($print == 1){
661 $print = 2;
662 binmode $sock;
663 }
664 if($buffer =~ /Content-Type/){
665 $print = 1;
666 }
667 };
668 }else{
669 while(my $line = <$sock> ){
670 if($line =~ /Error/ || $line =~ /error/){
671 return 1;
672 }
673 if($print == 1){
674 print DATAOUT $line;
675 }
676 if($line =~ /Content-Type/){
677 $print = 1;
678 }
679 }}
680 close(DATAOUT);
681
682 ########################
683 # Close Socket
684 ########################
685 close($sock);
686 return 0;
687 }
688
689 # Function to print out version information
690 sub print_version{
691 system("cls");
692
693 print '############################################',"\n";
694 print '# MFold Submission/Result Retrieval Script #',"\n";
695 print '# Created by Wade Schulz - Univeristy of #',"\n";
696 print '# Minnesota - Department of Medicine #',"\n";
697 print '# Hosted at www.bioinformatics.org #',"\n";
698 print '# MFold Created by Dr. Michael Zuker #',"\n";
699 print '# www.bioinfo.rpi.edu #',"\n";
700 print '############################################',"\n\n";
701
702 }