class Bio::NeXML::Edge

Edge connect two nodes of a tree or a network. An edge should have a unique id. It should have a ‘source’ and a ‘target’ node and optionally a ‘length’ may be assigned to it.

Attributes

id[RW]

A file level unique identifier.

label[RW]

A human readable description.

source[RW]

Source of the edge.

target[RW]

Target of the edge.

Public Class Methods

new( id, options = {} ) click to toggle source

Create a new edge.

edge = Bio::NeXML::Edge.new( 'edge1' )
edge = Bio::NeXML::Edge.new( 'edge1', :source => node1, :target => node2 )
edge = Bio::NeXML::Edge.new( 'edge1', :source => node1, :target => node2, :length => 1 )
Calls superclass method
# File lib/bio/db/nexml/trees.rb, line 84
def initialize( id, options = {} )
  super( length )
  @id = id
  properties( options ) unless options.empty?
  block.arity < 1 ? instance_eval( &block ) : block.call( self ) if block_given?
end

Public Instance Methods

length() click to toggle source

Return the length of an edge.

# File lib/bio/db/nexml/trees.rb, line 92
def length
  distance
end
length=( length ) click to toggle source

Set the length of an edge.

# File lib/bio/db/nexml/trees.rb, line 97
def length=( length )
  self.distance = length
end
to_xml() click to toggle source
# File lib/bio/db/nexml/trees.rb, line 61
def to_xml
  @@writer.create_node( "edge", @@writer.attributes( self, :id, :source, :target, :length, :label ) )
end