[Bioperl-l] Bptutorial.pl

Jason Stajich jason@cgt.mc.duke.edu
Fri, 20 Dec 2002 16:19:19 -0500 (EST)


I'm confused about the error messages Paul was reporting, this is what I
get on linux calling the non-existant class method:

[jason@portabello core]$ perl bptutorial.pl  23

Beginning run_standaloneblast example...
Can't use string ("Bio::Tools::Run::StandAloneBlast") as a HASH ref while
"strict refs" in use at
/home/jason/bioperl/bioperl-run/Bio/Tools/Run/StandAloneBlast.pm line 366.

And the changes made in the tutorial are very simple - you initialize the
factory and then you test if $factory->executable is defined.

diff -u -r1.80 bptutorial.pl
--- bptutorial.pl       2002/12/19 17:11:55     1.80
+++ bptutorial.pl       2002/12/20 21:08:46
@@ -2152,8 +2152,8 @@
 StandAloneBlast object. This script shows how the blast report object
 can access a blast parser directly, eg

-  while (my $sbjct = $blast_report->nextSbjct){
-     while (my $hsp = $sbjct->nextHSP){
+  while (my $sbjct = $blast_report->next_hit){
+     while (my $hsp = $sbjct->next_hsp){
         print $hsp->score . " " . $hsp->subject->seqname . "\n";
      }
   }
@@ -2919,15 +2919,14 @@

     $database = $_[0] || 'ecoli.nt'; # user can select local nt database

-    $blast_present = Bio::Tools::Run::StandAloneBlast->exists_blast();
-    unless ($blast_present) {
-        warn "blast program not found. Skipping StandAloneBlast
example\n";
-        return 0;
-    }
     #@params = ('program' => 'blastn', 'database' => 'ecoli.nt');
     @params = ('program' => 'blastn', 'database' => $database);
     $factory = Bio::Tools::Run::StandAloneBlast->new(@params);

+    unless ($factory->executable('blastall')) {
+        warn "blast program not found. Skipping StandAloneBlast
example\n";
+        return 0;
+    }

     $str = Bio::SeqIO->new('-file'=>
Bio::Root::IO->catfile("t","data","dna2.fa") ,
 #    $str = Bio::SeqIO->new('-file'=>'t/data/dna2.fa' ,
@@ -2935,7 +2934,8 @@
     $seq1 = $str->next_seq();

     $blast_report = $factory->blastall($seq1);
-    $sbjct = $blast_report->nextSbjct;
+    my $result = $blast_report->next_result;
+    $sbjct = $result->next_hit;

     print " Hit name is ", $sbjct->name, " \n";

@@ -3140,12 +3140,9 @@
        while ($seq = $str->next_seq() ) { push (@seq_array, $seq) ;}
        $seq_array_ref = \@seq_array;
        # where @seq_array is an array of Bio::Seq objects
-
-       my $clustal_present =
-         Bio::Tools::Run::Alignment::Clustalw->exists_clustal();
-       if ($clustal_present) {
-           @params = ('ktuple' => 2, 'matrix' => 'BLOSUM', 'quiet' => 1);
-           $factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
+       @params = ('ktuple' => 2, 'matrix' => 'BLOSUM', 'quiet' => 1);
+       $factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
+       unless( $factory->executable ) {
            $ktuple = 3;
            $factory->ktuple($ktuple);  # change the parameter before
executing
            $aln = $factory->align($seq_array_ref);
@@ -3165,12 +3162,10 @@
         print STDERR "Skipping local TCoffee demo:\n";
        return 0;
     }
-    my $tcoffee_present =
-      Bio::Tools::Run::Alignment::TCoffee->exists_tcoffee();
-    if ($tcoffee_present) {
-        @params = ('ktuple' => 2, 'matrix' => 'BLOSUM', 'quiet' => 1);
-        $factory = Bio::Tools::Run::Alignment::TCoffee->new(@params);
-        $ktuple = 3;
+    @params = ('ktuple' => 2, 'matrix' => 'BLOSUM', 'quiet' => 1);
+    $factory = Bio::Tools::Run::Alignment::TCoffee->new(@params);
+    unless( $factory->executable ) {
+       $ktuple = 3;
         $factory->ktuple($ktuple);  # change the parameter before
executing
         $aln = $factory->align($seq_array_ref);
         $strout = Bio::AlignIO->newFh('-format' => 'msf');
@@ -3283,15 +3278,14 @@
        return 0;
     }

-    @params = ('program' => 'blastp', 'outfile' => 'bl2seq.out');
+    @params = ('outfile' => 'bl2seq.out');
+    $factory = Bio::Tools::Run::StandAloneBlast->new(@params);

-    my $blast_present = Bio::Tools::Run::StandAloneBlast->exists_blast();
-    unless ($blast_present) {
+    unless ($factory->executable('bl2seq') ) {
         warn "\n Blast program not found. Skipping bl2seq example\n\n";
         return 0;
     }

-    $factory = Bio::Tools::Run::StandAloneBlast->new(@params);
     $factory->bl2seq($seq1, $seq2);



Also, let me explain why the changes were made.

Because the object needs to store state for the actual location it needs
to be an object method rather than a class method (ie it caches where it
found the executable in the event that it needs to search the BLASTDIR env
variable is not set).

This was my interpretation if you want to be in a different way we can
probably play some games behind the scenes to make it work.

-jason
On Fri, 20 Dec 2002, Jason Stajich wrote:

> On Fri, 20 Dec 2002, Peter Schattner wrote:
>
> >
> > I dunno, Jason. The bptuorial script was working before the change to
> > StandAloneBlast.pm was made. I would suppose that any other
> > previously-working script which uses any of the exists_blast,
> > exists_clustalw  etc methods will also crash after upgrading bioperl-run.
>
> > Moreover the crash will be accompanied by a cryptic message such as the
> > one Paul initially received (the messages are coming from the module’s
> > AUTOLOADER trying unsuccessfully to interpret the method call).  Anyway
> > I think if no clear warning is added for people uisng the exists_blast
> > etc methods, there will be a bunch of qustions coming onto the bioperl
> > bug and/or query lists.
> >
>
> I'm sorry that is the case but we need to build a general extensible
> framework for runnable wrappers which includes a single method one can
> call to test for the existance of the executable.  This permits a much
> more extensible pipeline system and a unified interface to application
> wrappers.  If you have feedback or comments on how to structure these the
> base class is Bio::Tools::Run::WrapperBase and we would welcome
> contributions.  The Fugu team has been quite actively developing new
> wrapper tools in this manner.
>
> I think in fact that no one is helping maintain the scripts and examples
> files after Brian O needed to take a hiatus so I'm quite sure there are
> things that don't work.  Scripts which run things probably should be
> reorganized into the bioperl-run directory as well.
>
> If you would like the old exists_XX functions to be there we can add them
> back in for backwards compatability.
>
> > > Peter - I think it makes sense perhaps to split the parts which run
> > > applications out of bptutorial into something in
> > > bioperl-run/bpruntutorial.pl or core/bpruntutorial.pl to avoid throwing
> > > people for too much of a loop.  What do you think?
> >
> > Well I agree with you here.  Actually there are only three bptutorial demos
> > that use the run-library programs, so, unless there is loud complaint, I
> > intend to simply remove the 3 demos from bptutorial.pl (and _not_ create a
> > new script "bpruntutorial.").
> >
> > My first thought here was to simply point the bptutorial reader to the
> > standaloneblast.pl script in the script/tools directory as an example.
> > However the interface has changed sufficiently that this script now gives
> > multiple errors with no clear indication of what is causing them. I don’t
> > have the time to track these down myself right now,  so I am separately
> > submitting a bug report on them.
> >
> > All of this does bring up another issue: Is anyone checking that the sample
> > scripts in the "examples" and "scripts" directories still work?  Having lots
> > of examples is nice but only if they work.  Otherwise better to remove them.
> > Unfortunately I do not have the time to pursue this myself.  Any interest
> > Brian or anyone else?
> >
> > Peter
> >
> >
> >
>
> --
> Jason Stajich
> Duke University
> jason at cgt.mc.duke.edu
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu