Class: Dbxref

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/dbxref.rb

Instance Method Summary collapse

Instance Method Details

#associated_termsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/dbxref.rb', line 21

def associated_terms
  unless @associated_terms
    @associated_terms = if gene_product.nil?
      []
    else
      term_ids = gene_product.associations.collect {|a| a.term_id}.uniq
      
      # selecting the graph paths in this way is MUCH quicker than using 
      # GraphPath.find because it doesn't instantiate GraphPath objects
      associated_ids =  GraphPath.connection.select_all(%Q{select term1_id from #{GraphPath.table_name} where term2_id in (#{term_ids.join(',')})}) 
      associated_ids =  associated_ids.collect {|gp| gp["term1_id"] }.uniq
      
      Term.find(:all, :conditions => ["id in (?)", associated_ids])
    end
  end
  @associated_terms
end

#associated_terms=(input) ⇒ Object



17
18
19
# File 'app/models/dbxref.rb', line 17

def associated_terms=(input)
  @associated_terms = input
end