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


1071
1072
1073
1074
1075
1076
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1071

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

Instance Attribute Details

#absentObject

Returns the value of attribute absent


1052
1053
1054
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1052

def absent
  @absent
end

#absent_countObject

Returns the value of attribute absent_count


1053
1054
1055
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1053

def absent_count
  @absent_count
end

#bc_typeObject

Returns the value of attribute bc_type


1052
1053
1054
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1052

def bc_type
  @bc_type
end

#gainedObject

Returns the value of attribute gained


1052
1053
1054
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1052

def gained
  @gained
end

#gained_countObject

Returns the value of attribute gained_count


1053
1054
1055
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1053

def gained_count
  @gained_count
end

#lostObject

Returns the value of attribute lost


1052
1053
1054
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1052

def lost
  @lost
end

#lost_countObject

Returns the value of attribute lost_count


1053
1054
1055
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1053

def lost_count
  @lost_count
end

#presentObject

Returns the value of attribute present


1052
1053
1054
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1052

def present
  @present
end

#present_countObject

Returns the value of attribute present_count


1053
1054
1055
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1053

def present_count
  @present_count
end

Instance Method Details

#to_xmlObject

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


1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# 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