Class: MS::Sequest::Sqt
- Inherits:
-
Object
- Object
- MS::Sequest::Sqt
- Includes:
- Ident::SearchLike
- Defined in:
- lib/ms/sequest/sqt.rb
Defined Under Namespace
Classes: Header, Locus, Match, Spectrum
Constant Summary collapse
- PercolatorHeaderMatch =
/^Percolator v/
- Delimiter =
"\t"
- NEW_PROT =
lambda do |_prot, _peptides| MS::Sequest::Sqt::Locus.new(_prot.locus, _prot.description, _peptides) end
Instance Attribute Summary collapse
-
#base_name ⇒ Object
Returns the value of attribute base_name.
-
#header ⇒ Object
Returns the value of attribute header.
-
#percolator_results ⇒ Object
boolean.
-
#spectra ⇒ Object
Returns the value of attribute spectra.
Class Method Summary collapse
-
.db_info(dbfile) ⇒ Object
assumes the file exists and is readable returns [DBSeqLength, DBLocusCount, DBMD5Sum].
-
.db_md5sum(dbfile) ⇒ Object
– this is implemented separate from sequence length because seq length uses Archive which doesn’t preserve carriage returns and newlines.
-
.db_seq_length_and_locus_count(dbfile) ⇒ Object
returns [sequence_length, locus_count] of the fasta file.
Instance Method Summary collapse
-
#from_file(filename, opts = {}) ⇒ Object
if the file contains the header key ‘/$Percolator v/’ then the results will be interpreted as percolator results regardless of the value passed in.
-
#initialize(filename = nil, opts = {}) ⇒ Sqt
constructor
opts = :percolator_results => false | true (default false) :link_protein_hits => true | false (default true).
- #protein_class ⇒ Object
Constructor Details
#initialize(filename = nil, opts = {}) ⇒ Sqt
opts =
:percolator_results => false | true (default false)
:link_protein_hits => true | false (default true)
109 110 111 112 113 114 |
# File 'lib/ms/sequest/sqt.rb', line 109 def initialize(filename=nil, opts={}) peptide_hits = [] if filename from_file(filename, opts) end end |
Instance Attribute Details
#base_name ⇒ Object
Returns the value of attribute base_name.
63 64 65 |
# File 'lib/ms/sequest/sqt.rb', line 63 def base_name @base_name end |
#header ⇒ Object
Returns the value of attribute header.
61 62 63 |
# File 'lib/ms/sequest/sqt.rb', line 61 def header @header end |
#percolator_results ⇒ Object
boolean
65 66 67 |
# File 'lib/ms/sequest/sqt.rb', line 65 def percolator_results @percolator_results end |
#spectra ⇒ Object
Returns the value of attribute spectra.
62 63 64 |
# File 'lib/ms/sequest/sqt.rb', line 62 def spectra @spectra end |
Class Method Details
.db_info(dbfile) ⇒ Object
assumes the file exists and is readable returns [DBSeqLength, DBLocusCount, DBMD5Sum]
97 98 99 100 |
# File 'lib/ms/sequest/sqt.rb', line 97 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) ⇒ Object
– this is implemented separate from sequence length because seq length uses Archive which doesn’t preserve carriage returns and newlines. ++
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ms/sequest/sqt.rb', line 84 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) ⇒ Object
returns [sequence_length, locus_count] of the fasta file
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ms/sequest/sqt.rb', line 68 def self.db_seq_length_and_locus_count(dbfile) total_sequence_length = 0 fastasize = 0 MS::Fasta.open(dbfile) do |fasta| fasta.each do |entry| total_sequence_length += entry.sequence.size fastasize += 1 end end [total_sequence_length, fastasize] end |
Instance Method Details
#from_file(filename, opts = {}) ⇒ Object
if the file contains the header key ‘/$Percolator v/’ then the results will be interpreted as percolator results regardless of the value passed in.
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/ms/sequest/sqt.rb', line 123 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 = MS::Sequest::Sqt::Header.new.from_handle(fh) if @header.keys.any? {|v| v =~ PercolatorHeaderMatch } @percolator_results = true end (@spectra, @peptides) = MS::Sequest::Sqt::Spectrum.spectra_from_handle(fh, @base_name, @percolator_results) end end |