class MS::Sequest::Srf::Header

Constants

Byte_length
Byte_length_v32
NEWLINE_OR_NULL_RE
Start_byte

Attributes

combined[R]

true if this is a combined file, false if represents a single file this is set by examining the DtaGen object for signs of a single file

db_filename[RW]
dta_gen[RW]
dta_log_filename[RW]
enzyme[RW]
ion_series[RW]
model[RW]
modifications[RW]
params_filename[RW]
raw_filename[RW]
sequest_log_filename[RW]
version[RW]

Public Class Methods

from_io(fh) click to toggle source
# File lib/ms/sequest/srf.rb, line 377
def self.from_io(fh)
  self.new.from_io(fh)
end

Public Instance Methods

from_io(fh) click to toggle source

sets fh to 0 and grabs the information it wants

# File lib/ms/sequest/srf.rb, line 382
def from_io(fh)
  st = fh.read(4) 
  @version = '3.' + st.unpack('I').first.to_s
  @dta_gen = MS::Sequest::Srf::DtaGen.from_io(fh)
  # if the start_mass end_mass start_scan and end_scan are all zero, its a
  # combined srf file:
  @combined = [0.0, 0.0, 0, 0].zip(%w(start_mass end_mass start_scan end_scan)).all? do |one,two|
    one == @dta_gen.send(two.to_sym)
  end

  ## get the rest of the info
  byte_length = Byte_length.dup
  byte_length.merge! Byte_length_v32 if @version == '3.2'

  fh.pos = Start_byte[:enzyme]
  [:enzyme, :ion_series, :model, :modifications, :raw_filename, :db_filename, :dta_log_filename, :params_filename, :sequest_log_filename].each do |param|
    send("#{param}=".to_sym, get_null_padded_string(fh, byte_length[param], @combined))
  end
  self
end
num_dta_files() click to toggle source
# File lib/ms/sequest/srf.rb, line 373
def num_dta_files
  @dta_gen.num_dta_files
end

Private Instance Methods

get_null_padded_string(fh, bytes, combined=false) click to toggle source
# File lib/ms/sequest/srf.rb, line 404
def get_null_padded_string(fh, bytes, combined=false)
  st = fh.read(bytes)
  # for empty declarations
  if st[0] == 0x000000
    return ''
  end
  if combined
    st = st[ 0, st.index(NEWLINE_OR_NULL_RE) ]
  else
    st.rstrip!
  end
  st
end