Sha256: 659c70aafa5d26cbff876b2a4f7c88b02abc94fa13d8f1eb40dc2528d24392bf

Contents?: true

Size: 613 Bytes

Versions: 3

Compression:

Stored size: 613 Bytes

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rubygems'
require 'mzml'
require 'spec'
require 'spec/autorun'

class Mgf < Struct.new(:title, :mz, :intensity); end

def parse_mgf(fname)
  mgf = Mgf.new(nil,[],[])
  File.open(fname).each do |l|
    l.chomp!
    case l
    when /^TITLE=(.+)/
      mgf.title = $1
    when /^\d/
      m,i = l.split(' ').map{|e| (e.to_f * 1000).to_i() / 1000.0 }
      mgf.mz << m
      mgf.intensity << i
    when /^END IONS/
      break
    end
  end
  return mgf
end

Spec::Runner.configure do |config|
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mzml-0.3.1 spec/spec_helper.rb
mzml-0.3.0 spec/spec_helper.rb
mzml-0.2.2 spec/spec_helper.rb