~ubuntu-branches/ubuntu/oneiric/bioperl/oneiric

« back to all changes in this revision

Viewing changes to Bio/Seq.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2007-09-21 22:52:22 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070921225222-tt20m2yy6ycuy2d8
Tags: 1.5.2.102-1
* Developer release.
* Upgraded source package to debhelper 5 and standards-version 3.7.2.
* Added libmodule-build-perl and libtest-harness-perl to
  build-depends-indep.
* Disabled automatic CRAN download.
* Using quilt instead of .diff.gz to manage modifications.
* Updated Recommends list for the binary package.
* Moved the "production-quality" scripts to /usr/bin/.
* New maintainer: Debian-Med packaging team mailing list.
* New uploaders: Charles Plessy and Steffen Moeller.
* Updated Depends, Recommends and Suggests.
* Imported in Debian-Med's SVN repository on Alioth.
* Executing the regression tests during package building.
* Moved the Homepage: field out from the package's description.
* Updated watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: Seq.pm,v 1.81 2003/09/24 13:05:55 bosborne Exp $
 
1
# $Id: Seq.pm,v 1.91.4.1 2006/10/02 23:10:12 sendu Exp $
2
2
#
3
3
# BioPerl module for Bio::Seq
4
4
#
52
52
    # sequences may have a species
53
53
 
54
54
    if( defined $seq->species ) {
55
 
        print "Sequence is from ",$species->binomial_name," [",$species->common_name,"]\n";
 
55
        print "Sequence is from ",$species->binomial," [",$species->common_name,"]\n";
56
56
    }
57
57
 
58
58
    # annotation objects are Bio::AnnotationCollectionI's
91
91
In Bioperl we have 3 main players that people are going to use frequently
92
92
 
93
93
  Bio::PrimarySeq  - just the sequence and its names, nothing else.
94
 
  Bio::SeqFeatureI - a location on a sequence, potentially with a sequence
95
 
                     and annotation.
 
94
  Bio::SeqFeatureI - a feature on a sequence, potentially with a sequence
 
95
                     and a location and annotation.
96
96
  Bio::Seq         - A sequence and a collection of sequence features
97
97
                     (an aggregate) with its own annotation.
98
98
 
412
412
Bioperl modules. Send your comments and suggestions preferably to one
413
413
of the Bioperl mailing lists. Your participation is much appreciated.
414
414
 
415
 
  bioperl-l@bioperl.org              - General discussion
416
 
  http://bio.perl.org/MailList.html  - About the mailing lists
 
415
  bioperl-l@bioperl.org                  - General discussion
 
416
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
417
417
 
418
418
=head2 Reporting Bugs
419
419
 
420
420
Report bugs to the Bioperl bug tracking system to help us keep track
421
 
the bugs and their resolution.  Bug reports can be submitted via email
422
 
or the web:
 
421
the bugs and their resolution.  Bug reports can be submitted via the
 
422
web:
423
423
 
424
 
  bioperl-bugs@bioperl.org
425
 
  http://bugzilla.bioperl.org/
 
424
  http://bugzilla.open-bio.org/
426
425
 
427
426
=head1 AUTHOR - Ewan Birney, inspired by Ian Korf objects
428
427
 
445
444
 
446
445
 
447
446
package Bio::Seq;
448
 
use vars qw(@ISA);
449
447
use strict;
450
448
 
451
 
 
452
 
# Object preamble - inherits from Bio::Root::Object
453
 
 
454
 
use Bio::Root::Root;
455
 
use Bio::SeqI;
456
449
use Bio::Annotation::Collection;
457
450
use Bio::PrimarySeq;
458
 
use Bio::IdentifiableI;
459
 
use Bio::DescribableI;
460
 
use Bio::AnnotatableI;
461
 
use Bio::FeatureHolderI;
462
 
 
463
 
 
464
 
@ISA = qw(Bio::Root::Root Bio::SeqI
465
 
          Bio::IdentifiableI Bio::DescribableI
466
 
          Bio::AnnotatableI Bio::FeatureHolderI);
 
