[Bioperl-l] How to check the validity of an accession number ?

michael watson (IAH-C) michael.watson at bbsrc.ac.uk
Mon Nov 10 04:26:45 EST 2003


There should be a ";" after the eval statement:

   eval {
       $seq = $stream -> get_Seq_by_acc($an);
   };
   if ($@) {
       print STDERR "Not a valid accession [$an]\n";
       next;
   }

The $@ variable is where perl puts any error messages that come from the eval statement.  If no errors, then $@ is undefined.

-----Original Message-----
From: Damien Marsic [mailto:damien at rael.org]
Sent: 09 November 2003 00:05
To: heikki at ebi.ac.uk
Cc: Bioperl
Subject: Re: [Bioperl-l] How to check the validity of an accession
number ?


Thank you for your help. However, when I try it says "Syntax error". Sorry I
am not very good at perl and I have never seen "$@" before so I don't know
how to use it. But it really seems that there is a spelling error in your
example. PLease help.

Damien

----- Original Message ----- 
From: "Heikki Lehvaslaiho" <heikki at nildram.co.uk>
To: "Damien Marsic" <damien at rael.org>
Cc: "Bioperl" <bioperl-l at bioperl.org>
Sent: Saturday, November 08, 2003 3:10 AM
Subject: Re: [Bioperl-l] How to check the validity of an accession number ?


> Damien,
>
> The change is in the bioperl code. It was put in almost 11 months ago
> for the 1.2 release. As the error message indicates, line 177 in
> Bio::DB::WebDBSeqI now throws an error. You can catch it with eval
> statement, e.g:
>
>   eval {
>       $seq = $stream -> get_Seq_by_acc($an);
>   }
>   if ($@) {
>       print STDERR "Not a valid accession [$an]\n";
>       next;
>   }
>
>
> The Web interface to the bioperl CVS repository can help you track
> whys, whens and hows of code changes:
>
>
http://cvs.bioperl.org/cgi-bin/viewcvs/viewcvs.cgi/bioperl-live/Bio/DB/WebDBSeqI.pm?cvsroot=bioperl
>
> Yours,
>
> -Heikki
>
>
> On Sat, 2003-11-08 at 05:02, Damien Marsic wrote:
> > Hello,
> >
> > I hope someone will be able to help. I wrote a program that does the
> > following:
> >
> > - opens a file containing sequences named with their Genbank accession
> > number if it exists (and an arbitrary name if the sequence is not in
> > Genbank)
> >
> > - reads each sequence name, looks in Genbank if it is an accession
number,
> > and if it is, retrieves the organism name and other information. If the
name
> > is not recognized as an accession number, the program says it and
proposes
> > to continue with the next sequences.
> >
> > My programs worked perfectly during the last 2 years or so. But for the
last
> > few months it does not work anymore, although I did not make any change
to
> > it. What is happening now is that when there is a sequence name that is
not
> > an accession number, the program crashes.
> >
> > The problem lies with this line:
> >
> >    $seq = $stream -> get_Seq_by_acc($an);
> >
> > When $an was an invalid accession number, $seq used to be "undefined"
and
> > the program could go on (the program checks whether &seq in defined or
> > undefined and then goes to the appropriate step).
> >
> > But now, when $an is an invalid accession number, the program just
crashes
> > with the following message:
> >
> >  ------------- EXCEPTION  -------------
> >  MSG: acc does not exist
> >  STACK Bio::DB::WebDBSeqI::get_Seq_by_acc
> >  /usr/lib/perl5/site_perl/5.6.1/Bio/DB/WebDBSeqI.pm:177
> >  STACK Bio::DB::GenBank::get_Seq_by_acc
> >  /usr/lib/perl5/site_perl/5.6.1/Bio/DB/GenBank.pm:216
> >  STACK toplevel phylplus.pl:90
> >  --------------------------------------
> >
> > Can someone helps me understand what is happening ? Were there some
changes
> > at Genbank that could explain why my program behaves differently ? Is
there
> > anything I can do to make it behave like it did before ?
> >
> > Is there any other way than "get_Seq_by_acc" to check if an accession
number
> > exists or not ?
> >
> > Thanks in advance for the replies.
> >
> > Damien
> >
> >
> > _______________________________________________
> > Bioperl-l mailing list
> > Bioperl-l at portal.open-bio.org
> > http://portal.open-bio.org/mailman/listinfo/bioperl-l
>

_______________________________________________
Bioperl-l mailing list
Bioperl-l at portal.open-bio.org
http://portal.open-bio.org/mailman/listinfo/bioperl-l


More information about the Bioperl-l mailing list