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-phyloxml/phyloxml_elements.rb
1060 def initialize
1061   @gained = []
1062   @lost = []
1063   @present = []
1064   @absent = []
1065 end

Public Instance Methods

absent_count=(str) click to toggle source
     # File lib/bio-phyloxml/phyloxml_elements.rb
1056 def absent_count=(str)
1057   @absent_count = str.to_i
1058 end
gained_count=(str) click to toggle source
     # File lib/bio-phyloxml/phyloxml_elements.rb
1044 def gained_count=(str)
1045   @gained_count = str.to_i
1046 end
lost_count=(str) click to toggle source
     # File lib/bio-phyloxml/phyloxml_elements.rb
1048 def lost_count=(str)
1049   @lost_count = str.to_i
1050 end
present_count=(str) click to toggle source
     # File lib/bio-phyloxml/phyloxml_elements.rb
1052 def present_count=(str)
1053   @present_count = str.to_i
1054 end
to_xml() click to toggle source

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

     # File lib/bio-phyloxml/phyloxml_elements.rb
1068 def to_xml
1069   bc = LibXML::XML::Node.new('binary_characters')
1070   bc['type'] = @bc_type
1071   PhyloXML::Writer.generate_xml(bc, self, [
1072       [:attr, 'gained_count'],
1073       [:attr, 'lost_count'],
1074       [:attr, 'present_count'],
1075       [:attr, 'absent_count']])
1076 
1077   if not @gained.empty?
1078     gained_xml = LibXML::XML::Node.new('gained')
1079     PhyloXML::Writer.generate_xml(gained_xml, self, [[:simplearr, 'bc', @gained]])
1080     bc << gained_xml
1081   end
1082 
1083   if not @lost.empty?
1084     lost_xml = LibXML::XML::Node.new('lost')
1085     PhyloXML::Writer.generate_xml(lost_xml, self, [[:simplearr, 'bc', @lost]])
1086     bc << lost_xml
1087   end
1088 
1089   if not @present.empty?
1090     present_xml = LibXML::XML::Node.new('present')
1091     PhyloXML::Writer.generate_xml(present_xml, self, [[:simplearr, 'bc', @present]])
1092     bc << present_xml
1093   end
1094 
1095   if not @absent.empty?
1096     absent_xml = LibXML::XML::Node.new('absent')
1097     PhyloXML::Writer.generate_xml(absent_xml, self, [[:simplearr, 'bc', @absent]])
1098     bc << absent_xml
1099   end
1100 
1101   return bc
1102 end