451
 
 
452
use base qw(Bio::Root::Root Bio::SeqI Bio::IdentifiableI Bio::DescribableI Bio::AnnotatableI Bio::FeatureHolderI);
467
453
 
468
454
=head2 new
469
455
 
583
569
           lead to an exception if passed to seq().
584
570
 
585
571
           The implementation provided here does not take alphabet() into
586
 
           account. Allowed are all letters (A-Z) and '-','.', and '*'.
 
572
           account. Allowed are all letters (A-Z), '-','.','*','=', and '~'.
587
573
 
588
574
 Example :
589
575
 Returns : 1 if the supplied sequence string is valid for the object, and
722
708
           For sequences with no natural id, this method should return
723
709
           a stringified memory location.
724
710
 
725
 
           Can also be used to set the primary_id.
726
 
 
727
 
           Also notice that this method is not delegated to the
728
 
           internal Bio::PrimarySeq object
 
711
           Can also be used to set the primary_id (or unset to undef).
729
712
 
730
713
           [Note this method name is likely to change in 1.3]
731
714
 
732
715
 Example : $id = $seq->primary_id or $seq->primary_id($id)
733
716
 Returns : A string
734
 
 Args    : None or an id
 
717
 Args    : None or an id, or undef to unset the primary id.
735
718
 
736
719
 
737
720
=cut
738
721
 
739
722
sub primary_id {
740
 
   my ($obj,$value) = @_;
741
 
 
742
 
   if( defined $value) {
743
 
      $obj->{'primary_id'} = $value;
744
 
    }
745
 
   if( ! exists $obj->{'primary_id'} ) {
746
 
       return "$obj";
747
 
   }
748
 
   return $obj->{'primary_id'};
 
723
    # Note: this used to not delegate to the primary seq. This is
 
724
    # really bad in very subtle ways. E.g., if you created the object
 
725
    # with a primary id given to the constructor and then later you
 
726
    # change the primary id, if this method wouldn't delegate you'd
 
727
    # have different values for primary id in the PrimarySeq object
 
728
    # compared to this instance. Not good.
 
729
 
 
730
    # I can't remember why not delegating was ever deemed
 
731
    # advantageous, but I hereby claim that its problems far outweigh
 
732
    # its advantages, if there are any. Convince me otherwise if you
 
733
    # disagree. HL 2004/08/05
 
734
 
 
735
    return shift->primary_seq->primary_id(@_);
749
736
}
750
737
 
751
738
=head2 can_call_new
780
767
 
781
768
 Title   : alphabet
782
769
 Usage   : if ( $obj->alphabet eq 'dna' ) { /Do Something/ }
783
 
 Function: Returns the type of sequence being one of
 
770
 Function: Get/Set the type of sequence being one of
784
771
           'dna', 'rna' or 'protein'. This is case sensitive.
785
772
 
786
773
           This is not called <type> because this would cause
789
776
 Returns : A string either 'dna','rna','protein'. NB - the object must
790
777
           make a call of the type - if there is no type specified it
791
778
           has to guess.
792
 
 Args    : None
 
779
 Args    : optional string to set : 'dna' | 'rna' | 'protein'
793
780
 
794
781
 
795
782
=cut
938
925
=head2 annotation
939
926
 
940
927
 Title   : annotation
941
 
 Usage   : $ann = $seq->annotation or $seq->annotation($annotation)
 
928
 Usage   : $ann = $seq->annotation or 
 
929
           $seq->annotation($ann)
942
930
 Function: Gets or sets the annotation
943
 
 Returns : L<Bio::AnnotationCollectionI> object
944
 
 Args    : None or L<Bio::AnnotationCollectionI> object
 
931
 Returns : Bio::AnnotationCollectionI object
 
932
 Args    : None or Bio::AnnotationCollectionI object
945
933
 
946
934
See L<Bio::AnnotationCollectionI> and L<Bio::Annotation::Collection>
947
935
for more information