Commit 61926980 authored by Sebastien Moretti's avatar Sebastien Moretti
Browse files

improve webblast code

parent 07eece73
......@@ -4,14 +4,14 @@
#date : 2007/11/19
#prog : webblast.pl
#subj : make a BLAST/WU-BLAST (by HTTP request or locally) against a database with a file containing sequences in fasta format
####### method genid, pdbid and profile
####### method genid, pdbid and profile
#
#############################################################################################
#use Env qw(HOME);
#use lib "$HOME/.lib_webblast/";
use LWP::UserAgent;
use HTML::Parser; # @@@@@@@ #
use HTTP::Request::Common qw(POST); # @/^ ^\@ #
use LWP::UserAgent;
use HTML::Parser; # @@@@@@@ #
use HTTP::Request::Common qw(POST); # @/^ ^\@ #
use URI::Escape; # @/ - - \@ #
use Getopt::Long; ## \ ^ / ##
use strict; ## | 0 | ##
......@@ -23,80 +23,105 @@ use warnings; ####### \ _ / #######
my $database_expresso = 'pdb'; #PDB database name #
my $blast_dir_expresso = '/mnt/local/bin/blastall'; #blastall executable #
my $BLASTMAT = 'export BLASTMAT=/mnt/local/ncbi/data/'; #matrix directory for blast #
my $BLASTDB = 'export BLASTDB=/scratch/frt/blastnet/database/'; #PDB directoty #
my $BLASTDB = 'export BLASTDB=/scratch/frt/blastnet/database/'; #PDB_seqres directoty #
########################################################################################################
my $runblast = '/mnt/local/bin/runblast.pl';
my(@list_encoded)=(), my(@list_pdb)=(), my(%deja_vu)=(), my(@pdb_list)=(),my($i)=0, my(@names)=(), my $locale=0, my $distant=0, my $database, my $blast_way;
my($ua)= LWP::UserAgent->new;
##-- Variables d'environnements
##-- Environmental Variables
my($database_var)= $ENV { 'DATABASE' };
my($blast_var) = $ENV { 'BLAST_DIRECTORY' };
my ($database_var) = $ENV { 'DATABASE' };
my ($blast_var) = $ENV { 'BLAST_DIRECTORY' };
##-- Recupere Options/parametres du BLAST && controle des options ds OPTIONS_GET
my($program,$database_line,$blast_line,$query_file,
$out_file,$identity_treshold,$cover_tresh,$Eval,
$align,$matrix,$filter,$method,$orgn,$process,$quiet,$gigablast)= &OPTIONS_GET();
##-- Get BLAST Options/parameters && check user options
##-- Determination BLAST LOCAL /DISTANT && Controle database/programme
my ($program, $database_line, $blast_line, $query_file,
$out_file, $identity_treshold, $cover_tresh, $Eval,
$align, $matrix, $filter, $method, $orgn, $process, $quiet, $gigablast) = &OPTIONS_GET();
##-- Define local or remote BLAST && Check database/program
unless (-e $query_file ) { print {*STDERR} "\nfile does not exist!\n";exit;}
unless (-s $query_file ) { print {*STDERR} "\nyour file is empty!\n";exit; }
if ((($database_line || $database_var) && ($blast_line || $blast_var)) )
{
if ($database_line=~/expressopdb/ && $blast_line=~/blastexpresso/)
{
#mode special pour fichier de configuration du serveur Expresso
$locale=1;
$database="expressopdb";
unless ($quiet=~ /on/i) { print {*STDERR} "\nRUN BLAST LOCALY\n"; }
if ( ($database_line || $database_var) && ($blast_line || $blast_var) ){
if ( $database_line=~/expressopdb/ && $blast_line=~/blastexpresso/ ){
#special mode for configuration file of Expresso server
$locale = 1;
$database = 'expressopdb';
unless ( $quiet=~ /on/i ){
print {*STDERR} "\nRUN BLAST LOCALY\n";
}
}
else
{
($database)=$database_line || $database_var;
my($blast_tp)=$blast_var || $blast_line; $locale=1;
$blast_way = &CONTROLE_DB_PG($database,$blast_tp,$program);
unless ($quiet=~ /on/i) { print {*STDERR} "\nRUN BLAST LOCALY\n"; }
else{
($database) = $database_line || $database_var;
my ($blast_tp) = $blast_var || $blast_line;
$locale = 1;
$blast_way = &CONTROLE_DB_PG($database, $blast_tp, $program);
unless ( $quiet=~ /on/i ){
print {*STDERR} "\nRUN BLAST LOCALY\n";
}
}
}
else
{
$database = &NCBI_DATABASE($database_line); $distant=1;
if ($gigablast=~ /^yes$/i) { $locale=2; $distant=0; unless ($quiet=~ /on/i) { print {*STDERR} "\nRUN GIGABLASTER\n"; }}
else { unless ($quiet=~ /on/i) {print {*STDERR} "\nRUN BLAST AT THE NCBI\n";}}
else{
$database = &NCBI_DATABASE($database_line);
$distant = 1;
if ( $gigablast=~ /^yes$/i ){
$locale = 2;
$distant = 0;
unless ( $quiet=~ /on/i ){
print {*STDERR} "\nRUN GIGABLASTER\n";
}
}
else{
unless ( $quiet=~ /on/i ){
print {*STDERR} "\nRUN BLAST AT THE NCBI\n";
}
}
}
##-fixation de parametres selon la valeur du flag -method
if ($method=~ /^pdbid$/i)
{
if ($gigablast=~ /^yes$/i)
{
if ($database ne "pdb") { print {*STDERR} "\nprovide a valid database name FOR RUN GIGABLASTER: nr,pdb or refseq_protein\n";exit;} else {$database="pdbaa";}
##- Define parameters through -method flag
if ( $method=~ /^pdbid$/i ){
if ( $gigablast=~ /^yes$/i ){
if ( $database ne 'pdb' ){
print {*STDERR} "\nprovide a valid database name to RUN GIGABLASTER: nr, pdb or refseq_protein\n";
exit 1;
}
else {
$database = 'pdbaa';
}
}
elsif ( $gigablast=~ /^no$/i && $distant==1 ){
$database = 'pdb';
}
elsif ($gigablast=~ /^no$/i && $distant==1) { $database="pdb";}
}
elsif ($method=~ /^geneid$/i)
{
if ($distant==1) { unless ($database eq "nr" || $database eq "swissprot" || $database eq "pdb") { $database="refseq_protein";}}
elsif ( $method=~ /^geneid$/i ){
if ( $distant==1 ){
unless ( $database eq 'nr' || $database eq 'swissprot' || $database eq 'pdb'){
$database = 'refseq_protein';
}
}
}
elsif ($method=~/^profile$/i)
{
if ($distant==1) { unless ($database eq "nr" || $database eq "swissprot" || $database eq "refseq_protein" ) { $database="pdb"; } }
elsif ( $method=~/^profile$/i ){
if ( $distant==1 ){
unless ( $database eq 'nr' || $database eq 'swissprot' || $database eq 'refseq_protein' ){
$database = 'pdb';
}
}
}
else {
die "unknown method\n";
}
else { die "unknown method\n";}
if (($orgn !~ /All\+organisms/) && ($locale=~/1|2/))
{ print {*STDERR} "-organism option can't be used locally or with -gigablast option!\n";exit;}
if ( $orgn !~ /All\+organisms/ && $locale=~/1|2/ ){
print {*STDERR} "-organism option can't be used locally or with -gigablast option!\n";
exit 1;
}
##---PRINT option values
unless ( $quiet =~ /on/i ){
......@@ -132,34 +157,43 @@ unless ( $quiet =~ /on/i ){
}
#-- LOCAL/DISTANT BLASTP
if ($locale==1 || $locale==2) {@list_pdb= &LOCAL_BLAST ($blast_way,$database,$query_file,$Eval,$align,$method,$matrix,$filter,$process,$gigablast,$database_expresso,$blast_dir_expresso,$runblast); }
elsif ($distant==1) { @list_pdb= &WEB_BLAST ($query_file,$Eval,$program,$database,$matrix,$method,$align,$orgn,$filter); }
else { die " Report bug to armougom\@igs.cnrs-mrs.fr\n"};
#-- Local/Remote BLASTP
if ( $locale==1 || $locale==2 ){
@list_pdb = &LOCAL_BLAST($blast_way, $database, $query_file, $Eval, $align, $method, $matrix, $filter,
$process, $gigablast, $database_expresso, $blast_dir_expresso, $runblast);
}
elsif ( $distant==1 ){
@list_pdb = &WEB_BLAST($query_file, $Eval, $program, $database, $matrix, $method, $align, $orgn, $filter);
}
else {
die " Report bug to armougom\@igs.cnrs-mrs.fr\n";
}
#-- PARSE BLAST RESULTS -> MAKE A PDB_ID LIST
if ($method =~ /^pdbid$/i)
{
my(@result_sort)= &PARSING (\@list_pdb,$locale,$distant,$method,$quiet,$database,$gigablast);
&AFFICHAGE_PDB_PARSING (\@result_sort,$cover_tresh,$identity_treshold,$out_file);
exit;
if ( $method =~ /^pdbid$/i ){
my (@result_sort) = &PARSING(\@list_pdb, $locale, $distant, $method, $quiet, $database, $gigablast);
&AFFICHAGE_PDB_PARSING(\@result_sort, $cover_tresh, $identity_treshold, $out_file);
exit 0;
}
#-- PARSE BLAST RESULT -> MAKE LIST OF REFSEQ ID
elsif ($method =~ /^geneid$/i)
{
my(@result_sort)= &PARSING (\@list_pdb,$locale,$distant,$method,$quiet,$database,$gigablast);
&AFFICHAGE_REFSEQ_PARSING (\@result_sort,$cover_tresh,$identity_treshold,$out_file);
exit;
elsif ( $method =~ /^geneid$/i ){
my (@result_sort) = &PARSING(\@list_pdb, $locale, $distant, $method, $quiet, $database, $gigablast);
&AFFICHAGE_REFSEQ_PARSING(\@result_sort, $cover_tresh, $identity_treshold, $out_file);
exit 0;
}
#-- PARSE BLAST RESULT -> MAKE PROFILE
elsif ($method=~ /^profile$/i) { &PROFILE (\@list_pdb,$out_file,$distant); exit; }
else { die " \nFATAL ERROR : Method or database error\n" ;}
elsif ( $method=~ /^profile$/i ){
&PROFILE(\@list_pdb, $out_file, $distant);
exit 0;
}
else {
die " \nFATAL ERROR : Method or database error\n";
}
exit;
exit 0;
##############
############################################### FONCTIONS ####################################################################
......
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