Class: Bio::NeXML::Nexml
- Inherits:
-
Object
- Object
- Bio::NeXML::Nexml
- Includes:
- Mapper, Enumerable
- Defined in:
- lib/bio/db/nexml.rb
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.
52 53 54 55 |
# File 'lib/bio/db/nexml.rb', line 52 def initialize( version = '0.9', generator = 'bioruby' ) @version = version @generator = generator end |
Instance Attribute Details
#generator ⇒ Object
Returns the value of attribute generator.
46 47 48 |
# File 'lib/bio/db/nexml.rb', line 46 def generator @generator end |
#version ⇒ Object
Returns the value of attribute version.
45 46 47 |
# File 'lib/bio/db/nexml.rb', line 45 def version @version end |
Instance Method Details
#<<(element) ⇒ Object
Append a Otus, Trees, or Characters object to any Nexml object.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bio/db/nexml.rb', line 59 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
82 83 84 85 86 87 88 89 |
# File 'lib/bio/db/nexml.rb', line 82 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
70 71 72 73 74 |
# File 'lib/bio/db/nexml.rb', line 70 def create_otus( = {} ) otus = Otus.new( Bio::NeXML.generate_id( Otus ), ) self << otus otus end |
#create_trees(options) ⇒ Object
76 77 78 79 80 |
# File 'lib/bio/db/nexml.rb', line 76 def create_trees( ) trees = Trees.new( Bio::NeXML.generate_id( Trees ), ) self << trees trees end |
#to_xml ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/bio/db/nexml.rb', line 91 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 |