Class: Bio::FlatFileIndex::Results

Inherits:
Hash show all
Defined in:
lib/bio/io/flatfile/index.rb

Overview

Results stores search results created by Bio::FlatFileIndex methods.

Currently, this class inherits Hash, but internal structure of this class may be changed anytime. Only using methods described below are strongly recomended.

Instance Method Summary collapse

Instance Method Details

#*(a) ⇒ Object

Returns set intersection of results. “a * b” means “a AND b”.

  • Example

    # I want to search 'HIS_KIN' AND 'human'
    db = Bio::FlatFIleIndex.new(location)
    hk = db.search('HIS_KIN')
    hu = db.search('human')
    # hk and hu are Bio::FlatFileIndex::Results objects.
    print hk * hu
    


351
352
353
354
355
356
# File 'lib/bio/io/flatfile/index.rb', line 351

def *(a)
  raise 'argument must be Results class' unless a.is_a?(self.class)
  res = self.class.new
  a.each_key { |x| res.store(x, a[x]) if self[x] }
  res
end

#+(a) ⇒ Object

Add search results. “a + b” means “a OR b”.

  • Example

    # I want to search 'ADH_IRON_1' OR 'ADH_IRON_2'
    db = Bio::FlatFIleIndex.new(location)
    a1 = db.search('ADH_IRON_1')
    a2 = db.search('ADH_IRON_2')
    # a1 and a2 are Bio::FlatFileIndex::Results objects.
    print a1 + a2
    


334
335
336
337
338
339
# File 'lib/bio/io/flatfile/index.rb', line 334

def +(a)
  raise 'argument must be Results class' unless a.is_a?(self.class)
  res = self.dup
  res.update(a)
  res
end

#sizeObject

Returns number of results. Same as to_a.size.



392
# File 'lib/bio/io/flatfile/index.rb', line 392

def size; end

#to_sObject

Returns a string. (concatinated if multiple results exists). Same as to_a.join('').



361
362
363
# File 'lib/bio/io/flatfile/index.rb', line 361

def to_s
  self.values.join
end