ms-in_silico 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ pkg/
3
+ rdoc/
4
+ backup/
5
+ .*.swp
data/History CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.4.0 / 2010-06-23
2
+
3
+ * moving to jeweler and specs
4
+
1
5
  == 0.3.0 / 2009-05-25
2
6
 
3
7
  * updates to use tap-0.17.0
@@ -18,4 +22,4 @@
18
22
  Maintenance release with minor updates to use
19
23
  Tap 0.12.0.
20
24
 
21
- * Added History
25
+ * Added History
File without changes
File without changes
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'rake'
2
+ require 'jeweler'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'rcov/rcovtask'
6
+
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "ms-in_silico"
9
+ gem.summary = 'in-silico calculations for mass spec data'
10
+ gem.description = 'peptide fragmentation and protein digestion'
11
+ gem.email = "jtprince@gmail.com"
12
+ gem.homepage = "http://github.com/jtprince/ms-in_silico"
13
+ gem.authors = ["Simon Chiang"]
14
+ gem.rubyforge_project = "mspire"
15
+ gem.add_dependency("molecules", ">= 0.2.0")
16
+ gem.add_dependency("tap", ">= 0.17.0")
17
+ gem.add_development_dependency("tap-test", ">= 0.1.0")
18
+ gem.add_development_dependency("spec-more", ">= 0")
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+
22
+ Rake::TestTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.pattern = 'spec/**/*_spec.rb'
25
+ spec.verbose = true
26
+ end
27
+
28
+ Rcov::RcovTask.new do |spec|
29
+ spec.libs << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.verbose = true
32
+ end
33
+
34
+ task :default => :spec
35
+
36
+ Rake::RDocTask.new do |rdoc|
37
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
38
+
39
+ rdoc.rdoc_dir = 'rdoc'
40
+ rdoc.title = "ms-in_silico #{version}"
41
+ rdoc.rdoc_files.include('README*')
42
+ rdoc.rdoc_files.include('lib/**/*.rb')
43
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.0
@@ -239,25 +239,49 @@ module Ms
239
239
  end
240
240
  end
241
241
 
