Commit 4427c275 authored by Sebastien Moretti's avatar Sebastien Moretti
Browse files

Start cleaning/debugging webblast & runblast.pl is cleaned

parent e1af607f
......@@ -3,7 +3,8 @@
use strict;
use warnings;
use diagnostics;
#use Env qw(HOME);
#use lib "$HOME/.lib_webblast/";
#use HTTP::GHTTP qw/:methods/;
use CGI;
use URI::Escape;
......@@ -12,7 +13,7 @@ my $ua = LWP::UserAgent->new;
use HTTP::Request::Common qw(POST);
use Getopt::Long ;
my ( $program, $evalue, $vvalue, $dbname, $inputfile, $outputmethod, $filter, $html ) = ( '', '1.e-10', '20', '', '', 0, 'on', 'off' ); #Default values
my ($program, $evalue, $vvalue, $dbname, $inputfile, $outputmethod, $filter, $html) = ('', '1.e-10',20, '', '', 0, 'on', 'off'); #Default values
my $ret = GetOptions( 'p=s' => \$program,
'e=s' => \$evalue,
'v=s' => \$vvalue,
......@@ -20,9 +21,9 @@ my $ret = GetOptions( 'p=s' => \$program,
'i=s' => \$inputfile,
'm=i' => \$outputmethod,
'F=s' => \$filter,
'T=s' , \$html );
'T=s' => \$html,);
if( $program eq ''){
if( $program eq '' ){
&Usage();
exit(0);
}
......@@ -43,11 +44,10 @@ $html = 'on' if( $html eq 'T' );
# Build Command script
my @command;
# Add program
push ( @command , "Program=$program" ) ;
push( @command , "Program=$program" ) ;
# Add database
push( @command , "$dbtype=$dbname" ) ;
push( @command , "evalue=$evalue" ) ;
......@@ -55,37 +55,37 @@ push( @command , "vvalue=$vvalue" ) ;
push( @command , "filter=$filter" ) ;
push( @command , "outputmethod=$outputmethod" ) ;
push( @command , "html=$html" ) ;
push( @command , 'blastmethod=new' ) ;
push( @command , 'raw=on' ) ;
push( @command , "blastmethod=new" ) ;
push( @command , "raw=on" ) ;
# Read sequence
my $sequence = '';
if( $inputfile eq '' ){
if ( $inputfile eq '' ){
while( <STDIN> ){
if(/^>/ ){
&RunBlast() if( $sequence ne '' );
$sequence = $_ ;
}
else {
$sequence .= $_ ;
}
if( /^>/ ){
&RunBlast() if( $sequence ne '' );
$sequence = $_ ;
}
else {
$sequence .= $_ ;
}
}
&RunBlast();
}
elsif ( $inputfile ne '' ){
open( my $INFILE, '<', "$inputfile") if ( -e "$inputfile" );
while(<$INFILE>){
if(/^>/){
&RunBlast() if( $sequence ne '' );
$sequence = $_ ;
}
else {
# chomp();
$sequence .= $_ ;
}
elsif ( $inputfile ne ''){
open(INFILE,"$inputfile") if ( -e "$inputfile" );
while(<INFILE>){
if( /^>/ ){
&RunBlast() if( $sequence ne '' );
$sequence = $_ ;
}
else {
# chomp();
$sequence .= $_ ;
}
}
close $INFILE;
close INFILE;
&RunBlast();
}
else{
......@@ -96,7 +96,7 @@ else{
sub RunBlast{
my $mybody = join("&" , (@command , 'sequence='.uri_escape($sequence) )) ;
my $mybody = join('&' , (@command , 'sequence='.uri_escape($sequence) )) ;
# print $mybody ;
# my $r = HTTP::GHTTP->new();
......@@ -110,15 +110,18 @@ sub RunBlast{
# print $r->get_body();
# my $r = HTTP::Request->new($method, $uri, $header,$mybody);# $content);
my $uri = 'http://www.igs.cnrs-mrs.fr/adele/~database/remoteblast.cgi';
# my $uri = "http://www.igs.cnrs-mrs.fr/adele/~database/remoteblast.cgi";
my $uri = 'http://www.igs.cnrs-mrs.fr/Giga2/~database/remoteblast.cgi';
my $method = 'POST';
my $r = HTTP::Request->new($method, $uri);
my $r = HTTP::Request->new($method, $uri);
$r -> content_type('application/x-www-form-urlencoded'); # = $header
$r -> content($mybody);
my $response = $ua->request($r);
my $print = $response->content;
$print =~ s/<[^<>]+>//g;
my $print = $response->content;
$print =~ s/<[^<>]+>//g;
print $print;
return;
}
......@@ -163,9 +166,9 @@ sub Usage{
uniprot_sptr
virus
eto
";
exit;
exit 0;
return;
}
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment