Class: MS::Tcsv_file_writer

Inherits:
Object
  • Object
show all
Defined in:
lib/ms/tr_file_writer.rb

Class Method Summary collapse

Class Method Details

.write(db, file_name, opts) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ms/tr_file_writer.rb', line 51

def self.write(db,file_name,opts)
  prog = Progress.new("Writing csv:")
  spectra = db.execute "SELECT * FROM spectra AS S JOIN peptides AS P ON S.pep_id=P.Id"
  total = spectra.size

  #write
  file = File.open("#{file_name}_truth.csv","w")
  file.puts "simulator_options=#{opts.inspect}"
  file.puts "rt,mz,int,centroid_id,merge_id,peptide_id,protien_id,seq,charge,abu"
  count = 0
  
  num = 0
  step = total/100
  spectra.each do |cent|
    file.puts "#{cent[2]},#{cent[3]},#{cent[4]},#{cent[0]},#{cent[5]},#{cent[1]},#{cent[18]},#{cent[7]},#{cent[9]},#{cent[14]}"
  end
  file.close
  prog.finish!
end