mspire-simulator 0.2.1 → 0.3.0

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/lib/ms/noise.rb CHANGED
@@ -7,7 +7,7 @@ module MS
7
7
  module_function
8
8
  def noiseify(opts,max_mz)
9
9
  # spectra is {rt => [[mzs],[ints]]}
10
- desity = opts[:noise_density]
10
+ density = opts[:noise_density]
11
11
  max_int = opts[:noiseMaxInt]
12
12
  min_int = opts[:noiseMinInt]
13
13
  @noise = {}
@@ -10,49 +10,56 @@ module MS
10
10
  module Rtgenerator
11
11
 
12
12
  module_function
13
- def generateRT(peptides, one_d)
14
-
13
+ def generateRT(one_d,db)
14
+ prog = Progress.new("Generating retention times:")
15
15
  @r_times = Sim_Spectra.r_times
16
16
 
17
17
  # Gets retention times from the weka model
18
- peptides = MS::Weka.predict_rts(peptides)
19
- MS::Weka.predict_ints(peptides)
18
+ MS::Weka.predict_rts(db)
19
+ MS::Weka.predict_ints(db)
20
20
 
21
21
 
22
22
  #-----------------------------------------------------------------
23
- prog = Progress.new("Generating retention times:")
24
23
  num = 0
25
- total = peptides.size
26
- step = total/100.0
27
24
 
28
25
  max_rt = 4*(@r_times.max/5)
29
26
  r_end = max_rt + (@r_times.max/5)/2
30
27
  r_start = @r_times.max/5
31
-
32
- peptides.each_with_index do |pep,ind|
33
- if ind > step * (num + 1)
34
- num = (((ind+1)/total.to_f)*100).to_i
35
- prog.update(num)
36
- end
28
+ peps = db.execute "SELECT Id,p_rt,abu,seq FROM peptides"
29
+ total = peps.size
30
+ step = total/100.0
31
+ peps.each do |pep|
32
+ ind = pep.delete_at(0)
33
+ init_p_rt = pep[0]
34
+ abu = pep[1]
35
+ seq = pep[2]
36
+ pep_p_rt = nil
37
+ pep_p_rt_i = nil
38
+ if ind > step * (num + 1)
39
+ num = (((ind+1)/total.to_f)*100).to_i
40
+ prog.update(num)
41
+ end
37
42
 
38
43
 
39
44
  #Fit retention times into scan times
40
- p_rt = pep.p_rt * 10**-2
41
- percent_time = p_rt
42
- sx = RThelper.gaussian(percent_time,0.5,0.45,1.0) * Math.sqrt(pep.abu) #need to figure out what these values should be
43
- pep.sx = sx
45
+ p_rt = init_p_rt * 10**-2
46
+ percent_time = p_rt
47
+ sx = RThelper.gaussian(percent_time,0.5,0.45,1.0) * Math.sqrt(abu) #need to figure out what these values should be
44
48
 
45
49
 
46
50
  if p_rt > 1
47
- pep.p_rt = @r_times.find {|i| i >= r_end}
48
- pep.p_rt_i = @r_times.index(pep.p_rt)
51
+ pep_p_rt = @r_times.find {|i| i >= r_end}
52
+ pep_p_rt_i = @r_times.index(pep_p_rt)
49
53
  else
50
- pep.p_rt = @r_times.find {|i| i >= (p_rt * max_rt)}
51
- pep.p_rt_i = @r_times.index(pep.p_rt)
54
+ pep_p_rt = @r_times.find {|i| i >= (p_rt * max_rt)}
55
+ pep_p_rt_i = @r_times.index(pep_p_rt)
52
56
  end
57
+
58
+ a = nil
59
+ b = nil
53
60
 
