mspire 0.10.4 → 0.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mspire/spectrum_like.rb +19 -0
- data/lib/mspire/version.rb +1 -1
- data/spec/mspire/spectrum_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4dcc320a2ee49559d1d64c2c42f1d647a33901c
|
4
|
+
data.tar.gz: 2562f3e4bcd33b71da96151cb6fc7cae172277a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f680070a1151cd563e2ade3b3ced3691f630ea42a67bbef4c866c6edfb163356f249ea519eefebd57149f0a2a4b23f8a16a964274d8df6a141edb6b79c4df29
|
7
|
+
data.tar.gz: eca1464a336117c98312e71c392761d7d3dd4b3e58528e8da05647319eb516f958bd248ba2a86db702d1010f896329ab5a8513b287da1ba5ef4d014cc0d6f90f
|
data/lib/mspire/spectrum_like.rb
CHANGED
@@ -120,6 +120,25 @@ module Mspire
|
|
120
120
|
self
|
121
121
|
end
|
122
122
|
|
123
|
+
# the range begin value will also be excluded on an exact match if
|
124
|
+
# exclude_begin is true. (respects the ranges exclude_end? value for the
|
125
|
+
# end).
|
126
|
+
def select_indices(range, exclude_begin=false)
|
127
|
+
indices = []
|
128
|
+
_mzs = mzs
|
129
|
+
lo_i = _mzs.bsearch_lower_boundary {|v| v <=> range.begin }
|
130
|
+
return indices unless lo_i
|
131
|
+
|
132
|
+
hi_i = nil
|
133
|
+
(lo_i..._mzs.size).each do |i|
|
134
|
+
break unless range === _mzs[i]
|
135
|
+
indices << i
|
136
|
+
end
|
137
|
+
|
138
|
+
indices.shift if exclude_begin && range.begin == _mzs[indices.first]
|
139
|
+
indices
|
140
|
+
end
|
141
|
+
|
123
142
|
# returns the m/z that is closest to the value, favoring the lower m/z in
|
124
143
|
# the case of a tie. Uses a binary search.
|
125
144
|
def find_nearest(val)
|
data/lib/mspire/version.rb
CHANGED
@@ -43,5 +43,16 @@ describe Mspire::Spectrum do
|
|
43
43
|
spec.mzs.should == subject.mzs
|
44
44
|
spec.intensities.should == subject.intensities
|
45
45
|
end
|
46
|
+
|
47
|
+
specify 'select_indices returns the indices whose m/z values lie within the given range' do
|
48
|
+
spec = Mspire::Spectrum.new [[10.1, 10.5, 10.7, 11.5, 11.6], [2, 1, 4, 3, 5]]
|
49
|
+
expect(spec.select_indices( 10.5...11.5 )).to eq([1,2])
|
50
|
+
expect(spec.select_indices( 10.5..11.5 )).to eq([1,2,3])
|
51
|
+
expect(spec.select_indices( 10.5...11.5, true )).to eq([2])
|
52
|
+
|
53
|
+
[10.6..10.65, 0..1, 12..13].each do |range|
|
54
|
+
expect(spec.select_indices(range)).to eq([])
|
55
|
+
end
|
56
|
+
end
|
46
57
|
end
|
47
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mspire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John T. Prince
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|