mspire 0.5.0 → 0.6.1
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/README.rdoc +24 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/cv/description.rb +18 -0
- data/lib/cv/param.rb +33 -0
- data/lib/cv.rb +3 -0
- data/lib/io/bookmark.rb +13 -0
- data/lib/merge.rb +7 -0
- data/lib/ms/cvlist.rb +76 -0
- data/lib/ms/digester.rb +245 -0
- data/lib/ms/fasta.rb +86 -0
- data/lib/ms/ident/peptide/db.rb +243 -0
- data/lib/ms/ident/peptide.rb +72 -0
- data/lib/ms/ident/peptide_hit/qvalue.rb +56 -0
- data/lib/ms/ident/peptide_hit.rb +26 -0
- data/lib/ms/ident/pepxml/modifications.rb +83 -0
- data/lib/ms/ident/pepxml/msms_pipeline_analysis.rb +70 -0
- data/lib/ms/ident/pepxml/msms_run_summary.rb +82 -0
- data/lib/ms/ident/pepxml/parameters.rb +14 -0
- data/lib/ms/ident/pepxml/sample_enzyme.rb +165 -0
- data/lib/ms/ident/pepxml/search_database.rb +49 -0
- data/lib/ms/ident/pepxml/search_hit/modification_info.rb +79 -0
- data/lib/ms/ident/pepxml/search_hit.rb +144 -0
- data/lib/ms/ident/pepxml/search_result.rb +35 -0
- data/lib/ms/ident/pepxml/search_summary.rb +92 -0
- data/lib/ms/ident/pepxml/spectrum_query.rb +85 -0
- data/lib/ms/ident/pepxml.rb +112 -0
- data/lib/ms/ident/protein.rb +33 -0
- data/lib/ms/ident/protein_group.rb +80 -0
- data/lib/ms/ident/search.rb +114 -0
- data/lib/ms/ident.rb +37 -0
- data/lib/ms/isotope/aa.rb +59 -0
- data/lib/ms/mascot.rb +6 -0
- data/lib/ms/mass/aa.rb +79 -0
- data/lib/ms/mass.rb +55 -0
- data/lib/ms/mzml/index_list.rb +98 -0
- data/lib/ms/mzml/plms1.rb +34 -0
- data/lib/ms/mzml.rb +197 -0
- data/lib/ms/obo.rb +38 -0
- data/lib/ms/plms1.rb +156 -0
- data/lib/ms/quant/qspec/protein_group_comparison.rb +22 -0
- data/lib/ms/quant/qspec.rb +112 -0
- data/lib/ms/spectrum.rb +154 -8
- data/lib/ms.rb +3 -10
- data/lib/msplat.rb +2 -0
- data/lib/obo/ims.rb +5 -0
- data/lib/obo/ms.rb +7 -0
- data/lib/obo/ontology.rb +41 -0
- data/lib/obo/unit.rb +5 -0
- data/lib/openany.rb +23 -0
- data/lib/write_file_or_string.rb +18 -0
- data/obo/ims.obo +562 -0
- data/obo/ms.obo +11677 -0
- data/obo/unit.obo +2563 -0
- data/spec/ms/cvlist_spec.rb +60 -0
- data/spec/ms/digester_spec.rb +351 -0
- data/spec/ms/fasta_spec.rb +100 -0
- data/spec/ms/ident/peptide/db_spec.rb +108 -0
- data/spec/ms/ident/pepxml/sample_enzyme_spec.rb +181 -0
- data/spec/ms/ident/pepxml/search_hit/modification_info_spec.rb +37 -0
- data/spec/ms/ident/pepxml_spec.rb +442 -0
- data/spec/ms/ident/protein_group_spec.rb +68 -0
- data/spec/ms/mass_spec.rb +8 -0
- data/spec/ms/mzml/index_list_spec.rb +122 -0
- data/spec/ms/mzml/plms1_spec.rb +62 -0
- data/spec/ms/mzml_spec.rb +50 -0
- data/spec/ms/plms1_spec.rb +38 -0
- data/spec/ms/quant/qspec_spec.rb +25 -0
- data/spec/msplat_spec.rb +24 -0
- data/spec/obo_spec.rb +25 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/testfiles/ms/ident/peptide/db/uni_11_sp_tr.fasta +69 -0
- data/spec/testfiles/ms/ident/peptide/db/uni_11_sp_tr.msd_clvg2.min_aaseq4.yml +728 -0
- data/spec/testfiles/ms/mzml/j24z.idx_comp.3.mzML +271 -0
- data/spec/testfiles/ms/mzml/openms.noidx_nocomp.12.mzML +330 -0
- data/spec/testfiles/ms/quant/kill_extra_tabs.rb +13 -0
- data/spec/testfiles/ms/quant/max_quant_output.provenance.txt +15 -0
- data/spec/testfiles/ms/quant/max_quant_output.txt +199 -0
- data/spec/testfiles/ms/quant/pdcd5_final.killedextratabs.tsv +199 -0
- data/spec/testfiles/ms/quant/pdcd5_final.killedextratabs.tsv_qspecgp +199 -0
- data/spec/testfiles/ms/quant/pdcd5_final.killedextratabs.tsv_qspecgp.csv +199 -0
- data/spec/testfiles/ms/quant/pdcd5_final.txt +199 -0
- data/spec/testfiles/ms/quant/pdcd5_final.txt_qspecgp +0 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_qspec.CSV.csv +199 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_qspec.csv +199 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_qspec.oneprot.csv +199 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_qspec.oneprot.tsv +199 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_qspec.oneprot.tsv_qspecgp +199 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_qspec.oneprot.tsv_qspecgp.csv +199 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_qspec.txt +199 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_tabdel.txt +134 -0
- data/spec/testfiles/ms/quant/pdcd5_lfq_tabdel.txt_qspecgp +134 -0
- data/spec/testfiles/ms/quant/remove_rest_of_proteins.rb +13 -0
- data/spec/testfiles/ms/quant/unlog_transform.rb +13 -0
- data/spec/testfiles/plms1/output.key +0 -0
- metadata +157 -40
- data/README +0 -77
- data/changelog.txt +0 -196
- data/lib/ms/calc.rb +0 -32
- data/lib/ms/data/interleaved.rb +0 -60
- data/lib/ms/data/lazy_io.rb +0 -73
- data/lib/ms/data/lazy_string.rb +0 -15
- data/lib/ms/data/simple.rb +0 -59
- data/lib/ms/data/transposed.rb +0 -41
- data/lib/ms/data.rb +0 -57
- data/lib/ms/format/format_error.rb +0 -12
- data/lib/ms/support/binary_search.rb +0 -126
data/lib/ms/spectrum.rb
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
module
|
|
1
|
+
module MS
|
|
2
2
|
class Spectrum
|
|
3
|
+
include Enumerable
|
|
4
|
+
|
|
3
5
|
# The underlying data store.
|
|
4
6
|
attr_reader :data
|
|
5
7
|
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def initialize(data
|
|
8
|
+
# data takes an array: [mzs, intensities]
|
|
9
|
+
# @return [MS::Spectrum]
|
|
10
|
+
# @param [Array] data two element array of mzs and intensities
|
|
11
|
+
def initialize(data)
|
|
10
12
|
@data = data
|
|
11
|
-
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.from_peaks(ar_of_doublets)
|
|
16
|
+
_mzs = []
|
|
17
|
+
_ints = []
|
|
18
|
+
ar_of_doublets.each do |mz, int|
|
|
19
|
+
_mzs << mz
|
|
20
|
+
_ints << int
|
|
21
|
+
end
|
|
22
|
+
self.new([_mzs, _ints])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# found by querying the size of the data store. This should almost always
|
|
26
|
+
# be 2 (m/z and intensities)
|
|
27
|
+
def size
|
|
28
|
+
@data.size
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def ==(other)
|
|
32
|
+
mzs == other.mzs && intensities == other.intensities
|
|
12
33
|
end
|
|
13
34
|
|
|
14
35
|
# An array of the mz data.
|
|
@@ -20,6 +41,131 @@ module Ms
|
|
|
20
41
|
def intensities
|
|
21
42
|
@data[1]
|
|
22
43
|
end
|
|
23
|
-
|
|
44
|
+
|
|
45
|
+
def mzs_and_intensities
|
|
46
|
+
[@data[0], @data[1]]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# retrieve an m/z and intensity doublet at that index
|
|
50
|
+
def [](array_index)
|
|
51
|
+
[mzs[array_index], intensities[array_index]]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# yields(mz, inten) across the spectrum, or array of doublets if no block
|
|
55
|
+
def peaks(&block)
|
|
56
|
+
(m, i) = mzs_and_intensities
|
|
57
|
+
m.zip(i, &block)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
alias_method :each, :peaks
|
|
61
|
+
alias_method :each_peak, :peaks
|
|
62
|
+
|
|
63
|
+
# if the mzs and intensities are the same then the spectra are considered
|
|
64
|
+
# equal
|
|
65
|
+
def ==(other)
|
|
66
|
+
mzs == other.mzs && intensities == other.intensities
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# returns a new spectrum whose intensities have been normalized by the tic
|
|
70
|
+
def normalize
|
|
71
|
+
tic = self.intensities.inject(0.0) {|sum,int| sum += int }
|
|
72
|
+
MS::Spectrum.new([self.mzs, self.intensities.map {|v| v / tic }])
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
## uses index function and returns the intensity at that value
|
|
76
|
+
#def intensity_at_mz(mz)
|
|
77
|
+
#if x = index(mz)
|
|
78
|
+
#intensities[x]
|
|
79
|
+
#else
|
|
80
|
+
#nil
|
|
81
|
+
#end
|
|
82
|
+
#end
|
|
83
|
+
|
|
84
|
+
## index mz, tolerance = :nearest(1), Float, :nearest_within_integer
|
|
85
|
+
|
|
86
|
+
## returns the index of the first value matching that m/z. the argument m/z
|
|
87
|
+
## may be less precise than the actual m/z (rounding to the same precision
|
|
88
|
+
## given) but must be at least integer precision (after rounding)
|
|
89
|
+
## implemented as binary search (bsearch from the web)
|
|
90
|
+
#def index(mz)
|
|
91
|
+
#mz_ar = mzs
|
|
92
|
+
#return_val = nil
|
|
93
|
+
#ind = mz_ar.bsearch_lower_boundary{|x| x <=> mz }
|
|
94
|
+
#if mz_ar[ind] == mz
|
|
95
|
+
#return_val = ind
|
|
96
|
+
#else
|
|
97
|
+
## do a rounding game to see which one is it, or nil
|
|
98
|
+
## find all the values rounding to the same integer in the locale
|
|
99
|
+
## test each one fully in turn
|
|
100
|
+
#mz = mz.to_f
|
|
101
|
+
#mz_size = mz_ar.size
|
|
102
|
+
#if ((ind < mz_size) and equal_after_rounding?(mz_ar[ind], mz))
|
|
103
|
+
#return_val = ind
|
|
104
|
+
#else # run the loop
|
|
105
|
+
#up = ind
|
|
106
|
+
#loop do
|
|
107
|
+
#up += 1
|
|
108
|
+
#if up >= mz_size
|
|
109
|
+
#break
|
|
110
|
+
#end
|
|
111
|
+
#mz_up = mz_ar[up]
|
|
112
|
+
#if (mz_up.ceil - mz.ceil >= 2)
|
|
113
|
+
#break
|
|
114
|
+
#else
|
|
115
|
+
#if equal_after_rounding?(mz_up, mz)
|
|
116
|
+
#return_val = up
|
|
117
|
+
#return return_val
|
|
118
|
+
#end
|
|
119
|
+
#end
|
|
120
|
+
#end
|
|
121
|
+
#dn= ind
|
|
122
|
+
#loop do
|
|
123
|
+
#dn -= 1
|
|
124
|
+
#if dn < 0
|
|
125
|
+
#break
|
|
126
|
+
#end
|
|
127
|
+
#mz_dn = mz_ar[dn]
|
|
128
|
+
#if (mz.floor - mz_dn.floor >= 2)
|
|
129
|
+
#break
|
|
130
|
+
#else
|
|
131
|
+
#if equal_after_rounding?(mz_dn, mz)
|
|
132
|
+
#return_val = dn
|
|
133
|
+
#return return_val
|
|
134
|
+
#end
|
|
135
|
+
#end
|
|
136
|
+
#end
|
|
137
|
+
#end
|
|
138
|
+
#end
|
|
139
|
+
#return_val
|
|
140
|
+
#end
|
|
141
|
+
|
|
142
|
+
## less_precise should be a float
|
|
143
|
+
## precise should be a float
|
|
144
|
+
#def equal_after_rounding?(precise, less_precise) # :nodoc:
|
|
145
|
+
## determine the precision of less_precise
|
|
146
|
+
#exp10 = precision_as_neg_int(less_precise)
|
|
147
|
+
##puts "EXP10: #{exp10}"
|
|
148
|
+
#answ = ((precise*exp10).round == (less_precise*exp10).round)
|
|
149
|
+
##puts "TESTING FOR EQUAL: #{precise} #{less_precise}"
|
|
150
|
+
##puts answ
|
|
151
|
+
#(precise*exp10).round == (less_precise*exp10).round
|
|
152
|
+
#end
|
|
153
|
+
|
|
154
|
+
## returns 1 for ones place, 10 for tenths, 100 for hundredths
|
|
155
|
+
## to a precision exceeding 1e-6
|
|
156
|
+
#def precision_as_neg_int(float) # :nodoc:
|
|
157
|
+
#neg_exp10 = 1
|
|
158
|
+
#loop do
|
|
159
|
+
#over = float * neg_exp10
|
|
160
|
+
#rounded = over.round
|
|
161
|
+
#if (over - rounded).abs <= 1e-6
|
|
162
|
+
#break
|
|
163
|
+
#end
|
|
164
|
+
#neg_exp10 *= 10
|
|
165
|
+
#end
|
|
166
|
+
#neg_exp10
|
|
167
|
+
#end
|
|
168
|
+
|
|
169
|
+
|
|
24
170
|
end
|
|
25
|
-
end
|
|
171
|
+
end
|
data/lib/ms.rb
CHANGED
data/lib/msplat.rb
ADDED
data/lib/obo/ims.rb
ADDED
data/lib/obo/ms.rb
ADDED
data/lib/obo/ontology.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'obo' # the gem obo
|
|
2
|
+
|
|
3
|
+
module Obo
|
|
4
|
+
class Ontology
|
|
5
|
+
DIR = File.expand_path(File.dirname(__FILE__) + '/../../obo')
|
|
6
|
+
attr_accessor :header
|
|
7
|
+
attr_accessor :elements
|
|
8
|
+
|
|
9
|
+
def initialize(file_or_io)
|
|
10
|
+
obo = Obo::Parser.new(file_or_io)
|
|
11
|
+
@elements = obo.elements.to_a
|
|
12
|
+
@header = elements.shift
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# returns an id to name Hash
|
|
16
|
+
def id_to_name
|
|
17
|
+
@id_to_name ||= build_hash('id', 'name')
|
|
18
|
+
end
|
|
19
|
+
# returns a name to id Hash
|
|
20
|
+
def name_to_id
|
|
21
|
+
@name_to_id ||= build_hash('name', 'id')
|
|
22
|
+
end
|
|
23
|
+
def id_to_element
|
|
24
|
+
@id_to_element ||= build_hash('id', nil)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
protected
|
|
28
|
+
def build_hash(key,val)
|
|
29
|
+
hash = {}
|
|
30
|
+
@elements.each do |el|
|
|
31
|
+
tv = el.tagvalues
|
|
32
|
+
if val.nil?
|
|
33
|
+
hash[tv[key].first] = el
|
|
34
|
+
else
|
|
35
|
+
hash[tv[key].first] = tv[val].first
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
hash
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/obo/unit.rb
ADDED
data/lib/openany.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
# takes a filename or an io object, hands a rewinded io object to the
|
|
3
|
+
# reciever and then closes the file or places the io in the original
|
|
4
|
+
# position.
|
|
5
|
+
def openany(arg, &block)
|
|
6
|
+
io =
|
|
7
|
+
if arg.is_a?(String) # filename
|
|
8
|
+
File.open(arg)
|
|
9
|
+
else
|
|
10
|
+
orig_pos = arg.pos
|
|
11
|
+
arg.rewind
|
|
12
|
+
arg
|
|
13
|
+
end
|
|
14
|
+
reply = block.call(io)
|
|
15
|
+
if arg.is_a?(String) # filename
|
|
16
|
+
io.close
|
|
17
|
+
else
|
|
18
|
+
arg.pos = orig_pos
|
|
19
|
+
end
|
|
20
|
+
reply
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
# if given a filename, writes to the file (and returns the filename),
|
|
3
|
+
# otherwise, writes to a string. Yields an io object to write to.
|
|
4
|
+
def write_file_or_string(filename=nil, &block)
|
|
5
|
+
out =
|
|
6
|
+
if filename
|
|
7
|
+
File.open(filename,'w')
|
|
8
|
+
else
|
|
9
|
+
StringIO.new
|
|
10
|
+
end
|
|
11
|
+
block.call(out)
|
|
12
|
+
if filename
|
|
13
|
+
out.close
|
|
14
|
+
filename
|
|
15
|
+
else
|
|
16
|
+
out.string
|
|
17
|
+
end
|
|
18
|
+
end
|