3 # BioPerl module for Bio::Seq::RichSeq
5 # Cared for by Ewan Birney <birney@ebi.ac.uk>
7 # Copyright Ewan Birney
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
15 Bio::Seq::RichSeq - Module implementing a sequence created from a rich
16 sequence database entry
20 See L<Bio::Seq::RichSeqI> and documentation of methods.
24 This module implements Bio::Seq::RichSeqI, an interface for sequences
25 created from or created for entries from/of rich sequence databanks,
26 like EMBL, GenBank, and SwissProt. Methods added to the Bio::SeqI
27 interface therefore focus on databank-specific information. Note that
28 not every rich databank format may use all of the properties provided.
30 =head1 Implemented Interfaces
32 This class implementes the following interfaces.
36 =item Bio::Seq::RichSeqI
38 Note that this includes implementing Bio::PrimarySeqI and Bio::SeqI.
40 =item Bio::IdentifiableI
42 =item Bio::DescribableI
44 =item Bio::AnnotatableI
52 User feedback is an integral part of the evolution of this
53 and other Bioperl modules. Send your comments and suggestions preferably
54 to one of the Bioperl mailing lists.
55 Your participation is much appreciated.
57 bioperl-l@bioperl.org - General discussion
58 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
62 Report bugs to the Bioperl bug tracking system to help us keep track
63 the bugs and their resolution. Bug reports can be submitted via the
66 http://bugzilla.open-bio.org/
68 =head1 AUTHOR - Ewan Birney
70 Email birney@ebi.ac.uk
74 The rest of the documentation details each of the object
75 methods. Internal methods are usually preceded with a _
80 # Let the code begin...
83 package Bio
::Seq
::RichSeq
;
84 use vars
qw($AUTOLOAD);
89 use base qw(Bio::Seq Bio::Seq::RichSeqI);
95 Usage : $seq = Bio::Seq::RichSeq->new( -seq => 'ATGGGGGTGGTGGTACCCT',
97 -accession_number => 'AL000012',
100 Function: Returns a new seq object from
101 basic constructors, being a string for the sequence
102 and strings for id and accession_number
103 Returns : a new Bio::Seq::RichSeq object
108 # standard new call..
109 my($caller,@args) = @_;
110 my $self = $caller->SUPER::new
(@args);
112 $self->{'_dates'} = [];
113 $self->{'_secondary_accession'} = [];
115 my ($dates, $xtra, $sv,
116 $keywords, $pid, $mol,
117 $division ) = $self->_rearrange([qw(DATES
126 defined $division && $self->division($division);
127 defined $mol && $self->molecule($mol);
128 if(defined($keywords)) {
129 if(ref($keywords) && (ref($keywords) eq "ARRAY")) {
130 $self->add_keyword(@
$keywords);
132 # got a string - use the old API
133 $self->keywords($keywords);
136 defined $sv && $self->seq_version($sv);
137 defined $pid && $self->pid($pid);
139 if( defined $dates ) {
140 if( ref($dates) eq "ARRAY" ) {
145 $self->add_date($dates);
149 if( defined $xtra ) {
150 if( ref($xtra) eq "ARRAY" ) {
152 $self->add_secondary_accession($_);
155 $self->add_secondary_accession($xtra);
166 Usage : $obj->division($newval)
168 Returns : value of division
169 Args : newvalue (optional)
178 $obj->{'_division'} = $value;
180 return $obj->{'_division'};
187 Usage : $obj->molecule($newval)
189 Returns : type of molecule (DNA, mRNA)
190 Args : newvalue (optional)
199 $obj->{'_molecule'} = $value;
201 return $obj->{'_molecule'};
208 Usage : $self->add_date($datestr)
209 Function: adds one or more dates
211 This implementation stores dates as keyed annotation, the
212 key being 'date_changed'. You can take advantage of this
213 fact when accessing the annotation collection directly.
217 Args : a date string or an array of such strings
223 return shift->_add_annotation_value('date_changed',@_);
229 Usage : my @dates = $seq->get_dates;
230 Function: Get the dates of the sequence (usually, when it was created and
232 Returns : an array of date strings
239 return shift->_get_annotation_values('date_changed');
246 Usage : my $pid = $seq->pid();
247 Function: Get (and set, depending on the implementation) the PID property
258 return $self->{'_pid'} = shift if @_;
259 return $self->{'_pid'};
266 Usage : $obj->accession($newval)
267 Function: Whilst the underlying sequence object does not
268 have an accession, so we need one here.
270 In this implementation this is merely a synonym for
273 Returns : value of accession
274 Args : newvalue (optional)
280 my ($obj,@args) = @_;
281 return $obj->accession_number(@args);
284 =head2 add_secondary_accession
286 Title : add_secondary_accession
287 Usage : $self->add_domment($ref)
288 Function: adds a secondary_accession
290 This implementation stores secondary accession numbers as
291 keyed annotation, the key being 'secondary_accession'. You
292 can take advantage of this fact when accessing the
293 annotation collection directly.
297 Args : a string or an array of strings
302 sub add_secondary_accession
{
303 return shift->_add_annotation_value('secondary_accession',@_);
306 =head2 get_secondary_accessions
308 Title : get_secondary_accessions
309 Usage : my @acc = $seq->get_secondary_accessions();
310 Function: Get the secondary accession numbers as strings.
311 Returns : An array of strings
317 sub get_secondary_accessions
{
318 return shift->_get_annotation_values('secondary_accession');
324 Usage : $obj->seq_version($newval)
325 Function: Get/set the sequence version
326 Returns : value of seq_version (a scalar)
327 Args : on set, new value (a scalar or undef, optional)
335 return $self->{'_seq_version'} = shift if @_;
336 return $self->{'_seq_version'};
343 Usage : $obj->add_keyword($newval)
344 Function: Add a new keyword to the annotation of the sequence.
346 This implementation stores keywords as keyed annotation,
347 the key being 'keyword'. You can take advantage of this
348 fact when accessing the annotation collection directly.
351 Args : value to be added (optional) (a string)
357 return shift->_add_annotation_value('keyword',@_);
363 Usage : $obj->get_keywords($newval)
364 Function: Get the keywords for this sequence as an array of strings.
365 Returns : an array of strings
372 return shift->_get_annotation_values('keyword');
375 =head1 Private methods and synonyms for backward compatibility
379 =head2 _add_annotation_value
381 Title : _add_annotation_value
383 Function: Adds a value to the annotation collection under the specified
384 key. Note that this is not a public method.
386 Args : key (a string), value(s) (one or more scalars)
391 sub _add_annotation_value
{
395 foreach my $val (@_) {
396 $self->annotation->add_Annotation(
397 Bio
::Annotation
::SimpleValue
->new(-tagname
=> $key,
403 =head2 _get_annotation_values
405 Title : _get_annotation_values
407 Function: Gets the values of a specific annotation as identified by the
408 key from the annotation collection. Note that this is not a
411 Returns : an array of strings
412 Args : the key (a string)
417 sub _get_annotation_values
{
420 return map { $_->value(); } $self->annotation->get_Annotations(shift);
425 ### Deprecated methods kept for ease of transition
432 # have we been called in set mode?
434 # yes; translate to the new API
435 foreach my $kwd (@_) {
436 $self->add_keyword(split(/\s*;\s*/,$kwd));
439 # no; translate read-only to the new API
440 return join("; ",$self->get_keywords());
446 $self->warn("Deprecated method... please use get_dates");
447 return $self->get_dates;
451 sub each_secondary_accession
{
453 $self->warn("each_secondary_accession - deprecated method. use get_secondary_accessions");
454 return $self->get_secondary_accessions;
459 my ($obj,$value) = @_;
460 $obj->warn("sv - deprecated method. use seq_version");
461 $obj->seq_version($value);