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
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
|