class Bio::PhyloXML::Node

Description

Class to hold clade element of phyloXML.

Attributes

binary_characters[RW]

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

color[RW]

BranchColor object. Apply for the whole clade unless overwritten in sub-clade.

confidences[RW]

Array of Confidence objects. Indicates the support for a clade/parent branch.

date[RW]

Date object. A date associated with a clade/node.

distributions[RW]

Array of Distribution objects. The geographic distribution of the items of a clade (species, sequences), intended for phylogeographic applications.

events[RW]

Events at the root node of a clade (e.g. one gene duplication).

id_source[RW]

String. Used to link other elements to a clade (node) (on the xml-level).

name[RW]

String. Name of the node.

node_id[RW]

Id object

other[RW]

Array of Other objects. Used to save additional information from other than PhyloXML namspace.

properties[RW]

An array of Property objects, for example depth for sea animals.

references[RW]

Array of Reference objects. A literature reference for a clade.

sequences[RW]

Array of Sequence objects. Represents a molecular sequence (Protein, DNA, RNA) associated with a node.

taxonomies[RW]

Array of Taxonomy objects. Describes taxonomic information for a clade.

width[R]

Float. Branch width for this node (including parent branch). Applies for the whole clade unless overwritten in sub-clades.

Public Class Methods

new() click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
209 def initialize
210   @confidences = []
211   @sequences = []
212   @taxonomies = []
213   @distributions = []
214   @references = []
215   @properties = []
216   @other = []
217 end

Public Instance Methods

extract_biosequence(seq_i=0) click to toggle source

Extracts the relevant information from node (specifically taxonomy and sequence) to create Bio::Sequence object. Node can have several sequences, so parameter to this method is to specify which sequence to extract.


Returns

Bio::Sequence

    # File lib/bio-phyloxml/phyloxml_elements.rb
257 def extract_biosequence(seq_i=0)
258 
259   seq = @sequences[seq_i].to_biosequence
260   seq.classification = []
261   @taxonomies.each do |t|
262     seq.classification << t.scientific_name
263     if t.rank == "species"
264       seq.species = t.scientific_name
265     end
266   end
267 
268   #seq.division => .. http://www.ebi.ac.uk/embl/Documentation/User_manual/usrman.html#3_2
269   # It doesn't seem there is anything in PhyloXML corresponding to this.
270 
271   return seq
272 end
to_biotreenode() click to toggle source

Converts to a Bio::Tree::Node object. If it contains several taxonomies Bio::Tree::Node#scientific name will get the scientific name of the first taxonomy.

If there are several confidence values, the first with bootstrap type will be returned as Bio::Tree::Node#bootstrap

tree = phyloxmlparser.next_tree

node = tree.get_node_by_name(“A”).to_biotreenode


Returns

Bio::Tree::Node

    # File lib/bio-phyloxml/phyloxml_elements.rb
233 def to_biotreenode
234   node = Bio::Tree::Node.new
235   node.name = @name
236   node.scientific_name = @taxonomies[0].scientific_name if not @taxonomies.empty?
237   #@todo what if there are more?
238   node.taxonomy_id = @taxonomies[0].taxononmy_id if @taxonomies[0] != nil
239 
240   if not @confidences.empty?
241     @confidences.each do |confidence|
242       if confidence.type == "bootstrap"
243         node.bootstrap = confidence.value
244         break
245       end
246     end
247   end      
248   return node
249 end
to_xml(branch_length, write_branch_length_as_subelement) click to toggle source

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

    # File lib/bio-phyloxml/phyloxml_elements.rb
275 def to_xml(branch_length,  write_branch_length_as_subelement)
276   clade = LibXML::XML::Node.new('clade')
277   
278   PhyloXML::Writer.generate_xml(clade, self, [[:simple, 'name', (defined? @name) ? @name : nil]])
279 
280   if branch_length != nil       
281     if write_branch_length_as_subelement
282       clade << LibXML::XML::Node.new('branch_length', branch_length.to_s)
283     else
284       clade["branch_length"] = branch_length.to_s
285     end
286   end
287 
288   #generate all elements, except clade
289   PhyloXML::Writer.generate_xml(clade, self, [
290       [:attr, "id_source"],
291       [:objarr, 'confidence', 'confidences'],
292       [:simple, 'width', (defined? @width) ? @width : nil],
293       [:complex, 'branch_color', (defined? @branch_color) ? @branch_color : nil],
294       [:simple, 'node_id', (defined? @node_id) ? @node_id : nil],
295       [:objarr, 'taxonomy', 'taxonomies'],
296       [:objarr, 'sequence', 'sequences'],
297       [:complex, 'events', (defined? @events) ? @events : nil],
298       [:complex, 'binary_characters', (defined? @binary_characters) ? @binary_characters : nil],
299       [:objarr, 'distribution', 'distributions'],
300       [:complex, 'date', (defined? @date) ? @date : nil],
301       [:objarr, 'reference', 'references'],
302       [:objarr, 'propery', 'properties']])
303  
304   return clade
305 end
width=(str) click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
171 def width=(str)
172   @width = str.to_f
173 end