~ubuntu-branches/ubuntu/edgy/bioperl/edgy

« back to all changes in this revision

Viewing changes to Bio/Symbol/ProteinAlphabet.pm

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2002-03-20 01:16:30 UTC
  • Revision ID: james.westby@ubuntu.com-20020320011630-wyvmxwc7o5bi4665
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: ProteinAlphabet.pm,v 1.2 2001/12/13 23:09:52 jason Exp $
 
2
#
 
3
# BioPerl module for Bio::Symbol::ProteinAlphabet
 
4
#
 
5
# Cared for by Jason Stajich <jason@bioperl.org>
 
6
#
 
7
# Copyright Jason Stajich
 
8
#
 
9
# You may distribute this module under the same terms as perl itself
 
10
 
 
11
# POD documentation - main docs before the code
 
12
 
 
13
=head1 NAME
 
14
 
 
15
Bio::Symbol::ProteinAlphabet - A ready made Protein alphabet
 
16
 
 
17
=head1 SYNOPSIS
 
18
 
 
19
    use Bio::Symbol::ProteinAlphabet;
 
20
    my $alpha = new Bio::Symbol::ProteinAlphabet();
 
21
    foreach my $symbol ( $alpha->symbols ) {
 
22
        print "symbol is $symbol\n";
 
23
    }
 
24
 
 
25
=head1 DESCRIPTION
 
26
 
 
27
This object builds an Alphabet with Protein symbols.
 
28
 
 
29
=head1 FEEDBACK
 
30
 
 
31
=head2 Mailing Lists
 
32
 
 
33
User feedback is an integral part of the evolution of this and other
 
34
Bioperl modules. Send your comments and suggestions preferably to
 
35
the Bioperl mailing list.  Your participation is much appreciated.
 
36
 
 
37
  bioperl-l@bioperl.org              - General discussion
 
38
  http://bioperl.org/MailList.shtml  - About the mailing lists
 
39
 
 
40
=head2 Reporting Bugs
 
41
 
 
42
Report bugs to the Bioperl bug tracking system to help us keep track
 
43
of the bugs and their resolution. Bug reports can be submitted via
 
44
email or the web:
 
45
 
 
46
  bioperl-bugs@bioperl.org
 
47
  http://bioperl.org/bioperl-bugs/
 
48
 
 
49
=head1 AUTHOR - Jason Stajich
 
50
 
 
51
Email jason@bioperl.org
 
52
 
 
53
Describe contact details here
 
54
 
 
55
=head1 CONTRIBUTORS
 
56
 
 
57
Additional contributors names and emails here
 
58
 
 
59
=head1 APPENDIX
 
60
 
 
61
The rest of the documentation details each of the object methods.
 
62
Internal methods are usually preceded with a _
 
63
 
 
64
=cut
 
65
 
 
66
 
 
67
# Let the code begin...
 
68
 
 
69
 
 
70
package Bio::Symbol::ProteinAlphabet;
 
71
use vars qw(@ISA);
 
72
use strict;
 
73
 
 
74
use Bio::Symbol::Alphabet;
 
75
use Bio::Symbol::Symbol;
 
76
use Bio::Tools::IUPAC;
 
77
use Bio::SeqUtils;
 
78
 
 
79
@ISA = qw(Bio::Symbol::Alphabet);
 
80
 
 
81
=head2 new
 
82
 
 
83
 Title   : new
 
84
 Usage   : my $obj = new Bio::Symbol::ProteinAlphabet();
 
85
 Function: Builds a new Bio::Symbol::ProteinAlphabet object 
 
86
 Returns : Bio::Symbol::ProteinAlphabet
 
87
 Args    :
 
88
 
 
89
 
 
90
=cut
 
91
 
 
92
sub new {
 
93
  my($class,@args) = @_;
 
94
  my $self = $class->SUPER::new(@args);  
 
95
  my %aa = Bio::SeqUtils->valid_aa(2);
 
96
  my %codes = Bio::Tools::IUPAC->iupac_iup();
 
97
  my %symbols;
 
98
  my @left;
 
99
  
 
100
  foreach my $let ( keys %codes  ) {  
 
101
      next if( $let eq 'U');
 
102
      if( scalar @{$codes{$let}} != 1) { push @left, $let; next; }
 
103
      $symbols{$let} = new Bio::Symbol::Symbol(-name => $aa{$let},
 
104
                                               -token => $let);      
 
105
  }
 
106
  foreach my $l ( @left ) {
 
107
      my @subsym;
 
108
      foreach my $sym ( @{$codes{$l}} ) {
 
109
          push @subsym, $symbols{$sym};
 
110
      }
 
111
      my $alpha = new Bio::Symbol::Alphabet(-symbols => \@subsym);
 
112
      $symbols{$l} = new Bio::Symbol::Symbol(-name => $aa{$l},
 
113
                                               -token => $l,
 
114
                                               -matches => $alpha,
 
115
                                               -symbols => \@subsym);
 
116
  }
 
117
  
 
118
  $self->symbols(values %symbols); 
 
119
  return $self;
 
120
}
 
121
 
 
122
 
 
123
1;