~ubuntu-branches/ubuntu/hoary/bioperl/hoary

« back to all changes in this revision

Viewing changes to Bio/Tools/OddCodes.pm

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#$Id: OddCodes.pm,v 1.9 2001/11/20 02:09:40 lstein Exp $
 
1
#$Id: OddCodes.pm,v 1.13 2003/05/17 19:03:57 heikki Exp $
2
2
#-----------------------------------------------------------------------------
3
3
# PACKAGE    : OddCodes.pm
4
4
# PURPOSE    : To write amino acid sequences in alternative alphabets
5
5
# AUTHOR     : Derek Gatherer (D.Gatherer@organon.nhe.akzonobel.nl)
6
 
# SOURCE     : 
 
6
# SOURCE     :
7
7
# CREATED    : 8th July 2000
8
 
# MODIFIED   : 
9
 
# DISCLAIMER : I am employed in the pharmaceutical industry but my 
 
8
# MODIFIED   :
 
9
# DISCLAIMER : I am employed in the pharmaceutical industry but my
10
10
#            : employers do not endorse or sponsor this module
11
11
#            : in any way whatsoever.  The above email address is
12
12
#            : given purely for the purpose of easy communication
13
13
#            : with the author, and does not imply any connection
14
14
#            : between my employers and anything written below.
15
 
# LICENCE    : You may distribute this module under the same terms 
 
15
# LICENCE    : You may distribute this module under the same terms
16
16
#            : as the rest of BioPerl.
17
17
#----------------------------------------------------------------------------
18
18
 
19
19
=head1 NAME
20
20
 
21
 
Bio::Tools::OddCodes - Object holding alternative alphabet coding for 
 
21
Bio::Tools::OddCodes - Object holding alternative alphabet coding for
22
22
one protein sequence
23
23
 
24
24
=head1 SYNOPSIS
25
25
 
26
 
Take a sequence object from eg, an inputstream, and creates an object
27
 
for the purposes of rewriting that sequence in another alphabet.
28
 
These are abbreviated amino acid sequence alphabets, designed to
29
 
simplify the statistical aspects of analysing protein sequences, by
30
 
reducing the combinatorial explosion of the 20-letter alphabet.  These
31
 
abbreviated alphabets range in size from 2 to 8.
32
 
 
33
 
