8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/ms/noise.rb', line 8
def noiseify(opts,max_mz)
density = opts[:noise_density]
max_int = opts[:noiseMaxInt]
min_int = opts[:noiseMinInt]
@noise = {}
r_times = Sim_Spectra.r_times
count = 0
prog = Progress.new("Adding noise:")
num = 0
total = r_times.size
step = total/100.0
r_times.each do |rt|
if count > step * (num + 1)
num = (((count/total)*100.0).to_i)
prog.update(num)
end
nmzs = []
nints = []
density.times do
rmz = RThelper.RandomFloat(0.0,max_mz)
rint = RThelper.RandomFloat(min_int,max_int)
nmzs<<rmz
nints<<rint
end
@noise[rt] = [nmzs,nints]
count += 1
end
prog.finish!
return @noise
end
|