Summary | Included libraries | Package variables | Description | General documentation | Methods |
G::Tools::EMBOSS - Wrapper interface to EMBOSS software suite
This class is a part of G-language Genome Analysis Environment, collecting interfaces to EMBOSS software suite.
seqret | Description | Code |
seqret | code | next | Top |
Name: seqret - reads and writes (returns) sequences (interface to EMBOSS) Description: This is a wrapper around EMBOSS Explorer web service provided by http://emboss.bioinformatics.nl/. |
seqret | description | prev | next | Top |
require CGI; require LWP::UserAgent; require HTML::Form; my @args = opt_get(@_); my $USA = opt_val("sequence") || shift @args; my $feature = opt_val("feature"); my $firstonly = opt_val("firstonly"); my $osformat = opt_val("osformat"); my $help = opt_val("help"); my $outseq = opt_val("outseq") || shift @args; if($help){ print << '__HELP__'}
Standard (Mandatory) qualifiers:
[-sequence] seqall (Gapped) sequence(s) filename and optional
format, or reference (input USA)
[-outseq] seqoutall [<sequence>.<format>] Sequence set(s)
filename and optional format (output USA)
Additional (Optional) qualifiers: (none)
Advanced (Unprompted) qualifiers:
-feature boolean Use feature information
-firstonly boolean Read one sequence and stop
General qualifiers:
-help boolean Report command line options. More
information on associated and general
qualifiers can be found with -help -verbose
__HELP__
exit; } msg_error("Reads and writes (returns) sequences\n"); if(length($USA) < 1){ msg_error("Input (gapped) sequence(s): "); $USA = <STDIN>; chomp($USA); } unless(length($osformat)){ if ($USA =~ /(.+)::(.+)/) { ($osformat, $USA) = ($1, $2); } if ($outseq =~ /(.+)::(.+)/) { ($osformat, $outseq) = ($1, $2); } if ($outseq =~ /(.+):(.+)/) { ($osformat, $outseq) = ($1,$2);; } } my $ua = LWP::UserAgent->new; my $request = $ua->get("http://emboss.bioinformatics.nl/cgi-bin/emboss/seqret"); my $form = HTML::Form->parse($request->decoded_content, $request->base); if (-e $USA) { $form->value("sequence.file","$USA"); } else { $form->value("sequence.db","$USA"); } $form->value('outseq',"${osformat}::outseq") if $osformat; $form->value('feature','1') if $feature; $form->value('firstonly','1') if $firstonly; my $res = $ua->request($form->click('_run')); while ($res->is_redirect) { my $url = $res->header('Location'); $res = $ua->request(HTTP::Request->new(GET => $url)); } my $query = CGI->new; my $result = $res->content(); $result =~ m/<pre>(.+)<\/pre>/s; $result = $query->unescapeHTML($1); while ($result =~ /<pre>/) { $result =~ m/^(.+)<\/pre>.+<pre>(.+)/sg; $result = "$1\n$2"; } while ($result =~ /Warning/) { $result =~ /(Warning.+)/; msg_error($1,"\n"); $result =~ /$1\n+(.+)/s; $result = $1; } if ($result =~ /with -auto/) { my @error = split(/:/,$USA); msg_error("Error: Failed to open filename\" $error[0]\"\n"); msg_error("Error: Unable to read sequence\" $USA\"\n"); msg_error("Died: seqret terminated: Bad value for '-sequence' and no prompt\n"); } else { $result =~ /\s+(.{6})/; my $name = $1; chomp($name); $osformat = "fasta" unless $osformat; if ($outseq eq "") { msg_error("output sequence(s) [$name.$osformat]: "); $outseq = <STDIN>; chomp($outseq); } if (lc($outseq) eq "stdout") { msg_send("$result\n"); } elsif ($outseq) { open(RESULT,">$outseq"); print RESULT "$result"; close(RESULT); } else { open(RESULT,">$name.$osformat"); print RESULT "$result"; close(RESULT); } }