Module: Ms::Mascot::Mgf

Defined in:
lib/ms/mascot/mgf.rb,
lib/ms/mascot/mgf/entry.rb,
lib/ms/mascot/mgf/archive.rb

Defined Under Namespace

Classes: Archive, Entry

Class Method Summary collapse

Class Method Details

.foreach(file, &block) ⇒ Object

returns each entry in the mgf file, like IO.foreach



27
28
29
30
31
# File 'lib/ms/mascot/mgf.rb', line 27

def foreach(file, &block)
  open(file) do |ar|
    ar.each &block
  end
end

.open(file, &block) ⇒ Object

Opens the file and yields an array of entries (well, the array is actually an Ms::Mascot::Mgf::Archive object that acts like an array but leaves data on disk until needed)

Ms::Mascot::Mgf.open("file.mgf") do |ar|
  entry5 = ar[4]  # -> 5th entry
  entry5.pepmass  # -> peptide mass
  entry5.data     # -> array of arrays
end


17
18
19
20
21
22
23
24
# File 'lib/ms/mascot/mgf.rb', line 17

def open(file, &block)
  File.open(file) do |io|
    a = Archive.new(io)
    a.reindex
    block.call(a)
    a.close
  end
end