Class: Mascot::DAT::Proteins
- Inherits:
-
Object
- Object
- Mascot::DAT::Proteins
- Includes:
- Enumerable
- Defined in:
- lib/mascot/dat/proteins.rb
Defined Under Namespace
Classes: ProteinEntry
Constant Summary collapse
- PROT_REGEXP =
/(.+)\=(\d+\.\d+),(.+)/
Instance Attribute Summary collapse
-
#byteoffset ⇒ Object
Example proteins section.
-
#dat_file ⇒ Object
Example proteins section.
-
#endbytepos ⇒ Object
Example proteins section.
-
#idx ⇒ Object
Example proteins section.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(dat_file, byteoffset, cache_index = true) ⇒ Proteins
constructor
A new instance of Proteins.
- #next_entry ⇒ Object
- #protein(accession) ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(dat_file, byteoffset, cache_index = true) ⇒ Proteins
Returns a new instance of Proteins.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mascot/dat/proteins.rb', line 16 def initialize(dat_file,byteoffset,cache_index=true) @byteoffset = byteoffset @dat_file = File.new(dat_file, 'r') @dat_file.pos = byteoffset @endbytepos = @dat_file.stat.size @idx = {} if cache_index index_protein_positions end end |
Instance Attribute Details
#byteoffset ⇒ Object
Example proteins section
––gc0p4Jq0M2Yt08jU534c0p Content-Type: application/x-Mascot; name=”proteins”“accession string”=protein mass, “title text”…
14 15 16 |
# File 'lib/mascot/dat/proteins.rb', line 14 def byteoffset @byteoffset end |
#dat_file ⇒ Object
Example proteins section
––gc0p4Jq0M2Yt08jU534c0p Content-Type: application/x-Mascot; name=”proteins”“accession string”=protein mass, “title text”…
14 15 16 |
# File 'lib/mascot/dat/proteins.rb', line 14 def dat_file @dat_file end |
#endbytepos ⇒ Object
Example proteins section
––gc0p4Jq0M2Yt08jU534c0p Content-Type: application/x-Mascot; name=”proteins”“accession string”=protein mass, “title text”…
14 15 16 |
# File 'lib/mascot/dat/proteins.rb', line 14 def endbytepos @endbytepos end |
#idx ⇒ Object
Example proteins section
––gc0p4Jq0M2Yt08jU534c0p Content-Type: application/x-Mascot; name=”proteins”“accession string”=protein mass, “title text”…
14 15 16 |
# File 'lib/mascot/dat/proteins.rb', line 14 def idx @idx end |
Instance Method Details
#each ⇒ Object
42 43 44 45 46 |
# File 'lib/mascot/dat/proteins.rb', line 42 def each while @dat_file.pos < @endbytepos yield next_entry end end |
#next_entry ⇒ Object
36 37 38 39 |
# File 'lib/mascot/dat/proteins.rb', line 36 def next_entry return nil if @dat_file.pos >= @endbytepos parse_entry(@dat_file.readline) end |
#protein(accession) ⇒ Object
31 32 33 34 |
# File 'lib/mascot/dat/proteins.rb', line 31 def protein(accession) @dat_file.pos = @idx[accession] if accession next_entry end |
#rewind ⇒ Object
27 28 29 |
# File 'lib/mascot/dat/proteins.rb', line 27 def rewind @dat_file.pos = @byteoffset end |