Class: Bio::PhyloXML::Confidence

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

Overview

A general purpose confidence element. For example this can be used to express the bootstrap support value of a clade (in which case the ‘type’ attribute is ‘bootstrap’).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, value) ⇒ Confidence

Returns a new instance of Confidence.



391
392
393
394
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 391

def initialize(type, value)
  @type = type
  @value = value.to_f
end

Instance Attribute Details

#typeObject

String. The type of confidence measure, for example, bootstrap.



387
388
389
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 387

def type
  @type
end

#valueObject

Float. The value of confidence measure.



389
390
391
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 389

def value
  @value
end

Instance Method Details

#to_xmlObject

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



397
398
399
400
401
402
403
404
405
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 397

def to_xml
  if @type == nil
    raise "Type is a required attribute for confidence."
  else
    confidence = LibXML::XML::Node.new('confidence', @value.to_s)
    confidence["type"] = @type          
    return confidence
  end
end