annotate ProteinDigestor.pl @ 0:163892325845 draft default tip

Initial commit.
author galaxyp
date Fri, 10 May 2013 17:15:08 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
163892325845 Initial commit.
galaxyp
parents:
diff changeset
1 #!/usr/bin/perl -w
163892325845 Initial commit.
galaxyp
parents:
diff changeset
2
163892325845 Initial commit.
galaxyp
parents:
diff changeset
3 ###############################################################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
4 # ProteinDigestor.pl
163892325845 Initial commit.
galaxyp
parents:
diff changeset
5 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
6 # =====================================================
163892325845 Initial commit.
galaxyp
parents:
diff changeset
7 # $Id: ProteinDigestor.pl 76 2011-01-04 13:16:56Z pieter.neerincx@gmail.com $
163892325845 Initial commit.
galaxyp
parents:
diff changeset
8 # $URL: https://trac.nbic.nl/svn/galaxytools/trunk/tools/general/FastaTools/ProteinDigestor.pl $
163892325845 Initial commit.
galaxyp
parents:
diff changeset
9 # $LastChangedDate: 2011-01-04 07:16:56 -0600 (Tue, 04 Jan 2011) $
163892325845 Initial commit.
galaxyp
parents:
diff changeset
10 # $LastChangedRevision: 76 $
163892325845 Initial commit.
galaxyp
parents:
diff changeset
11 # $LastChangedBy: pieter.neerincx@gmail.com $
163892325845 Initial commit.
galaxyp
parents:
diff changeset
12 # =====================================================
163892325845 Initial commit.
galaxyp
parents:
diff changeset
13 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
14 # (c) Dr. Ir. B. van Breukelen et al.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
15 # https://bioinformatics.chem.uu.nl
163892325845 Initial commit.
galaxyp
parents:
diff changeset
16 # http://www.netherlandsproteomicscentre.eu/
163892325845 Initial commit.
galaxyp
parents:
diff changeset
17 # b.vanbreukelen@pharm.uu.nl
163892325845 Initial commit.
galaxyp
parents:
diff changeset
18 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
19 # Software to create peptide databases from a fasta
163892325845 Initial commit.
galaxyp
parents:
diff changeset
20 # file of proteins. You can cut with several enzymes
163892325845 Initial commit.
galaxyp
parents:
diff changeset
21 # select on size, PI, etc etc etc.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
22 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
23 # TODO: put filters, enzymes, in seperate config file
163892325845 Initial commit.
galaxyp
parents:
diff changeset
24 ###############################################################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
25
163892325845 Initial commit.
galaxyp
parents:
diff changeset
26 #############################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
27 # Initialise environment
163892325845 Initial commit.
galaxyp
parents:
diff changeset
28 #############################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
29 use strict;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
30 use Getopt::Std;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
31 use Log::Log4perl qw(:easy);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
32
163892325845 Initial commit.
galaxyp
parents:
diff changeset
33 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
34 # Log levels for Log4perl.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
35 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
36 my %log_levels = (
163892325845 Initial commit.
galaxyp
parents:
diff changeset
37 'ALL' => $ALL,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
38 'TRACE' => $TRACE,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
39 'DEBUG' => $DEBUG,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
40 'INFO' => $INFO,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
41 'WARN' => $WARN,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
42 'ERROR' => $ERROR,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
43 'FATAL' => $FATAL,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
44 'OFF' => $OFF,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
45 );
163892325845 Initial commit.
galaxyp
parents:
diff changeset
46
163892325845 Initial commit.
galaxyp
parents:
diff changeset
47 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
48 # pK values array
163892325845 Initial commit.
galaxyp
parents:
diff changeset
49 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
50 my %cPk = (
163892325845 Initial commit.
galaxyp
parents:
diff changeset
51 'A'=>[3.55, 7.59, 0 , 0 , 0],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
52 'B'=>[3.55, 7.50, 0 , 0 , 0],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
53 'C'=>[3.55, 7.50, 9.00 , 9.00 , 9.00],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
54 'D'=>[4.55, 7.50, 4.05 , 4.05 , 4.05],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
55 'E'=>[4.75, 7.70, 4.45 , 4.45 , 4.45],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
56 'F'=>[3.55, 7.50, 0 , 0. , 0],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
57 'G'=>[3.55, 7.50, 0 , 0. , 0],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
58 'H'=>[3.55, 7.50, 5.98 , 5.98 , 5.98],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
59 'I'=>[3.55, 7.50, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
60 'J'=>[0.00, 0.00, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
61 'K'=>[3.55, 7.50, 10.00, 10.00, 10.00],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
62 'L'=>[3.55, 7.50, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
63 'M'=>[3.55, 7.00, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
64 'N'=>[3.55, 7.50, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
65 'O'=>[0.00, 0.00, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
66 'P'=>[3.55, 8.36, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
67 'Q'=>[3.55, 7.50, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
68 'R'=>[3.55, 7.50, 12.0 , 12.0 , 12.0],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
69 'S'=>[3.55, 6.93, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
70 'T'=>[3.55, 6.82, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
71 'U'=>[0.00, 0.00, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
72 'V'=>[3.55, 7.44, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
73 'W'=>[3.55, 7.50, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
74 'X'=>[3.55, 7.50, 0 , 0. , 0.],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
75 'Y'=>[3.55, 7.50, 10.00, 10.00, 10.00],
163892325845 Initial commit.
galaxyp
parents:
diff changeset
76 'Z'=>[3.55, 7.50, 0 , 0. , 0.]
163892325845 Initial commit.
galaxyp
parents:
diff changeset
77 );
163892325845 Initial commit.
galaxyp
parents:
diff changeset
78
163892325845 Initial commit.
galaxyp
parents:
diff changeset
79 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
80 # MW values array
163892325845 Initial commit.
galaxyp
parents:
diff changeset
81 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
82 my %cMWs = (
163892325845 Initial commit.
galaxyp
parents:
diff changeset
83 'A'=>89.09,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
84 'B'=>132.65,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
85 'C'=>121.15,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
86 'D'=>133.1,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
87 'E'=>147.13,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
88 'F'=>165.19,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
89 'G'=>75.07,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
90 'H'=>155.16,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
91 'I'=>131.18,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
92 'J'=>0.00,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
93 'K'=>146.19,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
94 'L'=>131.18,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
95 'M'=>149.22,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
96 'N'=>132.12,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
97 'O'=>0.00,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
98 'P'=>115.13,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
99 'Q'=>146.15,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
100 'R'=>174.21,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
101 'S'=>105.09,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
102 'T'=>119.12,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
103 'U'=>168.05,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
104 'V'=>117.15,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
105 'W'=>204.22,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
106 'X'=>129.26,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
107 'Y'=>181.19,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
108 'Z'=>146.73
163892325845 Initial commit.
galaxyp
parents:
diff changeset
109 );
163892325845 Initial commit.
galaxyp
parents:
diff changeset
110
163892325845 Initial commit.
galaxyp
parents:
diff changeset
111 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
112 # Digestion enzymes.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
113 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
114 # For example Trypsin cuts c-terminal of K and R not followed by a P at position p1 = c:K,R:P=1
163892325845 Initial commit.
galaxyp
parents:
diff changeset
115 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
116 my %enzymes = (
163892325845 Initial commit.
galaxyp
parents:
diff changeset
117 'Trypsin' => 'c:K,R:P=1',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
118 'Trypsin/P' => 'c:K,R',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
119 'Chymotrypsin' => 'c:F,L,W,Y:P=1',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
120 'Chymotrypsin/P' => 'c:F,L,W,Y',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
121 'V8_E' => 'c:E,Z:P=1',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
122 'V8_DE' => 'c:E,D,B,Z:P=1',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
123 'LysC' => 'c:K:P=1',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
124 'LysC/P' => 'c:K',
163892325845 Initial commit.
galaxyp
parents:
diff changeset
125 'LysN/P' => 'n:K'
163892325845 Initial commit.
galaxyp
parents:
diff changeset
126 );
163892325845 Initial commit.
galaxyp
parents:
diff changeset
127
163892325845 Initial commit.
galaxyp
parents:
diff changeset
128 my @filters = (
163892325845 Initial commit.
galaxyp
parents:
diff changeset
129 # "[R|K][R|K][R|K]..[S|T]."
163892325845 Initial commit.
galaxyp
parents:
diff changeset
130 # "[R|K][R|K][R|K].[S|T]." ,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
131 # "[R|K][R|K]..[S|T].",
163892325845 Initial commit.
galaxyp
parents:
diff changeset
132 # "[R|K]..[S|T].",
163892325845 Initial commit.
galaxyp
parents:
diff changeset
133 # "[R|K][R|K].[S|T].",
163892325845 Initial commit.
galaxyp
parents:
diff changeset
134 # "[R|K].[S|T]."
163892325845 Initial commit.
galaxyp
parents:
diff changeset
135 # "[S|T].[R|K]"
163892325845 Initial commit.
galaxyp
parents:
diff changeset
136 );
163892325845 Initial commit.
galaxyp
parents:
diff changeset
137
163892325845 Initial commit.
galaxyp
parents:
diff changeset
138 my %charges = ('A'=>0, 'B'=>0, 'C'=>0, 'D'=>-1, 'E'=>-1, 'F'=>0,'G'=>0, 'H'=>1, 'I'=>0,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
139 'J'=>0, 'K'=>1, 'L'=>0, 'M'=>0, 'N'=>0, 'O'=>0,'P'=>0, 'Q'=>0, 'R'=>1,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
140 'S'=>0, 'T'=>0, 'U'=>0, 'V'=>0, 'W'=>0, 'X'=>0,'Y'=>0, 'Z'=>0);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
141
163892325845 Initial commit.
galaxyp
parents:
diff changeset
142 my %pept = (); #hashed array of peptides (HASH) and fasta headers (VALUE)
163892325845 Initial commit.
galaxyp
parents:
diff changeset
143
163892325845 Initial commit.
galaxyp
parents:
diff changeset
144 my $H20 = 18.015; #Mol. weight water
163892325845 Initial commit.
galaxyp
parents:
diff changeset
145
163892325845 Initial commit.
galaxyp
parents:
diff changeset
146 my $PH_MIN = 0.0; #min pH value
163892325845 Initial commit.
galaxyp
parents:
diff changeset
147 my $PH_MAX = 14.0; #max pH value
163892325845 Initial commit.
galaxyp
parents:
diff changeset
148 my $MAXLOOP = 2000; # max number iterations
163892325845 Initial commit.
galaxyp
parents:
diff changeset
149 my $EPSI = 0.0001; # desired presision
163892325845 Initial commit.
galaxyp
parents:
diff changeset
150
163892325845 Initial commit.
galaxyp
parents:
diff changeset
151 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
152 # Get options.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
153 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
154 my %opts;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
155 Getopt::Std::getopts('i:o:e:r:p:m:n:c:l:sa', \%opts);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
156
163892325845 Initial commit.
galaxyp
parents:
diff changeset
157 my $input = $opts{'i'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
158 my $output = $opts{'o'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
159 my $enzyme = $opts{'e'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
160 my $enzyme_cleavage_site_rules = $opts{'r'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
161 my $partial_cleavage = $opts{'s'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
162 my $partial_cleavage_chance = $opts{'p'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
163 my $min_peptide_weight = $opts{'m'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
164 my $max_peptide_weight = $opts{'n'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
165 my $max_charge = $opts{'c'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
166 my $add_sequence_context = $opts{'a'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
167 my $log_level = $opts{'l'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
168
163892325845 Initial commit.
galaxyp
parents:
diff changeset
169 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
170 # Configure logging.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
171 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
172 # Provides default if user did not specify log level:
163892325845 Initial commit.
galaxyp
parents:
diff changeset
173 $log_level = (defined($log_level) ? $log_level : 'INFO');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
174
163892325845 Initial commit.
galaxyp
parents:
diff changeset
175 # Reset log level to default if user specified illegal log level.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
176 $log_level = (
163892325845 Initial commit.
galaxyp
parents:
diff changeset
177 defined($log_levels{$log_level})
163892325845 Initial commit.
galaxyp
parents:
diff changeset
178 ? $log_levels{$log_level}
163892325845 Initial commit.
galaxyp
parents:
diff changeset
179 : $log_levels{'INFO'});
163892325845 Initial commit.
galaxyp
parents:
diff changeset
180
163892325845 Initial commit.
galaxyp
parents:
diff changeset
181 #Log::Log4perl->init('log4perl.properties');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
182 Log::Log4perl->easy_init(
163892325845 Initial commit.
galaxyp
parents:
diff changeset
183
163892325845 Initial commit.
galaxyp
parents:
diff changeset
184 #{ level => $log_level,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
185 # file => ">>ProteinDigestor.log",
163892325845 Initial commit.
galaxyp
parents:
diff changeset
186 # layout => '%F{1}-%L-%M: %m%n' },
163892325845 Initial commit.
galaxyp
parents:
diff changeset
187 {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
188 level => $log_level,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
189 file => "STDOUT",
163892325845 Initial commit.
galaxyp
parents:
diff changeset
190 layout => '%d L:%L %p> %m%n'
163892325845 Initial commit.
galaxyp
parents:
diff changeset
191 },
163892325845 Initial commit.
galaxyp
parents:
diff changeset
192 );
163892325845 Initial commit.
galaxyp
parents:
diff changeset
193 my $logger = Log::Log4perl::get_logger();
163892325845 Initial commit.
galaxyp
parents:
diff changeset
194
163892325845 Initial commit.
galaxyp
parents:
diff changeset
195 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
196 # Check user input.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
197 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
198 unless (defined($input) && defined($output)) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
199 _Usage();
163892325845 Initial commit.
galaxyp
parents:
diff changeset
200 exit;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
201 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
202 if ($input =~ /^$/ || $output =~ /^$/) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
203 _Usage();
163892325845 Initial commit.
galaxyp
parents:
diff changeset
204 exit;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
205 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
206 if ($input eq $output) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
207 $logger->fatal('Output file is the same as the input file. Select a different file for the output.');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
208 exit;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
209 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
210
163892325845 Initial commit.
galaxyp
parents:
diff changeset
211 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
212 # Check input file.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
213 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
214 unless (-e $input && -f $input && -r $input) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
215 $logger->fatal('Cannot read from input file ' . $input . ': ' . $!);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
216 exit;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
217 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
218
163892325845 Initial commit.
galaxyp
parents:
diff changeset
219 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
220 # Set additional defaults.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
221 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
222 $partial_cleavage = (defined($partial_cleavage) ? $partial_cleavage : 0); # Disabled by default
163892325845 Initial commit.
galaxyp
parents:
diff changeset
223 $partial_cleavage_chance = (defined($partial_cleavage_chance) ? $partial_cleavage_chance : 0.1); # 10% change by default
163892325845 Initial commit.
galaxyp
parents:
diff changeset
224 $add_sequence_context = (defined($add_sequence_context) ? $add_sequence_context : 0); # Disabled by default
163892325845 Initial commit.
galaxyp
parents:
diff changeset
225
163892325845 Initial commit.
galaxyp
parents:
diff changeset
226 ########################################################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
227 # MAIN PROGRAM
163892325845 Initial commit.
galaxyp
parents:
diff changeset
228 ########################################################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
229
163892325845 Initial commit.
galaxyp
parents:
diff changeset
230 $logger->info('Starting...');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
231
163892325845 Initial commit.
galaxyp
parents:
diff changeset
232 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
233 # Get protease cleavage site specs.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
234 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
235 unless (defined($enzyme_cleavage_site_rules)) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
236
163892325845 Initial commit.
galaxyp
parents:
diff changeset
237 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
238 # Set default to Trypsin if the user did not specify an enzyme name nor a string with enzyme cleavage site rules.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
239 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
240 $enzyme = (defined($enzyme) ? $enzyme : 'Trypsin');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
241
163892325845 Initial commit.
galaxyp
parents:
diff changeset
242 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
243 # Check for illegal enzymes.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
244 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
245 unless (defined($enzymes{$enzyme})) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
246 $logger->fatal('Unkown enzyme ' . $enzyme . '.');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
247 exit;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
248 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
249
163892325845 Initial commit.
galaxyp
parents:
diff changeset
250 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
251 # Fetch enzyme cleavage site rules.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
252 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
253 $enzyme_cleavage_site_rules = $enzymes{$enzyme};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
254
163892325845 Initial commit.
galaxyp
parents:
diff changeset
255 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
256
163892325845 Initial commit.
galaxyp
parents:
diff changeset
257 $logger->info('Using enzyme cleavage site rules: ' . $enzyme_cleavage_site_rules);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
258 my @split_params = split(/:/, $enzyme_cleavage_site_rules);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
259 my $cut_term = $split_params[0];
163892325845 Initial commit.
galaxyp
parents:
diff changeset
260 my @cut_aa = split(/,/, $split_params[1]);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
261 my @inhibition_aa;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
262 if (defined($split_params[2])) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
263 @inhibition_aa = split(/,/, $split_params[2]);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
264 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
265 my $annotation = {};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
266 my $sequence = '';
163892325845 Initial commit.
galaxyp
parents:
diff changeset
267
163892325845 Initial commit.
galaxyp
parents:
diff changeset
268 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
269 # Create filehandles.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
270 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
271 open(my $input_fh, "$input");
163892325845 Initial commit.
galaxyp
parents:
diff changeset
272 open(my $output_fh, ">$output");
163892325845 Initial commit.
galaxyp
parents:
diff changeset
273
163892325845 Initial commit.
galaxyp
parents:
diff changeset
274 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
275 # Write header to result file.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
276 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
277 print($output_fh "Protein ID\tPeptide\tMW\tpI\tCharge\tnumber S\tnumber T\tnumber Y\n");
163892325845 Initial commit.
galaxyp
parents:
diff changeset
278
163892325845 Initial commit.
galaxyp
parents:
diff changeset
279 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
280 # Digest fasta files and store peptides in an array (hashed)
163892325845 Initial commit.
galaxyp
parents:
diff changeset
281 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
282 foreach my $line (<$input_fh>){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
283
163892325845 Initial commit.
galaxyp
parents:
diff changeset
284 if ($line =~ /^>/){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
285
163892325845 Initial commit.
galaxyp
parents:
diff changeset
286 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
287 # We found a new FASTA header.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
288 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
289
163892325845 Initial commit.
galaxyp
parents:
diff changeset
290 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
291 # Process the previously found protein if we already found one.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
292 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
293 unless ($sequence eq '') {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
294 _ProcessProtein();
163892325845 Initial commit.
galaxyp
parents:
diff changeset
295 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
296
163892325845 Initial commit.
galaxyp
parents:
diff changeset
297 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
298 # Parse new FASTA header.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
299 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
300 $line =~ s/[\r\n\f]+//g;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
301 $annotation = _ParseHeader($line);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
302 $sequence = '';
163892325845 Initial commit.
galaxyp
parents:
diff changeset
303
163892325845 Initial commit.
galaxyp
parents:
diff changeset
304 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
305
163892325845 Initial commit.
galaxyp
parents:
diff changeset
306 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
307 # Found a sequence line.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
308 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
309 $line =~ s/[\t\s\r\n\f0-9\*\-]+//g;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
310 $sequence .= $line;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
311 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
312 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
313
163892325845 Initial commit.
galaxyp
parents:
diff changeset
314 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
315 # Don't foget to process the last sequence!
163892325845 Initial commit.
galaxyp
parents:
diff changeset
316 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
317 _ProcessProtein();
163892325845 Initial commit.
galaxyp
parents:
diff changeset
318
163892325845 Initial commit.
galaxyp
parents:
diff changeset
319 close($input_fh);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
320 close($output_fh);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
321
163892325845 Initial commit.
galaxyp
parents:
diff changeset
322 $logger->info('Finished!');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
323
163892325845 Initial commit.
galaxyp
parents:
diff changeset
324 #########################################################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
325 # SUBS
163892325845 Initial commit.
galaxyp
parents:
diff changeset
326 #########################################################
163892325845 Initial commit.
galaxyp
parents:
diff changeset
327
163892325845 Initial commit.
galaxyp
parents:
diff changeset
328 sub _ProcessProtein {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
329
163892325845 Initial commit.
galaxyp
parents:
diff changeset
330 my $id = ${$annotation}{'ID'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
331 $logger->debug('Accession/ID: ' . $id);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
332 $logger->debug('Sequence: ' . $sequence . "\n");
163892325845 Initial commit.
galaxyp
parents:
diff changeset
333 my $total_length_sequence = length($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
334 my $total_peptide_length = 0;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
335
163892325845 Initial commit.
galaxyp
parents:
diff changeset
336 my ($peptides) = _Digest($sequence, $annotation, \@cut_aa, $cut_term, \@inhibition_aa);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
337
163892325845 Initial commit.
galaxyp
parents:
diff changeset
338 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
339 # Process peptides.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
340 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
341 foreach my $peptide_with_context (sort(keys(%{$peptides}))) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
342
163892325845 Initial commit.
galaxyp
parents:
diff changeset
343 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
344 # Get peptide properties.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
345 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
346 $logger->debug('Peptide with context: ' . $peptide_with_context);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
347 my ($bare_peptide) = _ParsePeptide($peptide_with_context);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
348 my $peplength = length($bare_peptide);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
349 my ($pepweight) = _MwCalc($bare_peptide);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
350
163892325845 Initial commit.
galaxyp
parents:
diff changeset
351 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
352 # Apply filters
163892325845 Initial commit.
galaxyp
parents:
diff changeset
353 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
354 # Filter 1 is on weight.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
355 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
356 if (defined($min_peptide_weight)) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
357
163892325845 Initial commit.
galaxyp
parents:
diff changeset
358 $logger->debug('Minimum weight filter:');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
359 $logger->debug("\t" . 'Peptide weight: ' . $pepweight);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
360
163892325845 Initial commit.
galaxyp
parents:
diff changeset
361 if ($pepweight >= $min_peptide_weight) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
362
163892325845 Initial commit.
galaxyp
parents:
diff changeset
363 $logger->debug("\t" . 'PASSED - Weight is >= ' . $min_peptide_weight);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
364
163892325845 Initial commit.
galaxyp
parents:
diff changeset
365 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
366
163892325845 Initial commit.
galaxyp
parents:
diff changeset
367 # Skip this one.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
368 $logger->debug("\t" . 'REJECTED - Weight is < ' . $min_peptide_weight);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
369 next;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
370
163892325845 Initial commit.
galaxyp
parents:
diff changeset
371 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
372 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
373
163892325845 Initial commit.
galaxyp
parents:
diff changeset
374 if (defined($max_peptide_weight)) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
375
163892325845 Initial commit.
galaxyp
parents:
diff changeset
376 $logger->debug('Maximum weight filter:');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
377 $logger->debug("\t" . 'Peptide weight: ' . $pepweight);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
378
163892325845 Initial commit.
galaxyp
parents:
diff changeset
379 if ($pepweight <= $max_peptide_weight) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
380
163892325845 Initial commit.
galaxyp
parents:
diff changeset
381 $logger->debug("\t" . 'PASSED - Weight is <= ' . $max_peptide_weight);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
382
163892325845 Initial commit.
galaxyp
parents:
diff changeset
383 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
384
163892325845 Initial commit.
galaxyp
parents:
diff changeset
385 # Skip this one.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
386 $logger->debug("\t" . 'REJECTED - Weight is > ' . $max_peptide_weight);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
387 next;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
388
163892325845 Initial commit.
galaxyp
parents:
diff changeset
389 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
390 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
391
163892325845 Initial commit.
galaxyp
parents:
diff changeset
392 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
393 # Filter 2 is on sequence motifs.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
394 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
395 if (scalar(@filters) > 0) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
396
163892325845 Initial commit.
galaxyp
parents:
diff changeset
397 $logger->debug('Motif filter:');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
398 my ($motif) = _ContainsMotif($bare_peptide, \@filters);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
399
163892325845 Initial commit.
galaxyp
parents:
diff changeset
400 if ($motif > 0) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
401
163892325845 Initial commit.
galaxyp
parents:
diff changeset
402 $logger->debug("\t" . 'PASSED - Peptide contains motif ' . $motif);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
403
163892325845 Initial commit.
galaxyp
parents:
diff changeset
404 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
405
163892325845 Initial commit.
galaxyp
parents:
diff changeset
406 # Skip this one.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
407 $logger->debug("\t" . 'REJECTED - Peptide does not contain any motif.');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
408 next;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
409
163892325845 Initial commit.
galaxyp
parents:
diff changeset
410 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
411 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
412
163892325845 Initial commit.
galaxyp
parents:
diff changeset
413 my ($pepPI) = _PiCalc($bare_peptide);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
414 my ($pepCharge) = _ChargeCalc($bare_peptide);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
415
163892325845 Initial commit.
galaxyp
parents:
diff changeset
416 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
417 # Filter 3 is on the amount of charges.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
418 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
419 if (defined($max_charge)) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
420
163892325845 Initial commit.
galaxyp
parents:
diff changeset
421 $logger->debug('Charge filter:');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
422 $logger->debug("\t" . 'Peptide charge: ' . $pepCharge);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
423
163892325845 Initial commit.
galaxyp
parents:
diff changeset
424 if (defined($max_charge) && $pepCharge <= $max_charge) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
425
163892325845 Initial commit.
galaxyp
parents:
diff changeset
426 $logger->debug("\t" . 'PASSED - Charge <= ' . $max_charge);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
427
163892325845 Initial commit.
galaxyp
parents:
diff changeset
428 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
429
163892325845 Initial commit.
galaxyp
parents:
diff changeset
430 # Skip this one.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
431 $logger->debug("\t" . 'REJECTED - Charge > ' . $max_charge);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
432 next;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
433
163892325845 Initial commit.
galaxyp
parents:
diff changeset
434 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
435 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
436
163892325845 Initial commit.
galaxyp
parents:
diff changeset
437 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
438 # If there is no partial digestion we can calculated the % coverage.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
439 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
440 unless ($partial_cleavage) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
441 $total_peptide_length += length($bare_peptide);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
442 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
443
163892325845 Initial commit.
galaxyp
parents:
diff changeset
444 my ($residue_count) = _CountResiduesSTY($bare_peptide);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
445
163892325845 Initial commit.
galaxyp
parents:
diff changeset
446 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
447 # Store peptide.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
448 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
449 my $pep_sequence;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
450
163892325845 Initial commit.
galaxyp
parents:
diff changeset
451 if ($add_sequence_context) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
452 $pep_sequence = $peptide_with_context;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
453 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
454 $pep_sequence = $bare_peptide;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
455 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
456
163892325845 Initial commit.
galaxyp
parents:
diff changeset
457 print($output_fh $id . "\t" . $pep_sequence . "\t" . $pepweight . "\t" . $pepPI. "\t" . $pepCharge. "\t" . $residue_count . "\n");
163892325845 Initial commit.
galaxyp
parents:
diff changeset
458
163892325845 Initial commit.
galaxyp
parents:
diff changeset
459 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
460
163892325845 Initial commit.
galaxyp
parents:
diff changeset
461 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
462 # If partial digestion was not enabled, we can calculated the % coverage.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
463 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
464 unless ($partial_cleavage) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
465 my $coverage = ($total_peptide_length / $total_length_sequence)*100;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
466 $logger->debug("Sequence residues: $total_length_sequence | #peptide residues: $total_peptide_length | %Coverage: $coverage");
163892325845 Initial commit.
galaxyp
parents:
diff changeset
467 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
468 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
469
163892325845 Initial commit.
galaxyp
parents:
diff changeset
470 sub _ParseHeader {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
471
163892325845 Initial commit.
galaxyp
parents:
diff changeset
472 my ($header) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
473 my %annotation;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
474 my $ids;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
475 my $id;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
476 my $description;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
477
163892325845 Initial commit.
galaxyp
parents:
diff changeset
478 $header=~ s/^>//;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
479
163892325845 Initial commit.
galaxyp
parents:
diff changeset
480 if ($header =~ m/([^\s]+)\s+([^\s]+.*)/) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
481 $ids = $1;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
482 $description = $2;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
483 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
484 $ids = $header;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
485 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
486
163892325845 Initial commit.
galaxyp
parents:
diff changeset
487 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
488 # Redimentory support for detecting multiple IDs: check for pipe sperated IDs.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
489 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
490 if ($ids =~ m/([^\|])\|/) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
491 $id = $1;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
492 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
493 $id = $ids;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
494 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
495
163892325845 Initial commit.
galaxyp
parents:
diff changeset
496 $annotation{'ID'} = $id;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
497 $annotation{'DE'} = $description;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
498
163892325845 Initial commit.
galaxyp
parents:
diff changeset
499 return (\%annotation);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
500
163892325845 Initial commit.
galaxyp
parents:
diff changeset
501 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
502
163892325845 Initial commit.
galaxyp
parents:
diff changeset
503 sub _ContainsMotif{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
504
163892325845 Initial commit.
galaxyp
parents:
diff changeset
505 my ($peptide, $filters) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
506 my $cnt = 0;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
507
163892325845 Initial commit.
galaxyp
parents:
diff changeset
508 foreach my $filter (@{$filters}){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
509
163892325845 Initial commit.
galaxyp
parents:
diff changeset
510 $cnt++;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
511 if ($peptide =~ /$filter/){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
512 return($cnt);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
513 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
514
163892325845 Initial commit.
galaxyp
parents:
diff changeset
515 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
516
163892325845 Initial commit.
galaxyp
parents:
diff changeset
517 return(0);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
518
163892325845 Initial commit.
galaxyp
parents:
diff changeset
519 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
520
163892325845 Initial commit.
galaxyp
parents:
diff changeset
521 sub _ParsePeptide{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
522
163892325845 Initial commit.
galaxyp
parents:
diff changeset
523 my ($peptide_with_flanking_context) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
524
163892325845 Initial commit.
galaxyp
parents:
diff changeset
525 my @pep = split(/\./, $peptide_with_flanking_context);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
526 my $bare_peptide = uc($pep[1]);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
527
163892325845 Initial commit.
galaxyp
parents:
diff changeset
528 return($bare_peptide);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
529
163892325845 Initial commit.
galaxyp
parents:
diff changeset
530 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
531
163892325845 Initial commit.
galaxyp
parents:
diff changeset
532 sub _Digest{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
533
163892325845 Initial commit.
galaxyp
parents:
diff changeset
534 my ($sequence, $annotation, $enz_cutting, $cut_term, $enz_restrict) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
535
163892325845 Initial commit.
galaxyp
parents:
diff changeset
536 $sequence = uc($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
537 my %pept = ();
163892325845 Initial commit.
galaxyp
parents:
diff changeset
538
163892325845 Initial commit.
galaxyp
parents:
diff changeset
539 # we start by scanning the sequence.. to find one of the cutting rulez not followed by a restict rule
163892325845 Initial commit.
galaxyp
parents:
diff changeset
540 # what is the sequence length
163892325845 Initial commit.
galaxyp
parents:
diff changeset
541 my @array = split(//, $sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
542 my $length = scalar(@array);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
543 my $start_offset = 0;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
544 my $offset_adjust_for_cleavage_terminus = 0;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
545 if ($cut_term eq 'n') {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
546 $offset_adjust_for_cleavage_terminus = 1;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
547 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
548
163892325845 Initial commit.
galaxyp
parents:
diff changeset
549 my $peptide = '';
163892325845 Initial commit.
galaxyp
parents:
diff changeset
550
163892325845 Initial commit.
galaxyp
parents:
diff changeset
551 my $counter = 1;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
552 if (!($partial_cleavage)) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
553 $partial_cleavage_chance = 0;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
554 } else {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
555 $counter = 100;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
556 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
557
163892325845 Initial commit.
galaxyp
parents:
diff changeset
558 #this is for incomplete cleavage... we repeat digest 100 times with a probability that the enzyme will not cut
163892325845 Initial commit.
galaxyp
parents:
diff changeset
559 for (my $cnt = 0; $cnt < $counter; $cnt++) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
560
163892325845 Initial commit.
galaxyp
parents:
diff changeset
561 AA:for (my $aa_offset = 0 + $offset_adjust_for_cleavage_terminus; $aa_offset < ($length - 1 + $offset_adjust_for_cleavage_terminus); $aa_offset++) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
562
163892325845 Initial commit.
galaxyp
parents:
diff changeset
563 my $this_aa = substr($sequence, $aa_offset, 1);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
564
163892325845 Initial commit.
galaxyp
parents:
diff changeset
565 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
566 # Check if protease recognizes this amino acid as cleavage site.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
567 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
568 foreach my $cut_aa (@{$enz_cutting}) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
569
163892325845 Initial commit.
galaxyp
parents:
diff changeset
570 if ($this_aa eq $cut_aa) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
571
163892325845 Initial commit.
galaxyp
parents:
diff changeset
572 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
573 # Check if AA is not preceeded or followed by an AA that inhibits the protease...
163892325845 Initial commit.
galaxyp
parents:
diff changeset
574 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
575 foreach my $inhibit (@{$enz_restrict}) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
576
163892325845 Initial commit.
galaxyp
parents:
diff changeset
577
163892325845 Initial commit.
galaxyp
parents:
diff changeset
578 my @inhibit_conditions = split(/=/, $inhibit);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
579 my $inhibit_aa = $inhibit_conditions[0];
163892325845 Initial commit.
galaxyp
parents:
diff changeset
580 my $position_to_check = $inhibit_conditions[1];
163892325845 Initial commit.
galaxyp
parents:
diff changeset
581
163892325845 Initial commit.
galaxyp
parents:
diff changeset
582 my $neighborhood_aa = substr($sequence, $aa_offset + $position_to_check, 1);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
583
163892325845 Initial commit.
galaxyp
parents:
diff changeset
584 if ($neighborhood_aa eq $inhibit_aa){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
585 $logger->debug('No cleavage due to inhibition by ' . $inhibit_aa . ' at position ' . $position_to_check);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
586 next AA;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
587 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
588 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
589
163892325845 Initial commit.
galaxyp
parents:
diff changeset
590 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
591 # Consider the possibility of not cutting when doing incomplete digestions!
163892325845 Initial commit.
galaxyp
parents:
diff changeset
592 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
593 my $random = 1;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
594 if ($partial_cleavage){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
595 $random = rand(1);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
596 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
597 if ($random <= $partial_cleavage_chance){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
598 $logger->debug('No cleavage due to incomplete digestion.');
163892325845 Initial commit.
galaxyp
parents:
diff changeset
599 next AA;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
600 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
601
163892325845 Initial commit.
galaxyp
parents:
diff changeset
602 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
603 # If no inhibition spoiled the cleavage, lets cut!
163892325845 Initial commit.
galaxyp
parents:
diff changeset
604 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
605 my $cut_offset;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
606 if ($cut_term eq 'c') {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
607 $cut_offset = $aa_offset + 1;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
608 } elsif ($cut_term eq 'n') {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
609 $cut_offset = $aa_offset;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
610 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
611
163892325845 Initial commit.
galaxyp
parents:
diff changeset
612 # nice formatting of peptide
163892325845 Initial commit.
galaxyp
parents:
diff changeset
613 if ($start_offset == 0){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
614 $peptide .="terminus.";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
615 $peptide .= substr($sequence, $start_offset, $cut_offset - $start_offset).".";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
616 }else{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
617 $peptide .= substr($sequence, $start_offset - 3, 3).".";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
618 $peptide .= substr($sequence, $start_offset, $cut_offset - $start_offset).".";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
619 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
620 $peptide .= substr($sequence, $cut_offset, 3);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
621 $start_offset = $cut_offset;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
622
163892325845 Initial commit.
galaxyp
parents:
diff changeset
623 # check if peptide already exists
163892325845 Initial commit.
galaxyp
parents:
diff changeset
624 # if so, concatenate this fasta header
163892325845 Initial commit.
galaxyp
parents:
diff changeset
625 #if (exists($pept{$peptide})){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
626 # $fasta_header .= $pept{$peptide};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
627 #}
163892325845 Initial commit.
galaxyp
parents:
diff changeset
628 $pept{$peptide} = ${$annotation}{'ID'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
629 $peptide = '';
163892325845 Initial commit.
galaxyp
parents:
diff changeset
630 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
631 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
632 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
633
163892325845 Initial commit.
galaxyp
parents:
diff changeset
634 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
635 # The last peptide sequence !
163892325845 Initial commit.
galaxyp
parents:
diff changeset
636 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
637 $peptide = substr($sequence, $start_offset - 3, 3).".";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
638 $peptide .= substr($sequence, $start_offset, $length);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
639 $peptide .= ".terminus";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
640 $pept{$peptide} = ${$annotation}{'ID'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
641
163892325845 Initial commit.
galaxyp
parents:
diff changeset
642 } #COUNT
163892325845 Initial commit.
galaxyp
parents:
diff changeset
643
163892325845 Initial commit.
galaxyp
parents:
diff changeset
644 return(\%pept);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
645
163892325845 Initial commit.
galaxyp
parents:
diff changeset
646 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
647
163892325845 Initial commit.
galaxyp
parents:
diff changeset
648 sub _PiCalc{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
649
163892325845 Initial commit.
galaxyp
parents:
diff changeset
650 my ($sequence) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
651
163892325845 Initial commit.
galaxyp
parents:
diff changeset
652 my $nTermResidue;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
653 my $cTermResidue;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
654 my $phMin;my $phMid ;my $phMax;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
655 my $charge;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
656 my $cter; my $nter; my $carg; my $chis; my $clys;my $casp;my $cglu;my $ccys;my $ctyr;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
657
163892325845 Initial commit.
galaxyp
parents:
diff changeset
658 my $composition = _GetComposition($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
659 my $strlength = length($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
660 $nTermResidue = substr($sequence, 0, 1);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
661 for ($nTermResidue){s/[\s\n\r\t]//g;};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
662 $cTermResidue = substr($sequence, $strlength - 1, 1);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
663 for ($cTermResidue){s/[\s\n\r\t]//g;};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
664 $phMin = $PH_MIN;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
665 $phMax = $PH_MAX;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
666 my $i;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
667
163892325845 Initial commit.
galaxyp
parents:
diff changeset
668 for ($i=0, $charge = 1.0; $i<$MAXLOOP && ($phMax-$phMin)>$EPSI; $i++){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
669 $phMid = $phMin + ($phMax - $phMin) / 2;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
670 $cter = 10**(-$cPk{$cTermResidue}->[0]) / (10**(-$cPk{$cTermResidue}->[0]) + 10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
671 $nter = 10**(-$phMid)/(10**(-$cPk{$nTermResidue}->[1])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
672
163892325845 Initial commit.
galaxyp
parents:
diff changeset
673 $carg = ${$composition}{R} * 10**(-$phMid) / (10**(-$cPk{'R'}->[2])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
674 $chis = ${$composition}{H} * 10**(-$phMid) / (10**(-$cPk{'H'}->[2])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
675 $clys = ${$composition}{K} * 10**(-$phMid) / (10**(-$cPk{'K'}->[2])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
676
163892325845 Initial commit.
galaxyp
parents:
diff changeset
677 $casp = ${$composition}{D} * 10**(-$cPk{'D'}->[2]) / (10**(-$cPk{'D'}->[2])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
678 $cglu = ${$composition}{E} * 10**(-$cPk{'E'}->[2]) / (10**(-$cPk{'E'}->[2])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
679
163892325845 Initial commit.
galaxyp
parents:
diff changeset
680 $ccys = ${$composition}{C} * 10**(-$cPk{'C'}->[2]) / (10**(-$cPk{'C'}->[2])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
681 $ctyr = ${$composition}{Y} * 10**(-$cPk{'Y'}->[2]) / (10**(-$cPk{'Y'}->[2])+10**(-$phMid));
163892325845 Initial commit.
galaxyp
parents:
diff changeset
682
163892325845 Initial commit.
galaxyp
parents:
diff changeset
683 $charge = $carg + $clys + $chis + $nter - ($casp + $cglu + $ctyr + $ccys + $cter);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
684
163892325845 Initial commit.
galaxyp
parents:
diff changeset
685 if ($charge > 0.0){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
686 $phMin = $phMid;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
687 }else{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
688 $phMax = $phMid;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
689 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
690 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
691
163892325845 Initial commit.
galaxyp
parents:
diff changeset
692 return($phMid);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
693
163892325845 Initial commit.
galaxyp
parents:
diff changeset
694 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
695
163892325845 Initial commit.
galaxyp
parents:
diff changeset
696 sub _MwCalc{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
697
163892325845 Initial commit.
galaxyp
parents:
diff changeset
698 my ($sequence) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
699
163892325845 Initial commit.
galaxyp
parents:
diff changeset
700 my $mw;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
701 my $strlength = length($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
702 my $composition = _GetComposition($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
703
163892325845 Initial commit.
galaxyp
parents:
diff changeset
704 # subtract N-1 water molecules
163892325845 Initial commit.
galaxyp
parents:
diff changeset
705 $mw = - ($strlength -1) * $H20;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
706
163892325845 Initial commit.
galaxyp
parents:
diff changeset
707 foreach my $aa (sort keys %{$composition}){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
708 $logger->trace('AA:' . $aa . ' | frequency: ' . ${$composition}{$aa} . ' | AA MW: ' . $cMWs{$aa});
163892325845 Initial commit.
galaxyp
parents:
diff changeset
709 $mw += ${$composition}{$aa} * $cMWs{$aa};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
710 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
711
163892325845 Initial commit.
galaxyp
parents:
diff changeset
712 return($mw);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
713
163892325845 Initial commit.
galaxyp
parents:
diff changeset
714 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
715
163892325845 Initial commit.
galaxyp
parents:
diff changeset
716 sub _ChargeCalc{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
717
163892325845 Initial commit.
galaxyp
parents:
diff changeset
718 my ($sequence) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
719
163892325845 Initial commit.
galaxyp
parents:
diff changeset
720 my $charge;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
721 my $composition = _GetComposition($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
722
163892325845 Initial commit.
galaxyp
parents:
diff changeset
723 foreach my $aa (sort(keys(%{$composition}))){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
724 $charge += ${$composition}{$aa} * $charges{$aa};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
725 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
726
163892325845 Initial commit.
galaxyp
parents:
diff changeset
727 return($charge);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
728
163892325845 Initial commit.
galaxyp
parents:
diff changeset
729 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
730
163892325845 Initial commit.
galaxyp
parents:
diff changeset
731 sub _CountResiduesSTY{
163892325845 Initial commit.
galaxyp
parents:
diff changeset
732
163892325845 Initial commit.
galaxyp
parents:
diff changeset
733 my ($sequence) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
734
163892325845 Initial commit.
galaxyp
parents:
diff changeset
735 my $composition = _GetComposition($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
736 my $sty_residues = ${$composition}{'S'} . "\t" . ${$composition}{'T'} . "\t" . ${$composition}{'Y'};
163892325845 Initial commit.
galaxyp
parents:
diff changeset
737
163892325845 Initial commit.
galaxyp
parents:
diff changeset
738 return($sty_residues);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
739
163892325845 Initial commit.
galaxyp
parents:
diff changeset
740 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
741
163892325845 Initial commit.
galaxyp
parents:
diff changeset
742 sub _GetComposition {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
743
163892325845 Initial commit.
galaxyp
parents:
diff changeset
744 my ($sequence) = @_;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
745
163892325845 Initial commit.
galaxyp
parents:
diff changeset
746 my $i;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
747 my $c;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
748 my %composition = ('A'=>0, 'B'=>0,'C'=>0, 'D'=>0, 'E'=>0, 'F'=>0,'G'=>0, 'H'=>0, 'I'=>0,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
749 'J'=>0, 'K'=>0,'L'=>0, 'M'=>0, 'N'=>0, 'O'=>0,'P'=>0, 'Q'=>0, 'R'=>0,
163892325845 Initial commit.
galaxyp
parents:
diff changeset
750 'S'=>0, 'T'=>0,'U'=>0, 'V'=>0, 'W'=>0, 'X'=>0,'Y'=>0, 'Z'=>0);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
751
163892325845 Initial commit.
galaxyp
parents:
diff changeset
752 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
753 # Compute aminoacid composition.
163892325845 Initial commit.
galaxyp
parents:
diff changeset
754 #
163892325845 Initial commit.
galaxyp
parents:
diff changeset
755 my $strlength = length($sequence);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
756 for ($i=0; $i<$strlength; $i++){
163892325845 Initial commit.
galaxyp
parents:
diff changeset
757 $c = substr($sequence, $i, 1);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
758 $composition{$c}++;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
759 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
760
163892325845 Initial commit.
galaxyp
parents:
diff changeset
761 return(\%composition);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
762
163892325845 Initial commit.
galaxyp
parents:
diff changeset
763 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
764
163892325845 Initial commit.
galaxyp
parents:
diff changeset
765 sub _Usage {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
766
163892325845 Initial commit.
galaxyp
parents:
diff changeset
767 my $longest_enzyme_name_length = 0;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
768 foreach my $protease (keys(%enzymes)) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
769 if (length($protease) > $longest_enzyme_name_length) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
770 $longest_enzyme_name_length = length($protease);
163892325845 Initial commit.
galaxyp
parents:
diff changeset
771 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
772 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
773 my $field_formatting = '%-' . ($longest_enzyme_name_length + 3) . 's';
163892325845 Initial commit.
galaxyp
parents:
diff changeset
774
163892325845 Initial commit.
galaxyp
parents:
diff changeset
775 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
776 print "ProteinDigestor.pl - Digests protein sequences from a FASTA file\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
777 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
778 print "Usage:\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
779 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
780 print " ProteinDigestor.pl options\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
781 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
782 print "Available options are:\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
783 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
784 print " -i [file] Input FASTA file.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
785 print " -o [file] Output stats file.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
786 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
787 print " You can either specify a protease this tool knows with -e\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
788 print " or you can specify the cleavage rule for a protease this does not know (yet) with -r\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
789 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
790 print " -e [enzyme_name] Digestion enzyme. Known enzymes and their cleavage rules:\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
791
163892325845 Initial commit.
galaxyp
parents:
diff changeset
792 foreach my $protease (sort(keys(%enzymes))) {
163892325845 Initial commit.
galaxyp
parents:
diff changeset
793 print ' ' . sprintf("$field_formatting", $protease) . $enzymes{$protease} . "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
794 }
163892325845 Initial commit.
galaxyp
parents:
diff changeset
795
163892325845 Initial commit.
galaxyp
parents:
diff changeset
796 print " -r [enzyme_rule] Protease cleavage site rule. This rule contains sperated by colons:\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
797 print " * The terminus that indicates on which side of a recognized amino acid the protease will cleave: c or n.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
798 print " * The amino acids recognized by the protease.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
799 print " Multiple amino acids separated by a comma.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
800 print " * The amino acids that inhibit cleavage and their position relative to amino acids recognized by the protease.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
801 print ' Amino acid and its relative position separated by an equals sign (=).' . "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
802 print " Multiple amino acids separated by a comma.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
803 print ' For example \'c:K,R:P=1\' for Trypsin with proline inhibition.' . "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
804 print " -s Semi for partial digestion.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
805 print " -p [chance] Number between 0 and 1 indicating the chance that a site will not be cleaved.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
806 print " -m [weight] Minimum weight for a peptide.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
807 print " -n [weight] Maximum weight for a peptide.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
808 print " -c [int] Maximum charge a peptide is allowed to have.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
809 print " -a Add sequence context.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
810 print " This will add max 3 amino acids or the word terminus on each side of the peptides.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
811 print " Contexts and peptides are separated with a dot.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
812 print " Examples of peptides with a context:\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
813 print " terminus.MSVSLSAK.ASH\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
814 print " SAK.ASHLLCSSTR.VSL\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
815 print " STR.VSLSPAVTSSSSSPVVRPALSSSTS.terminus\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
816 print " -l [LEVEL] Log4perl log level. One of: ALL, TRACE, DEBUG, INFO (default), WARN, ERROR, FATAL or OFF.\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
817 print "\n";
163892325845 Initial commit.
galaxyp
parents:
diff changeset
818 exit;
163892325845 Initial commit.
galaxyp
parents:
diff changeset
819
163892325845 Initial commit.
galaxyp
parents:
diff changeset
820 }