242
- ARG_C = mascot_parse('Arg-C C-Term R P no no')
243
- ASP_N = mascot_parse('Asp-N N-Term BD no no')
244
- ASP_N_AMBIC = mascot_parse('Asp-N_ambic N-Term DE no no')
245
- CHYMOTRYPSIN = mascot_parse('Chymotrypsin C-Term FLWY P no no')
246
- CNBR = mascot_parse('CNBr C-Term M no no')
247
- LYS_C = mascot_parse('Lys-C C-Term K P no no')
248
- LYS_C_P = mascot_parse('Lys-C/P C-Term K no no')
249
- PEPSIN_A = mascot_parse('PepsinA C-Term FL no no')
250
- TRYP_CNBR = mascot_parse('Tryp-CNBr C-Term KMR P no no')
251
- TRYP_CHYMO = mascot_parse('TrypChymo C-Term FKLRWY P no no')
252
- TRYPSIN_P = mascot_parse('Trypsin/P C-Term KR no no')
253
- V8_DE = mascot_parse('V8-DE C-Term BDEZ P no no')
254
- V8_E = mascot_parse('V8-E C-Term EZ P no no')
255
- TRYPSIN = mascot_parse('Trypsin C-Term KR P no no')
256
- V8_E_TRYPSIN = mascot_parse('V8-E+Trypsin C-Term EKRZ P no no')
257
- V8_DE_TRYPSIN = mascot_parse('V8-DE+Trypsin C-Term BDEKRZ P no no')
258
-
242
+ # ARG_C = mascot_parse('Arg-C C-Term R P no no')
243
+ # ENZYMES[:arg_c] = ARG_C
244
+ ENZYMES = {
245
+ :arg_c => 'Arg-C C-Term R P no no',
246
+ :asp_n => 'Asp-N N-Term BD no no',
247
+ :asp_n_ambic => 'Asp-N_ambic N-Term DE no no',
248
+ :chymotrypsin => 'Chymotrypsin C-Term FLWY P no no',
249
+ :cnbr => 'CNBr C-Term M no no',
250
+ :lys_c => 'Lys-C C-Term K P no no',
251
+ :lys_c_p => 'Lys-C/P C-Term K no no',
252
+ :pepsin_a => 'PepsinA C-Term FL no no',
253
+ :tryp_cnbr => 'Tryp-CNBr C-Term KMR P no no',
254
+ :tryp_chymo => 'TrypChymo C-Term FKLRWY P no no',
255
+ :trypsin_p => 'Trypsin/P C-Term KR no no',
256
+ :v8_de => 'V8-DE C-Term BDEZ P no no',
257
+ :v8_e => 'V8-E C-Term EZ P no no',
258
+ :trypsin => 'Trypsin C-Term KR P no no',
259
+ :v8_e_trypsin => 'V8-E+Trypsin C-Term EKRZ P no no',
260
+ :v8_de_trypsin => 'V8-DE+Trypsin C-Term BDEKRZ P no no',
261
+ :arg_c => 'Arg-C C-Term R P no no',
262
+ :asp_n => 'Asp-N N-Term BD no no',
263
+ :asp_n_ambic => 'Asp-N_ambic N-Term DE no no',
264
+ :chymotrypsin => 'Chymotrypsin C-Term FLWY P no no',
265
+ :cnbr => 'CNBr C-Term M no no',
266
+ :lys_c => 'Lys-C C-Term K P no no',
267
+ :lys_c_p => 'Lys-C/P C-Term K no no',
268
+ :pepsin_a => 'PepsinA C-Term FL no no',
269
+ :tryp_cnbr => 'Tryp-CNBr C-Term KMR P no no',
270
+ :tryp_chymo => 'TrypChymo C-Term FKLRWY P no no',
271
+ :trypsin_p => 'Trypsin/P C-Term KR no no',
272
+ :v8_de => 'V8-DE C-Term BDEZ P no no',
273
+ :v8_e => 'V8-E C-Term EZ P no no',
274
+ :trypsin => 'Trypsin C-Term KR P no no',
275
+ :v8_e_trypsin => 'V8-E+Trypsin C-Term EKRZ P no no',
276
+ :v8_de_trypsin => 'V8-DE+Trypsin C-Term BDEKRZ P no no',
277
+ }
278
+ ENZYMES.each do |k,v|
279
+ self.const_set(k.upcase, mascot_parse(v))
280
+ ENZYMES[k] = self.const_get(k.upcase)
281
+ end
282
+
259
283
  include Constants::Library
260
284
  library.index_by_attribute :name
261
285
  end
262
286
  end
263
- end
287
+ end
@@ -149,7 +149,7 @@ module Ms
149
149
  hash = {}
150
150
  0.upto(residues_to_locate.length-1) do |index|
151
151
  letter = residues_to_locate[index, 1]
152
- byte = letter[0]
152
+ byte = letter[0,1].ord
153
153
  hash[letter] = locations[byte]
154
154
  end
155
155
 
@@ -454,4 +454,4 @@ module Ms
454
454
  end
455
455
  end
456
456
  end
