ms-core 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +13 -0
- data/Gemfile.lock +22 -0
- data/Rakefile +21 -14
- data/VERSION +1 -1
- data/lib/ms/mass/aa.rb +119 -5
- data/spec/ms/mass/aa_spec.rb +14 -0
- data/spec/spec_helper.rb +12 -1
- metadata +49 -16
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "spec-more", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.5.2"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
bacon (1.1.0)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.5.2)
|
7
|
+
bundler (~> 1.0.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.8.7)
|
11
|
+
rcov (0.9.9)
|
12
|
+
spec-more (0.0.4)
|
13
|
+
bacon
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.0.0)
|
20
|
+
jeweler (~> 1.5.2)
|
21
|
+
rcov
|
22
|
+
spec-more
|
data/Rakefile
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
2
10
|
require 'rake'
|
3
|
-
require 'jeweler'
|
4
|
-
require 'rcov/rcovtask'
|
5
|
-
require 'rake/rdoctask'
|
6
|
-
require 'rake/testtask'
|
7
11
|
|
12
|
+
require 'jeweler'
|
8
13
|
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
9
15
|
gem.name = "ms-core"
|
10
|
-
gem.
|
11
|
-
gem.
|
12
|
-
|
13
|
-
gem.
|
14
|
-
gem.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# dev dependencies:
|
19
|
-
gem.add_development_dependency "spec-more", ">= 0"
|
16
|
+
gem.homepage = "http://github.com/jtprince/ms-core"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{basic, shared functionality for mspire libraries}
|
19
|
+
gem.description = %Q{basic, shared functionality for mspire libraries}
|
20
|
+
gem.email = "jtprince@gmail.com"
|
21
|
+
gem.authors = ["John T. Prince", "Simon Chiang"]
|
22
|
+
# Dependencies in Gemfile
|
20
23
|
end
|
24
|
+
Jeweler::RubygemsDotOrgTasks.new
|
21
25
|
|
26
|
+
require 'rake/testtask'
|
22
27
|
Rake::TestTask.new(:spec) do |spec|
|
23
28
|
spec.libs << 'lib' << 'spec'
|
24
29
|
spec.pattern = 'spec/**/*_spec.rb'
|
25
30
|
spec.verbose = true
|
26
31
|
end
|
27
32
|
|
33
|
+
require 'rcov/rcovtask'
|
28
34
|
Rcov::RcovTask.new do |spec|
|
29
35
|
spec.libs << 'spec'
|
30
36
|
spec.pattern = 'spec/**/*_spec.rb'
|
@@ -33,6 +39,7 @@ end
|
|
33
39
|
|
34
40
|
task :default => :spec
|
35
41
|
|
42
|
+
require 'rake/rdoctask'
|
36
43
|
Rake::RDocTask.new do |rdoc|
|
37
44
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
38
45
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/lib/ms/mass/aa.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'yaml'
|
2
|
+
|
2
3
|
require 'ms/mass'
|
3
4
|
|
4
5
|
module Ms
|
5
6
|
module Mass
|
6
7
|
|
8
|
+
|
7
9
|
# A module for working with commonly used residue masses in proteomics.
|
8
10
|
#
|
9
11
|
# require 'ms/mass/aa'
|
@@ -15,10 +17,96 @@ module Ms
|
|
15
17
|
# # or use symbols
|
16
18
|
# MONO[:A] # => 71.0371137878
|
17
19
|
#
|
18
|
-
#
|
20
|
+
# molecules is built on constants and constants on ruby-units and it seems
|
21
|
+
# impossible to get ruby-units 1.9 compatible. Until that point, values
|
22
|
+
# will remain hard coded and these values are free of dependencies.
|
23
|
+
#
|
24
|
+
# The values are built using the excellent {'molecules'
|
19
25
|
# library}[http://github.com/bahuvrihi/molecules/tree/master]. See that
|
20
26
|
# library for more serious work with masses.
|
21
27
|
module AA
|
28
|
+
|
29
|
+
yaml = <<-END
|
30
|
+
---
|
31
|
+
avg:
|
32
|
+
"*": 118.88603
|
33
|
+
A: 71.0779
|
34
|
+
B: 172.1405
|
35
|
+
C: 103.1429
|
36
|
+
D: 115.0874
|
37
|
+
E: 129.11398
|
38
|
+
F: 147.17386
|
39
|
+
G: 57.05132
|
40
|
+
H: 137.13928
|
41
|
+
I: 113.15764
|
42
|
+
K: 128.17228
|
43
|
+
L: 113.15764
|
44
|
+
M: 131.19606
|
45
|
+
N: 114.10264
|
46
|
+
O: 211.28076
|
47
|
+
P: 97.11518
|
48
|
+
Q: 128.12922
|
49
|
+
R: 156.18568
|
50
|
+
S: 87.0773
|
51
|
+
T: 101.10388
|
52
|
+
U: 150.0379
|
53
|
+
V: 99.13106
|
54
|
+
W: 186.2099
|
55
|
+
X: 118.88603
|
56
|
+
Y: 163.17326
|
57
|
+
Z: 128.6231
|
58
|
+
mono:
|
59
|
+
"*": 118.805716
|
60
|
+
A: 71.0371137878
|
61
|
+
B: 172.048405
|
62
|
+
C: 103.0091844778
|
63
|
+
D: 115.026943032
|
64
|
+
E: 129.0425930962
|
65
|
+
F: 147.0684139162
|
66
|
+
G: 57.0214637236
|
67
|
+
H: 137.0589118624
|
68
|
+
I: 113.0840639804
|
69
|
+
K: 128.0949630177
|
70
|
+
L: 113.0840639804
|
71
|
+
M: 131.0404846062
|
72
|
+
N: 114.0429274472
|
73
|
+
O: 211.1446528645
|
74
|
+
P: 97.052763852
|
75
|
+
Q: 128.0585775114
|
76
|
+
R: 156.1011110281
|
77
|
+
S: 87.0320284099
|
78
|
+
T: 101.0476784741
|
79
|
+
U: 150.9536355878
|
80
|
+
V: 99.0684139162
|
81
|
+
W: 186.0793129535
|
82
|
+
X: 118.805716
|
83
|
+
Y: 163.0633285383
|
84
|
+
Z: 128.550585
|
85
|
+
END
|
86
|
+
|
87
|
+
|
88
|
+
embedded_mass_hashes = YAML.load(yaml)
|
89
|
+
# amino_acids keys as strings, monoisotopic masses
|
90
|
+
MONO_STRING = embedded_mass_hashes['mono']
|
91
|
+
# amino_acids keys as symbols, monoisotopic masses
|
92
|
+
MONO_SYM = Hash[MONO_STRING.map {|aa,mass| [aa.to_sym, mass] } ]
|
93
|
+
|
94
|
+
# amino_acids keys as strings, average masses
|
95
|
+
AVG_STRING = embedded_mass_hashes['avg']
|
96
|
+
# amino_acids keys as symbols, average masses
|
97
|
+
AVG_SYM = Hash[AVG_STRING.map {|aa,mass| [aa.to_sym, mass] } ]
|
98
|
+
|
99
|
+
# amino_acids keys as symbols and also strings, monoisotopic masses
|
100
|
+
MONO = MONO_SYM.merge(MONO_STRING)
|
101
|
+
# amino_acids keys as symbols and also strings, average masses
|
102
|
+
AVG = AVG_SYM.merge(AVG_STRING)
|
103
|
+
|
104
|
+
###########################################################################
|
105
|
+
# This section is broken in 1.9 (ruby-units fault), so we generate the
|
106
|
+
# data and include it.
|
107
|
+
###########################################################################
|
108
|
+
|
109
|
+
=begin
|
22
110
|
# These are included here to offer maximum functionality
|
23
111
|
MOLECULES_MONO_UNSUPPORTED = {
|
24
112
|
:B => 172.048405, # average of aspartic acid and asparagine
|
@@ -39,10 +127,11 @@ module Ms
|
|
39
127
|
# returns a hash based on the molecules library of amino acid residues.
|
40
128
|
# type is :mono or :avg
|
41
129
|
def self.mass_index(type=:mono)
|
130
|
+
require 'molecules'
|
42
131
|
hash = {}
|
43
132
|
('A'..'Z').each do |letter|
|
44
133
|
if res = Molecules::Libraries::Residue[letter]
|
45
|
-
hash[letter] =
|
134
|
+
hash[letter.to_sym] =
|
46
135
|
if type == :mono
|
47
136
|
res.mass
|
48
137
|
elsif type == :avg
|
@@ -55,13 +144,38 @@ module Ms
|
|
55
144
|
hash
|
56
145
|
end
|
57
146
|
|
147
|
+
# Returns mono and avg tables as yaml with all keys as strings.
|
148
|
+
# The top level keys are 'avg' and 'mono'
|
149
|
+
def self.indices_to_yaml
|
150
|
+
# this only works with ruby1.8 currently, so we use it to generate the
|
151
|
+
# data we need
|
152
|
+
require 'molecules'
|
153
|
+
[AVG, MONO].each do |hash|
|
154
|
+
hash.each {|k,v| hash[k.to_s] = hash.delete(k) }
|
155
|
+
end
|
156
|
+
{'avg' => AVG, 'mono' => MONO}.to_yaml
|
157
|
+
end
|
158
|
+
|
58
159
|
MONO = MOLECULES_MONO_UNSUPPORTED.merge( self.mass_index(:mono) )
|
59
160
|
AVG = MOLECULES_AVG_UNSUPPORTED.merge( self.mass_index(:avg) )
|
60
|
-
|
61
|
-
|
161
|
+
|
162
|
+
# the script to sort it nicely using ruby 1.9:
|
163
|
+
require 'yaml'
|
164
|
+
h = YAML.load_file(ARGV.shift)
|
165
|
+
new_hash = {}
|
166
|
+
h.sort.each do |key, aahash|
|
167
|
+
new_hash[key] = Hash[aahash.sort]
|
62
168
|
end
|
169
|
+
puts new_hash.to_yaml
|
170
|
+
|
171
|
+
=end
|
172
|
+
|
173
|
+
###########################################################################
|
174
|
+
# End fudge
|
175
|
+
###########################################################################
|
63
176
|
|
64
177
|
end
|
65
178
|
end
|
66
179
|
end
|
67
180
|
|
181
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'ms/mass/aa'
|
4
|
+
|
5
|
+
describe 'using a mass table' do
|
6
|
+
it 'has monoisotopic masses by string or symbol' do
|
7
|
+
Ms::Mass::AA::MONO['A'].is 71.0371137878
|
8
|
+
Ms::Mass::AA::MONO[:A].is 71.0371137878
|
9
|
+
end
|
10
|
+
it 'has average masses by string or symbol' do
|
11
|
+
Ms::Mass::AA::AVG['A'].is 71.0779
|
12
|
+
Ms::Mass::AA::AVG[:A].is 71.0779
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
3
10
|
require 'benchmark'
|
11
|
+
require 'spec/more'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
15
|
|
5
16
|
Bacon.summary_on_exit
|
metadata
CHANGED
@@ -5,22 +5,21 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 10
|
9
|
+
version: 0.0.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
+
- John T. Prince
|
12
13
|
- Simon Chiang
|
13
|
-
- John Prince
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-24 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
23
|
-
prerelease: false
|
22
|
+
name: spec-more
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
@@ -28,15 +27,43 @@ dependencies:
|
|
28
27
|
- !ruby/object:Gem::Version
|
29
28
|
segments:
|
30
29
|
- 0
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
type: :runtime
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
prerelease: false
|
35
33
|
version_requirements: *id001
|
36
34
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
prerelease: false
|
35
|
+
name: bundler
|
39
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
version: 1.0.0
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: jeweler
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 1
|
58
|
+
- 5
|
59
|
+
- 2
|
60
|
+
version: 1.5.2
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: rcov
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
40
67
|
none: false
|
41
68
|
requirements:
|
42
69
|
- - ">="
|
@@ -45,7 +72,8 @@ dependencies:
|
|
45
72
|
- 0
|
46
73
|
version: "0"
|
47
74
|
type: :development
|
48
|
-
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: *id004
|
49
77
|
description: basic, shared functionality for mspire libraries
|
50
78
|
email: jtprince@gmail.com
|
51
79
|
executables: []
|
@@ -55,6 +83,8 @@ extensions: []
|
|
55
83
|
extra_rdoc_files:
|
56
84
|
- README.rdoc
|
57
85
|
files:
|
86
|
+
- Gemfile
|
87
|
+
- Gemfile.lock
|
58
88
|
- History
|
59
89
|
- MIT-LICENSE
|
60
90
|
- README.rdoc
|
@@ -82,12 +112,13 @@ files:
|
|
82
112
|
- lib/openany.rb
|
83
113
|
- spec/ms/calc_spec.rb
|
84
114
|
- spec/ms/data_spec.rb
|
115
|
+
- spec/ms/mass/aa_spec.rb
|
85
116
|
- spec/ms/support/binary_search_spec.rb
|
86
117
|
- spec/spec_helper.rb
|
87
118
|
has_rdoc: true
|
88
|
-
homepage: http://github.com/jtprince/ms-core
|
89
|
-
licenses:
|
90
|
-
|
119
|
+
homepage: http://github.com/jtprince/ms-core
|
120
|
+
licenses:
|
121
|
+
- MIT
|
91
122
|
post_install_message:
|
92
123
|
rdoc_options: []
|
93
124
|
|
@@ -98,6 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
129
|
requirements:
|
99
130
|
- - ">="
|
100
131
|
- !ruby/object:Gem::Version
|
132
|
+
hash: -2752488455848385314
|
101
133
|
segments:
|
102
134
|
- 0
|
103
135
|
version: "0"
|
@@ -119,5 +151,6 @@ summary: basic, shared functionality for mspire libraries
|
|
119
151
|
test_files:
|
120
152
|
- spec/ms/calc_spec.rb
|
121
153
|
- spec/ms/data_spec.rb
|
154
|
+
- spec/ms/mass/aa_spec.rb
|
122
155
|
- spec/ms/support/binary_search_spec.rb
|
123
156
|
- spec/spec_helper.rb
|