54
- if pep.p_rt == nil
55
- puts "\n\n\t#{pep} TIME-> #{p_rt*max_rt} :: Peptide not predicted in time range: try increasing run time\n\n."
61
+ if pep_p_rt == nil
62
+ puts "\n\n\t#{seq} TIME-> #{p_rt*max_rt} :: Peptide not predicted in time range: try increasing run time\n\n."
56
63
  else
57
64
 
58
65
  #Give peptide retention times
@@ -66,8 +73,8 @@ module MS
66
73
  tail_length = 300 * sx
67
74
  end
68
75
 
69
- a = @r_times.find {|i| i >= (pep.p_rt-head_length)}
70
- b = @r_times.find {|i| i >= (pep.p_rt+tail_length)}
76
+ a = @r_times.find {|i| i >= (pep_p_rt-head_length)}
77
+ b = @r_times.find {|i| i >= (pep_p_rt+tail_length)}
71
78
  a = @r_times.index(a)
72
79
  b = @r_times.index(b)
73
80
 
@@ -79,15 +86,11 @@ module MS
79
86
  b = @r_times[@r_times.length-1]
80
87
  end
81
88
 
82
- pep.set_rts(a,b)
83
-
84
89
  end
90
+ db.execute "UPDATE peptides SET p_rt=#{pep_p_rt},p_rt_index=#{pep_p_rt_i},sx=#{sx},rt_a=#{a},rt_b=#{b} WHERE Id='#{ind}'"
85
91
  end
86
92
  #-----------------------------------------------------------------
87
93
  prog.finish!
88
-
89
- return peptides
90
-
91
94
  end
92
95
  end
93
96
  end
data/lib/ms/rt/weka.rb CHANGED
@@ -5,13 +5,16 @@ module MS
5
5
  module Weka
6
6
  #James Dalg
7
7
  module_function
8
- def predict_rts(peptides)
8
+ def predict_rts(db)
9
9
  #mz,charge,intensity,rt,A,R,N,D,B,C,E,Q,Z,G,H,I,L,K,M,F,P,S,T,W,Y,V,J,mass,hydro,pi
10
10
  #make arrf file to feed weka model
11
11
  data = []
12
- peptides.each do |pep|
13
- data<<pep.aa_counts
12
+ rs = db.execute "SELECT * FROM aac"
13
+ rs.each do |row|
14
+ row.delete_at(0)
15
+ data<<row
14
16
  end
17
+
15
18
  arff = make_rt_arff(Time.now.nsec.to_s,data)
16
19
 
