[Bioperl-l] Bio::DB::Fasta + Bio::SeqIO

Chris Fields cjfields at illinois.edu
Tue Sep 8 20:20:32 UTC 2009


On Sep 8, 2009, at 2:43 PM, Jason Stajich wrote:

> Bio::DB::Fasta returns Bio::PrimarySeq::Fasta objects which are  
> perfectly fine to write with Bio::SeqIO::fasta but not for any of  
> the rich-seq writers.
> Do we think this is a bug or feature.  The solution is to write the  
> PrimarySeq wrapped in a Bio::Seq object.

I think SeqIO requires any SeqI but doesn't specify anything for a  
simpler PrimarySeqI.  We could add some kind of general convenience  
wrapper in Bio::SeqIO to convert any PrimarySeqI to a requested SeqI  
class and just delegate to write_seq():

   # get a PrimarySeq somehow $seq, $out is Bio::SeqIO
   $out->write_PrimarySeq($seq); # or somesuch

> See this gist -- I would imagine this as additional test lines in t/ 
> LocalDB/DBFasta.t but I don't know what we really expect?
> http://gist.github.com/183169
>
> I also notice that $seq->description & $seq->display_id don't allow  
> 'set' option - which probably makes sense since this is a read-only  
> object that came from the DB, but it basically silently ignores  
> set.  I often do this if I pull seqs from a DB::Fasta db and re- 
> format the IDs or description line.  So I end up making a new object  
> and copying the data over.  I *think* this is really a feature not a  
> bug, just wanted to bring it up.
>
> -jason
> --
> Jason Stajich
> jason.stajich at gmail.com
> jason at bioperl.org

One can already cheat and do a few things.  For instance:

$seq->{id} = 'Foo';
print $seq->display_id; # should be 'Foo'

Won't work for all of them, though, such as description().   
Personally, if one made clear that such changes aren't retained in the  
database but must be redirected as output to another file then I don't  
see a problem (other PrimarySeqI are mutable, so why not these?).

Would there be any real performance hit from making those get/set  
accessors instead of ro getters?  The class is fairly small.

chris




More information about the Bioperl-l mailing list