class Bio::NeXML::Nexml
Attributes
generator[RW]
version[RW]
Public Class Methods
new( version = '0.9', generator = 'bioruby' )
click to toggle source
# File lib/bio/db/nexml.rb, line 39 def initialize( version = '0.9', generator = 'bioruby' ) @version = version @generator = generator end
Public Instance Methods
<<( element )
click to toggle source
Append a Otus
, Trees
, or Characters
object to any Nexml
object.
# 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 = {} )
click to toggle source
# File lib/bio/db/nexml.rb, line 69 def create_characters( type = "Dna", verbose = false, options = {} ) 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 ), options ) self << characters characters end
create_otus( options = {} )
click to toggle source
# File lib/bio/db/nexml.rb, line 57 def create_otus( options = {} ) otus = Otus.new( Bio::NeXML.generate_id( Otus ), options ) self << otus otus end
create_trees( options )
click to toggle source
# File lib/bio/db/nexml.rb, line 63 def create_trees( options ) trees = Trees.new( Bio::NeXML.generate_id( Trees ), options ) self << trees trees end
to_xml()
click to toggle source
# 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