class Bio::PhyloXML::BinaryCharacters

Description

The names and/or counts of binary characters present, gained, and lost at the root of a clade.

Attributes

absent[RW]
absent_count[R]
bc_type[RW]
gained[RW]
gained_count[R]
lost[RW]
lost_count[R]
present[RW]
present_count[R]

Public Class Methods

new() click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1071
def initialize
  @gained = []
  @lost = []
  @present = []
  @absent = []
end

Public Instance Methods

absent_count=(str) click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1067
def absent_count=(str)
  @absent_count = str.to_i
end
gained_count=(str) click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1055
def gained_count=(str)
  @gained_count = str.to_i
end
lost_count=(str) click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1059
def lost_count=(str)
  @lost_count = str.to_i
end
present_count=(str) click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1063
def present_count=(str)
  @present_count = str.to_i
end
to_xml() click to toggle source

Converts elements to xml representation. Called by PhyloXML::Writer class.

# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1079
def to_xml
  bc = LibXML::XML::Node.new('binary_characters')
  bc['type'] = @bc_type
  PhyloXML::Writer.generate_xml(bc, self, [
      [:attr, 'gained_count'],
      [:attr, 'lost_count'],
      [:attr, 'present_count'],
      [:attr, 'absent_count']])

  if not @gained.empty?
    gained_xml = LibXML::XML::Node.new('gained')
    PhyloXML::Writer.generate_xml(gained_xml, self, [[:simplearr, 'bc', @gained]])
    bc << gained_xml
  end

  if not @lost.empty?
    lost_xml = LibXML::XML::Node.new('lost')
    PhyloXML::Writer.generate_xml(lost_xml, self, [[:simplearr, 'bc', @lost]])
    bc << lost_xml
  end

  if not @present.empty?
    present_xml = LibXML::XML::Node.new('present')
    PhyloXML::Writer.generate_xml(present_xml, self, [[:simplearr, 'bc', @present]])
    bc << present_xml
  end

  if not @absent.empty?
    absent_xml = LibXML::XML::Node.new('absent')
    PhyloXML::Writer.generate_xml(absent_xml, self, [[:simplearr, 'bc', @absent]])
    bc << absent_xml
  end

  return bc
end