blib/lib/MS/PepInfo.pm

filter: Statementstmt 16.3% 23 / 141 Branchbran 0.0% 0 / 66 Conditioncond 0.0% 0 / 22 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 46.1% 6 / 13 Podpod 100% 6 / 6 totaltotal 13.4% 35 / 260 CC 50 SCAR 59.3
CC
50
Cov
10%
calc_fragments
650.0
_series
342.0
digest
90.0
CRAP 374.7
↑ Summary blib/script/cv2storable.pl »
1 package MS::PepInfo;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use List::Util qw/sum/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use List::MoreUtils qw/uniq/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Exporter qw/import/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use MS::Mass qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 1 our @EXPORT_OK = qw/calc_mw calc_gravy calc_parker calc_aliphatic calc_fragments digest/;
13  
14 1 my %ave_mass = (
15 A => 71.0788,
16 R => 156.1875,
17 N => 114.1038,
18 D => 115.0886,
19 C => 103.1388,
20 Q => 128.1307,
21 E => 129.1155,
22 G => 57.0519,
23 H => 137.1411,
24 I => 113.1594,
25 L => 113.1594,
26 K => 128.1741,
27 M => 131.1926,
28 F => 147.1766,
29 P => 97.1167,
30 S => 87.0782,
31 T => 101.1051,
32 W => 186.2132,
33 Y => 163.1760,
34 V => 99.1326,
35 H2O => 18.01524,
36 );
37  
38 1 my %kyte_doolittle = (
39 A => 1.8,
40 R => -4.5,
41 N => -3.5,
42 D => -3.5,
43 C => 2.5,
44 Q => -3.5,
45 E => -3.5,
46 G => -0.4,
47 H => -3.2,
48 I => 4.5,
49 L => 3.8,
50 K => -3.9,
51 M => 1.9,
52 F => 2.8,
53 P => -1.6,
54 S => -0.8,
55 T => -0.7,
56 W => -0.9,
57 Y => -1.3,
58 V => 4.2,
59 );
60  
61 1 my %parker_guo_hodges = (
62 A => 2.1,
63 R => 4.2,
64 N => 7.0,
65 D => 10.0,
66 C => 1.4,
67 Q => 6.0,
68 E => 7.8,
69 G => 5.7,
70 H => 2.1,
71 I => -8.0,
72 L => -9.2,
73 K => 5.7,
74 M => -4.2,
75 F => -9.2,
76 P => 2.1,
77 S => 6.5,
78 T => 5.2,
79 W => -10.0,
80 Y => -1.9,
81 V => -3.7,
82 );
83  
84  
85 sub digest {
86  
87 0 ▶ my ($seq, $enzymes, $missed) = @_;
Subroutine digest: not called CC=9 SCAR=45.0
Pod documented
88  
89 0 ▶ $enzymes = [$enzymes] if (! ref $enzymes);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $enzymes 0 0 0
90  
91 0 ▶ $missed = $missed // 0;
Condition0%0/2
$missed // 0
l!l
00
MC/DC0%0/1
$missed // 0
$missed
Truth table0%0/2
A
A= $missed
Aresult
11
00
92  
93 0 my %re = (
94 'trypsin' => qr/[KR](?!P)/,
95 'Asp-N' => qr/(?=[NC])/,
96 'Glu-C' => qr/[QN]/,
97 'Lys-C' => qr/K/,
98 'Arg-C' => qr/R/,
99 );
100  
101 0 my @cut_sites = (0);
102  
103 0 for (@{$enzymes}) {
104 die "Unsupported enzyme specified\n"
105 0 ▶ if (! defined $re{$_});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $re{$_} 0 0 0
106 0 ▶ while ($seq =~ /$re{$_}/ig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq =~ /$re{$_}/gi) 0 0 0
107 0 push @cut_sites, $+[0];
108 }
109 }
110  
111 0 push @cut_sites, length($seq);
112 0 @cut_sites = sort {$a <=> $b} uniq @cut_sites;
113  
114 0 my @pieces;
115 0 for my $i (0..$#cut_sites) {
116 A:
117 0 for my $a (1..$missed+1) {
118 0 $a = $i + $a;
119 0 ▶ last A if ($a > $#cut_sites);
Branch: 1 branch
BranchTrueFalseTotal
if $a > $#cut_sites 0 0 0
120 0 push @pieces, substr($seq,$cut_sites[$i],$cut_sites[$a]-$cut_sites[$i]);
121 }
122 }
123  
124 0 return @pieces;
125  
126 }
127  
128 sub calc_gravy {
129  
130 0 ▶ return sum( map {$kyte_doolittle{$_}} split( '', $_[0]) )/length($_[0]);
Subroutine calc_gravy: not called CC=1 SCAR=6.9
Pod documented
131  
132 }
133  
134 sub calc_parker {
135  
136 0 ▶ return sum( map {$parker_guo_hodges{$_}} split( '', $_[0]) )/length($_[0]);
Subroutine calc_parker: not called CC=1 SCAR=6.9
Pod documented
137  
138 }
139  
140 sub calc_aliphatic {
141  
142 0 ▶ my @aa = split '', $_[0];
Subroutine calc_aliphatic: not called CC=1 SCAR=6.9
Pod documented
143 0 my $mf_A = grep {$_ eq 'A'} @aa;
144 0 my $mf_V = grep {$_ eq 'V'} @aa;
145 0 my $mf_IL = grep {$_ =~ /[IL]/} @aa;
146 0 return ($mf_A + 2.9*$mf_V + 3.9*$mf_IL) * 100 / scalar(@aa);
147  
148 }
149  
150 sub calc_mw {
151  
152 0 ▶ return sum map {$ave_mass{$_}} (split('',$_[0]),'H2O');
Subroutine calc_mw: not called CC=1 SCAR=6.9
Pod documented
153  
154 }
155  
156 sub calc_fragments {
157  
158 0 ▶ my ($peptide,$mod_ref,$max_charge,$incl_nloss) = @_;
Subroutine calc_fragments: not called CC=25 SCAR=64.8
Pod documented
159  
160 0 my $PROTON = elem_mass('H');
161 0 ▶ $max_charge = $max_charge // 1;
Condition0%0/2
$max_charge // 1
l!l
00
MC/DC0%0/1
$max_charge // 1
$max_charge
Truth table0%0/2
A
A= $max_charge
Aresult
11
00
162 0 my @masses = map {aa_mass($_)} split('',$peptide);
163 0 unshift @masses, 0;
164 0 push @masses, formula_mass('HOH');
165  
166 # check that mod array length equals mass array length
167 0 my $n_mass = scalar(@masses);
168 0 my $n_mods = scalar(@$mod_ref);
169 0 ▶ die "mod array len mismatch ($n_mass mass vs $n_mods mods)"
Branch: 1 branch
BranchTrueFalseTotal
if $n_mass ne $n_mods 0 0 0
170 if ($n_mass ne $n_mods);
171  
172 0 for (0..$#{$mod_ref}) {
173 0 my $mod = $mod_ref->[$_];
174 0 ▶ if (defined $mod) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mod) 0 0 0
175 0 ▶ if ($mod =~ /^[\d\-\.e]+$/) { # is a float, use directly
Branch: 1 branch
BranchTrueFalseTotal
if ($mod =~ /^[\d\-\.e]+$/) { } 0 0 0
176 0 $masses[$_] += $mod;
177 }
178 else {
179 0 my $mass = mod_mass($mod);
180 0 ▶ die "Mass for $mod not found" if (! defined $mass);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mass 0 0 0
181 0 $masses[$_] += $mass;
182 }
183 }
184 }
185  
186 0 my @pre_groups = ([@masses]);
187 0 my @cuts = ();
188
189 # calculate neutral loss peptides if peptide is not non-mobile
190  
191 0 my $R_count = $peptide =~ tr/R/R/;
192 0 ▶ if ($incl_nloss && $R_count < $max_charge) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incl_nloss and $R_count < $max_charge) 0 0 0
Condition0%0/3
$incl_nloss and $R_count < $max_charge
!ll&&!rl&&r
000
MC/DC0%0/2
$incl_nloss and $R_count < $max_charge
$incl_nloss $R_count < $max_charge
Truth table0%0/3
A and B
A= $incl_nlossB= $R_count < $max_charge
ABresult
0X0
100
111
193 0 ▶ while ($peptide =~ /P/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peptide =~ /P/g) 0 0 0
194 0 ▶ push @cuts, $-[0] if (
Branch: 1 branch
BranchTrueFalseTotal
if $-[0] > 0 and $-[0] < 6 and $-[0] < $#masses - 1 0 0 0
Condition0%0/6
$-[0] > 0 and $-[0] < 6 and $-[0] < $#masses - 1
!ll&&!rl&&r
000
$-[0] > 0 and $-[0] < 6
!ll&&!rl&&r
000
MC/DC0%0/3
$-[0] > 0 and $-[0] < 6 and $-[0] < $#masses - 1
$-[0] > 0 $-[0] < 6 $-[0] < $#masses - 1
Truth table0%0/4
A and B and C
A= $-[0] > 0B= $-[0] < 6C= $-[0] < $#masses - 1
ABCresult
0XX0
10X0
1100
1111
195 $-[0] > 0
196 && $-[0] < 6
197 && $-[0] < $#masses-1);
198 }
199 0 pos($peptide) = 0;
200  
201 0 ▶ while ($peptide =~ /H/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peptide =~ /H/g) 0 0 0
202 0 ▶ push @cuts, $-[0] if (
Branch: 1 branch
BranchTrueFalseTotal
if $-[0] > 1 and $-[0] < 4 and $-[0] < $#masses - 1 0 0 0
Condition0%0/6
$-[0] > 1 and $-[0] < 4 and $-[0] < $#masses - 1
!ll&&!rl&&r
000
$-[0] > 1 and $-[0] < 4
!ll&&!rl&&r
000
MC/DC0%0/3
$-[0] > 1 and $-[0] < 4 and $-[0] < $#masses - 1
$-[0] > 1 $-[0] < 4 $-[0] < $#masses - 1
Truth table0%0/4
A and B and C
A= $-[0] > 1B= $-[0] < 4C= $-[0] < $#masses - 1
ABCresult
0XX0
10X0
1100
1111
203 $-[0] > 1
204 && $-[0] < 4
205 && $-[0] < $#masses-1);
206 }
207 0 pos($peptide) = 0;
208  
209 0 ▶ while ($peptide =~ /D/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peptide =~ /D/g) 0 0 0
210 0 ▶ push @cuts, $-[0]+1 if (
Branch: 1 branch
BranchTrueFalseTotal
if $-[0] < 6 and $-[0] < $#masses - 2 0 0 0
Condition0%0/3
$-[0] < 6 and $-[0] < $#masses - 2
!ll&&!rl&&r
000
MC/DC0%0/2
$-[0] < 6 and $-[0] < $#masses - 2
$-[0] < 6 $-[0] < $#masses - 2
Truth table0%0/3
A and B
A= $-[0] < 6B= $-[0] < $#masses - 2
ABresult
0X0
100
111
211 $-[0] < 6
212 && $-[0] < $#masses-2);
213 }
214 0 pos($peptide) = 0;
215  
216 0 @cuts = uniq @cuts;
217 0 for (@cuts) {
218 0 my @sub = @masses[$_+1..$#masses];
219  
220 # put on front so more common frags will overwrite
221 0 unshift @pre_groups, [@sub];
222 }
223 }
224  
225 0 my @series = ();
226 0 for my $g (0..$#pre_groups) {
227 0 my @m = @{$pre_groups[$g]};
228 0 my $tag = '';
229 0 ▶ if ($g > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g > 0) 0 0 0
230 0 my $lost = scalar(@masses) - scalar(@m) - 1;
231 0 $tag = "-$lost<sub>N</sub>";
232 }
233  
234 #calculate [M]
235 0 my $pre_mz = (sum(@m) + $max_charge*$PROTON)/$max_charge;
236  
237 0 push @series, [$pre_mz, '[M]', '', $max_charge, $tag];
238 0 for (1..$max_charge) {
239 #push @series, _series('a', $peptide, \@m, 1);
240 0 push @series, _series('b', $peptide, \@m, $_, $tag);
241 0 ▶ push @series, _series('y', $peptide, \@m, $_, $tag)
Branch: 1 branch
BranchTrueFalseTotal
if $g == 0 0 0 0
242 if ($g == 0);
243 }
244 }
245  
246 0 @series = sort {$a->[0] <=> $b->[0]} @series;
247 #@series = grep {$_->[0] > 100} @series;
248 0 return @series;
249  
250 }
251  
252 sub _series {
253  
254 0 ▶ my ($type, $peptide, $mass_ref, $charge, $tag) = @_;
Subroutine _series: not called CC=18 SCAR=58.3
255  
256 0 my $PROTON = elem_mass('H');
257 0 my @masses = @{$mass_ref};
258 0 my @series;
259  
260 0 ▶ my $term = $type =~ /^[y]$/ ? 'C' : 'N';
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /^[y]$/ ? : 0 0 0
261  
262 # calculate standard series
263 0 for my $i (1..$#masses-1) {
264 #for my $i ($charge..$#masses-1) {
265 #for my $i ($charge..$#masses-2) {
266  
267 0 ▶ my ($start,$end)
Branch: 1 branch
BranchTrueFalseTotal
$term eq 'N' ? : 0 0 0
268 = $term eq 'N' ? (0, $i) : ($#masses-$i, $#masses);
269 0 ▶ my $adjust
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'a' ? : 0 0 0
270 = $type eq 'a' ? - formula_mass('CO')
271 : 0;
272  
273 0 my $mz = (sum(@masses[$start..$end]) + $adjust
274 + $PROTON*$charge)/$charge;
275  
276 0 push @series, [$mz,$type,$i,$charge, $tag];
277  
278 }
279  
280 # neutral ammonia loss
281 0 ▶ while ($peptide =~ /[RKQN]/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peptide =~ /[RKQN]/g) 0 0 0
282 0 my $i = $-[0]+1;
283 0 ▶ $i = $#masses - $i if ($term eq 'C');
Branch: 1 branch
BranchTrueFalseTotal
if $term eq "C" 0 0 0
284 0 ▶ next if ($i < $charge);
Branch: 1 branch
BranchTrueFalseTotal
if $i < $charge 0 0 0
285 0 ▶ next if ($i >= $#masses -1);
Branch: 1 branch
BranchTrueFalseTotal
if $i >= $#masses - 1 0 0 0
286 0 ▶ my ($start,$end)
Branch: 1 branch
BranchTrueFalseTotal
$term eq 'N' ? : 0 0 0
287 = $term eq 'N' ? (0, $i) : ($#masses-$i, $#masses);
288 0 ▶ my $adjust
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'a' ? : 0 0 0
289 = $type eq 'a' ? - formula_mass('CO')
290 : 0;
291 0 my $mz = (sum(@masses[$start..$end]) + $adjust - formula_mass('NH3')
292 + $PROTON*$charge)/$charge;
293 0 push @series, [$mz,$type,$i,$charge,"-NH3$tag"];
294  
295 }
296 0 pos($peptide) = 0;
297  
298 # neutral water loss
299 0 ▶ if ($type ne 'a') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "a") 0 0 0
300 0 ▶ while ($peptide =~ /[STED]/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peptide =~ /[STED]/g) 0 0 0
301 0 my $i = $-[0]+1;
302 0 ▶ $i = $#masses - $i if ($term eq 'C');
Branch: 1 branch
BranchTrueFalseTotal
if $term eq "C" 0 0 0
303 0 ▶ next if ($i < $charge);
Branch: 1 branch
BranchTrueFalseTotal
if $i < $charge 0 0 0
304 0 ▶ next if ($i >= $#masses -1);
Branch: 1 branch
BranchTrueFalseTotal
if $i >= $#masses - 1 0 0 0
305 0 ▶ my ($start,$end)
Branch: 1 branch
BranchTrueFalseTotal
$term eq 'N' ? : 0 0 0
306 = $term eq 'N' ? (0, $i) : ($#masses-$i, $#masses);
307 0 ▶ my $adjust
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'a' ? : 0 0 0
308 = $type eq 'a' ? - formula_mass('CO')
309 : 0;
310 0 my $mz = (sum(@masses[$start..$end]) + $adjust - formula_mass('H2O')
311 + $PROTON*$charge)/$charge + $adjust;
312 0 push @series, [$mz,$type,$i,$charge,"-H2O$tag"];
313  
314 }
315 }
316 0 return @series;
317
318  
319 }
320  
321  
322
323 1 1;
324  
325 __END__
↑ Summary blib/script/cv2storable.pl »