Class: Bio::NeXML::Edge
- Inherits:
-
Tree::Edge
- Object
- Tree::Edge
- Bio::NeXML::Edge
- Includes:
- Mapper
- Defined in:
- lib/bio/db/nexml/trees.rb
Overview
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.
Constant Summary
- @@writer =
Bio::NeXML::Writer.new
Instance Attribute Summary (collapse)
-
- (Object) id
A file level unique identifier.
-
- (Object) label
A human readable description.
-
- (Object) source
Source of the edge.
-
- (Object) target
Target of the edge.
Instance Method Summary (collapse)
-
- (Edge) initialize(id, options = {})
constructor
Create a new edge.
-
- (Object) length
Return the length of an edge.
-
- (Object) length=(length)
Set the length of an edge.
- - (Object) to_xml
Methods included from Mapper
Constructor Details
- (Edge) initialize(id, options = {})
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 )
84 85 86 87 88 89 |
# File 'lib/bio/db/nexml/trees.rb', line 84 def initialize( id, = {} ) super( length ) @id = id properties( ) unless .empty? block.arity < 1 ? instance_eval( &block ) : block.call( self ) if block_given? end |
Instance Attribute Details
- (Object) id
A file level unique identifier.
66 67 68 |
# File 'lib/bio/db/nexml/trees.rb', line 66 def id @id end |
- (Object) label
A human readable description.
75 76 77 |
# File 'lib/bio/db/nexml/trees.rb', line 75 def label @label end |
- (Object) source
Source of the edge.
69 70 71 |
# File 'lib/bio/db/nexml/trees.rb', line 69 def source @source end |
- (Object) target
Target of the edge.
72 73 74 |
# File 'lib/bio/db/nexml/trees.rb', line 72 def target @target end |
Instance Method Details
- (Object) length
Return the length of an edge.
92 93 94 |
# File 'lib/bio/db/nexml/trees.rb', line 92 def length distance end |
- (Object) length=(length)
Set the length of an edge.
97 98 99 |
# File 'lib/bio/db/nexml/trees.rb', line 97 def length=( length ) self.distance = length end |
- (Object) to_xml
61 62 63 |
# 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 |