Class: Bio::PhyloXML::BinaryCharacters

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/phyloxml/phyloxml_elements.rb

Overview

Description

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBinaryCharacters

Returns a new instance of BinaryCharacters



1057
1058
1059
1060
1061
1062
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1057

def initialize
  @gained = []
  @lost = []
  @present = []
  @absent = []
end

Instance Attribute Details

#absentObject

Returns the value of attribute absent



1038
1039
1040
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1038

def absent
  @absent
end

#absent_countObject

Returns the value of attribute absent_count



1039
1040
1041
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1039

def absent_count
  @absent_count
end

#bc_typeObject

Returns the value of attribute bc_type



1038
1039
1040
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1038

def bc_type
  @bc_type
end

#gainedObject

Returns the value of attribute gained



1038
1039
1040
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1038

def gained
  @gained
end

#gained_countObject

Returns the value of attribute gained_count



1039
1040
1041
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1039

def gained_count
  @gained_count
end

#lostObject

Returns the value of attribute lost



1038
1039
1040
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1038

def lost
  @lost
end

#lost_countObject

Returns the value of attribute lost_count



1039
1040
1041
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1039

def lost_count
  @lost_count
end

#presentObject

Returns the value of attribute present



1038
1039
1040
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1038

def present
  @present
end

#present_countObject

Returns the value of attribute present_count



1039
1040
1041
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1039

def present_count
  @present_count
end

Instance Method Details

#to_xmlObject

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



1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1065

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