457
- end
457
+ end
@@ -0,0 +1,301 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ require 'ms/in_silico/digester'
4
+ require 'pp'
5
+
6
+ describe 'a digester' do
7
+ before do
8
+ @digester = Ms::InSilico::Digester.new('arg', 'R')
9
+ end
10
+
11
+ def spp(input, str="")
12
+ PP.singleline_pp(input, str)
13
+ end
14
+
15
+ def nk_string(n, split)
16
+ str = []
17
+ count = 0
18
+
19
+ (n * 1000).times do
20
+ count += 1
21
+ if count < split
22
+ str << 'A'
23
+ else
24
+ count = 0
25
+ str << 'R'
26
+ end
27
+ end
28
+
29
+ str.join('')
30
+ end
31
+
32
+ it 'performs digestion and can specify sites of digestion' do
33
+ trypsin = Ms::InSilico::Digester['Trypsin']
34
+
35
+ expected = [
36
+ 'MIVIGR',
37
+ 'SIVHPYITNEYEPFAAEK',
38
+ 'QQILSIMAG']
39
+ trypsin.digest('MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG').is expected
40
+
41
+ expected = [
42
+ 'MIVIGR',
43
+ 'MIVIGRSIVHPYITNEYEPFAAEK',
44
+ 'SIVHPYITNEYEPFAAEK',
45
+ 'SIVHPYITNEYEPFAAEKQQILSIMAG',
46
+ 'QQILSIMAG']
47
+ trypsin.digest('MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG', 1).is expected
48
+
49
+ expected = [
50
+ [0,6],
51
+ [0,24],
52
+ [6,24],
53
+ [6,33],
54
+ [24,33]]
55
+ trypsin.site_digest('MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG', 1).is expected
56
+ end
57
+
58
+ it 'completely ignores whitespace inside protein sequences' do
59
+ expected = [
60
+ "\tMIVIGR",
61
+ "SIVHP\nYITNEYEPFAAE K",
62
+ "QQILSI\rMAG"]
63
+ Ms::InSilico::Digester['Trypsin'].digest("\tMIVIGRSIVHP\nYITNEYEPFAAE KQQILSI\rMAG").is expected
64
+ end
65
+
66
+ it 'runs cleavage sites documentation' do
67
+ d = Ms::InSilico::Digester.new('Trypsin', 'KR', 'P')
68
+ seq = "AARGGR"
69
+ sites = d.cleavage_sites(seq)
70
+ sites.is [0, 3, 6]
71
+
72
+ seq[sites[0], sites[0+1] - sites[0]].is "AAR"
73
+ seq[sites[1], sites[1+1] - sites[1]].is "GGR"
74
+
75
+ seq = "AAR \n GGR"
76
+ sites = d.cleavage_sites(seq)
77
+ sites.is [0, 8, 11]
78
+
79
+ seq[sites[0], sites[0+1] - sites[0]].is "AAR \n "
80
+ seq[sites[1], sites[1+1] - sites[1]].is "GGR"
81
+ end
82
+
83
+ it 'finds cleavage site indices' do
84
+ {
85
+ "" => [0,0],
86
+ "A" => [0,1],
87
+ "R" => [0,1],
88
+ "AAA" => [0,3],
89
+ "RAA" => [0,1,3],
90
+ "ARA" => [0,2,3],
91
+ "AAR" => [0,3],
92
+ "RRA" => [0,1,2,3],
93
+ "RAR" => [0,1,3],
94
+ "RRR" => [0,1,2,3],
95
+
96
+ "R\nR\nR" => [0,2,4,5],
97
+ "R\n\n\nR\nR\n\n" => [0,4,6,9]
98
+ }.each do |sequence, expected|
99
+ @digester.cleavage_sites(sequence).is expected
100
+ end
101
+ end
102
+
103
+ it 'finds cleavage sites with exception' do
104
+ @digester = Ms::InSilico::Digester.new('argp', 'R', 'P')
105
+ {
106
+ "" => [0,0],
107
+ "A" => [0,1],
108
+ "R" => [0,1],
109
+ "AAA" => [0,3],
110
+ "RAA" => [0,1,3],
111
+ "ARA" => [0,2,3],
112
+ "AAR" => [0,3],
113
+ "RRA" => [0,1,2,3],
114
+ "RAR" => [0,1,3],
115
+ "RRR" => [0,1,2,3],
116
+
117
+ "PR" => [0,1,2],
118
+ "PR" => [0,2],
119
+ "PRR" => [0,2,3],
120
+ "RPR" => [0,3],
121
+ "RRP" => [0,1,3],
122
+ "APRA" => [0,3,4],
123
+ "ARPA" => [0,4],
124
+ "ARPARA" => [0,5,6],
125
+ "R\nPR\nR" => [0,5,6],
126
+ "RP\nR\nR" => [0,5,6],
127
+ "RP\nR\nR\n" => [0,5,7]
128
+ }.each do |sequence, expected|
129
+ @digester.cleavage_sites(sequence).is expected
130
+ end
131
+ end
132
+
133
+ it 'finds cleavage sites with offset and limit' do
134
+ {
135
+ "RxxR" => [2,4],
136
+ "RxAxR" => [2,4],
137
+ "RxAAAxR" => [2,4],
138
+ "RxRRRxR" => [2,3,4]
139
+ }.each do |sequence, expected|
140
+ @digester.cleavage_sites(sequence, 2, 2).is expected
141
+ end
142
+ end
143
+
144
+ it 'finds cleavage sites fast' do
145
+ str = nk_string(10, 1000)
146
+ @digester.cleavage_sites(str).length.is 11
147
+ benchmark(20) do |x|
148
+ x.report("10kx - fragments") do
149
+ 10000.times { @digester.cleavage_sites(str) }
150
+ end
151
+ end
152
+ end
153
+
154
+ it 'digests proteins' do
155
+ {
156
+ "" => [''],
157
+ "A" => ["A"],
158
+ "R" => ["R"],
159
+ "AAA" => ["AAA"],
160
+ "RAA" => ["R", "AA"],
161
+ "ARA" => ["AR", "A"],
162
+ "AAR" => ["AAR"],
163
+ "RRA" => ["R", "R", "A"],
164
+ "RAR" => ["R", "AR"],
165
+ "RRR" => ["R", "R", "R"]
166
+ }.each do |sequence, expected|
167
+ # spp(sequence)
168
+ @digester.digest(sequence) {|frag, s, e| frag}.is expected
169
+ end
170
+ end
171
+
172
+ it 'digests with missed cleavages' do
173
+ {
174
+ "" => [''],
175
+ "A" => ["A"],
176
+ "R" => ["R"],
177
+ "AAA" => ["AAA"],
178
+ "RAA" => ["R", "RAA", "AA"],
179
+ "ARA" => ["AR", "ARA", "A"],
180
+ "AAR" => ["AAR"],
181
+ "RRA" => ["R", "RR", "R", "RA", "A"],
182
+ "RAR" => ["R", "RAR", "AR"],
183
+ "RRR" => ["R", "RR", "R", "RR", "R"]
184
+ }.each do |sequence, expected|
185
+ @digester.digest(sequence, 1) {|frag, s, e| frag}.is expected
186
+ end
187
+ end
188
+
189
+ it 'digests with two missed cleavages' do
190
+ {
191
+ "" => [''],
192
+ "A" => ["A"],
193
+ "R" => ["R"],
194
+ "AAA" => ["AAA"],
195
+ "RAA" => ["R", "RAA", "AA"],
196
+ "ARA" => ["AR", "ARA", "A"],
197
+ "AAR" => ["AAR"],
198
+ "RRA" => ["R", "RR", "RRA", "R", "RA", "A"],
199
+ "RAR" => ["R", "RAR", "AR"],
200
+ "RRR" => ["R", "RR", "RRR", "R", "RR", "R"]
201
+ }.each do |sequence, expected|
202
+ @digester.digest(sequence, 2) {|frag, s, e| frag}.is expected
203
+ end
204
+ end
205
+
206
+ it 'digests fast' do
207
+ str = nk_string(10, 1000)
208
+ @digester.digest(str).length.is 10
209
+ benchmark(20) do |x|
210
+ x.report("10kx - fragments") do
211
+ 10000.times { @digester.digest(str) }
212
+ end
213
+ end
214
+ end
215
+
216
+ it 'finds sites to be digested' do
217
+ {
218
+ "" => [[0,0]],
219
+ "A" => [[0,1]],
220
+ "R" => [[0,1]],
221
+ "AAA" => [[0,3]],
222
+ "RAA" => [[0,1],[1,3]],
223
+ "ARA" => [[0,2],[2,3]],
224
+ "AAR" => [[0,3]],
225
+ "RRA" => [[0,1],[1,2],[2,3]],
226
+ "RAR" => [[0,1],[1,3]],
227
+ "RRR" => [[0,1],[1,2],[2,3]]
228
+ }.each do |sequence, expected|
229
+ @digester.site_digest(sequence).is expected
230
+ end
231
+ end
232
+
233
+ it 'finds sites to be digested with missed cleavages' do
234
+ {
235
+ "" => [[0,0]],
236
+ "A" => [[0,1]],
237
+ "R" => [[0,1]],
238
+ "AAA" => [[0,3]],
239
+ "RAA" => [[0,1],[0,3],[1,3]],
240
+ "ARA" => [[0,2],[0,3],[2,3]],
241
+ "AAR" => [[0,3]],
242
+ "RRA" => [[0,1],[0,2],[1,2],[1,3],[2,3]],
243
+ "RAR" => [[0,1],[0,3],[1,3]],
244
+ "RRR" => [[0,1],[0,2],[1,2],[1,3],[2,3]]
245
+ }.each do |sequence, expected|
246
+ @digester.site_digest(sequence, 1).is expected
247
+ end
248
+ end
249
+
250
+ it 'finds sites to be digested with two missed cleavages' do
251
+ {
252
+ "" => [[0,0]],
253
+ "A" => [[0,1]],
254
+ "R" => [[0,1]],
255
+ "AAA" => [[0,3]],
256
+ "RAA" => [[0,1],[0,3],[1,3]],
257
+ "ARA" => [[0,2],[0,3],[2,3]],
258
+ "AAR" => [[0,3]],
259
+ "RRA" => [[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]],
260
+ "RAR" => [[0,1],[0,3],[1,3]],
261
+ "RRR" => [[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
262
+ }.each do |sequence, expected|
263
+ @digester.site_digest(sequence, 2).is expected
264
+ end
265
+ end
266
+
267
+ it 'does site digestion fast' do
268
+ str = nk_string(10, 1000)
269
+ @digester.site_digest(str).length.is 10
270
+ benchmark(20) do |x|
271
+ x.report("10kx - fragments") do
272
+ 10000.times { @digester.site_digest(str) }
273
+ end
274
+ end
275
+ end
276
+
277
+ it 'does a trypsin digest' do
278
+ trypsin = Ms::InSilico::Digester::TRYPSIN
279
+ {
280
+ "" => [''],
281
+ "A" => ["A"],
282
+ "R" => ["R"],
283
+ "AAA" => ["AAA"],
284
+ "RAA" => ["R", "AA"],
285
+ "ARA" => ["AR", "A"],
286
+ "AAR" => ["AAR"],
287
+ "RRA" => ["R", "R", "A"],
288
+ "RAR" => ["R", "AR"],
289
+ "RRR" => ["R", "R", "R"],
290
+ "RKR" => ["R", "K", "R"],
291
+
292
+ "ARP" => ["ARP"],
293
+ "PRA" => ["PR","A"],
294
+ "ARPARAA" => ["ARPAR", "AA"],
295
+ "RPRRR" => ["RPR", "R", "R"]
296
+ }.each do |sequence, expected|
297
+ trypsin.digest(sequence) {|frag, s, e| frag}.is expected
298
+ end
299
+ end
300
+
301
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ require 'ms/in_silico/fragment'
4
+
5
+ describe 'creating fragmentation spectra' do
6
+
7
+ it 'creates tandem mass spectra from a peptide' do
8
+ frag = Ms::InSilico::Fragment.new :charge => 1, :series => ['b']
9
+ spec = Ms::InSilico::Spectrum.new('TVQQEL', 'H', 'HO')
10
+
11
+ headers = frag.headers(spec)
12
+ headers[:charge].is 1
13
+ headers[:nterm].is 'H'
14
+ headers[:cterm].is 'HO'
15
+ headers[:parent_ion_mass].should.be.close 717.377745628191, 0.000000000001
16
+ headers[:series].is ['b']
17
+ end
18
+ end
19
+
@@ -0,0 +1,68 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'ms/in_silico/spectrum'
3
+
4
+ # class locate_residues tests
5
+ class Subclass < Ms::InSilico::Spectrum
6
+ locate_residues "PS"
7
+ end
8
+
9
+ class Cumulative < Ms::InSilico::Spectrum
10
+ locate_residues "PS"
11
+ end
12
+
13
+
14
+ describe 'creating spectral fragmentation ladders' do
15
+
16
+ it 'locates residues' do
17
+ Subclass.new('RPPGFSPFR').residue_locations.is( {'P' => [1, 2, 6], 'S' => [5]} )
18
+ end
19
+
20
+ it 'does cumulative locate calls' do
21
+ Cumulative.residues_to_locate.is "PS"
22
+ Cumulative.locate_residues "R"
23
+ Cumulative.residues_to_locate.is "PSR"
24
+
25
+ Cumulative.locate_residues "G"
26
+ Cumulative.residues_to_locate.is "PSRG"
27
+ end
28
+
29
+ it 'creates spectral series' do
30
+ f = Ms::InSilico::Spectrum.new 'RPPGFSPFR'
31
+ f.y_series.is f.series('y')
32
+ f.b_series(2).is f.series('b++')
33
+ f.nladder_series(-1).is f.series('nladder-')
34
+ end
35
+
36
+ it 'specifies charges' do
37
+ f = Ms::InSilico::Spectrum.new 'RPPGFSPFR'
38
+ f.y_series.is f.series('y')
39
+
40
+ f.y_series(-1).is f.series('y-')
41
+ f.y_series(-2).is f.series('y--')
42
+
43
+ f.y_series(1).is f.series('y+')
44
+ f.y_series(2).is f.series('y++')
45
+
46
+ f.y_series(-1).is f.series('y++---')
47
+ end
48
+
49
+ it 'raises an error for zero charge or unknown series' do
50
+ f = Ms::InSilico::Spectrum.new('SAMPLE')
51
+ lambda { f.series 'y+-' }.should.raise ArgumentError
52
+ lambda { f.series 'q' }.should.raise ArgumentError
53
+ end
54
+
55
+ it 'handles whitespace in the peptide spec' do
56
+ s = Ms::InSilico::Spectrum.new('SAMPLE')
57
+ s1 = Ms::InSilico::Spectrum.new(" SA\n MPL\t \rE ")
58
+ s1.series('y').is s.series('y')
59
+ end
60
+
61
+ it 'is fast' do
62
+ 1.is 1
63
+ benchmark(20) do |x|
64
+ x.report("1k RPPGFSPFR * 10") { 1000.times { Ms::InSilico::Spectrum.new("RPPGFSPFR" * 10) } }
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+ require 'ms/in_silico/digester'
3
+ require 'ms/in_silico/spectrum'
4
+
5
+ describe 'readme documentation' do
6
+
7
+ it 'works' do
8
+ trypsin = Ms::InSilico::Digester['Trypsin']
9
+ peptides = trypsin.digest('MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG')
10
+ expected = [
11
+ 'MIVIGR',
12
+ 'SIVHPYITNEYEPFAAEK',
13
+ 'QQILSIMAG']
14
+ peptides.sort.is expected.sort
15
+
16
+ spectrum = Ms::InSilico::Spectrum.new(peptides[0])
17
+ spectrum.parent_ion_mass.should.be.close 688.417442373391, 10**-12
18
+
19
+ expected = [
20
+ 132.047761058391,
21
+ 245.131825038791,
22
+ 344.200238954991,
23
+ 457.284302935391,
24
+ 514.305766658991,
25
+ 670.406877687091]
26
+ spectrum.series('b').zip(expected) do |o,e|
27
+ o.should.be.close e, 10**-12
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'spec/more'
3
+
4
+ require 'benchmark'
5
+
6
+ Bacon.summary_on_exit
7
+
8
+ module Bacon
9
+ class Context
10
+ def benchmark(width=7, &block)
11
+ if ENV['BENCHMARK']
12
+ Benchmark.bm(width, &block)
13
+ end
14
+ end
15
+ def assert_equal(x,y)
16
+ x.is y
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'tap/test/unit'
File without changes
@@ -0,0 +1,72 @@
1
+ require File.join(File.dirname(__FILE__), '../../tap_test_helper.rb')
2
+ require 'ms/in_silico/digest'
3
+
4
+ class Ms::InSilico::DigestTest < Test::Unit::TestCase
5
+ include Ms::InSilico
6
+ acts_as_tap_test
7
+ acts_as_shell_test(
8
+ :cmd_pattern => '% ',
9
+ :env => {'TAP_GEMS' => ''}
10
+ )
11
+
12
+ attr_accessor :d
13
+
14
+ def setup
15
+ super
16
+ @d = Digest.new
17
+ end
18
+
19
+ def test_digest_documentation
20
+ sh_test %q{
21
+ % rap digest MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG --:i dump
22
+ MIVIGR
23
+ SIVHPYITNEYEPFAAEK
24
+ QQILSIMAG
25
+ }
26
+ end
27
+
28
+ #
29
+ # process test
30
+ #
31
+
32
+ def test_process_returns_array_of_peptide_fragments
33
+ assert_equal %w{
34
+ MIVIGR
35
+ SIVHPYITNEYEPFAAEK
36
+ QQILSIMAG
37
+ }, d.process("MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG")
38
+ end
39
+
40
+ def test_process_removes_whitespace_from_sequence
41
+ assert_equal %w{
42
+ MIVIGR
43
+ SIVHPYITNEYEPFAAEK
44
+ QQILSIMAG
45
+ }, d.process(" MIVI\nGRSIVHP YITNEYEPFA \n\r\nAEKQQILSIMAG\n")
46
+ end
47
+
48
+ def test_process_skips_header_of_fasta_entries
49
+ assert_equal %w{
50
+ MIVIGR
51
+ SIVHPYITNEYEPFAAEK
52
+ QQILSIMAG
53
+ }, d.process(">header\nMIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG")
54
+ end
55
+
56
+ def test_process_filters_on_min_max_length
57
+ d.min_length = 9
58
+ d.max_length = 9
59
+ assert_equal %w{
60
+ QQILSIMAG
61
+ }, d.process("MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG")
62
+
63
+ d.min_length = 6
64
+ d.max_length = 18
65
+ assert_equal %w{
66
+ MIVIGR
67
+ SIVHPYITNEYEPFAAEK
68
+ QQILSIMAG
69
+ }, d.process("MIVIGRSIVHPYITNEYEPFAAEKQQILSIMAG")
70
+ end
71
+
72
+ end
@@ -0,0 +1,36 @@
1
+ require File.join(File.dirname(__FILE__), '../../tap_test_helper.rb')
2
+ require 'ms/in_silico/fragment'
3
+
4
+ class FragmentTest < Test::Unit::TestCase
5
+ include Ms::InSilico
6
+ acts_as_tap_test
7
+
8
+ #
9
+ # process test
10
+ #
11
+
12
+ def test_process_returns_data_and_a_hash_of_headers
13
+ data, headers = Fragment.new.process('TVQQEL')
14
+
15
+ assert_equal %w{
16
+ 102.054954926291
17
+ 132.101905118891
18
+ 201.123368842491
19
+ 261.144498215091
20
+ 329.181946353891
21
+ 389.203075726491
22
+ 457.240523865291
23
+ 517.261653237891
24
+ 586.283116961491
25
+ 616.330067154091
26
+ 699.367180941891
27
+ 717.377745628191
28
+ }, data.collect {|mass| mass.to_s }
29
+
30
+ assert_equal 1, headers[:charge]
31
+ assert_equal 'H', headers[:nterm]
32
+ assert_equal 'HO', headers[:cterm]
33
+ assert_in_delta 717.377745628191, headers[:parent_ion_mass], 0.000000000001
34
+ assert_equal ['y', 'b'], headers[:series]
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ms-in_silico
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Simon Chiang
@@ -9,84 +14,131 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-05-25 00:00:00 -06:00
17
+ date: 2010-06-23 00:00:00 -06:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: tap
21
+ name: molecules
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 2
30
+ - 0
31
+ version: 0.2.0
17
32
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: tap
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
20
38
  requirements:
21
39
  - - ">="
22
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 17
44
+ - 0
23
45
  version: 0.17.0
24
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
25
48
  - !ruby/object:Gem::Dependency
26
49
  name: tap-test
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
30
52
  requirements:
31
53
  - - ">="
32
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 1
58
+ - 0
33
59
  version: 0.1.0
34
- version:
60
+ type: :development
61
+ version_requirements: *id003
35
62
  - !ruby/object:Gem::Dependency
36
- name: molecules
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
63
+ name: spec-more
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
40
66
  requirements:
41
67
  - - ">="
42
68
  - !ruby/object:Gem::Version
43
- version: 0.2.0
44
- version:
45
- description:
46
- email: simon.a.chiang@gmail.com
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ type: :development
73
+ version_requirements: *id004
74
+ description: peptide fragmentation and protein digestion
75
+ email: jtprince@gmail.com
47
76
  executables: []
48
77
 
49
78
  extensions: []
50
79
 
51
80
  extra_rdoc_files:
52
- - README
53
- - MIT-LICENSE
54
- - History
81
+ - LICENSE
82
+ - README.rdoc
55
83
  files:
84
+ - .gitignore
85
+ - History
86
+ - LICENSE
87
+ - README.rdoc
88
+ - Rakefile
89
+ - VERSION
56
90
  - lib/ms/in_silico.rb
57
91
  - lib/ms/in_silico/digest.rb
58
92
  - lib/ms/in_silico/digester.rb
59
93
  - lib/ms/in_silico/fragment.rb
60
94
  - lib/ms/in_silico/spectrum.rb
95
+ - spec/ms/in_silico/digester_spec.rb
96
+ - spec/ms/in_silico/fragment_spec.rb
97
+ - spec/ms/in_silico/spectrum_spec.rb
98
+ - spec/readme_spec.rb
99
+ - spec/spec_helper.rb
100
+ - spec/tap_test_helper.rb
101
+ - spec/tap_test_suite.rb
61
102
  - tap.yml
62
- - README
63
- - MIT-LICENSE
64
- - History
103
+ - test/ms/in_silico/digest_test.rb
104
+ - test/ms/in_silico/fragment_test.rb
65
105
  has_rdoc: true
66
- homepage: http://mspire.rubyforge.org/projects/ms-in_silico/
67
- post_install_message:
68
- rdoc_options: []
106
+ homepage: http://github.com/jtprince/ms-in_silico
107
+ licenses: []
69
108
 
109
+ post_install_message:
110
+ rdoc_options:
111
+ - --charset=UTF-8
70
112
  require_paths:
71
113
  - lib
72
114
  required_ruby_version: !ruby/object:Gem::Requirement
73
115
  requirements:
74
116
  - - ">="
75
117
  - !ruby/object:Gem::Version
118
+ segments:
119
+ - 0
76
120
  version: "0"
77
- version:
78
121
  required_rubygems_version: !ruby/object:Gem::Requirement
79
122
  requirements:
80
123
  - - ">="
81
124
  - !ruby/object:Gem::Version
125
+ segments:
126
+ - 0
82
127
  version: "0"
83
- version:
84
128
  requirements: []
85
129
 
86
130
  rubyforge_project: mspire
87
- rubygems_version: 1.3.1
131
+ rubygems_version: 1.3.6
88
132
  signing_key:
89
- specification_version: 2
133
+ specification_version: 3
90
134
  summary: in-silico calculations for mass spec data
91
135
  test_files:
92
- - test/tap_test_suite.rb
136
+ - spec/tap_test_suite.rb
137
+ - spec/ms/in_silico/fragment_spec.rb
138
+ - spec/ms/in_silico/spectrum_spec.rb
139
+ - spec/ms/in_silico/digester_spec.rb
140
+ - spec/readme_spec.rb
141
+ - spec/tap_test_helper.rb
142
+ - spec/spec_helper.rb
143
+ - test/ms/in_silico/digest_test.rb
144
+ - test/ms/in_silico/fragment_test.rb