Class: Bio::NeXML::Otu

Inherits:
Object
  • Object
show all
Includes:
Mapper
Defined in:
lib/bio/db/nexml/taxa.rb

Overview

DESCRIPTION

Otu represents a taxon; an implementation of the Taxon[http://nexml.org/nexml/html/doc/schema-1/taxa/taxa/#Taxon] type. An Otu must have an ‘id’ and may take an an optional ‘label’.

taxon1 = Bio::NeXML::Otu.new( 'taxon1', :label => 'Label for taxon1' )
taxon1.id    #=> 'taxon1'
taxon1.label #=> 'Label for taxon1'
taxon1.otus  #=> otus object they belong to; see docs for Otus

Constant Summary collapse

@@writer =
Bio::NeXML::Writer.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mapper

#properties

Constructor Details

#initialize(id, options = {}, &block) ⇒ Otu

Create a new otu.

otu = Bio::NeXML::Otu.id( 'o1' )
otu = Bio::NeXML::Otu.id( 'o1', :label => 'A label' )


32
33
34
35
36
# File 'lib/bio/db/nexml/taxa.rb', line 32

def initialize( id, options = {}, &block )
  @id = id
  properties( options ) unless options.empty?
  block.arity < 1 ? instance_eval( &block ) : block.call( self ) if block_given?
end

Instance Attribute Details

#idObject

A file level unique identifier.



16
17
18
# File 'lib/bio/db/nexml/taxa.rb', line 16

def id
  @id
end

#labelObject

A human readable description.



19
20
21
# File 'lib/bio/db/nexml/taxa.rb', line 19

def label
  @label
end

Instance Method Details

#to_xmlObject



38
39
40
# File 'lib/bio/db/nexml/taxa.rb', line 38

def to_xml
  @@writer.create_node( "otu", @@writer.attributes( self, :id, :label ) )
end