[Bioperl-l] Problem with Bio::Annotation

Jason Stajich jason@cgt.mc.duke.edu
Wed, 11 Dec 2002 12:23:46 -0500 (EST)


Try this instead.

Also, I've updated docs in Bio::SeqIO writers which use Annotation
collections to document what are the fields they recognize.

#!/usr/bin/perl -w

use Bio::SeqIO;
use Bio::Seq;
use Bio::Annotation::SimpleValue;
use Bio::Annotation::Comment;

$out = Bio::SeqIO->new( -format => 'GenBank');

$seq = Bio::Seq->new( '-seq' => 'atgcctgatctggatcgtt',
		      '-display_id' => 'something',
		      '-accession_number' => 'AC_000001');

# annotation is a Bio::Annotation::Collection object which is
# created on the fly -- it is a collection because you probably
# want to store more than 1 annotation for a sequence object.

# Note -- this annotation won't be output by the genbank writer because
# genbank writer only recognizes 'comment' and 'reference'
$seq->annotation->add_Annotation('description',
				 Bio::Annotation::SimpleValue->new(-value => 'some description'));

# put the description in the comment field
$seq->annotation->add_Annotation('comment',
				 Bio::Annotation::Comment->new(-text => 'some description as a comment'));


# if you wanted to store a description for a seq - either specify it
# when you initialize the object or set it with a method call like this:

$seq->desc('A description here');

# write out the sequence
$out->write_seq($seq);


On Tue, 10 Dec 2002, Harry Wild wrote:

>
> Hi bioperl Community!
>
> I'm trying to write out genome data from a relational database to Genbank
> format.
> But I'm not able to get the annotations out of the Seq-Objects that I
> create.
>
> My little test-code
>
> 	use Bio::SeqIO;
> 	use Bio::Seq;
> 	use Bio::Annotation;
>
> 	$out = Bio::SeqIO->new( -file => ">/home/wild/test1.gb" ,
>                        	                      -format => 'GenBank');
>
> 	$seq = Bio::Seq->new( '-seq' => 'atgcctgatctggatcgtt',
>                                              '-display_id' => 'something',
>                                              '-accession_number' =>
> 'AC_000001');
>
> 	$seq->annotation( new Bio::Annotation( '-description' => 'some
> description'));
>
> 	$out->write_seq($seq);
>
> 	$out->close;
>
> always produces the following output:
>
> Can't locate object method "get_Annotations" via package "Bio::Annotation"
> at
> /usr/local/lib/perl5/site_perl/5.005/Bio/SeqIO/genbank.pm line 466.
>
> What's wrong with my code?
>
> Thanks for help,
> Harry
>
>

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