2 # BioPerl module for Bio::Seq::RichSeq
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Ewan Birney <birney@ebi.ac.uk>
8 # Copyright Ewan Birney
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Seq::RichSeq - Module implementing a sequence created from a rich
17 sequence database entry
21 See L<Bio::Seq::RichSeqI> and documentation of methods.
25 This module implements Bio::Seq::RichSeqI, an interface for sequences
26 created from or created for entries from/of rich sequence databanks,
27 like EMBL, GenBank, and SwissProt. Methods added to the Bio::SeqI
28 interface therefore focus on databank-specific information. Note that
29 not every rich databank format may use all of the properties provided.
31 For more information, please see the relevant
33 =head1 Implemented Interfaces
35 This class implementes the following interfaces.
39 =item L<Bio::Seq::RichSeqI>
41 Note that this includes implementing L<Bio::PrimarySeqI> and L<Bio::SeqI>,
42 specifically via L<Bio::Seq> and L<Bio::PrimarySeq>. Please review the
43 documentation for those modules on implementation details relevant to those
44 interfaces, as well as the ones below.
46 =item L<Bio::IdentifiableI>
48 =item L<Bio::DescribableI>
50 =item L<Bio::AnnotatableI>
58 User feedback is an integral part of the evolution of this
59 and other Bioperl modules. Send your comments and suggestions preferably
60 to one of the Bioperl mailing lists.
61 Your participation is much appreciated.
63 bioperl-l@bioperl.org - General discussion
64 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
68 Please direct usage questions or support issues to the mailing list:
70 I<bioperl-l@bioperl.org>
72 rather than to the module maintainer directly. Many experienced and
73 reponsive experts will be able look at the problem and quickly
74 address it. Please include a thorough description of the problem
75 with code and data examples if at all possible.
79 Report bugs to the Bioperl bug tracking system to help us keep track
80 the bugs and their resolution. Bug reports can be submitted via the
83 https://redmine.open-bio.org/projects/bioperl/
85 =head1 AUTHOR - Ewan Birney
87 Email birney@ebi.ac.uk
91 The rest of the documentation details each of the object
92 methods. Internal methods are usually preceded with a _
97 # Let the code begin...
100 package Bio
::Seq
::RichSeq
;
101 use vars
qw($AUTOLOAD);
106 use base qw(Bio::Seq Bio::Seq::RichSeqI);
112 Usage : $seq = Bio::Seq::RichSeq->new( -seq => 'ATGGGGGTGGTGGTACCCT',
114 -accession_number => 'AL000012',
117 Function: Returns a new seq object from
118 basic constructors, being a string for the sequence
119 and strings for id and accession_number
120 Returns : a new Bio::Seq::RichSeq object
125 # standard new call..
126 my($caller,@args) = @_;
127 my $self = $caller->SUPER::new
(@args);
129 $self->{'_dates'} = [];
130 $self->{'_secondary_accession'} = [];
132 my ($dates, $xtra, $sv,
133 $keywords, $pid, $mol,
134 $division ) = $self->_rearrange([qw(DATES
143 defined $division && $self->division($division);
144 defined $mol && $self->molecule($mol);
145 if(defined($keywords)) {
146 if(ref($keywords) && (ref($keywords) eq "ARRAY")) {
147 $self->add_keyword(@
$keywords);
149 # got a string - use the old API
150 $self->keywords($keywords);
153 defined $sv && $self->seq_version($sv);
154 defined $pid && $self->pid($pid);
156 if( defined $dates ) {
157 if( ref($dates) eq "ARRAY" ) {
162 $self->add_date($dates);
166 if( defined $xtra ) {
167 if( ref($xtra) eq "ARRAY" ) {
169 $self->add_secondary_accession($_);
172 $self->add_secondary_accession($xtra);
183 Usage : $obj->division($newval)
185 Returns : value of division
186 Args : newvalue (optional)
195 $obj->{'_division'} = $value;
197 return $obj->{'_division'};
204 Usage : $obj->molecule($newval)
206 Returns : type of molecule (DNA, mRNA)
207 Args : newvalue (optional)
216 $obj->{'_molecule'} = $value;
218 return $obj->{'_molecule'};
225 Usage : $self->add_date($datestr)
226 Function: adds one or more dates
228 This implementation stores dates as keyed annotation, the
229 key being 'date_changed'. You can take advantage of this
230 fact when accessing the annotation collection directly.
234 Args : a date string or an array of such strings
240 return shift->_add_annotation_value('date_changed',@_);
246 Usage : my @dates = $seq->get_dates;
247 Function: Get the dates of the sequence (usually, when it was created and
249 Returns : an array of date strings
256 return shift->_get_annotation_values('date_changed');
263 Usage : my $pid = $seq->pid();
264 Function: Get (and set, depending on the implementation) the PID property
275 return $self->{'_pid'} = shift if @_;
276 return $self->{'_pid'};
283 Usage : $obj->accession($newval)
284 Function: Whilst the underlying sequence object does not
285 have an accession, so we need one here.
287 In this implementation this is merely a synonym for
290 Returns : value of accession
291 Args : newvalue (optional)
297 my ($obj,@args) = @_;
298 return $obj->accession_number(@args);
301 =head2 add_secondary_accession
303 Title : add_secondary_accession
304 Usage : $self->add_domment($ref)
305 Function: adds a secondary_accession
307 This implementation stores secondary accession numbers as
308 keyed annotation, the key being 'secondary_accession'. You
309 can take advantage of this fact when accessing the
310 annotation collection directly.
314 Args : a string or an array of strings
319 sub add_secondary_accession
{
320 return shift->_add_annotation_value('secondary_accession',@_);
323 =head2 get_secondary_accessions
325 Title : get_secondary_accessions
326 Usage : my @acc = $seq->get_secondary_accessions();
327 Function: Get the secondary accession numbers as strings.
328 Returns : An array of strings
334 sub get_secondary_accessions
{
335 return shift->_get_annotation_values('secondary_accession');
341 Usage : $obj->seq_version($newval)
342 Function: Get/set the sequence version
343 Returns : value of seq_version (a scalar)
344 Args : on set, new value (a scalar or undef, optional)
345 Note : this differs from Bio::PrimarySeq version() in that this explicitly
346 refers to the sequence record version one would find in a typical
354 return $self->{'_seq_version'} = shift if @_;
355 return $self->{'_seq_version'};
362 Usage : $obj->add_keyword($newval)
363 Function: Add a new keyword to the annotation of the sequence.
365 This implementation stores keywords as keyed annotation,
366 the key being 'keyword'. You can take advantage of this
367 fact when accessing the annotation collection directly.
370 Args : value to be added (optional) (a string)
376 return shift->_add_annotation_value('keyword',@_);
382 Usage : $obj->get_keywords($newval)
383 Function: Get the keywords for this sequence as an array of strings.
384 Returns : an array of strings
391 return shift->_get_annotation_values('keyword');
394 =head1 Private methods and synonyms for backward compatibility
398 =head2 _add_annotation_value
400 Title : _add_annotation_value
402 Function: Adds a value to the annotation collection under the specified
403 key. Note that this is not a public method.
405 Args : key (a string), value(s) (one or more scalars)
410 sub _add_annotation_value
{
414 foreach my $val (@_) {
415 $self->annotation->add_Annotation(
416 Bio
::Annotation
::SimpleValue
->new(-tagname
=> $key,
422 =head2 _get_annotation_values
424 Title : _get_annotation_values
426 Function: Gets the values of a specific annotation as identified by the
427 key from the annotation collection. Note that this is not a
430 Returns : an array of strings
431 Args : the key (a string)
436 sub _get_annotation_values
{
439 return map { $_->value(); } $self->annotation->get_Annotations(shift);
444 ### Deprecated methods kept for ease of transition
451 # have we been called in set mode?
453 # yes; translate to the new API
454 foreach my $kwd (@_) {
455 $self->add_keyword(split(/\s*;\s*/,$kwd));
458 # no; translate read-only to the new API
459 return join("; ",$self->get_keywords());
465 $self->warn("Deprecated method... please use get_dates");
466 return $self->get_dates;
470 sub each_secondary_accession
{
472 $self->warn("each_secondary_accession - deprecated method. use get_secondary_accessions");
473 return $self->get_secondary_accessions;
478 my ($obj,$value) = @_;
479 $obj->warn("sv - deprecated method. use seq_version");
480 $obj->seq_version($value);