Class Bio::PhyloXML::SequenceRelation
In: lib/bio/db/phyloxml/phyloxml_elements.rb
Parent: Object

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’).

Methods

distance=   to_xml   type=  

Attributes

distance  [R]  Float
id_ref_0  [RW]  String
id_ref_1  [RW]  String
type  [RW]  String

Public Instance methods

@todo it has Confidences objects.

[Source]

      # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1116
1116:       def distance=(str)
1117:         @distance = str.to_f if str != nil
1118:       end

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

[Source]

      # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1133
1133:       def to_xml
1134:         if @id_ref_0 == nil or @id_ref_1 == nil or @type == nil
1135:           raise "Attributes id_ref_0, id_ref_1, type are required elements by SequenceRelation element."
1136:         else
1137:           sr = LibXML::XML::Node.new('sequence_relation')
1138:           sr['id_ref_0'] = @id_ref_0
1139:           sr['id_ref_1'] = @id_ref_1
1140:           sr['distance'] = @distance.to_s if @distance != nil
1141:           sr['type'] = @type
1142:           return sr
1143:         end
1144:       end

[Source]

      # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 1120
1120:       def type=(str)
1121:         #@todo do warning instead?
1122:         #@todo do validation at actually writing xml
1123:         allowed_values = ["orthology", "one_to_one_orthology", "super_orthology", "paralogy",
1124:             "ultra_paralogy", "xenology", "unknown", "other"]
1125:         if not allowed_values.include? str
1126:           raise "SequenceRelation#type has to be one one of #{allowed_values.join("; ")}"
1127:         else
1128:           @type = str
1129:         end
1130:       end

[Validate]