Class: Mascot::MGF

Inherits:
File
  • Object
show all
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

Instance Method Summary collapse

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.expand_path(mgf_file_path)
  @cache_index = cache_index
  @curr_index = 0
  @idx = {}
  parse_index()
end

Instance Attribute Details

#curr_indexObject (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_pathObject (readonly)

Returns the value of attribute full_path.



4
5
6
# File 'lib/mascot/mgf.rb', line 4

def full_path
  @full_path
end

#idxObject (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_queryObject



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_countObject

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

#rewindObject



14
15
16
17
# File 'lib/mascot/mgf.rb', line 14

def rewind
  super
  @curr_index = 0
end