[Bio] / FigMetagenomeTools / RemoteBlast.pl Repository:
ViewVC logotype

View of /FigMetagenomeTools/RemoteBlast.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Fri Mar 16 20:51:25 2007 UTC (12 years, 8 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, mgrast_rel_2008_0806, mgrast_dev_10262011, mgrast_dev_02212011, mgrast_rel_2008_0923, mgrast_release_3_0, mgrast_dev_03252011, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, mgrast_rel_2008_0919, mgrast_rel_2008_1110, myrast_33, mgrast_rel_2008_0917, mgrast_dev_04052011, mgrast_dev_02222011, HEAD
Changes since 1.1: +0 -1 lines
initial tweaks

#!/usr/bin/perl -w 
#
# run remote blast against some sequences. Hopefully this will blast against the entire nr

use strict;
use Bio::Tools::Run::RemoteBlast;

my $usage =<<EOF;

$0 [-n,p,x,tn,s,tx] [-0] file [blast options]
        -n      blastn          nt query, nt database
        -p      blastp          protein query, protein database
        -x      blastx          nt query, protein database
        -tn     tblastn         protein query, nt database
        -s      psitblastn      protein query, nt database psi-blast
        -tx     tblastx         nt query, nt database
        
        -0      skip responses that don't match anything

EOF

my $blast=shift || die $usage;
my $blastprogram;
if ($blast eq "-n") {$blastprogram="blastn"}
elsif ($blast eq "-p") {$blastprogram="blastp"}
elsif ($blast eq "-x") {$blastprogram="blastx"}
elsif ($blast eq "-s") {$blastprogram="psiblast"}
elsif ($blast eq "-tn") {$blastprogram="tblastn"}
elsif ($blast eq "-tx") {$blastprogram="tblastx"}
die $usage unless ($blastprogram); 

my $test=shift || die $usage;

my @files;
if (-T $test) {push @files, $test}
elsif (-d $test) {
 opendir(DIR, $test) || die "Can't open dir $test\n";
 while (my $file2=readdir(DIR)) {
  push (@files, "$test/$file2");
 }
}
else {
 die "Not sure what $test is";
} 

foreach my $file (@files) {
my $rb=Bio::Tools::Run::RemoteBlast->new(
  '-prog' => $blastprogram, '-data' => 'nr', '-expect' => 10, '-readmethod' => 'SearchIO'
);

 my $res = $rb->submit_blast($file); 
 
 my $matched=0;
 #sleep 5;
 #my @rids=$rb->each_rid;
 #until ($matched == scalar @rids) {
 while (my @rids=$rb->each_rid) {
  #@rids=$rb->each_rid;
  foreach my $rid (@rids) {
    print STDERR "For $file, there are ", scalar @rids, " rids waiting. $matched are complete\n";
    my $rc = $rb->retrieve_blast($rid);
   if (!ref($rc)) {
      if ($rc < 0) {
         $rb->remove_rid($rid);
      }
      sleep 5;
   } else {
    $matched++;
    $rb->save_output("$file.$blastprogram.nr");
    $rb->remove_rid($rid);
   }
  }
 }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3