Class: Mascot::MGF
- Inherits:
-
File
- Object
- File
- Mascot::MGF
- Defined in:
- lib/mascot/mgf.rb,
lib/mascot/mgf/query.rb,
lib/mascot/mgf/version.rb
Defined Under Namespace
Classes: Query
Constant Summary collapse
- VERSION =
"0.2.3"
Instance Attribute Summary collapse
-
#curr_index ⇒ Object
readonly
Returns the value of attribute curr_index.
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#idx ⇒ Object
readonly
Returns the value of attribute idx.
Instance Method Summary collapse
- #each_query ⇒ Object
-
#initialize(mgf_file_path, cache_index = true, open_mode = "r") ⇒ MGF
constructor
A new instance of MGF.
-
#query(n = nil) ⇒ Object
0-based index.
-
#query_count ⇒ Object
reports how many queries are in this MGF file.
- #readquery(n = nil) ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(mgf_file_path, cache_index = true, open_mode = "r") ⇒ MGF
Returns a new instance of MGF.
5 6 7 8 9 10 11 12 |
# File 'lib/mascot/mgf.rb', line 5 def initialize(mgf_file_path,cache_index=true,open_mode="r") super(mgf_file_path, open_mode) @full_path = File.(mgf_file_path) @cache_index = cache_index @curr_index = 0 @idx = {} parse_index() end |
Instance Attribute Details
#curr_index ⇒ Object (readonly)
Returns the value of attribute curr_index.
4 5 6 |
# File 'lib/mascot/mgf.rb', line 4 def curr_index @curr_index end |
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
4 5 6 |
# File 'lib/mascot/mgf.rb', line 4 def full_path @full_path end |
#idx ⇒ Object (readonly)
Returns the value of attribute idx.
4 5 6 |
# File 'lib/mascot/mgf.rb', line 4 def idx @idx end |
Instance Method Details
#each_query ⇒ Object
29 30 31 32 33 |
# File 'lib/mascot/mgf.rb', line 29 def each_query while !self.eof? yield self.query() if block_given? end end |
#query(n = nil) ⇒ Object
0-based index
43 44 45 |
# File 'lib/mascot/mgf.rb', line 43 def query(n=nil) Mascot::MGF::Query.new(self.readquery(n)) end |
#query_count ⇒ Object
reports how many queries are in this MGF file
48 49 50 |
# File 'lib/mascot/mgf.rb', line 48 def query_count() return @idx.length end |
#readquery(n = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/mascot/mgf.rb', line 19 def readquery(n=nil) if n @curr_index = n end self.pos = @idx[@curr_index][0] bytelength = @idx[@curr_index][1] - @idx[@curr_index][0] @curr_index += 1 self.read(bytelength) end |
#rewind ⇒ Object
14 15 16 17 |
# File 'lib/mascot/mgf.rb', line 14 def rewind super @curr_index = 0 end |