Class: Bio::Go::SubsumeTester

Inherits:
Object
  • Object
show all
Defined in:
lib/go.rb

Overview

When repeatedly testing subsumtion by a certain GO term, it is faster to instantiate a SubsumeTester and use Bio::GO::SubsumeTester#subsume?, rather than repeatedly calling Bio::GO#subsume? because SubsumeTester does caching.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(go_object, subsumer_go_id, check_for_synonym = true) ⇒ SubsumeTester

Returns a new instance of SubsumeTester.



192
193
194
195
196
197
198
199
200
201
202
# File 'lib/go.rb', line 192

def initialize(go_object, subsumer_go_id, check_for_synonym=true)
  @go = go_object
  
  if check_for_synonym
    @master_go_id = @go.primary_go_id(subsumer_go_id)
  else
    @master_go_id = subsumer_go_id
  end
  @subsumer_offspring = @go.go_offspring(@master_go_id)
  @subsumer_offspring_hash = [@subsumer_offspring].flatten.to_hash
end

Instance Attribute Details

#master_go_idObject (readonly)

Returns the value of attribute master_go_id.



190
191
192
# File 'lib/go.rb', line 190

def master_go_id
  @master_go_id
end

#subsumer_offspringObject (readonly)

Returns the value of attribute subsumer_offspring.



190
191
192
# File 'lib/go.rb', line 190

def subsumer_offspring
  @subsumer_offspring
end

Instance Method Details

#subsume?(subsumer_go_id, check_for_synonym = true) ⇒ Boolean

Returns:

  • (Boolean)


204
205
206
207
208
209
210
# File 'lib/go.rb', line 204

def subsume?(subsumer_go_id, check_for_synonym=true)
  primaree = check_for_synonym ?
  @go.primary_go_id(subsumer_go_id) :
  subsumer_go_id
  return true if @master_go_id == primaree
  @subsumer_offspring_hash.has_key?(primaree)
end