3 # BioPerl module for Bio::Seq::RichSeq
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Ewan Birney <birney@ebi.ac.uk>
9 # Copyright Ewan Birney
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Seq::RichSeq - Module implementing a sequence created from a rich
18 sequence database entry
22 See L<Bio::Seq::RichSeqI> and documentation of methods.
26 This module implements Bio::Seq::RichSeqI, an interface for sequences
27 created from or created for entries from/of rich sequence databanks,
28 like EMBL, GenBank, and SwissProt. Methods added to the Bio::SeqI
29 interface therefore focus on databank-specific information. Note that
30 not every rich databank format may use all of the properties provided.
32 For more information, please see the relevant
34 =head1 Implemented Interfaces
36 This class implementes the following interfaces.
40 =item L<Bio::Seq::RichSeqI>
42 Note that this includes implementing L<Bio::PrimarySeqI> and L<Bio::SeqI>,
43 specifically via L<Bio::Seq> and L<Bio::PrimarySeq>. Please review the
44 documentation for those modules on implementation details relevant to those
45 interfaces, as well as the ones below.
47 =item L<Bio::IdentifiableI>
49 =item L<Bio::DescribableI>
51 =item L<Bio::AnnotatableI>
59 User feedback is an integral part of the evolution of this
60 and other Bioperl modules. Send your comments and suggestions preferably
61 to one of the Bioperl mailing lists.
62 Your participation is much appreciated.
64 bioperl-l@bioperl.org - General discussion
65 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
69 Please direct usage questions or support issues to the mailing list:
71 I<bioperl-l@bioperl.org>
73 rather than to the module maintainer directly. Many experienced and
74 reponsive experts will be able look at the problem and quickly
75 address it. Please include a thorough description of the problem
76 with code and data examples if at all possible.
80 Report bugs to the Bioperl bug tracking system to help us keep track
81 the bugs and their resolution. Bug reports can be submitted via the
84 http://bugzilla.open-bio.org/
86 =head1 AUTHOR - Ewan Birney
88 Email birney@ebi.ac.uk
92 The rest of the documentation details each of the object
93 methods. Internal methods are usually preceded with a _
98 # Let the code begin...
101 package Bio
::Seq
::RichSeq
;
102 use vars
qw($AUTOLOAD);
107 use base qw(Bio::Seq Bio::Seq::RichSeqI);
113 Usage : $seq = Bio::Seq::RichSeq->new( -seq => 'ATGGGGGTGGTGGTACCCT',
115 -accession_number => 'AL000012',
118 Function: Returns a new seq object from
119 basic constructors, being a string for the sequence
120 and strings for id and accession_number
121 Returns : a new Bio::Seq::RichSeq object
126 # standard new call..
127 my($caller,@args) = @_;
128 my $self = $caller->SUPER::new
(@args);
130 $self->{'_dates'} = [];
131 $self->{'_secondary_accession'} = [];
133 my ($dates, $xtra, $sv,
134 $keywords, $pid, $mol,
135 $division ) = $self->_rearrange([qw(DATES
144 defined $division && $self->division($division);
145 defined $mol && $self->molecule($mol);
146 if(defined($keywords)) {
147 if(ref($keywords) && (ref($keywords) eq "ARRAY")) {
148 $self->add_keyword(@
$keywords);
150 # got a string - use the old API
151 $self->keywords($keywords);
154 defined $sv && $self->seq_version($sv);
155 defined $pid && $self->pid($pid);
157 if( defined $dates ) {
158 if( ref($dates) eq "ARRAY" ) {
163 $self->add_date($dates);
167 if( defined $xtra ) {
168 if( ref($xtra) eq "ARRAY" ) {
170 $self->add_secondary_accession($_);
173 $self->add_secondary_accession($xtra);
184 Usage : $obj->division($newval)
186 Returns : value of division
187 Args : newvalue (optional)
196 $obj->{'_division'} = $value;
198 return $obj->{'_division'};
205 Usage : $obj->molecule($newval)
207 Returns : type of molecule (DNA, mRNA)
208 Args : newvalue (optional)
217 $obj->{'_molecule'} = $value;
219 return $obj->{'_molecule'};
226 Usage : $self->add_date($datestr)
227 Function: adds one or more dates
229 This implementation stores dates as keyed annotation, the
230 key being 'date_changed'. You can take advantage of this
231 fact when accessing the annotation collection directly.
235 Args : a date string or an array of such strings
241 return shift->_add_annotation_value('date_changed',@_);
247 Usage : my @dates = $seq->get_dates;
248 Function: Get the dates of the sequence (usually, when it was created and
250 Returns : an array of date strings
257 return shift->_get_annotation_values('date_changed');
264 Usage : my $pid = $seq->pid();
265 Function: Get (and set, depending on the implementation) the PID property
276 return $self->{'_pid'} = shift if @_;
277 return $self->{'_pid'};
284 Usage : $obj->accession($newval)
285 Function: Whilst the underlying sequence object does not
286 have an accession, so we need one here.
288 In this implementation this is merely a synonym for
291 Returns : value of accession
292 Args : newvalue (optional)
298 my ($obj,@args) = @_;
299 return $obj->accession_number(@args);
302 =head2 add_secondary_accession
304 Title : add_secondary_accession
305 Usage : $self->add_domment($ref)
306 Function: adds a secondary_accession
308 This implementation stores secondary accession numbers as
309 keyed annotation, the key being 'secondary_accession'. You
310 can take advantage of this fact when accessing the
311 annotation collection directly.
315 Args : a string or an array of strings
320 sub add_secondary_accession
{
321 return shift->_add_annotation_value('secondary_accession',@_);
324 =head2 get_secondary_accessions
326 Title : get_secondary_accessions
327 Usage : my @acc = $seq->get_secondary_accessions();
328 Function: Get the secondary accession numbers as strings.
329 Returns : An array of strings
335 sub get_secondary_accessions
{
336 return shift->_get_annotation_values('secondary_accession');
342 Usage : $obj->seq_version($newval)
343 Function: Get/set the sequence version
344 Returns : value of seq_version (a scalar)
345 Args : on set, new value (a scalar or undef, optional)
353 return $self->{'_seq_version'} = shift if @_;
354 return $self->{'_seq_version'};
361 Usage : $obj->add_keyword($newval)
362 Function: Add a new keyword to the annotation of the sequence.
364 This implementation stores keywords as keyed annotation,
365 the key being 'keyword'. You can take advantage of this
366 fact when accessing the annotation collection directly.
369 Args : value to be added (optional) (a string)
375 return shift->_add_annotation_value('keyword',@_);
381 Usage : $obj->get_keywords($newval)
382 Function: Get the keywords for this sequence as an array of strings.
383 Returns : an array of strings
390 return shift->_get_annotation_values('keyword');
393 =head1 Private methods and synonyms for backward compatibility
397 =head2 _add_annotation_value
399 Title : _add_annotation_value
401 Function: Adds a value to the annotation collection under the specified
402 key. Note that this is not a public method.
404 Args : key (a string), value(s) (one or more scalars)
409 sub _add_annotation_value
{
413 foreach my $val (@_) {
414 $self->annotation->add_Annotation(
415 Bio
::Annotation
::SimpleValue
->new(-tagname
=> $key,
421 =head2 _get_annotation_values
423 Title : _get_annotation_values
425 Function: Gets the values of a specific annotation as identified by the
426 key from the annotation collection. Note that this is not a
429 Returns : an array of strings
430 Args : the key (a string)
435 sub _get_annotation_values
{
438 return map { $_->value(); } $self->annotation->get_Annotations(shift);
443 ### Deprecated methods kept for ease of transition
450 # have we been called in set mode?
452 # yes; translate to the new API
453 foreach my $kwd (@_) {
454 $self->add_keyword(split(/\s*;\s*/,$kwd));
457 # no; translate read-only to the new API
458 return join("; ",$self->get_keywords());
464 $self->warn("Deprecated method... please use get_dates");
465 return $self->get_dates;
469 sub each_secondary_accession
{
471 $self->warn("each_secondary_accession - deprecated method. use get_secondary_accessions");
472 return $self->get_secondary_accessions;
477 my ($obj,$value) = @_;
478 $obj->warn("sv - deprecated method. use seq_version");
479 $obj->seq_version($value);