Module: MS::LipidMaps

Defined in:
lib/ms/lipid_maps.rb

Class Method Summary collapse

Class Method Details

.parse_file(lipidmaps_tsv, high_res_mass = true, skip_clas_defs = true) ⇒ Object

returns an array of Lipids if high_res_mass is true (default), then the formula is used to calculate a higher resolution mass than what is in lipidmaps



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ms/lipid_maps.rb', line 9

def self.parse_file(lipidmaps_tsv, high_res_mass=true, skip_clas_defs=true)
  seen_first_line = false
  IO.foreach(lipidmaps_tsv).map do |line|
    line.chomp!
    pieces = line.split("\t")
    if pieces[3] !~ /[A-Z]/  # <- there is no formula!
      nil
    else
      if seen_first_line
        pieces[4] = MS::Mass.formula_to_exact_mass(pieces[3]) if high_res_mass
        l = MS::Lipid.new *pieces
      else
        seen_first_line = true
        warn "lipidmaps column headers are not right!" unless pieces.map(&:downcase) == MS::Lipid.members.map(&:to_s)
        nil
      end
    end
  end.compact
end