Creating the OddCodes object, eg:
34
 
 
35
 
        my $inputstream = Bio::SeqIO->new( '-file' => "seqfile", 
 
26
  # Take a sequence object from eg, an inputstream, and creates an
 
27
  # object for the purposes of rewriting that sequence in another
 
28
  # alphabet.  These are abbreviated amino acid sequence alphabets,
 
29
  # designed to simplify the statistical aspects of analysing protein
 
30
  # sequences, by reducing the combinatorial explosion of the
 
31
  # 20-letter alphabet.  These abbreviated alphabets range in size
 
32
  # from 2 to 8.
 
33
 
 
34
  # Creating the OddCodes object, eg:
 
35
 
 
36
        my $inputstream = Bio::SeqIO->new( '-file' => "seqfile",
36
37
                                           '-format' => 'Fasta');
37
38
        my $seqobj = $inputstream->next_seq();
38
39
        my $oddcode_obj = Bio::Tools::Oddcodes->new(-seq => $seqobj);
39
40
 
40
 
or:
 
41
  # or:
41
42
 
42
43
        my $seqobj = Bio::PrimarySeq->new
43
 
              (-seq=>'[cut and paste a sequence here]', 
44
 
               -alphabet = 'protein', 
45
 
               -id = 'test');
 
44
              (-seq=>'[cut and paste a sequence here]',
 
45
               -alphabet => 'protein',
 
46
               -id => 'test');
46
47
        my $oddcode_obj  =  Bio::Tools::OddCodes->new(-seq => $seqobj);
47
48
 
48
 
do the alternative coding, returning the answer as a reference to a string
 
49
  # do the alternative coding, returning the answer as a reference to
 
50
  # a string
49
51
 
50
52
        my $output = $oddcode_obj->structural();
51
53
        my $output = $oddcode_obj->chemical();
57
59
        my $output = $oddcode_obj->Stanfel();
58
60
 
59
61
 
60
 
display sequence in new form, eg:
 
62
  # display sequence in new form, eg:
61
63
 
62
64
        my $new_coding = $$output;
63
65
        print "\n$new_coding";
72
74
produced by the full 20-letter alphabet (eg. 400 dimers, 8000 trimers
73
75
etc.)
74
76
 
 
77
The objects will print out a warning if the input sequence is not a
 
78
protein. If you know what you are doing, you can silence the warning
 
79
by setting verbose() to a negetive value.
 
80
 
75
81
See Synopsis above for object creation code.
76
82
 
77
83
=head1 FEEDBACK
93
99
or the web:
94
100
 
95
101
  bioperl-bugs@bioperl.org
96
 
  http://www.bioperl.org/bioperl-bugs/
 
102
  http://www.bugzilla.bioperl.org/
97
103
 
98
104
=head1 AUTHOR
99
105
 
101
107
 
102
108
=head1 APPENDIX
103
109
 
104
 
The rest of the documentation details each of the object methods. 
 
110
The rest of the documentation details each of the object methods.
105
111
Internal methods are usually preceded with a _
106
112
 
107
113
=cut
117
123
@ISA = qw(Bio::Root::Root);
118
124
 
119
125
 
120
 
sub new 
 
126
sub new
121
127
{
122
128
    my($class,@args) = @_;
123
129
 
128
134
        # parameter not passed as named parameter?
129
135
        $seqobj = $args[0];
130
136
    }
131
 
    unless  ($seqobj->isa("Bio::PrimarySeqI")) 
 
137
    unless  ($seqobj->isa("Bio::PrimarySeqI"))
132
138
    {
133
139
        die("die in _init, OddCodes works only on PrimarySeqI
134
140
objects\n");
142
148
=head2 structural
143
149
 
144
150
 Title   : structural
145
 
 Usage   : $output = $oddcode_obj->structural(); 
 
151
 Usage   : $output = $oddcode_obj->structural();
146
152
 Function: turns amino acid sequence into 3-letter structural alphabet
147
153
         : A (ambivalent), E (external), I (internal)
148
154
 Example : a sequence ACDEFGH will become AAEEIAE
173
179
=head2 functional
174
180
 
175
181
 Title   : functional
176
 
 Usage   : $output = $oddcode_obj->functional(); 
 
182
 Usage   : $output = $oddcode_obj->functional();
177
183
 Function: turns amino acid sequence into 4-letter functional alphabet
178
184
         : A (acidic), C (basic), H (hydrophobic), P (polar)
179
 
 Example : a sequence ACDEFGH will become HPAAHHC 
 
185
 Example : a sequence ACDEFGH will become HPAAHHC
180
186
 Returns : Reference to the new sequence string
181
187
 Args    : none
182
188
 
206
212
=head2 hydrophobic
207
213
 
208
214
 Title   : hydrophobic
209
 
 Usage   : $output = $oddcode_obj->hydrophobic(); 
 
215
 Usage   : $output = $oddcode_obj->hydrophobic();
210
216
 Function: turns amino acid sequence into 2-letter hydrophobicity alphabet
211
217
         : O (hydrophobic), I (hydrophilic)
212
218
 Example : a sequence ACDEFGH will become OIIIOII
235
241
=head2 Dayhoff
236
242
 
237
243
 Title   : Dayhoff
238
 
 Usage   : $output = $oddcode_obj->Dayhoff(); 
 
244
 Usage   : $output = $oddcode_obj->Dayhoff();
239
245
 Function: turns amino acid sequence into 6-letter Dayhoff alphabet
240
 
 Example : a sequence ACDEFGH will become CADDGCE 
 
246
 Example : a sequence ACDEFGH will become CADDGCE
241
247
 Returns : Reference to the new sequence string
242
248
 Args    : none
243
249
 
271
277
=head2 Sneath
272
278
 
273
279
 Title   : Sneath
274
 
 Usage   : $output = $oddcode_obj->Sneath(); 
 
280
 Usage   : $output = $oddcode_obj->Sneath();
275
281
 Function: turns amino acid sequence into 7-letter Sneath alphabet
276
282
 Example : a sequence ACDEFGH will become CEFFHCF
277
283
 Returns : Reference to the new sequence string
309
315
=head2 Stanfel
310
316
 
311
317
 Title   : Stanfel
312
 
 Usage   : $output = $oddcode_obj->Stanfel(); 
 
318
 Usage   : $output = $oddcode_obj->Stanfel();
313
319
 Function: turns amino acid sequence into 4-letter Stanfel alphabet
314
320
 Example : a sequence ACDEFGH will become AACCDAE
315
321
 Returns : Reference to the new sequence string
341
347
=head2 chemical()
342
348
 
343
349
 Title   : chemical
344
 
 Usage   : $output = $oddcode_obj->chemical(); 
 
350
 Usage   : $output = $oddcode_obj->chemical();
345
351
 Function: turns amino acid sequence into 8-letter chemical alphabet
346
352
         : A (acidic), L (aliphatic), M (amide), R (aromatic)
347
353
         : C (basic), H (hydroxyl), I (imino), S (sulphur)
348
 
 Example : a sequence ACDEFGH will become LSAARAC 
 
354
 Example : a sequence ACDEFGH will become LSAARAC
349
355
 Returns : Reference to the new sequence string
350
356
 Args    : none
351
357
 
383
389
=head2 charge
384
390
 
385
391
 Title   : charge
386
 
 Usage   : $output = $oddcode_obj->charge(); 
 
392
 Usage   : $output = $oddcode_obj->charge();
387
393
 Function: turns amino acid sequence into 3-letter charge alphabet
388
 
 Example : a sequence ACDEFGH will become NNAANNC 
 
394
 Example : a sequence ACDEFGH will become NNAANNC
389
395
 Returns : Reference to the new sequence string
390
396
 Args    : none
391
397
 
419
425
 
420
426
        my $seqobj =  $self->{'_seqref'};
421
427
        
422
 
        unless  ($seqobj->isa("Bio::PrimarySeqI")) 
 
428
        unless  ($seqobj->isa("Bio::PrimarySeqI"))
423
429
        {
424
430
                die("die, OddCodes works only on PrimarySeqI objects\n");
425
431
        }
 
432
        $self->warn("\tAll OddCode alphabets need a protein sequence,\n".
 
433
                    "\tbut BioPerl thinks this is not: [". $seqobj->id. "]")
 
434
            unless $seqobj->alphabet eq 'protein' or $self->verbose < 0;;
426
435
 
427
436
        my $seqstring = uc $seqobj->seq();
428
437