Class: Bio::PhyloXML::Node
- Inherits:
-
Object
- Object
- Bio::PhyloXML::Node
- Defined in:
- lib/bio-phyloxml/phyloxml_elements.rb
Overview
Description
Class to hold clade element of phyloXML.
Instance Attribute Summary collapse
-
#binary_characters ⇒ Object
BinaryCharacters object.
-
#color ⇒ Object
BranchColor object.
-
#confidences ⇒ Object
Array of Confidence objects.
-
#date ⇒ Object
Date object.
-
#distributions ⇒ Object
Array of Distribution objects.
-
#events ⇒ Object
Events at the root node of a clade (e.g. one gene duplication).
-
#id_source ⇒ Object
String.
-
#name ⇒ Object
String.
-
#node_id ⇒ Object
Id object.
-
#other ⇒ Object
Array of Other objects.
-
#properties ⇒ Object
An array of Property objects, for example depth for sea animals.
-
#references ⇒ Object
Array of Reference objects.
-
#sequences ⇒ Object
Array of Sequence objects.
-
#taxonomies ⇒ Object
Array of Taxonomy objects.
-
#width ⇒ Object
Float.
Instance Method Summary collapse
-
#extract_biosequence(seq_i = 0) ⇒ Object
Extracts the relevant information from node (specifically taxonomy and sequence) to create Bio::Sequence object.
-
#initialize ⇒ Node
constructor
A new instance of Node.
-
#to_biotreenode ⇒ Object
Converts to a Bio::Tree::Node object.
-
#to_xml(branch_length, write_branch_length_as_subelement) ⇒ Object
Converts elements to xml representation.
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
209 210 211 212 213 214 215 216 217 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 209 def initialize @confidences = [] @sequences = [] @taxonomies = [] @distributions = [] @references = [] @properties = [] @other = [] end |
Instance Attribute Details
#binary_characters ⇒ Object
BinaryCharacters object. The names and/or counts of binary characters present, gained, and lost at the root of a clade.
191 192 193 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 191 def binary_characters @binary_characters end |
#color ⇒ Object
BranchColor object. Apply for the whole clade unless overwritten in sub-clade.
182 183 184 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 182 def color @color end |
#confidences ⇒ Object
Array of Confidence objects. Indicates the support for a clade/parent branch.
179 180 181 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 179 def confidences @confidences end |
#date ⇒ Object
Date object. A date associated with a clade/node.
197 198 199 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 197 def date @date end |
#distributions ⇒ Object
Array of Distribution objects. The geographic distribution of the items of a clade (species, sequences), intended for phylogeographic applications.
194 195 196 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 194 def distributions @distributions end |
#events ⇒ Object
Events at the root node of a clade (e.g. one gene duplication).
160 161 162 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 160 def events @events end |
#id_source ⇒ Object
String. Used to link other elements to a clade (node) (on the xml-level).
163 164 165 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 163 def id_source @id_source end |
#name ⇒ Object
String. Name of the node.
166 167 168 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 166 def name @name end |
#node_id ⇒ Object
Id object
185 186 187 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 185 def node_id @node_id end |
#other ⇒ Object
Array of Other objects. Used to save additional information from other than PhyloXML namspace.
207 208 209 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 207 def other @other end |
#properties ⇒ Object
An array of Property objects, for example depth for sea animals.
203 204 205 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 203 def properties @properties end |
#references ⇒ Object
Array of Reference objects. A literature reference for a clade.
200 201 202 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 200 def references @references end |
#sequences ⇒ Object
Array of Sequence objects. Represents a molecular sequence (Protein, DNA, RNA) associated with a node.
188 189 190 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 188 def sequences @sequences end |
#taxonomies ⇒ Object
Array of Taxonomy objects. Describes taxonomic information for a clade.
176 177 178 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 176 def taxonomies @taxonomies end |
#width ⇒ Object
Float. Branch width for this node (including parent branch). Applies for the whole clade unless overwritten in sub-clades.
169 170 171 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 169 def width @width end |
Instance Method Details
#extract_biosequence(seq_i = 0) ⇒ Object
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
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 257 def extract_biosequence(seq_i=0) seq = @sequences[seq_i].to_biosequence seq.classification = [] @taxonomies.each do |t| seq.classification << t.scientific_name if t.rank == "species" seq.species = t.scientific_name end end #seq.division => .. http://www.ebi.ac.uk/embl/Documentation/User_manual/usrman.html#3_2 # It doesn't seem there is anything in PhyloXML corresponding to this. return seq end |
#to_biotreenode ⇒ Object
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
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 233 def to_biotreenode node = Bio::Tree::Node.new node.name = @name node.scientific_name = @taxonomies[0].scientific_name if not @taxonomies.empty? #@todo what if there are more? node.taxonomy_id = @taxonomies[0].taxononmy_id if @taxonomies[0] != nil if not @confidences.empty? @confidences.each do |confidence| if confidence.type == "bootstrap" node.bootstrap = confidence.value break end end end return node end |
#to_xml(branch_length, write_branch_length_as_subelement) ⇒ Object
Converts elements to xml representation. Called by PhyloXML::Writer class.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 275 def to_xml(branch_length, write_branch_length_as_subelement) clade = LibXML::XML::Node.new('clade') PhyloXML::Writer.generate_xml(clade, self, [[:simple, 'name', (defined? @name) ? @name : nil]]) if branch_length != nil if write_branch_length_as_subelement clade << LibXML::XML::Node.new('branch_length', branch_length.to_s) else clade["branch_length"] = branch_length.to_s end end #generate all elements, except clade PhyloXML::Writer.generate_xml(clade, self, [ [:attr, "id_source"], [:objarr, 'confidence', 'confidences'], [:simple, 'width', (defined? @width) ? @width : nil], [:complex, 'branch_color', (defined? @branch_color) ? @branch_color : nil], [:simple, 'node_id', (defined? @node_id) ? @node_id : nil], [:objarr, 'taxonomy', 'taxonomies'], [:objarr, 'sequence', 'sequences'], [:complex, 'events', (defined? @events) ? @events : nil], [:complex, 'binary_characters', (defined? @binary_characters) ? @binary_characters : nil], [:objarr, 'distribution', 'distributions'], [:complex, 'date', (defined? @date) ? @date : nil], [:objarr, 'reference', 'references'], [:objarr, 'propery', 'properties']]) return clade end |