17
20
  path = Gem.bin_path('mspire-simulator', 'mspire-simulator').split(/\//)
@@ -24,23 +27,24 @@ module MS
24
27
  count = 0
25
28
  while line = file.gets
26
29
  if line =~ /(\d*\.\d{0,3}){1}/
27
- peptides[count].p_rt = line.match(/(\d*\.\d{0,3}){1}/)[0].to_f
30
+ p_rt = line.match(/(\d*\.\d{0,3}){1}/)[0].to_f
31
+ db.execute "UPDATE peptides SET p_rt=#{p_rt} WHERE Id='#{count}'"
28
32
  count += 1
29
33
  end
30
34
  end
31
35
  system("rm #{arff}.out")
32
- return peptides
33
36
  end
34
37
 
35
38
 
36
39
 
37
- def predict_ints(peptides)
40
+ def predict_ints(db)
38
41
  data = []
39
- peptides.each do |pep|
40
- array = []
41
- array<<pep.mono_mz<<pep.charge<<pep.mass<<pep.p_rt
42
- data << array.concat(pep.aa_counts)
42
+ aas = "A,R,N,D,B,C,E,Q,Z,G,H,I,L,K,M,F,P,S,T,W,Y,V,J,place_holder"
43
+ rs = db.execute "SELECT mono_mz, charge, mass, p_rt,#{aas} FROM peptides NATURAL JOIN aac" #JOIN aac
44
+ rs.each do |row|
45
+ data<<row
43
46
  end
47
+
44
48
  arff = make_int_arff(Time.now.nsec.to_s,data)
45
49
 
46
50
  path = Gem.bin_path('mspire-simulator', 'mspire-simulator').split(/\//)
@@ -53,12 +57,12 @@ module MS
53
57
  count = 0
54
58
  while line = file.gets
55
59
  if line =~ /(\d*\.\d{0,3}){1}/
56
- peptides[count].p_int = line.match(/(\d*\.\d{0,3}){1}/)[0].to_f
60
+ p_int = line.match(/(\d*\.\d{0,3}){1}/)[0].to_f
61
+ db.execute "UPDATE peptides SET p_int=#{p_int} WHERE Id='#{count}'"
57
62
  count += 1
58
63
  end
59
64
  end
60
65
  system("rm #{arff}.out")
61
- return peptides
62
66
  end
63
67
 
64
68
 
@@ -1,34 +1,32 @@
1
+
2
+ require 'obo/ontology'
3
+
1
4
  class String
2
- abu = 0
3
- attr_reader :abu
4
- attr_writer :abu
5
+ attr_reader :abu, :prot_id
6
+ attr_writer :abu, :prot_id
5
7
  end
6
8
 
7
9
  module MS
8
10
  class Sim_Digester
9
11
 
10
- attr_reader :digested_file
11
- attr_writer :digested_file
12
-
13
- def initialize(digestor,pH)
14
- @digestor = digestor
15
- @pH = pH
16
- @digested_file = ".#{Time.now.nsec.to_s}"
17
- system("mkdir .m .i")
18
- system("mkdir .m/A .m/R .m/N .m/D .m/C .m/E .m/Q .m/G .m/H .m/I .m/L .m/K .m/M .m/F .m/P .m/S .m/T .m/W .m/Y .m/V .m/U .m/O")
19
- system("mkdir .i/A .i/R .i/N .i/D .i/C .i/E .i/Q .i/G .i/H .i/I .i/L .i/K .i/M .i/F .i/P .i/S .i/T .i/W .i/Y .i/V .i/U .i/O")
12
+ def initialize(opts,db)
13
+ @db = db
14
+ @db.execute "CREATE TABLE IF NOT EXISTS digested(prot_id INTEGER PRIMARY KEY,header TEXT, abu REAL, sequence TEXT, peptides TEXT)"
15
+ @digestor = opts[:digestor]
16
+ @pH = opts[:pH]
17
+ @missed_cleavages = opts[:missed_cleavages]
18
+ @modifications = Modifications.new(opts[:modifications]).modifications
19
+ @digested = nil
20
20
  end
21
21
 
22
- def clean
23
- system("rm -r -f .m .i")
24
- end
25
-
26
- def create_digested_file(file)
22
+ def create_digested(file)
27
23
  abundances = []
24
+ headers = []
28
25
  inFile = File.open(file,"r")
29
26
  seq = ""
30
27
  inFile.each_line do |sequence|
31
28
  if sequence =~ />/
29
+ headers<<sequence
32
30
  num = sequence.match(/\#.+/).to_s.chomp.gsub('#','')
33
31
  if num != ""
34
32
  abundances<<(num.to_f)*10.0**-2
@@ -38,7 +36,7 @@ module MS
38
36
  sequence
39
37
  seq = seq<<";"
40
38
  elsif sequence == "/n"; else
41
- seq = seq<<sequence.chomp
39
+ seq = seq<<sequence.chomp.upcase
42
40
  end
43
41
  end
44
42
  inFile.close
@@ -47,72 +45,49 @@ module MS
47
45
 
48
46
  trypsin = Mspire::Digester[@digestor]
49
47
 
50
- digested = []
51
- d_file = File.open(@digested_file, "w")
48
+ @digested = []
52
49
  proteins.each_with_index do |prot,index|
53
- dig = trypsin.digest(prot)
50
+ dig = trypsin.digest(prot,@missed_cleavages) # two missed cleavages for fig 6
51
+ @db.execute "INSERT INTO digested(header,abu,sequence,peptides) VALUES(\"#{headers[index]}\",#{abundances[index]},\"#{prot}\",'#{dig}')"
54
52
  dig.each do |d|
55
53
  d.abu = abundances[index]
56
- digested<<d
54
+ d.prot_id = index
55
+ @digested<<d
57
56
  end
58
57
  end
59
58
  proteins.clear
60
- digested.uniq!
61
-
62
- trun_digested = []
63
- if digested.length > 50000
64
- 50000.times do
65
- trun_digested<<digested[rand(digested.length)]
66
- end
67
- digested.clear
68
- digested = trun_digested
69
- end
70
-
71
- digested.each do |dig|
72
- d_file.puts(dig<<"#"<<dig.abu.to_s)
73
- end
74
- d_file.close
75
- num_digested = digested.size
76
- digested.clear
59
+ dige = @digested.uniq!
60
+
61
+ num_digested = @digested.size
77
62
  puts "Number of peptides: #{num_digested}"
78
- return num_digested
79
63
  end
80
64
 
81
65
  def digest(file)
82
- num_digested = create_digested_file(file)
66
+ prog = Progress.new("Creating peptides '#{file}':")
67
+ create_digested(file)
83
68
 
84
- d_file = File.open(@digested_file, "r")
85
69
  i = 0
86
-
87
- peptides = []
88
-
89
- prog = Progress.new("Creating peptides '#{file}':")
70
+ count = 0
90
71
  num = 0
91
- total = num_digested
72
+ total = @digested.size
92
73
  step = total/100.0
93
- d_file.each_line do |peptide_seq|
94
- peptide_seq.chomp!
95
- peptide_seq.abu = peptide_seq.match(/#.+/).to_s.chomp.gsub('#','').to_f
96
- peptide_seq.gsub!(/#.+/,'')
97
- if i > step * (num + 1)
98
- num = ((i/total.to_f)*100.0).to_i
74
+ @digested.each do |peptide_seq|
75
+ if count > step * (num + 1)
76
+ num = ((count/total.to_f)*100.0).to_i
99
77
  prog.update(num)
100
78
  end
101
79
 
102
80
  charge_ratio = charge_at_pH(identify_potential_charges(peptide_seq), @pH)
103
81
  charge_f = charge_ratio.floor
104
82
  charge_c = charge_ratio.ceil
105
- peptide_f = MS::Peptide.new(peptide_seq, charge_f, peptide_seq.abu) if charge_f != 0
106
- peptide_c = MS::Peptide.new(peptide_seq, charge_c, peptide_seq.abu) if charge_c != 0
83
+ peptide_f = MS::Peptide.new(peptide_seq, charge_f, peptide_seq.abu,@db,i,peptide_seq.prot_id,@modifications) if charge_f != 0
84
+ i += 1 if charge_f != 0
85
+ peptide_c = MS::Peptide.new(peptide_seq, charge_c, peptide_seq.abu,@db,i,peptide_seq.prot_id,@modifications) if charge_c != 0
86
+ i += 1 if charge_c != 0
107
87
 
108
- peptides<<peptide_f if charge_f != 0
109
- peptides<<peptide_c if charge_c != 0
110
- i += 1
88
+ count += 1
111
89
  end
112
90
  prog.finish!
113
- d_file.close
114
- File.delete(@digested_file)
115
- return peptides
116
91
  end
117
92
  end
118
93
  end
@@ -5,20 +5,11 @@ require 'ms/sim_peptide'
5
5
  require 'ms/rt/rt_helper'
6
6
  require 'ms/tr_file_writer'
7
7
 
8
- class Array
9
- attr_reader :ms2, :ms_level, :pre_mz, :pre_int, :pre_charge
10
- attr_writer :ms2, :ms_level, :pre_mz, :pre_int, :pre_charge
11
- end
12
-
13
8
  module MS
14
9
  class Sim_Feature
15
- def initialize(peptides,opts,one_d)
16
-
17
- @features = []
18
- @data = {}
19
- @max_int = 0.0
10
+ def initialize(opts,one_d,db)
11
+ @db = db
20
12
  @one_d = one_d
21
- @max_time = Sim_Spectra.r_times.max
22
13
  @opts = opts
23
14
  @max_mz = -1
24
15
 
@@ -26,113 +17,25 @@ module MS
26
17
  #------------------Each_Peptide_=>_Feature----------------------
27
18
  prog = Progress.new("Generating features:")
28
19
  num = 0
29
- total = peptides.size
20
+ @db.execute "CREATE TABLE IF NOT EXISTS spectra(cent_id INTEGER PRIMARY KEY,pep_id INTEGER,rt REAL,mzs REAL,ints REAL,merge_id INTEGER)"
21
+ @cent_id = 0
22
+ peps = @db.execute "SELECT * FROM peptides"
23
+ total = peps.size
30
24
  step = total/100.0
31
- peptides.each_with_index do |pep,ind|
25
+ peps.each do |pep|
26
+ ind = pep[0]
32
27
  if ind > step * (num + 1)
33
28
  num = (((ind+1)/total.to_f)*100).to_i
34
29
  prog.update(num)
35
30
  end
36
-
37
- feature = getInts(pep)
38
-
39
- @features<<feature
31
+
32
+ getInts(pep)
40
33
  end
41
34
  prog.finish!
42
- #---------------------------------------------------------------
43
-
44
-
45
-
46
- #-----------------Transform_to_spectra_data_for_mzml------------
47
- # rt => [[mzs],[ints]]
48
- prog = Progress.new("Generating MS2 & Populating structure for mzml:")
49
- num = 0
50
- total = @features.size
51
- step = total/100.0
52
- ms2_count = 0
53
- seq = nil
54
-
55
- @features.each_with_index do |fe,k|
56
- if k > step * (num + 1)
57
- num = ((k/total.to_f)*100).to_i
58
- prog.update(num)
59
- end
60
-
61
- fe_ints = fe.ints
62
- fe_mzs = fe.mzs
63
-
64
- ms2_int = fe.ints.flatten.max
65
- ms2 = false
66
- pre_mz = nil
67
- pre_charge = nil
68
-
69
- fe.rts.each_with_index do |rt,i|
70
- rt_mzs = []
71
- rt_ints = []
72
-
73
- fe.core_mzs.size.times do |j|
74
- mz,int = [ fe_mzs[j][i], fe_ints[j][i] ]
75
- if @max_mz < mz
76
- @max_mz = mz
77
- end
78
- if int == nil
79
- int = 0.0
80
- end
81
- if int > 0.9
82
- rt_mzs<<mz
83
- rt_ints<<int
84
- if int == ms2_int and fe.sequence.size > 1
85
- ms2 = true
86
- pre_mz = mz
87
- pre_charge = fe.charge
88
- end
89
- end
90
- end
91
-
92
- spec = nil
93
- if rt_mzs.include?(nil) or rt_mzs.empty?; else
94
- if @data.key?(rt)
95
- ms1 = @data[rt]
96
- spec = [ms1[0] + rt_mzs, ms1[1] + rt_ints]
97
- spec.ms_level = ms1.ms_level
98
- spec.ms2 = ms1.ms2
99
- else
100
- spec = [rt_mzs, rt_ints]
101
- end
102
- if false#ms2 and fe.sequence != seq
103
- #add ms2 spec
104
- seq = fe.sequence
105
- spec.ms_level = 2
106
- ms2_mzs = MS::Fragmenter.new.fragment(seq)
107
- ms2_ints = Array.new(ms2_mzs.size,500.to_f)
108
- spec2 = [(rt + RThelper.RandomFloat(0.01,@opts[:sampling_rate] - 0.1)), ms2_mzs, ms2_ints]
109
- spec2.ms_level = 2
110
- spec2.pre_mz = pre_mz
111
- spec2.pre_int = ms2_int
112
- spec2.pre_charge = pre_charge
113
- if spec.ms2 != nil
114
- ms2_arr = spec.ms2
115
- ms2_arr<<spec2
116
- spec.ms2 = ms2_arr
117
- else
118
- spec.ms2 = [spec2]
119
- end
120
- ms2_count += 1
121
- end
122
- @data[rt] = spec
123
- end
124
- ms2 = false
125
- end
126
- end
127
- prog.finish!
128
- puts "MS2s = #{ms2_count}"
129
-
130
- #---------------------------------------------------------------
131
-
132
35
  end
133
36
 
134
- attr_reader :data, :features, :max_mz
135
- attr_writer :data, :features, :max_mz
37
+ attr_reader :max_mz, :cent_id
38
+ attr_writer :max_mz, :cent_id
136
39
 
137
40
  # Intensities are shaped in the rt direction by a gaussian with
138
41
  # a dynamic standard deviation.
@@ -140,50 +43,55 @@ module MS
140
43
  # by a simple gaussian curve (see 'factor' below).
141
44
  #
142
45
  def getInts(pep)
143
- p_int = pep.p_int + RThelper.RandomFloat(-5,2)
46
+ pep_id = pep[0]
47
+ p_int = pep[7] + RThelper.RandomFloat(-5,2)
144
48
  if p_int > 10
145
49
  p_int -= 10
146
50
  end
147
51
  predicted_int = (p_int * 10**-1) * 14183000.0
148
- relative_ints = pep.core_ints
149
- avg = pep.p_rt
52
+ low = 0.1*predicted_int
53
+ relative_ints = (@db.execute "SELECT ints FROM core_spec WHERE pep_id=#{pep_id}").flatten[0].gsub(/\[/,"").split(/,/).map{|val| val.to_f}
54
+ core_mzs = (@db.execute "SELECT mzs FROM core_spec WHERE pep_id=#{pep_id}").flatten[0].gsub(/\[/,"").split(/,/).map{|val| val.to_f}
55
+ avg = pep[5] #p_rt
150
56
 
151
57
  sampling_rate = @opts[:sampling_rate].to_f
152
- tail = @opts[:tail].to_f
153
- front = @opts[:front].to_f
58
+ wobA = Distribution::Normal.rng(@opts[:wobA].to_f,0.0114199604).call #0.0014199604 is the standard deviation from Hek_cells_100904050914 file
59
+ wobB = Distribution::Normal.rng(@opts[:wobB].to_f,0.01740082).call #1.20280082 is the standard deviation from Hek_cells_100904050914 file
60
+ tail = Distribution::Normal.rng(@opts[:tail].to_f,0.018667495).call #0.258667495 is the standard deviation from Hek_cells_100904050914 file
61
+ front = Distribution::Normal.rng(@opts[:front].to_f,0.01466692).call #4.83466692 is the standard deviation from Hek_cells_100904050914 file
62
+ # These number didn't work. May need to get more samples or figure something else out. For now this will give us some
63
+ # meta variance in any case
154
64
  mu = @opts[:mu].to_f
155
65
 
156
66
  index = 0
157
- sx = pep.sx
158
- sy = (sx**-1) * Math.sqrt(pep.abu)
67
+ sx = pep[9]
68
+ sy = (sx**-1) * Math.sqrt(pep[8]) #abu
159
69
 
160
70
  shuff = RThelper.RandomFloat(0.05,1.0)
161
- pep.core_mzs.each do |mzmu|
162
-
163
- fin_mzs = []
164
- fin_ints = []
71
+ core_mzs.each do |mzmu|
165
72
 
166
73
  relative_abundances_int = relative_ints[index]
167
74
 
168
75
  t_index = 1
169
76
 
170
- pep.rts.each_with_index do |rt,i|
77
+ (Sim_Spectra::r_times[pep[10]..pep[11]]).each_with_index do |rt,i|
78
+
171
79
 
172
80
  if !@one_d
173
81
  #-------------Tailing-------------------------
174
82
  shape = (tail * (t_index / sx)) + front
175
- fin_ints << (RThelper.gaussian((t_index / sx) ,mu ,shape,100.0))
83
+ int = (RThelper.gaussian((t_index / sx) ,mu ,shape,100.0))
176
84
  t_index += 1
177
85
  #---------------------------------------------
178
86
 
179
87
  else
180
88
  #-----------Random 1d data--------------------
181
- fin_ints<<(relative_abundances_int * ints_factor) * shuff
89
+ int = (relative_abundances_int * ints_factor) * shuff
182
90
  #---------------------------------------------
183
91
  end
184
92
 
185
- if fin_ints[i] < 0.01
186
- fin_ints[i] = RThelper.RandomFloat(0.001,0.4)
93
+ if int < 0.01
94
+ int = RThelper.RandomFloat(0.001,0.4)
187
95
  end
188
96
 
189
97
  =begin
@@ -196,38 +104,37 @@ module MS
196
104
  end
197
105
  =end
198
106
 
199
- if fin_ints[i] > 0.4
200
- #-------------Jagged-ness---------------------
201
- sd = (@opts[:jagA] * (1-Math.exp(-(@opts[:jagC]) * fin_ints[i])) + @opts[:jagB])/2
202
- diff = (Distribution::Normal.rng(0,sd).call)
203
- fin_ints[i] = fin_ints[i] + diff
204
- #---------------------------------------------
205
- end
206
-
207
- #-------------mz wobble-----------------------
208
- y = fin_ints[i]
209
- wobble_mz = nil
210
- if y > 0
211
- wobble_int = @opts[:wobA]*y**(@opts[:wobB])
212
- wobble_mz = Distribution::Normal.rng(mzmu,wobble_int).call
213
- if wobble_mz < 0
214
- wobble_mz = 0.01
215
- end
107
+ if int > 0.4
108
+ #-------------Jagged-ness---------------------
109
+ sd = (@opts[:jagA] * (1-Math.exp(-(@opts[:jagC]) * int)) + @opts[:jagB])/2
110
+ diff = (Distribution::Normal.rng(0,sd).call)
111
+ int += diff
112
+ #---------------------------------------------
113
+ end
216
114
 
217
- fin_mzs<<wobble_mz
218
- end
219
- #---------------------------------------------
115
+ #-------------mz wobble-----------------------
116
+ wobble_mz = nil
117
+ if int > 0
118
+ wobble_int = wobA*int**wobB
119
+ wobble_mz = Distribution::Normal.rng(mzmu,wobble_int).call
120
+ if wobble_mz < 0
121
+ wobble_mz = 0.01
122
+ end
123
+ end
124
+ #---------------------------------------------
220
125
 
221
126
 
222
- fin_ints[i] = fin_ints[i]*(predicted_int*(relative_abundances_int*10**-2)) * sy
127
+ int = int*(predicted_int*(relative_abundances_int*10**-2)) * sy
128
+ if int > low.abs and wobble_mz > 0
129
+ @db.execute "INSERT INTO spectra VALUES(#{@cent_id},#{pep_id},#{rt},#{wobble_mz},#{int},NULL)"
130
+ @cent_id += 1
131
+ if @max_mz < wobble_mz
132
+ @max_mz = wobble_mz
133
+ end
134
+ end
223
135
  end
224
-
225
- pep.insert_ints(fin_ints)
226
- pep.insert_mzs(fin_mzs)
227
-
228
136
  index += 1
229
137
  end
230
- return pep
231
138
  end
232
139
  end
233
140
  end