class Mspire::Sequest::Sqt

Constants

Delimiter
Locus
Match

Sqt format uses only indices 0 - 9

NEW_PROT
PercolatorHeaderMatch
Spectrum

all are cast as expected (total_intensity is a float) mh = observed mh

Attributes

base_name[RW]
header[RW]
percolator_results[RW]

boolean

spectra[RW]

Public Class Methods

db_info(dbfile) click to toggle source

assumes the file exists and is readable returns [DBSeqLength, DBLocusCount, DBMD5Sum]

# File lib/mspire/sequest/sqt.rb, line 95
def self.db_info(dbfile)
  # returns the 3 member array
  self.db_seq_length_and_locus_count(dbfile) << self.db_md5sum(dbfile)
end
db_md5sum(dbfile) click to toggle source
# File lib/mspire/sequest/sqt.rb, line 82
def self.db_md5sum(dbfile)
  chunksize = 61440
  digest = Digest::MD5.new
  File.open(dbfile) do |io|
    while chunk = io.read(chunksize)
      digest << chunk 
    end
  end
  digest.hexdigest
end
db_seq_length_and_locus_count(dbfile) click to toggle source

returns [sequence_length, locus_count] of the fasta file

# File lib/mspire/sequest/sqt.rb, line 66
def self.db_seq_length_and_locus_count(dbfile)
  total_sequence_length = 0
  fastasize = 0
  Mspire::Fasta.open(dbfile) do |fasta|
    fasta.each do |entry| 
      total_sequence_length += entry.sequence.size 
      fastasize += 1
    end
  end
  [total_sequence_length, fastasize]
end
new(filename=nil, opts={}) click to toggle source

opts =

:percolator_results => false | true (default false)
:link_protein_hits => true | false (default true)
# File lib/mspire/sequest/sqt.rb, line 107
def initialize(filename=nil, opts={})
  peptide_hits = []
  if filename
    from_file(filename, opts)
  end
end

Public Instance Methods

from_file(filename, opts={}) click to toggle source

if the file contains the header key ‘/$Percolator v/’ then the results will be interpreted as percolator results regardless of the value passed in.

# File lib/mspire/sequest/sqt.rb, line 121
def from_file(filename, opts={})
  opts = {:percolator_results=>false, :link_protein_hits => true}.merge(opts)
  @percolator_results = opts[:percolator_results]
  @base_name = File.basename( filename.gsub('\\','/') ).sub(/\.\w+$/, '')
  File.open(filename) do |fh| 
    @header = Mspire::Sequest::Sqt::Header.new.from_handle(fh)
    if @header.keys.any? {|v| v =~ PercolatorHeaderMatch }
      @percolator_results = true
    end
    (@spectra, @peptides) = Mspire::Sequest::Sqt::Spectrum.spectra_from_handle(fh, @base_name, @percolator_results)
  end
end
protein_class() click to toggle source
# File lib/mspire/sequest/sqt.rb, line 100
def protein_class
  Mspire::Sequest::Sqt::Locus
end