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
64
65
|
# File 'lib/protk/mzml_parser.rb', line 32
def spectrum_as_hash(spectrum)
index=spectrum.attributes['index']
sid = spectrum.attributes['id']
precursor_mz_param = spectrum.find(".//#{@mzml_ns_prefix}cvParam[@accession=\"MS:1000744\"]",@mzml_ns)[0]
mslevel_param = spectrum.find("./#{@mzml_ns_prefix}cvParam[@accession=\"MS:1000511\"]",@mzml_ns)[0]
title_param = spectrum.find("./#{@mzml_ns_prefix}cvParam[@accession=\"MS:1000796\"]",@mzml_ns)[0]
precursor_mz_mz = precursor_mz_param.attributes['value'] if precursor_mz_param
mslevel = mslevel_param.attributes['value'] if mslevel_param
spectrum_title = title_param['value'] if title_param
data_arrays = spectrum.find("./#{@mzml_ns_prefix}binaryDataArrayList/#{@mzml_ns_prefix}binaryDataArray",@mzml_ns)
data={}
data_arrays.each do |arr|
the_data = arr.find("./#{@mzml_ns_prefix}binary",@mzml_ns)[0].content
mzaccession = arr.find("./#{@mzml_ns_prefix}cvParam[@accession=\"MS:1000514\"]",@mzml_ns)
if ( mzaccession.length==1 )
data[:mz] = the_data
else
data[:intensity] = the_data
end
end
data[:title]=spectrum_title
data[:mzlevel]=mslevel
data[:index]=index
data[:precursormz]=precursor_mz_mz
data[:id]=sid
data
end
|