Class | Bio::PhyloXML::Node |
In: |
lib/bio/db/phyloxml/phyloxml_elements.rb
|
Parent: | Object |
Class to hold clade element of phyloXML.
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. |
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 221 221: def initialize 222: @confidences = [] 223: @sequences = [] 224: @taxonomies = [] 225: @distributions = [] 226: @references = [] 227: @properties = [] 228: @other = [] 229: end
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/db/phyloxml/phyloxml_elements.rb, line 269 269: def extract_biosequence(seq_i=0) 270: 271: seq = @sequences[seq_i].to_biosequence 272: seq.classification = [] 273: @taxonomies.each do |t| 274: seq.classification << t.scientific_name 275: if t.rank == "species" 276: seq.species = t.scientific_name 277: end 278: end 279: 280: #seq.division => .. http://www.ebi.ac.uk/embl/Documentation/User_manual/usrman.html#3_2 281: # It doesn't seem there is anything in PhyloXML corresponding to this. 282: 283: return seq 284: end
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/db/phyloxml/phyloxml_elements.rb, line 245 245: def to_biotreenode 246: node = Bio::Tree::Node.new 247: node.name = @name 248: node.scientific_name = @taxonomies[0].scientific_name if not @taxonomies.empty? 249: #@todo what if there are more? 250: node.taxonomy_id = @taxonomies[0].taxononmy_id if @taxonomies[0] != nil 251: 252: if not @confidences.empty? 253: @confidences.each do |confidence| 254: if confidence.type == "bootstrap" 255: node.bootstrap = confidence.value 256: break 257: end 258: end 259: end 260: return node 261: end
Converts elements to xml representation. Called by PhyloXML::Writer class.
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 287 287: def to_xml(branch_length, write_branch_length_as_subelement) 288: clade = LibXML::XML::Node.new('clade') 289: 290: PhyloXML::Writer.generate_xml(clade, self, [[:simple, 'name', @name]]) 291: 292: if branch_length != nil 293: if write_branch_length_as_subelement 294: clade << LibXML::XML::Node.new('branch_length', branch_length.to_s) 295: else 296: clade["branch_length"] = branch_length.to_s 297: end 298: end 299: 300: #generate all elements, except clade 301: PhyloXML::Writer.generate_xml(clade, self, [ 302: [:attr, "id_source"], 303: [:objarr, 'confidence', 'confidences'], 304: [:simple, 'width', @width], 305: [:complex, 'branch_color', @branch_color], 306: [:simple, 'node_id', @node_id], 307: [:objarr, 'taxonomy', 'taxonomies'], 308: [:objarr, 'sequence', 'sequences'], 309: [:complex, 'events', @events], 310: [:complex, 'binary_characters', @binary_characters], 311: [:objarr, 'distribution', 'distributions'], 312: [:complex, 'date', @date], 313: [:objarr, 'reference', 'references'], 314: [:objarr, 'propery', 'properties']]) 315: 316: return clade 317: end