Method: Bio::Pathway#append

Defined in:
lib/bio/pathway.rb

#append(rel, add_rel = true) ⇒ Object

Add an Bio::Relation object ‘rel’ to the @graph and @relations. If the second argument is false, @relations is not modified (only useful when genarating @graph from @relations internally).



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/bio/pathway.rb', line 145

def append(rel, add_rel = true)
  @relations.push(rel) if add_rel
  if @graph[rel.from].nil?
    @graph[rel.from] = {}
  end
  if @graph[rel.to].nil?
    @graph[rel.to] = {}
  end
  @graph[rel.from][rel.to] = rel.relation
  @graph[rel.to][rel.from] = rel.relation if @undirected
end