mspire 0.8.2 → 0.8.3
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.md +111 -10
- data/VERSION +1 -1
- data/lib/core_ext/enumerable.rb +5 -0
- data/lib/mspire/molecular_formula.rb +8 -3
- data/lib/mspire/mzml.rb +79 -33
- data/lib/mspire/mzml/io_indexable_list.rb +1 -1
- data/lib/mspire/mzml/software.rb +1 -1
- data/lib/mspire/mzml/source_file.rb +4 -4
- data/spec/mspire/molecular_formula_spec.rb +9 -0
- data/spec/mspire/mzml_spec.rb +14 -8
- data/spec/mspire/readme_spec.rb +117 -0
- data/spec/spec_helper.rb +17 -1
- data/spec/testfiles/mspire/mzml/j24z.idx_comp.3.NORMALIZED.CHECK.mzML +17 -7
- data/spec/testfiles/mspire/mzml/mspire_simulated.MSn.CHECK.mzML +1 -1
- metadata +4 -3
data/README.md
CHANGED
@@ -37,19 +37,120 @@ Mspire is the *only* converter from mzml into imzml.
|
|
37
37
|
|
38
38
|
## Examples
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
```ruby
|
41
|
+
mzml_file = "yourfile.mzML"
|
42
|
+
```
|
43
43
|
|
44
|
-
|
45
|
-
spectrum = mzml[0] # the first spectrum ( same as mzml.spectrum(0) )
|
46
|
-
spectrum = mzml["controllerType=0 controllerNumber=1 scan=2"] # query by id string
|
47
|
-
mzml.spectrum_from_scan_num(23) # raises ScanNumbersNotFound or ScanNumbersNotUnique errors if problems
|
48
|
-
end
|
44
|
+
### mzml
|
49
45
|
|
50
|
-
|
46
|
+
See Mspire::Mzml, Mspire::CV::Paramable, Mspire::Mzml::Spectrum and other
|
47
|
+
objects associated with Mzml files.
|
48
|
+
|
49
|
+
#### reading
|
51
50
|
|
52
|
-
|
51
|
+
```ruby
|
52
|
+
require 'mspire/mzml'
|
53
|
+
|
54
|
+
Mspire::Mzml.open(mzml_file) do |mzml|
|
55
|
+
|
56
|
+
# random access by index or id (even if file wasn't indexed)
|
57
|
+
spectrum = mzml[0]
|
58
|
+
spectrum = mzml["controllerType=0 controllerNumber=1 scan=2"]
|
59
|
+
|
60
|
+
spectrum.mzs
|
61
|
+
spectrum.intensities
|
62
|
+
|
63
|
+
# first 5 peaks
|
64
|
+
spectrum.peaks[0,5].each do |mz, intensity|
|
65
|
+
puts "#{mz} #{intensity}"
|
66
|
+
end
|
67
|
+
|
68
|
+
# true if key exists and no value, the value if present, or false
|
69
|
+
if spectrum.fetch_by_acc('MS:1000128')
|
70
|
+
puts "this is a profile spectrum!"
|
71
|
+
end
|
72
|
+
|
73
|
+
if spectrum.ms_level == 2
|
74
|
+
low_mz = spectrum.scan_list.first.scan_windows.first.fetch_by_acc("MS:1000501").to_i
|
75
|
+
puts "begin scan at #{low_mz} m/z"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
#### normalize spectra and write new mzML
|
81
|
+
|
82
|
+
See Mspire::Mzml for complete example building all objects from scratch.
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
require 'mspire/mzml'
|
86
|
+
|
87
|
+
Mspire::Mzml.open(mzml_file) do |mzml|
|
88
|
+
|
89
|
+
# MS:1000584 -> an mzML file
|
90
|
+
mzml.file_description.source_files << Mspire::Mzml::SourceFile[mzml_file].describe!('MS:1000584')
|
91
|
+
mspire = Mspire::Mzml::Software.new
|
92
|
+
mzml.software_list.push(mspire).uniq_by(&:id)
|
93
|
+
normalize_processing = Mspire::Mzml::DataProcessing.new("ms1_normalization") do |dp|
|
94
|
+
# 'MS:1001484' -> intensity normalization
|
95
|
+
dp.processing_methods << Mspire::Mzml::ProcessingMethod.new(mspire).describe!('MS:1001484')
|
96
|
+
end
|
97
|
+
|
98
|
+
mzml.data_processing_list << normalize_processing
|
99
|
+
|
100
|
+
spectra = mzml.map do |spectrum|
|
101
|
+
normalizer = 100.0 / spectrum.intensities.max
|
102
|
+
spectrum.intensities.map! {|i| i * normalizer }
|
103
|
+
spectrum
|
104
|
+
end
|
105
|
+
mzml.run.spectrum_list = Mspire::Mzml::SpectrumList.new(normalize_processing, spectra)
|
106
|
+
mzml.write(outfile)
|
107
|
+
end
|
108
|
+
```
|
109
|
+
### Masses
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
# very high precision NIST masses
|
113
|
+
aa_to_mass = Mspire::Mass::AA::MONO # a hash with residue masses
|
114
|
+
aa_to_mass['A'] # or access by symbol - Alanine
|
115
|
+
|
116
|
+
# elements
|
117
|
+
Mspire::Mass::MONO[:c] # carbon
|
118
|
+
Mspire::Mass::MONO[:e] # electron (includes other useful symbols)
|
119
|
+
```
|
120
|
+
|
121
|
+
### Isotopes and molecular formulas
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
require 'mspire/isotope'
|
125
|
+
isotopes = Mspire::Isotope::ISOTOPES # 288 isotopes
|
126
|
+
hydrogen_isotopes = isotopes.select {|iso| iso.element == :h }
|
127
|
+
|
128
|
+
c12 = Mspire::Isotope::BY_ELEMENT[:c].first
|
129
|
+
c12.atomic_number # also: mass_number atomic_mass relative_abundance average_mass
|
130
|
+
c12.mono # => true (this is the monoisotopic isotope)
|
131
|
+
|
132
|
+
require 'mspire/molecular_formula' # requires fftw gem
|
133
|
+
propane = Mspire::MolecularFormula['C3H8']
|
134
|
+
butane = propane + Mspire::MolecularFormula['CH2']
|
135
|
+
puts butane # => C4H10
|
136
|
+
|
137
|
+
require 'mspire/isotope/distribution' # requires fftw gem
|
138
|
+
puts butane.isotope_distribution # :total, :max, :first as arg to normalize
|
139
|
+
```
|
140
|
+
|
141
|
+
### Digestion
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
require 'mspire/digester'
|
145
|
+
trypsin = Mspire::Digester[:trypsin].
|
146
|
+
trypsin.digest("AACCKDDEERFFKPGG") # => ["AACCK", "DDEER", "FFKPGG"]
|
147
|
+
```
|
148
|
+
## TODO
|
149
|
+
|
150
|
+
* write the mzml index onto a file (along with correct SHA-1)
|
151
|
+
* implement spectrum unpack into an nmatrix or narray
|
152
|
+
* do a proper copy over of meta-data from mzml into imzml
|
153
|
+
* consider implementing params as a hash and formalizing more complete implementation agnostic params api
|
53
154
|
|
54
155
|
## Acronym
|
55
156
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.3
|
data/lib/core_ext/enumerable.rb
CHANGED
@@ -134,9 +134,14 @@ module Mspire
|
|
134
134
|
|
135
135
|
def to_s(alphabetize=true)
|
136
136
|
h = alphabetize ? self.sort : self
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
st = ''
|
138
|
+
h.each do |k,v|
|
139
|
+
if v > 0
|
140
|
+
st << k.to_s.capitalize
|
141
|
+
st << v.to_s if v > 1
|
142
|
+
end
|
143
|
+
end
|
144
|
+
st
|
140
145
|
end
|
141
146
|
|
142
147
|
def to_hash
|
data/lib/mspire/mzml.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
|
2
|
-
# TODO: trim down these require statements to only include upper level
|
3
2
|
require 'mspire'
|
4
3
|
require 'builder'
|
5
4
|
require 'core_ext/enumerable'
|
@@ -19,6 +18,23 @@ module Mspire
|
|
19
18
|
# spectrum.peaks do |mz,intensity|
|
20
19
|
# puts "mz: #{mz} intensity: #{intensity}"
|
21
20
|
# end
|
21
|
+
#
|
22
|
+
# spectrum.params # list all the params associated with an object
|
23
|
+
#
|
24
|
+
# # true if key exists and no value, the value if present, or false
|
25
|
+
# if spectrum.fetch_by_acc('MS:1000128')
|
26
|
+
# puts "this is a profile spectrum!"
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# if spectrum.ms_level == 2
|
30
|
+
# low_mz = spectrum.scan_list.first.scan_windows.first.to_i
|
31
|
+
# puts "begin scan at #{low_mz} m/z"
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# mzml.each_chromatogram do |chrm|
|
36
|
+
# chrm.times
|
37
|
+
# chrm.intensities
|
22
38
|
# end
|
23
39
|
# end
|
24
40
|
#
|
@@ -29,38 +45,68 @@ module Mspire
|
|
29
45
|
#
|
30
46
|
# Writing an mzml file from scratch:
|
31
47
|
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
48
|
+
# spec1 = Mspire::Mzml::Spectrum.new('scan=1') do |spec|
|
49
|
+
# # profile and ms_level 1
|
50
|
+
# spec.describe_many!(['MS:1000128', ['MS:1000511', 1]])
|
51
|
+
# spec.data_arrays = [
|
52
|
+
# Mspire::Mzml::DataArray[1,2,3].describe!('MS:1000514'),
|
53
|
+
# Mspire::Mzml::DataArray[4,5,6].describe!('MS:1000515')
|
54
|
+
# ]
|
55
|
+
# spec.scan_list = Mspire::Mzml::ScanList.new do |sl|
|
56
|
+
# scan = Mspire::Mzml::Scan.new do |scan|
|
57
|
+
# # retention time of 42 seconds
|
58
|
+
# scan.describe! 'MS:1000016', 40.0, 'UO:0000010'
|
59
|
+
# end
|
60
|
+
# sl << scan
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# spec2 = Mspire::Mzml::Spectrum.new('scan=2') do |spec|
|
65
|
+
# # centroid, ms_level 2, MSn spectrum,
|
66
|
+
# spec.describe_many!(['MS:1000127', ['MS:1000511', 2], "MS:1000580"])
|
67
|
+
# spec.data_arrays = [
|
68
|
+
# Mspire::Mzml::DataArray[1,2,3.5].describe!('MS:1000514'),
|
69
|
+
# Mspire::Mzml::DataArray[5,6,5].describe!('MS:1000515')
|
70
|
+
# ]
|
71
|
+
# spec.scan_list = Mspire::Mzml::ScanList.new do |sl|
|
72
|
+
# scan = Mspire::Mzml::Scan.new do |scan|
|
73
|
+
# # retention time of 42 seconds
|
74
|
+
# scan.describe! 'MS:1000016', 45.0, 'UO:0000010'
|
75
|
+
# end
|
76
|
+
# sl << scan
|
77
|
+
# end
|
78
|
+
# precursor = Mspire::Mzml::Precursor.new( spec1.id )
|
79
|
+
# si = Mspire::Mzml::SelectedIon.new
|
80
|
+
# # the selected ion m/z:
|
81
|
+
# si.describe! "MS:1000744", 2.0
|
82
|
+
# # the selected ion charge state
|
83
|
+
# si.describe! "MS:1000041", 2
|
84
|
+
# # the selected ion intensity
|
85
|
+
# si.describe! "MS:1000042", 5
|
86
|
+
# precursor.selected_ions = [si]
|
87
|
+
# spec.precursors = [precursor]
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# mzml = Mspire::Mzml.new do |mzml|
|
91
|
+
# mzml.id = 'ms1_and_ms2'
|
92
|
+
# mzml.cvs = Mspire::Mzml::CV::DEFAULT_CVS
|
93
|
+
# mzml.file_description = Mspire::Mzml::FileDescription.new do |fd|
|
94
|
+
# fd.file_content = Mspire::Mzml::FileContent.new
|
95
|
+
# fd.source_files << Mspire::Mzml::SourceFile.new
|
96
|
+
# end
|
97
|
+
# default_instrument_config = Mspire::Mzml::InstrumentConfiguration.new("IC").describe!('MS:1000031')
|
98
|
+
# mzml.instrument_configurations << default_instrument_config
|
99
|
+
# software = Mspire::Mzml::Software.new
|
100
|
+
# mzml.software_list << software
|
101
|
+
# default_data_processing = Mspire::Mzml::DataProcessing.new("did_nothing")
|
102
|
+
# mzml.data_processing_list << default_data_processing
|
103
|
+
# mzml.run = Mspire::Mzml::Run.new("little_run", default_instrument_config) do |run|
|
104
|
+
# spectrum_list = Mspire::Mzml::SpectrumList.new(default_data_processing, [spec1, spec2])
|
105
|
+
# run.spectrum_list = spectrum_list
|
106
|
+
# end
|
107
|
+
# end
|
108
|
+
#
|
109
|
+
# mzml.write("writtenxml.mzML")
|
64
110
|
class Mzml
|
65
111
|
include Enumerable # each_spectrum
|
66
112
|
|
@@ -20,7 +20,7 @@ module Mspire
|
|
20
20
|
# similar to an array but is really pulling objects by reading an io
|
21
21
|
# object. Sets the spectrum_list attribute of array_like if it can be
|
22
22
|
# set.
|
23
|
-
def initialize(default_data_processing, array_like, id_to_index=nil)
|
23
|
+
def initialize(default_data_processing, array_like=[], id_to_index=nil)
|
24
24
|
if array_like.respond_to?(:spectrum_list=)
|
25
25
|
array_like.spectrum_list = self
|
26
26
|
end
|
data/lib/mspire/mzml/software.rb
CHANGED
@@ -8,8 +8,6 @@ module Mspire
|
|
8
8
|
include Mspire::CV::Paramable
|
9
9
|
extend Mspire::Mzml::List
|
10
10
|
|
11
|
-
DEFAULT_SOURCEFILE_ID = 'sourcefile1'
|
12
|
-
|
13
11
|
# (required) An identifier for this file.
|
14
12
|
attr_accessor :id
|
15
13
|
# (required) Name of the source file, without reference to location
|
@@ -18,9 +16,11 @@ module Mspire
|
|
18
16
|
# (required) URI-formatted location where the file was retrieved.
|
19
17
|
attr_accessor :location
|
20
18
|
|
21
|
-
# expands the path and sets the name and location
|
19
|
+
# expands the path and sets the name and location. Sets the id to the
|
20
|
+
# basename.
|
22
21
|
def self.[](path, opts={})
|
23
|
-
|
22
|
+
(name, path) = uri_basename_and_path(path)
|
23
|
+
self.new(name, name, path)
|
24
24
|
end
|
25
25
|
|
26
26
|
# takes a filename (with a relative or expanded path) and returns the
|
@@ -33,6 +33,15 @@ describe Mspire::MolecularFormula do
|
|
33
33
|
Mspire::MolecularFormula['Ni7SE3'].to_hash.should == {:ni=>7, :s=>1, :e=>3}
|
34
34
|
end
|
35
35
|
|
36
|
+
describe 'correct to_s' do
|
37
|
+
subject {
|
38
|
+
Mspire::MolecularFormula.new({:c=>669, :h=>1129, :o=>185, :n=>215, :s=>4, :p=>0, :se=>0})
|
39
|
+
}
|
40
|
+
it 'to_s gives output' do
|
41
|
+
subject.to_s.should == "C669H1129N215O185S4"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
36
45
|
describe 'conversion' do
|
37
46
|
|
38
47
|
subject {
|
data/spec/mspire/mzml_spec.rb
CHANGED
@@ -62,22 +62,28 @@ describe Mspire::Mzml do
|
|
62
62
|
@file = TESTFILES + "/mspire/mzml/j24z.idx_comp.3.mzML"
|
63
63
|
end
|
64
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
65
|
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
66
|
outfile = TESTFILES + "/mspire/mzml/j24z.idx_comp.3.NORMALIZED.mzML"
|
67
|
+
|
74
68
|
Mspire::Mzml.open(@file) do |mzml|
|
69
|
+
|
70
|
+
# MS:1000584 -> an mzML file
|
71
|
+
mzml.file_description.source_files << Mspire::Mzml::SourceFile[@file].describe!('MS:1000584')
|
72
|
+
mspire = Mspire::Mzml::Software.new
|
73
|
+
mzml.software_list.push(mspire).uniq_by(&:id)
|
74
|
+
normalize_processing = Mspire::Mzml::DataProcessing.new("ms1_normalization") do |dp|
|
75
|
+
# 'MS:1001484' -> intensity normalization
|
76
|
+
dp.processing_methods << Mspire::Mzml::ProcessingMethod.new(mspire).describe!('MS:1001484')
|
77
|
+
end
|
78
|
+
|
79
|
+
mzml.data_processing_list << normalize_processing
|
80
|
+
|
75
81
|
spectra = mzml.map do |spectrum|
|
76
82
|
normalizer = 100.0 / spectrum.intensities.max
|
77
83
|
spectrum.intensities.map! {|i| i * normalizer }
|
78
84
|
spectrum
|
79
85
|
end
|
80
|
-
mzml.run.spectrum_list = Mspire::Mzml::SpectrumList.new(
|
86
|
+
mzml.run.spectrum_list = Mspire::Mzml::SpectrumList.new(normalize_processing, spectra)
|
81
87
|
mzml.write(outfile)
|
82
88
|
end
|
83
89
|
# this output was checked to be accurate with TOPPView
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# we aren't testing for preciseness in these examples (that is done
|
4
|
+
# elsewhere), but we are verifying that it runs with no errors (i.e., the
|
5
|
+
# syntax and api is all current)
|
6
|
+
|
7
|
+
describe 'performing what is on the readme' do
|
8
|
+
describe 'mzml' do
|
9
|
+
let(:mzml_file) { TESTFILES + "/mspire/mzml/j24z.idx_comp.3.mzML" }
|
10
|
+
let(:outfile) { TESTFILES + "/mspire/mzml/j24z.idx_comp.3.NORMALIZED.mzML" }
|
11
|
+
|
12
|
+
specify "reading an mzml file" do
|
13
|
+
|
14
|
+
reply = capture_stdout do
|
15
|
+
|
16
|
+
require 'mspire/mzml'
|
17
|
+
|
18
|
+
Mspire::Mzml.open(mzml_file) do |mzml|
|
19
|
+
|
20
|
+
# random access by index or id (even if file wasn't indexed)
|
21
|
+
spectrum = mzml[0]
|
22
|
+
spectrum = mzml["controllerType=0 controllerNumber=1 scan=2"]
|
23
|
+
|
24
|
+
spectrum.mzs
|
25
|
+
spectrum.intensities
|
26
|
+
|
27
|
+
# first 5 peaks
|
28
|
+
spectrum.peaks[0,5].each do |mz, intensity|
|
29
|
+
puts "#{mz} #{intensity}"
|
30
|
+
end
|
31
|
+
|
32
|
+
# true if key exists and no value, the value if present, or false
|
33
|
+
if spectrum.fetch_by_acc('MS:1000128')
|
34
|
+
puts "this is a profile spectrum!"
|
35
|
+
end
|
36
|
+
|
37
|
+
if spectrum.ms_level == 2
|
38
|
+
low_mz = spectrum.scan_list.first.scan_windows.first.fetch_by_acc("MS:1000501").to_i
|
39
|
+
puts "begin scan at #{low_mz} m/z"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
reply.each_line.map.to_a.size.should == 6
|
45
|
+
reply.include?('begin scan at 120').should be_true
|
46
|
+
end
|
47
|
+
|
48
|
+
specify "normalizing and writing an mzml file" do
|
49
|
+
require 'mspire/mzml'
|
50
|
+
|
51
|
+
Mspire::Mzml.open(mzml_file) do |mzml|
|
52
|
+
|
53
|
+
# MS:1000584 -> an mzML file
|
54
|
+
mzml.file_description.source_files << Mspire::Mzml::SourceFile[mzml_file].describe!('MS:1000584')
|
55
|
+
mspire = Mspire::Mzml::Software.new
|
56
|
+
mzml.software_list.push(mspire).uniq_by(&:id)
|
57
|
+
normalize_processing = Mspire::Mzml::DataProcessing.new("ms1_normalization") do |dp|
|
58
|
+
# 'MS:1001484' -> intensity normalization
|
59
|
+
dp.processing_methods << Mspire::Mzml::ProcessingMethod.new(mspire).describe!('MS:1001484')
|
60
|
+
end
|
61
|
+
|
62
|
+
mzml.data_processing_list << normalize_processing
|
63
|
+
|
64
|
+
spectra = mzml.map do |spectrum|
|
65
|
+
normalizer = 100.0 / spectrum.intensities.max
|
66
|
+
spectrum.intensities.map! {|i| i * normalizer }
|
67
|
+
spectrum
|
68
|
+
end
|
69
|
+
mzml.run.spectrum_list = Mspire::Mzml::SpectrumList.new(normalize_processing, spectra)
|
70
|
+
mzml.write(outfile)
|
71
|
+
end
|
72
|
+
file_check(outfile)
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
specify 'masses' do
|
78
|
+
require 'mspire/mass/aa'
|
79
|
+
|
80
|
+
# very high precision NIST masses
|
81
|
+
aa_to_mass = Mspire::Mass::AA::MONO # a hash with residue masses
|
82
|
+
aa_to_mass['A'] # or access by symbol - Alanine
|
83
|
+
|
84
|
+
# elements
|
85
|
+
Mspire::Mass::MONO[:c] # carbon
|
86
|
+
Mspire::Mass::MONO[:e] # electron (includes other useful symbols)
|
87
|
+
end
|
88
|
+
|
89
|
+
specify 'isotopes and molecular formulas' do
|
90
|
+
reply = capture_stdout do
|
91
|
+
|
92
|
+
require 'mspire/isotope'
|
93
|
+
isotopes = Mspire::Isotope::ISOTOPES # 288 isotopes
|
94
|
+
hydrogen_isotopes = isotopes.select {|iso| iso.element == :h }
|
95
|
+
|
96
|
+
c12 = Mspire::Isotope::BY_ELEMENT[:c].first
|
97
|
+
c12.atomic_number # also: mass_number atomic_mass relative_abundance average_mass
|
98
|
+
c12.mono # => true (this is the monoisotopic isotope)
|
99
|
+
|
100
|
+
require 'mspire/molecular_formula' # requires fftw gem
|
101
|
+
propane = Mspire::MolecularFormula['C3H8']
|
102
|
+
butane = propane + Mspire::MolecularFormula['CH2']
|
103
|
+
puts butane # => C4H10
|
104
|
+
|
105
|
+
require 'mspire/isotope/distribution' # requires fftw gem
|
106
|
+
puts butane.isotope_distribution # :total, :max, :first as arg to normalize
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
specify 'digestion' do
|
111
|
+
reply = capture_stdout do
|
112
|
+
require 'mspire/digester'
|
113
|
+
trypsin = Mspire::Digester[:trypsin]
|
114
|
+
p trypsin.digest("AACCKDDEERFFKPGG") # => ["AACCK", "DDEER", "FFKPGG"]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -44,5 +44,21 @@ def file_check(filename, delete=true, &block)
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def sanitize_mspire_version_xml(string)
|
47
|
-
string.gsub(/"mspire" version="([\.\d]+)"/, %Q{"mspire" version="X.X.X"})
|
47
|
+
string.gsub(/"mspire(_[\d\.]+)?" version="([\.\d]+)"/, %Q{"mspire" version="X.X.X"})
|
48
48
|
end
|
49
|
+
|
50
|
+
require 'stringio'
|
51
|
+
|
52
|
+
module Kernel
|
53
|
+
|
54
|
+
def capture_stdout
|
55
|
+
out = StringIO.new
|
56
|
+
$stdout = out
|
57
|
+
yield
|
58
|
+
out.string
|
59
|
+
ensure
|
60
|
+
$stdout = STDOUT
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
@@ -9,12 +9,15 @@
|
|
9
9
|
<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
|
10
10
|
<cvParam cvRef="MS" accession="MS:1000580" name="MSn spectrum"/>
|
11
11
|
</fileContent>
|
12
|
-
<sourceFileList count="
|
12
|
+
<sourceFileList count="2">
|
13
13
|
<sourceFile id="RAW1" name="j24.raw" location="file://.">
|
14
14
|
<cvParam cvRef="MS" accession="MS:1000768" name="Thermo nativeID format"/>
|
15
15
|
<cvParam cvRef="MS" accession="MS:1000563" name="Thermo RAW file"/>
|
16
16
|
<cvParam cvRef="MS" accession="MS:1000569" name="SHA-1" value="6023d121fb6ca7f19fada3b6c5e4d5da09c95f12"/>
|
17
17
|
</sourceFile>
|
18
|
+
<sourceFile id="j24z.idx_comp.3.mzML" name="j24z.idx_comp.3.mzML" location="file:///home/jtprince/dev/mspire/spec/testfiles/mspire/mzml">
|
19
|
+
<cvParam cvRef="MS" accession="MS:1000584" name="mzML file"/>
|
20
|
+
</sourceFile>
|
18
21
|
</sourceFileList>
|
19
22
|
</fileDescription>
|
20
23
|
<referenceableParamGroupList count="1">
|
@@ -23,13 +26,15 @@
|
|
23
26
|
<cvParam cvRef="MS" accession="MS:1000529" name="instrument serial number" value="SN1025B"/>
|
24
27
|
</referenceableParamGroup>
|
25
28
|
</referenceableParamGroupList>
|
26
|
-
<softwareList count="
|
29
|
+
<softwareList count="3">
|
27
30
|
<software id="Xcalibur" version="2.4 SP1">
|
28
31
|
<cvParam cvRef="MS" accession="MS:1000532" name="Xcalibur"/>
|
29
32
|
</software>
|
30
33
|
<software id="pwiz" version="2.1.2086">
|
31
34
|
<cvParam cvRef="MS" accession="MS:1000615" name="ProteoWizard"/>
|
32
35
|
</software>
|
36
|
+
<software id="mspire_0.8.2" version="0.8.2">
|
37
|
+
</software>
|
33
38
|
</softwareList>
|
34
39
|
<instrumentConfigurationList count="2">
|
35
40
|
<instrumentConfiguration id="IC1">
|
@@ -65,16 +70,21 @@
|
|
65
70
|
<softwareRef ref="Xcalibur"/>
|
66
71
|
</instrumentConfiguration>
|
67
72
|
</instrumentConfigurationList>
|
68
|
-
<dataProcessingList count="
|
73
|
+
<dataProcessingList count="2">
|
69
74
|
<dataProcessing id="pwiz_Reader_Thermo_conversion">
|
70
75
|
<processingMethod order="0" softwareRef="pwiz">
|
71
76
|
<cvParam cvRef="MS" accession="MS:1000544" name="Conversion to mzML"/>
|
72
77
|
</processingMethod>
|
73
78
|
</dataProcessing>
|
79
|
+
<dataProcessing id="ms1_normalization">
|
80
|
+
<processingMethod order="0" softwareRef="mspire_0.8.2">
|
81
|
+
<cvParam cvRef="MS" accession="MS:1001484" name="intensity normalization"/>
|
82
|
+
</processingMethod>
|
83
|
+
</dataProcessing>
|
74
84
|
</dataProcessingList>
|
75
85
|
<run id="j24" defaultInstrumentConfigurationRef="IC1" defaultSourceFileRef="RAW1" startTimeStamp="2010-07-08T11:34:52Z">
|
76
|
-
<spectrumList count="3" defaultDataProcessingRef="
|
77
|
-
<spectrum index="0" id="controllerType=0 controllerNumber=1 scan=1" defaultArrayLength="20168">
|
86
|
+
<spectrumList count="3" defaultDataProcessingRef="ms1_normalization">
|
87
|
+
<spectrum index="0" id="controllerType=0 controllerNumber=1 scan=1" defaultArrayLength="20168" dataProcessingRef="pwiz_Reader_Thermo_conversion">
|
78
88
|
<cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
|
79
89
|
<cvParam cvRef="MS" accession="MS:1000579" name="MS1 spectrum"/>
|
80
90
|
<cvParam cvRef="MS" accession="MS:1000130" name="positive scan"/>
|
@@ -113,7 +123,7 @@
|
|
113
123
|
</binaryDataArray>
|
114
124
|
</binaryDataArrayList>
|
115
125
|
</spectrum>
|
116
|
-
<spectrum index="1" id="controllerType=0 controllerNumber=1 scan=2" defaultArrayLength="315">
|
126
|
+
<spectrum index="1" id="controllerType=0 controllerNumber=1 scan=2" defaultArrayLength="315" dataProcessingRef="pwiz_Reader_Thermo_conversion">
|
117
127
|
<cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="2"/>
|
118
128
|
<cvParam cvRef="MS" accession="MS:1000580" name="MSn spectrum"/>
|
119
129
|
<cvParam cvRef="MS" accession="MS:1000130" name="positive scan"/>
|
@@ -173,7 +183,7 @@
|
|
173
183
|
</binaryDataArray>
|
174
184
|
</binaryDataArrayList>
|
175
185
|
</spectrum>
|
176
|
-
<spectrum index="2" id="controllerType=0 controllerNumber=1 scan=3" defaultArrayLength="634">
|
186
|
+
<spectrum index="2" id="controllerType=0 controllerNumber=1 scan=3" defaultArrayLength="634" dataProcessingRef="pwiz_Reader_Thermo_conversion">
|
177
187
|
<cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="2"/>
|
178
188
|
<cvParam cvRef="MS" accession="MS:1000580" name="MSn spectrum"/>
|
179
189
|
<cvParam cvRef="MS" accession="MS:1000130" name="positive scan"/>
|
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.8.
|
4
|
+
version: 0.8.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -342,6 +342,7 @@ files:
|
|
342
342
|
- spec/mspire/peaklist_spec.rb
|
343
343
|
- spec/mspire/plms1_spec.rb
|
344
344
|
- spec/mspire/quant/qspec_spec.rb
|
345
|
+
- spec/mspire/readme_spec.rb
|
345
346
|
- spec/mspire/spectrum_spec.rb
|
346
347
|
- spec/mspire/user_param_spec.rb
|
347
348
|
- spec/mspire_spec.rb
|
@@ -402,7 +403,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
402
403
|
version: '0'
|
403
404
|
requirements: []
|
404
405
|
rubyforge_project:
|
405
|
-
rubygems_version: 1.8.
|
406
|
+
rubygems_version: 1.8.23
|
406
407
|
signing_key:
|
407
408
|
specification_version: 3
|
408
409
|
summary: mass spectrometry proteomics, lipidomics, and tools
|