[Bioperl-l] catching a Bio::DB::GenPept::get_Seq_by_id() throw?

Dan Kortschak Dan Kortschak <kortschak@rsbs.anu.edu.au>
Fri, 26 Jul 2002 13:27:09 +1000 (EST)


Still on the hilly side of the learning curve, I've looked through the
Exceptions man pages, but I can't figure out how to catch the "id does not
exist" exception thrown by get_Seq_by_id(). At the moment the script
(below) works just by timing out after a defined number of tries, however
I'd like to make it just drop the attempt if the server has reported that
there is nothing to find. Even when the script tries to get a sequence
that I know (by manually checking) doesn't exist, the check line is not
executed. What is wrong with the thing as it stands (note: all of the
appropriate use lines are in)?

thanks
Dan Kortschak

      my $genpept = new Bio::DB::GenPept;
      print "Working on $id...\n";
      my $try=1;
      try {
         while () {
            $sequence = $genpept->get_Seq_by_id($id);
            last if (defined $sequence);
            last if $try++ > $tries;
            print (STDERR "Waiting for results from NCBI.\n");
         }
      }
      catch Bio::Root::Exception with {
         print "Catching\n"; # check mark for actually catching a throw
         if (/id does not exist/) {
            print (OUT "Sequence ($id) not found in database.\n");
         }
      };

-- 
_____________________________________________________________   .`.`o
                                                         o| ,\__ `./`r
  Dan Kortschak    kortschak@rsbs.anu.spanner.edu.au     <\/    \_O> O
                                                          "|`...'.\
  Before you criticise a man, try to walk a mile in his    `      :\
  shoes. Then, if he doesn't like what you have to say,           : \
  you'll be a mile away, and you'll have his shoes.               :  \

  The address above will not work, remove the spanner from the works.

By replying to this email you implicitly accept that your response may
be forwarded to other recipients.
Permission is granted for fair use reproduction.