Commit 1ebccb46 authored by Sebastien Moretti's avatar Sebastien Moretti
Browse files

No commit message

No commit message
parent 3f00beef
......@@ -12,14 +12,15 @@ use warnings;
use diagnostics;
use Carp;
use File::Which qw(which); # Locate external executable programs in the PATH
use Time::localtime; # Use localtime+PID for a pseudo-uniq temp file name
use Getopt::Long; # Options specifications
use Env qw(HOME); # Use only environmental (shell) HOME variable
use File::Copy qw(move); # Avoid external 'mv' command usage
use LWP::Simple; # To test gigablaster availability
use File::Which qw(which); # Locate external executable programs in the PATH
use Mail::Send; # Send warnings and errors files by e-mail ==> only if the $userEMail variable is defined
use lib '/mnt/common/share/ProtoGene/'; # Local path for ProtoGene's own perl modules
......@@ -31,7 +32,7 @@ use Views; # Non-text outputs, e.g. HTML/CSS
################## CONFIGURATION ##################
$ENV{'PATH'} .= ':/mnt/local/bin/'; # Additional path for executables
$ENV{'PATH'} .= ':/mnt/local/bin/:./'; # Additional path for executables
my $cachePath = '/scratch/cluster/monthly/t_coffee/ProtoGene_Cache'; # Cache directory
my $cacheStorageTime = 15; # Do not update sequences younger than X days
......@@ -42,42 +43,44 @@ my $userEMail = 'moretti.sebastien@gmail.com'; # To
my $VERSION = '4.0.0';
my $webblast_exe = which('webblast.pl') || '';
my $blast_prog = 'blastall'; # Or wu-blastall for Wu-BLAST; for local blast usage
my $blast_exe = which($blast_prog) || '';
my $exonerate_exe = which('exonerate-1.0') || ''; # Exonerate 1.0 because current parser only works with this version
my $webblast_exe = 'webblast.pl';
my $blast_prog = 'blastall'; # Or wu-blastall for Wu-BLAST; for local blast usage
my $blast_exe = $blast_prog;
my $exonerate_exe = 'exonerate-1.0'; # Exonerate 1.0 because current parser only works with this version
################## Option management
my ($msa, $revtrans, $pep, $hideBOJ, $run_name, $template, $lim, $cache) = ('', 0, 0, 0, '', '', 0, 'update');
my ($debug, $tmp) = (0, 0);
my ($db, $species, $local, $giga) = ('refseq_protein', 'All_organisms', 0, 0);
GetOptions('msa|in=s' => \$msa, # Input sequences
'revtrans' => \$revtrans, # Use to reverse-translate sequences with no match
'pep' => \$pep, # Add the original peptide query beneath the related CDS seq
'hideBOJ' => \$hideBOJ, # Hide BOJ output
'run_name=s' => \$run_name, # Use another name, instead of input seq name, for result files
'template=s' => \$template, # Use a template file
'lim=i' => \$lim, # Limit number of input query sequences
'cache=s' => \$cache, # Cache behavior
'orgm|species=s' => \$species, # Organism(s) to blast against
'db|database=s' => \$db, # Database to blast against
'local' => \$local, # Use to specify a local db query, definied in $local_db
'giga' => \$giga, # Use GigaBlaster server
'version|V' => sub { print "\n\tPROTOGENE : Bona-Fide Back Translation of Protein Multiple Sequence Alignments\n\tversion : $VERSION\n\n";
exit 0;
}, # Print version information
'help|H|?' => sub { system('perldoc', "$0")==0 || print {*STDERR} "\n\tCannot open the documentation with 'perldoc'\n\n";
exit 0;
}, # Print full help message
'debug' => \$debug, # Verbose output
'tmp' => \$tmp, # To keep traces of fake intermediate files like fake xml from NCBI, fake aln, ...
my %opts = ('msa|in=s' => \$msa, # Input sequences
'revtrans' => \$revtrans, # Use to reverse-translate sequences with no match
'pep' => \$pep, # Add the original peptide query beneath the related CDS seq
'hideBOJ' => \$hideBOJ, # Hide BOJ output
'run_name=s' => \$run_name, # Use another name, instead of input seq name, for result files
'template=s' => \$template, # Use a template file
'lim=i' => \$lim, # Limit number of input query sequences
'cache=s' => \$cache, # Cache behavior
'orgm|species=s' => \$species, # Organism(s) to blast against
'db|database=s' => \$db, # Database to blast against
'local' => \$local, # Use to specify a local db query, definied in $local_db
'giga' => \$giga, # Use GigaBlaster server
'version|V' => sub { print "\n\tPROTOGENE : Bona-Fide Back Translation of Protein Multiple Sequence Alignments\n\tversion : $VERSION\n\n";
exit 0;
}, # Print version information
'help|H|?' => sub { system('perldoc', "$0")==0 || print {*STDERR} "\n\tCannot open the documentation with 'perldoc'\n\n";
exit 0;
}, # Print full help message
'debug' => \$debug, # Verbose output
'tmp' => \$tmp, # To keep traces of fake intermediate files like fake xml from NCBI, fake aln, ...
);
my $test_option_values = Getopt::Long::GetOptions(%opts);
################## Short help message
if ( $msa eq '' || $species eq '' || $db eq '' || $cache eq '' ){
if ( !$test_option_values || $msa eq '' || $species eq '' || $db eq '' || $cache eq '' ){
print {*STDERR} "\n\tCannot open the MSA file in FASTA format
\tTry: $0 --msa=path_of_the_fasta_msa_file [Options]
......@@ -107,8 +110,9 @@ if ( $msa eq '' || $species eq '' || $db eq '' || $cache eq '' ){
}
checkProgramsPresence($webblast_exe, $exonerate_exe); # Check external programs presence in the PATH
################## Check external software
checkExternalPrograms($webblast_exe, $exonerate_exe, $blast_exe); # Check external programs presence in the PATH
#FIXME ???
$blast_exe =~ s/${blast_prog}$//;
checkCacheAccessibility($cachePath); # Check cache directory accessibility
......@@ -129,39 +133,6 @@ my ($templG, $templP, $templSeq);
($templG, $templP, $templSeq) = checkTemplate($template) if ($template);
#Short help message
if ( $msa eq '' || $species eq '' || $db eq '' || $cache eq '' ){
my $appli = basename($0);
print {*STDERR} "\n\tCannot open the MSA file in FASTA format
\tTry: $appli --msa=path_of_the_fasta_msa_file [Options]
\tOptions: --orgm=All_organisms, Bacteria, Viruses, Vertebrata,
\t Eukaryota, Mammalia, Primates, Homo_sapiens,
\t Gallus_gallus, Bos_taurus, Escherichia_coli,
\t Arabidopsis_thaliana, Mus_musculus,
\t Drosophila_Melanogaster, ...
\t default is 'All_organisms'
\t --db=nr, pdb, swissprot, refseq_protein
\t default is 'refseq_protein'
\t --local to execute a local BLAST query with
\t --db=path_for_a_local_db_blast_formated
\t --template to provide your own nucleotidic sequences
\t following the cds file format
\t --revtrans to reverse-translate sequences with no
\t blast hit, in IUB (IUPAC) depiction code
\t They are removed from the alignement by default
\t --pep to add the original peptide query beneath the
\t back-translated sequence
\t --cache=none, update, use, own_PATH_directory, old, empty
\t to select the cache mode
\t default is 'update'
\t --version to print version information
\t --help to print a full help message\n\n";
exit(1);
}
##Open and Check the fasta file
my $originalMSA = $msa;
my $change = 0;
......@@ -576,20 +547,16 @@ sub failure {
return;
}
#Check external programs presence in the PATH
sub checkProgramsPresence{
my ($webblast_exe, $exonerate_exe) = @_;
if ( $webblast_exe eq '' ){
failure();
print {*STDERR} "\twebblast.pl program is not reachable\n\tIt could not be in your PATH or not installed\n\n";
exit(1);
}
if ( $exonerate_exe eq '' ){
failure();
print {*STDERR} "\texonerate program is not reachable\n\tIt could not be in your PATH or not installed\n\n";
exit(1);
# Check external programs presence in the PATH
sub checkExternalPrograms{
for my $exe ( @_ ){
if ( ! which($exe) ){
failure();
print {*STDERR} "\t'$exe' program is not reachable\n\tIt could not be in your PATH or not installed\n\n";
exit(1);
}
}
return;
}
#Check cache directory accessibility: Test and change rights, if needs, of the $HOME/.ProtoGene/ cache directory
......
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