class Bio::PhyloXML::SequenceRelation

Description

This is used to express a typed relationship between two sequences. For example it could be used to describe an orthology (in which case attribute ‘type’ is ‘orthology’).

Attributes

distance[R]

Float

id_ref_0[RW]

String

id_ref_1[RW]

String

type[RW]

String

Public Instance Methods

distance=(str) click to toggle source

@todo it has Confidences objects.

# File lib/bio/phyloxml/elements.rb, line 1108
def distance=(str)
  @distance = str.to_f if str != nil
end
to_xml() click to toggle source

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

# File lib/bio/phyloxml/elements.rb, line 1125
def to_xml
  if @id_ref_0 == nil or @id_ref_1 == nil or @type == nil
    raise "Attributes id_ref_0, id_ref_1, type are required elements by SequenceRelation element."
  else
    sr = LibXML::XML::Node.new('sequence_relation')
    sr['id_ref_0'] = @id_ref_0
    sr['id_ref_1'] = @id_ref_1
    sr['distance'] = @distance.to_s if @distance != nil
    sr['type'] = @type
    return sr
  end
end
type=(str) click to toggle source
# File lib/bio/phyloxml/elements.rb, line 1112
def type=(str)
  #@todo do warning instead?
  #@todo do validation at actually writing xml
  allowed_values = ["orthology", "one_to_one_orthology", "super_orthology", "paralogy",
      "ultra_paralogy", "xenology", "unknown", "other"]
  if not allowed_values.include? str
    raise "SequenceRelation#type has to be one one of #{allowed_values.join("; ")}"
  else
    @type = str
  end
end