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
Constant Summary collapse
- VALID_LOCAL_HEADERS =
Set.new(%w(CHARGE COMP ETAG INSTRUMENT IT_MODS PEPMASS RTINSECONDS SCANS SEQ TAG TITLE TOL TOLU))
- VALID_GLOBAL_HEADERS =
Set.new(%w(ACCESSION CHARGE CLE COM CUTOUT DB DECOY ERRORTOLERANT FORMAT FRAMES INSTRUMENT IT_MODS ITOL ITOLU MASS MODS PEP_ISOTOPE_ERROR PFA PRECURSOR QUANTITATION REPORT REPTYPE SEARCH SEG TAXONOMY TOL TOLU USER00 USER01 USER02 USER03 USER04 USER05 USER06 USER07 USER08 USER09 USER10 USER11 USER12 USEREMAIL USERNAME))
Class Method Summary collapse
-
.foreach(file, &block) ⇒ Object
returns each entry in the mgf file, like IO.foreach.
-
.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).
-
.write(outfile) {|mgf| ... } ⇒ Object
yields an Ms::Mascot::Mgf::Archive object and writes the data to outfile.
Class Method Details
.foreach(file, &block) ⇒ Object
returns each entry in the mgf file, like IO.foreach
32 33 34 35 36 |
# File 'lib/ms/mascot/mgf.rb', line 32 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
22 23 24 25 26 27 28 29 |
# File 'lib/ms/mascot/mgf.rb', line 22 def open(file, &block) File.open(file) do |io| a = Archive.new(io) a.reindex block.call(a) a.close end end |
.write(outfile) {|mgf| ... } ⇒ Object
yields an Ms::Mascot::Mgf::Archive object and writes the data to outfile.
example of writing spetra to “out.mgf”:
Ms::Mascot::Mgf.write("out.mgf") do |mgf|
# use the Query#to_mgf method:
mgf << query.to_mgf(peptide_hit)
# create your own entry object
mgf << Ms::Mascot::Dat::Mgf::Entry.new(header, data)
# push on the strings
mgf << "BEGIN IONS"
mgf << "TITLE=mytitle"
# ... the rest of the info ...
mgf << "END IONS"
end
56 57 58 59 60 |
# File 'lib/ms/mascot/mgf.rb', line 56 def write(outfile) mgf = Archive.new yield mgf mgf.close(outfile, nil, true) end |