FAST/Bio/MySeqUtils.pm untested

filter: Statementstmt 0.0% 0 / 66 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 43 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 127 SCAR 30.0
CC
4
Cov
0%
seq3in
12.0
seq3
6.0
seq3gap
2.0
CRAP 20.0
1 #line 1 "inc/Bio/MySeqUtils.pm - /home/dave/lib//Bio/MySeqUtils.pm"
2  
3 #
4 # BioPerl module for FAST::Bio::SeqUtils
5 #
6 # Cared for by Heikki Lehvaslaiho <heikki@ebi.ac.uk>
7 #
8 # Copyright Heikki Lehvaslaiho
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 #line 79
15  
16  
17 # Let the code begin...
18  
19  
20 package FAST::Bio::SeqUtils;
21 use vars qw(@ISA);
22 use strict;
23 use Carp;
24 use FAST::Bio::Tools::CodonTable;
25  
26 @ISA = qw(FAST::Bio::Root::RootI);
27 # new inherited from RootI
28  
29 {
30  
31 my %onecode =
32 ('Ala' => 'A', 'Asx' => 'B', 'Cys' => 'C', 'Asp' => 'D',
33 'Glu' => 'E', 'Phe' => 'F', 'Gly' => 'G', 'His' => 'H',
34 'Ile' => 'I', 'Lys' => 'K', 'Leu' => 'L', 'Met' => 'M',
35 'Asn' => 'N', 'Pro' => 'P', 'Gln' => 'Q', 'Arg' => 'R',
36 'Ser' => 'S', 'Thr' => 'T', 'Val' => 'V', 'Trp' => 'W',
37 'Xaa' => 'X', 'Tyr' => 'Y', 'Glx' => 'Z', 'Ter' => '*',
38 'Sel' => 'U'
39 );
40  
41 my %threecode =
42 ('A' => 'Ala', 'B' => 'Asx', 'C' => 'Cys', 'D' => 'Asp',
43 'E' => 'Glu', 'F' => 'Phe', 'G' => 'Gly', 'H' => 'His',
44 'I' => 'Ile', 'K' => 'Lys', 'L' => 'Leu', 'M' => 'Met',
45 'N' => 'Asn', 'P' => 'Pro', 'Q' => 'Gln', 'R' => 'Arg',
46 'S' => 'Ser', 'T' => 'Thr', 'V' => 'Val', 'W' => 'Trp',
47 'Y' => 'Tyr', 'Z' => 'Glx', 'X' => 'Xaa', '*' => 'Ter',
48 'U' => 'Sel'
49 );
50  
51 #line 134
52  
53 { no warnings 'redefine'; #DHA FAST
54 sub seq3 {
55 my ($self, $seq, $stop, $sep ) = @_;
56  
57 $seq->isa('FAST::Bio::PrimarySeqI') ||
58 $self->throw('Not a FAST::Bio::PrimarySeqI object but [$self]');
59 $seq->alphabet eq 'protein' ||
60 $self->throw('Not a protein sequence');
61  
62 if (defined $stop) {
63 length $stop != 1 and $self->throw('One character stop needed, not [$stop]');
64 $threecode{$stop} = "Ter";
65 }
66 $sep ||= '';
67  
68 my $aa3s;
69 foreach my $aa (split //, uc $seq->seq) {
70 $threecode{$aa} and $aa3s .= $threecode{$aa}. $sep, next;
71 $aa3s .= 'Xaa'. $sep;
72 }
73 $sep and substr($aa3s, -(length $sep), length $sep) = '' ;
74 return $aa3s;
75 }
76 }
77  
78 #line 179
79  
80 { no warnings 'redefine'; #DHA FAST
81 sub seq3in {
82 my ($self, $seq, $string, $stop, $unknown) = @_;
83  
84 $seq->isa('FAST::Bio::PrimarySeqI') ||
85 $self->throw('Not a FAST::Bio::PrimarySeqI object but [$self]');
86 $seq->alphabet eq 'protein' ||
87 $self->throw('Not a protein sequence');
88  
89 if (defined $stop) {
90 length $stop != 1 and $self->throw('One character stop needed, not [$stop]');
91 $onecode{'Ter'} = $stop;
92 }
93 if (defined $unknown) {
94 length $unknown != 1 and $self->throw('One character stop needed, not [$unknown]');
95 $onecode{'Xaa'} = $unknown;
96 }
97  
98 my ($aas, $aa3);
99 my $length = (length $string) - 2;
100 for (my $i = 0 ; $i < $length ; $i += 3) {
101 $aa3 = substr($string, $i, 3);
102 $onecode{$aa3} and $aas .= $onecode{$aa3}, next;
103 warn("Unknown three letter amino acid code [$aa3] ignored");
104 }
105 $seq->seq($aas);
106 return $seq;
107 }
108 }
109  
110 #line 225
111  
112 sub seq3gap {
113 my ($self, $seq, $sep) = @_;
114  
115 $seq->isa('FAST::Bio::PrimarySeqI') ||
116 $self->throw('Not a FAST::Bio::PrimarySeqI object but [$self]');
117 $seq->alphabet eq 'protein' ||
118 $self->throw('Not a protein sequence');
119  
120 $sep ||= '~';
121  
122 my $aa3s;
123 foreach my $aa (split //, uc $seq->seq) {
124 $aa3s .= $aa . $sep x 2, next;
125 }
126 $sep and substr($aa3s, -(length $sep), length $sep) = '' ;
127 return $aa3s;
128  
129 }
130  
131 }
132  
133  
134 1;
135  
136  
137  
138  
139