[Bioperl-l] PrimarySeq object question

kevin.mcmahon at ttuhsc.edu kevin.mcmahon at ttuhsc.edu
Fri Dec 9 12:56:29 EST 2005


Wow, what a great response!  I'm very thankful for what everyone has done
for me.  

First, to answer some questions:

Thanks to Matt and Sam (my fellow beginners) for the help.  The file
converter you showed me works great, but (as mentioned below in Heikki's
response) this bug is in the Bio::Seq::SeqWithQuality module.  It only
throws this exception when you're working with these objects.  So while your
codes work great for someone converting Genbank to Fasta, it won't help me
read an empty scf file.  Instead, this exception will be thrown and the
program will stop.  

Now, on to Heikki and Brian.  Thanks a ton guys.  Here's what I eventually
did:

   if (eval {$in->next_seq()}){

	[Do some really cool stuff]
  }else{
    next;
  }

And now it works.  If there is still problems with this code, let us all
know for future reference and general education purposes.

As Heikki said, 
" It could be 
argued that it is overzealous to throw an exception if it can not find a 
sequence."

But, if you know the eval trick (which I should have been using all along)
you can get around this.

Thanks to everyone for helping.  I'll submit the Bugzilla report after
lunch.

Thanks a ton,

Wyatt

-----Original Message-----
From: Heikki Lehvaslaiho [mailto:heikki at sanbi.ac.za] 
Sent: Friday, December 09, 2005 12:53 AM
To: bioperl-l at portal.open-bio.org
Cc: McMahon, Kevin
Subject: Re: [Bioperl-l] PrimarySeq object question

Kevin,

The message you get comes from Bio::Seq::SeqWithQuality module. It could be 
argued that it is overzealous to throw an exception if it can not find a 
sequence. Also, the message comes after it has come to the conclusion that 
you have not set the alphabet that, according to your code snippet, you
have. 
Report this as a bug to bugzilla.bioperl.org and make sure you attach an 
example scf file.

Meanwhile, you can always avoid exiting from you code by wrapping the code 
within the eval statement.

eval { 
  # your code   
}; # note the ';'
if ($@) {
  # do something else
}

Yours,
       -Heikki

On Thursday 08 December 2005 19:36, kevin.mcmahon at ttuhsc.edu wrote:
> Everyone,
>
> I'm new to this, so please bear with me.
>
> I'm having some trouble with a scf to fasta converting program I'm
writing.
>
>   my $in  = Bio::SeqIO->new(-file => $infile , '-format' => 'scf',
> -alphabet => 'dna');
>
>     my $seq = $in->next_seq();
>     print "My sequence is:  " . $seq->seq() . "\n";
>
> Above is the code in discussion.  The $in object contains information from
> a file ($infile) in scf format.
>
> Here's my problem.  When we get to $in->next_seq(), if the file is empty,
> the program dies and returns:
>
> "MSG: If you want me to create a PrimarySeq object for your empty sequence
> <boggle> you must specify a -alphabet to satisfy the constructor
> requirements for a Bio::PrimarySeq object with no sequence.  Read the POD
> for it, luke."
>
> I guess what I need to know is: if this $in->next_seq() doesn't work, how
> can I test for this before I get this reply.
>
> Thanks in advance,
>
> Wyatt
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l

-- 
______ _/      _/_____________________________________________________
      _/      _/
     _/  _/  _/  Heikki Lehvaslaiho    heikki at_sanbi _ac _za
    _/_/_/_/_/  Associate Professor    skype: heikki_lehvaslaiho
   _/  _/  _/  SANBI, South African National Bioinformatics Institute
  _/  _/  _/  University of the Western Cape, South Africa
     _/      Phone: +27 21 959 2096   FAX: +27 21 959 2512
___ _/_/_/_/_/________________________________________________________


More information about the Bioperl-l mailing list