Sha256: e182e4d27b0ee7a06e407bb01c555d2bd033a89581956d5d8616e6197ed0d806

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

#!/usr/bin/ruby

require 'spec/mzxml/parser'
require 'optparse'
require 'ostruct'
require 'lmat'


# defaults:
opt = {}
opt[:baseline] = 0.0
opt[:newext] = ".lmat"
opt[:inc_mz] = 1.0

# get options:
opts = OptionParser.new do |op|
  op.banner = "usage: #{File.basename(__FILE__)} [options] file.mzXML ..."
  op.separator ""
  op.separator "(sums m/z values that round to the same bin)"
  op.separator ""
  op.on("--mz_inc N", Float, "m/z increment (def: 1.0)") {|n| opt[:mz_inc] = n.to_f}
  op.on("--mz_start N", Float, "m/z start (def: start of 1st full scan)") {|n| opt[:start_mz] = n.to_f}
  op.on("--mz_end N", Float, "m/z end (def: end of 1st full scan)") {|n| opt[:end_mz] = n.to_f}
  op.on("--baseline N", Float, "value for missing indices (def: #{opt[:baseline]})") {|n| opt[:baseline] = n.to_f}
  op.on("--ascii", "generates an lmata file instead") {opt[:ascii] = true}
end
opts.parse!

if ARGV.size < 1 
  puts opts
end

ARGV.each do |file|
  parser = Spec::MzXML::Parser.new
  (start_mz, end_mz) = parser.start_and_end_mz(file)
  (times, spectra) = parser.times_and_spectra(file)
  times.map! do |tm| tm.to_f end
  args = {
    :start_mz => start_mz,
    :end_mz => end_mz,

    :start_tm => times.first,
    :end_tm => times.last,
    :inc_tm => nil,
  }
  args.merge!(opt)
  lmat = LMat.new.from_raw_spectra(times, spectra, args)
  outfile = file.sub(/\.mzXML$/, opt[:newext])
  if args[:ascii]
    outfile << "a"
    lmat.print(outfile)
  else
    lmat.write(outfile)
  end
  puts "OUTPUT: #{outfile}"
end








Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mspire-0.1.7 bin/mzxml_to_lmat.rb
mspire-0.1.5 bin/mzxml_to_lmat.rb