Class: Bio::NeXML::Nexml
- Inherits:
-
Object
- Object
- Bio::NeXML::Nexml
- Includes:
- Mapper, Enumerable
- Defined in:
- lib/bio/db/nexml.rb
Overview
end module Base
Constant Summary collapse
Instance Attribute Summary collapse
-
#generator ⇒ Object
Returns the value of attribute generator.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#<<(element) ⇒ Object
Append a Otus, Trees, or Characters object to any Nexml object.
- #create_characters(type = "Dna", verbose = false, options = {}) ⇒ Object
- #create_otus(options = {}) ⇒ Object
- #create_trees(options) ⇒ Object
-
#initialize(version = '0.9', generator = 'bioruby') ⇒ Nexml
constructor
A new instance of Nexml.
- #to_xml ⇒ Object
Methods included from Mapper
Constructor Details
#initialize(version = '0.9', generator = 'bioruby') ⇒ Nexml
Returns a new instance of Nexml.
39 40 41 42 |
# File 'lib/bio/db/nexml.rb', line 39 def initialize( version = '0.9', generator = 'bioruby' ) @version = version @generator = generator end |
Instance Attribute Details
#generator ⇒ Object
Returns the value of attribute generator.
33 34 35 |
# File 'lib/bio/db/nexml.rb', line 33 def generator @generator end |
#version ⇒ Object
Returns the value of attribute version.
32 33 34 |
# File 'lib/bio/db/nexml.rb', line 32 def version @version end |
Instance Method Details
#<<(element) ⇒ Object
Append a Otus, Trees, or Characters object to any Nexml object.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bio/db/nexml.rb', line 46 def <<( element ) case element when Otus add_otus element when Trees add_trees element when Characters add_characters element end end |
#create_characters(type = "Dna", verbose = false, options = {}) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/bio/db/nexml.rb', line 69 def create_characters( type = "Dna", verbose = false, = {} ) subtype = verbose ? "Cells" : "Seqs" klass_name = "#{type.to_s.capitalize}#{subtype}" klass = NeXML.const_get( klass_name ) characters = klass.new( Bio::NeXML.generate_id( klass ), ) self << characters characters end |
#create_otus(options = {}) ⇒ Object
57 58 59 60 61 |
# File 'lib/bio/db/nexml.rb', line 57 def create_otus( = {} ) otus = Otus.new( Bio::NeXML.generate_id( Otus ), ) self << otus otus end |
#create_trees(options) ⇒ Object
63 64 65 66 67 |
# File 'lib/bio/db/nexml.rb', line 63 def create_trees( ) trees = Trees.new( Bio::NeXML.generate_id( Trees ), ) self << trees trees end |
#to_xml ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/bio/db/nexml.rb', line 78 def to_xml node = @@writer.create_node( "nex:nexml", :"xsi:schemaLocation" => "http://www.nexml.org/2009 http://www.nexml.org/2009/xsd/nexml.xsd", :generator => generator, :version => version ) node.namespaces = { nil => "http://www.nexml.org/2009", :xsi => "http://www.w3.org/2001/XMLSchema-instance", :xlink => "http://www.w3.org/1999/xlink", :nex => "http://www.nexml.org/2009" } self.each_otus do |otus| node << otus.to_xml end self.each_characters do |characters| node << characters.to_xml end self.each_trees do |trees| node << trees.to_xml end node end |