Class: Sniffer

Inherits:
Object
  • Object
show all
Defined in:
lib/protk/sniffer.rb

Class Method Summary collapse

Class Method Details

.is_mgf_format(filepath) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/protk/sniffer.rb', line 26

def self.is_mgf_format(filepath)
  lines = File.foreach(filepath).first(@sniff_lines).join("\n")
  if lines =~ /^BEGIN IONS/
    return true
  end
  return false
end

.is_mzml_format(filepath) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/protk/sniffer.rb', line 18

def self.is_mzml_format(filepath)
  lines = File.foreach(filepath).first(@sniff_lines).join("\n")
  if lines =~ /\<mzML.*http\:\/\/psi\.hupo\.org\/ms\/mzml/
    return true
  end
  return false
end

.sniff_format(filepath) ⇒ Object

Return nil if undetectable Return detected format otherwise



8
9
10
11
12
13
14
15
# File 'lib/protk/sniffer.rb', line 8

def self.sniff_format(filepath)
  if self.is_mgf_format(filepath)
    return "mgf"
  elsif self.is_mzml_format(filepath)
    return "mzML"
  end
  return nil
end