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 =head1 Implemented Interfaces
34 This class implementes the following interfaces.
38 =item Bio::Seq::RichSeqI
40 Note that this includes implementing Bio::PrimarySeqI and Bio::SeqI.
42 =item Bio::IdentifiableI
44 =item Bio::DescribableI
46 =item Bio::AnnotatableI
54 User feedback is an integral part of the evolution of this
55 and other Bioperl modules. Send your comments and suggestions preferably
56 to one of the Bioperl mailing lists.
57 Your participation is much appreciated.
59 bioperl-l@bioperl.org - General discussion
60 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64 Please direct usage questions or support issues to the mailing list:
66 L<bioperl-l@bioperl.org>
68 rather than to the module maintainer directly. Many experienced and
69 reponsive experts will be able look at the problem and quickly
70 address it. Please include a thorough description of the problem
71 with code and data examples if at all possible.
75 Report bugs to the Bioperl bug tracking system to help us keep track
76 the bugs and their resolution. Bug reports can be submitted via the
79 http://bugzilla.open-bio.org/
81 =head1 AUTHOR - Ewan Birney
83 Email birney@ebi.ac.uk
87 The rest of the documentation details each of the object
88 methods. Internal methods are usually preceded with a _
93 # Let the code begin...
96 package Bio
::Seq
::RichSeq
;
97 use vars
qw($AUTOLOAD);
102 use base qw(Bio::Seq Bio::Seq::RichSeqI);
108 Usage : $seq = Bio::Seq::RichSeq->new( -seq => 'ATGGGGGTGGTGGTACCCT',
110 -accession_number => 'AL000012',
113 Function: Returns a new seq object from
114 basic constructors, being a string for the sequence
115 and strings for id and accession_number
116 Returns : a new Bio::Seq::RichSeq object
121 # standard new call..
122 my($caller,@args) = @_;
123 my $self = $caller->SUPER::new
(@args);
125 $self->{'_dates'} = [];
126 $self->{'_secondary_accession'} = [];
128 my ($dates, $xtra, $sv,
129 $keywords, $pid, $mol,
130 $division ) = $self->_rearrange([qw(DATES
139 defined $division && $self->division($division);
140 defined $mol && $self->molecule($mol);
141 if(defined($keywords)) {
142 if(ref($keywords) && (ref($keywords) eq "ARRAY")) {
143 $self->add_keyword(@
$keywords);
145 # got a string - use the old API
146 $self->keywords($keywords);
149 defined $sv && $self->seq_version($sv);
150 defined $pid && $self->pid($pid);
152 if( defined $dates ) {
153 if( ref($dates) eq "ARRAY" ) {
158 $self->add_date($dates);
162 if( defined $xtra ) {
163 if( ref($xtra) eq "ARRAY" ) {
165 $self->add_secondary_accession($_);
168 $self->add_secondary_accession($xtra);
179 Usage : $obj->division($newval)
181 Returns : value of division
182 Args : newvalue (optional)
191 $obj->{'_division'} = $value;
193 return $obj->{'_division'};
200 Usage : $obj->molecule($newval)
202 Returns : type of molecule (DNA, mRNA)
203 Args : newvalue (optional)
212 $obj->{'_molecule'} = $value;
214 return $obj->{'_molecule'};
221 Usage : $self->add_date($datestr)
222 Function: adds one or more dates
224 This implementation stores dates as keyed annotation, the
225 key being 'date_changed'. You can take advantage of this
226 fact when accessing the annotation collection directly.
230 Args : a date string or an array of such strings
236 return shift->_add_annotation_value('date_changed',@_);
242 Usage : my @dates = $seq->get_dates;
243 Function: Get the dates of the sequence (usually, when it was created and
245 Returns : an array of date strings
252 return shift->_get_annotation_values('date_changed');
259 Usage : my $pid = $seq->pid();
260 Function: Get (and set, depending on the implementation) the PID property
271 return $self->{'_pid'} = shift if @_;
272 return $self->{'_pid'};
279 Usage : $obj->accession($newval)
280 Function: Whilst the underlying sequence object does not
281 have an accession, so we need one here.
283 In this implementation this is merely a synonym for
286 Returns : value of accession
287 Args : newvalue (optional)
293 my ($obj,@args) = @_;
294 return $obj->accession_number(@args);
297 =head2 add_secondary_accession
299 Title : add_secondary_accession
300 Usage : $self->add_domment($ref)
301 Function: adds a secondary_accession
303 This implementation stores secondary accession numbers as
304 keyed annotation, the key being 'secondary_accession'. You
305 can take advantage of this fact when accessing the
306 annotation collection directly.
310 Args : a string or an array of strings
315 sub add_secondary_accession
{
316 return shift->_add_annotation_value('secondary_accession',@_);
319 =head2 get_secondary_accessions
321 Title : get_secondary_accessions
322 Usage : my @acc = $seq->get_secondary_accessions();
323 Function: Get the secondary accession numbers as strings.
324 Returns : An array of strings
330 sub get_secondary_accessions
{
331 return shift->_get_annotation_values('secondary_accession');
337 Usage : $obj->seq_version($newval)
338 Function: Get/set the sequence version
339 Returns : value of seq_version (a scalar)
340 Args : on set, new value (a scalar or undef, optional)
348 return $self->{'_seq_version'} = shift if @_;
349 return $self->{'_seq_version'};
356 Usage : $obj->add_keyword($newval)
357 Function: Add a new keyword to the annotation of the sequence.
359 This implementation stores keywords as keyed annotation,
360 the key being 'keyword'. You can take advantage of this
361 fact when accessing the annotation collection directly.
364 Args : value to be added (optional) (a string)
370 return shift->_add_annotation_value('keyword',@_);
376 Usage : $obj->get_keywords($newval)
377 Function: Get the keywords for this sequence as an array of strings.
378 Returns : an array of strings
385 return shift->_get_annotation_values('keyword');
388 =head1 Private methods and synonyms for backward compatibility
392 =head2 _add_annotation_value
394 Title : _add_annotation_value
396 Function: Adds a value to the annotation collection under the specified
397 key. Note that this is not a public method.
399 Args : key (a string), value(s) (one or more scalars)
404 sub _add_annotation_value
{
408 foreach my $val (@_) {
409 $self->annotation->add_Annotation(
410 Bio
::Annotation
::SimpleValue
->new(-tagname
=> $key,
416 =head2 _get_annotation_values
418 Title : _get_annotation_values
420 Function: Gets the values of a specific annotation as identified by the
421 key from the annotation collection. Note that this is not a
424 Returns : an array of strings
425 Args : the key (a string)
430 sub _get_annotation_values
{
433 return map { $_->value(); } $self->annotation->get_Annotations(shift);
438 ### Deprecated methods kept for ease of transition
445 # have we been called in set mode?
447 # yes; translate to the new API
448 foreach my $kwd (@_) {
449 $self->add_keyword(split(/\s*;\s*/,$kwd));
452 # no; translate read-only to the new API
453 return join("; ",$self->get_keywords());
459 $self->warn("Deprecated method... please use get_dates");
460 return $self->get_dates;
464 sub each_secondary_accession
{
466 $self->warn("each_secondary_accession - deprecated method. use get_secondary_accessions");
467 return $self->get_secondary_accessions;
472 my ($obj,$value) = @_;
473 $obj->warn("sv - deprecated method. use seq_version");
474 $obj->seq_version($value);