Class: MS::Sim_Spectra
- Inherits:
-
Object
- Object
- MS::Sim_Spectra
- Defined in:
- lib/ms/sim_spectra.rb
Instance Attribute Summary collapse
-
#max_mz ⇒ Object
Returns the value of attribute max_mz.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts, one_d = false, db) ⇒ Sim_Spectra
constructor
A new instance of Sim_Spectra.
- #noiseify(db) ⇒ Object
Constructor Details
#initialize(opts, one_d = false, db) ⇒ Sim_Spectra
Returns a new instance of Sim_Spectra.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ms/sim_spectra.rb', line 9 def initialize(opts,one_d = false,db) @opts = opts @max_mz sampling_rate = opts[:sampling_rate] run_time = opts[:run_time] drop_percentage = opts[:dropout_percentage] #RTS var = 0.1/(sampling_rate*2) @@r_times = [] num_of_spec = sampling_rate*run_time spec_time = 1/sampling_rate num_of_spec.to_i.times do |k| @@r_times<<spec_time+RThelper.RandomFloat(-var,var) spec_time = spec_time + (1/sampling_rate) end @@r_times = MS::Noise.spec_drops(drop_percentage) MS::Rtgenerator.generateRT(one_d,db) #Features @features_o = MS::Sim_Feature.new(opts,one_d,db) @max_mz = @features_o.max_mz end |
Instance Attribute Details
#max_mz ⇒ Object
Returns the value of attribute max_mz.
51 52 53 |
# File 'lib/ms/sim_spectra.rb', line 51 def max_mz @max_mz end |
Class Method Details
.r_times ⇒ Object
47 48 49 |
# File 'lib/ms/sim_spectra.rb', line 47 def self.r_times @@r_times end |
Instance Method Details
#noiseify(db) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ms/sim_spectra.rb', line 34 def noiseify(db) @noise = MS::Noise.noiseify(@opts,@max_mz) cent_id = @features_o.cent_id + 1 @noise.each do |key,val| mzs = val[0] ints = val[1] mzs.each_with_index do |mz,index| db.execute "INSERT INTO spectra VALUES(#{cent_id},NULL,#{key},#{mz},#{ints[index]},NULL)" cent_id += 1 end end end |