mspire 0.8.1 → 0.8.2
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/VERSION +1 -1
- data/lib/mspire/cv/paramable.rb +25 -4
- data/lib/mspire/digester.rb +0 -16
- data/lib/mspire/imzml/writer.rb +1 -1
- data/lib/mspire/mzml/activation.rb +4 -0
- data/lib/mspire/mzml/chromatogram.rb +7 -3
- data/lib/mspire/mzml/component.rb +3 -1
- data/lib/mspire/mzml/data_array.rb +77 -87
- data/lib/mspire/mzml/data_array_container_like.rb +3 -8
- data/lib/mspire/mzml/isolation_window.rb +4 -0
- data/lib/mspire/mzml/precursor.rb +1 -1
- data/lib/mspire/mzml/reader.rb +3 -0
- data/lib/mspire/mzml/scan_window.rb +7 -0
- data/lib/mspire/mzml/selected_ion.rb +4 -0
- data/lib/mspire/mzml/spectrum.rb +18 -3
- data/lib/mspire/mzml.rb +2 -0
- data/lib/mspire/user_param.rb +13 -0
- data/spec/mspire/imzml/writer_spec.rb +17 -21
- data/spec/mspire/mzml/data_array_spec.rb +0 -5
- data/spec/mspire/mzml_spec.rb +56 -13
- data/spec/spec_helper.rb +22 -0
- data/spec/testfiles/mspire/{mzml → imzml}/1_BB7_SIM_478.5.CHECK.ibd +0 -0
- data/spec/testfiles/mspire/{mzml → imzml}/1_BB7_SIM_478.5.CHECK.imzML +144 -432
- data/spec/testfiles/mspire/imzml/{continuous_binary_check.ibd → continuous_binary.CHECK.ibd} +0 -0
- data/spec/testfiles/mspire/imzml/{processed_binary_check.ibd → processed_binary.CHECK.ibd} +0 -0
- data/spec/testfiles/mspire/mzml/j24z.idx_comp.3.NORMALIZED.CHECK.mzML +257 -0
- data/spec/testfiles/mspire/mzml/j24z.idx_comp.3.ROUNDTRIP.CHECK.mzML +257 -0
- data/spec/testfiles/mspire/mzml/{mspire_simulated.MSn.check.mzML → mspire_simulated.MSn.CHECK.mzML} +8 -6
- metadata +10 -8
data/spec/mspire/mzml_spec.rb
CHANGED
@@ -41,6 +41,50 @@ describe Mspire::Mzml do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
describe 'roundtrip: reading and then writing' do
|
45
|
+
before do
|
46
|
+
@file = TESTFILES + "/mspire/mzml/j24z.idx_comp.3.mzML"
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'works' do
|
50
|
+
outfile = TESTFILES + "/mspire/mzml/j24z.idx_comp.3.ROUNDTRIP.mzML"
|
51
|
+
Mspire::Mzml.open(@file) do |mzml|
|
52
|
+
mzml.write(outfile)
|
53
|
+
end
|
54
|
+
# I went through this file line by line to make sure it is correct
|
55
|
+
# output.
|
56
|
+
file_check(outfile)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'global normalizing spectra in a compressed mzML file (read in and write out)' do
|
61
|
+
before do
|
62
|
+
@file = TESTFILES + "/mspire/mzml/j24z.idx_comp.3.mzML"
|
63
|
+
end
|
64
|
+
|
65
|
+
specify 'adding to source file, software, and data processing'
|
66
|
+
#Mspire::Mzml.open(@file) do |mzml|
|
67
|
+
# mzml.source
|
68
|
+
#end
|
69
|
+
|
70
|
+
specify 'normalize highest peak of each spectrum to 100' do
|
71
|
+
# this is very bad form to not change data_processing etc, but it
|
72
|
+
# demonstrates the minimal amount to normalize the spectra.
|
73
|
+
outfile = TESTFILES + "/mspire/mzml/j24z.idx_comp.3.NORMALIZED.mzML"
|
74
|
+
Mspire::Mzml.open(@file) do |mzml|
|
75
|
+
spectra = mzml.map do |spectrum|
|
76
|
+
normalizer = 100.0 / spectrum.intensities.max
|
77
|
+
spectrum.intensities.map! {|i| i * normalizer }
|
78
|
+
spectrum
|
79
|
+
end
|
80
|
+
mzml.run.spectrum_list = Mspire::Mzml::SpectrumList.new(mzml.run.spectrum_list.default_data_processing, spectra)
|
81
|
+
mzml.write(outfile)
|
82
|
+
end
|
83
|
+
# this output was checked to be accurate with TOPPView
|
84
|
+
file_check(outfile)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
44
88
|
describe 'reading an indexed, compressed peaks, mzML file' do
|
45
89
|
|
46
90
|
describe 'reading the header things' do
|
@@ -302,15 +346,14 @@ describe Mspire::Mzml do
|
|
302
346
|
|
303
347
|
describe 'writing mzml' do
|
304
348
|
|
305
|
-
def sanitize_version(string)
|
306
|
-
string.gsub(/"mspire" version="([\.\d]+)"/, %Q{"mspire" version="X.X.X"})
|
307
|
-
end
|
308
|
-
|
309
349
|
it 'writes MS1 and MS2 spectra' do
|
310
350
|
spec1 = Mspire::Mzml::Spectrum.new('scan=1') do |spec|
|
311
351
|
# profile and ms_level 1
|
312
352
|
spec.describe_many!(['MS:1000128', ['MS:1000511', 1]])
|
313
|
-
spec.data_arrays = [
|
353
|
+
spec.data_arrays = [
|
354
|
+
Mspire::Mzml::DataArray[1,2,3].describe!('MS:1000514'),
|
355
|
+
Mspire::Mzml::DataArray[4,5,6].describe!('MS:1000515')
|
356
|
+
]
|
314
357
|
spec.scan_list = Mspire::Mzml::ScanList.new do |sl|
|
315
358
|
scan = Mspire::Mzml::Scan.new do |scan|
|
316
359
|
# retention time of 42 seconds
|
@@ -323,7 +366,10 @@ describe Mspire::Mzml do
|
|
323
366
|
spec2 = Mspire::Mzml::Spectrum.new('scan=2') do |spec|
|
324
367
|
# centroid, ms_level 2, MSn spectrum,
|
325
368
|
spec.describe_many!(['MS:1000127', ['MS:1000511', 2], "MS:1000580"])
|
326
|
-
spec.data_arrays = [
|
369
|
+
spec.data_arrays = [
|
370
|
+
Mspire::Mzml::DataArray[1,2,3.5].describe!('MS:1000514'),
|
371
|
+
Mspire::Mzml::DataArray[5,6,5].describe!('MS:1000515')
|
372
|
+
]
|
327
373
|
spec.scan_list = Mspire::Mzml::ScanList.new do |sl|
|
328
374
|
scan = Mspire::Mzml::Scan.new do |scan|
|
329
375
|
# retention time of 42 seconds
|
@@ -362,16 +408,13 @@ describe Mspire::Mzml do
|
|
362
408
|
end
|
363
409
|
end
|
364
410
|
|
365
|
-
|
366
|
-
tmpfile = TESTFILES + '/mspire/mzml/mspire_simulated.MSn.TMP.mzML'
|
411
|
+
tmpfile = TESTFILES + '/mspire/mzml/mspire_simulated.MSn.mzML'
|
367
412
|
mzml.to_xml(tmpfile)
|
368
413
|
as_string = mzml.to_xml
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
sanitize_version(check_string).should == sanitize_version(st)
|
414
|
+
as_string.should == IO.read(tmpfile)
|
415
|
+
file_check(tmpfile) do |string|
|
416
|
+
sanitize_mspire_version_xml(string)
|
373
417
|
end
|
374
|
-
File.unlink(tmpfile) if File.exist?(tmpfile)
|
375
418
|
end
|
376
419
|
end
|
377
420
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,3 +24,25 @@ def benchmark(*args, &block)
|
|
24
24
|
Benchmark.bmbm(*args, &block)
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
# given "filename.ext" returns "filename.CHECK.ext
|
29
|
+
# block can be given to sanitize each string
|
30
|
+
def file_check(filename, delete=true, &block)
|
31
|
+
ext = File.extname(filename)
|
32
|
+
base = filename.chomp(ext)
|
33
|
+
checkfile = base + ".CHECK" + ext
|
34
|
+
File.exist?(filename).should be_true
|
35
|
+
fstring = IO.read(filename)
|
36
|
+
cstring = IO.read(checkfile)
|
37
|
+
if block
|
38
|
+
(fstring, cstring) = [fstring, cstring].map do |string|
|
39
|
+
block.call(string)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
fstring.should == cstring
|
43
|
+
File.unlink(filename) if delete
|
44
|
+
end
|
45
|
+
|
46
|
+
def sanitize_mspire_version_xml(string)
|
47
|
+
string.gsub(/"mspire" version="([\.\d]+)"/, %Q{"mspire" version="X.X.X"})
|
48
|
+
end
|
File without changes
|