class Bio::PhyloXML::Taxonomy

Taxonomy class for PhyloXML

Attributes

authority[RW]

is used to keep the authority, such as ‘J. G. Cooper, 1863’, associated with the ‘scientific_name’.

code[RW]

pattern = [a-zA-Z0-9_]{2,10} Can refer to any code/abbreviation/mnemonic, such as Bsu for Bacillus subtilis.

common_names[RW]

An array of strings

id_source[RW]

Used to link other elements to a taxonomy (on the xml-level)

other[RW]

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

rank[RW]

value comes from list: domain kingdom, subkingdom, branch, infrakingdom, superphylum, phylum, subphylum, infraphylum, microphylum, superdivision, division, subdivision, infradivision, superclass, class, subclass, infraclass, superlegion, legion, sublegion, infralegion, supercohort, cohort, subcohort, infracohort, superorder, order, suborder, superfamily, family, subfamily, supertribe, tribe, subtribe, infratribe, genus, subgenus, superspecies, species, subspecies, variety, subvariety, form, subform, cultivar, unknown, other

scientific_name[RW]

String.

synonyms[RW]

An array of strings. Holds synonyms for scientific names or common names.

taxonomy_id[RW]

String. Unique identifier of a taxon.

uri[RW]

Uri object

Public Class Methods

new() click to toggle source

creates a new Bio::PhyloXML::Taxonomy object.

   # File lib/bio-phyloxml/phyloxml_elements.rb
56 def initialize
57   @common_names = []
58   @synonyms = []
59 
60   # below attributes may be PhyloXML specific.
61   @other = []
62 end

Public Instance Methods

to_xml() click to toggle source

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

   # File lib/bio-phyloxml/phyloxml_elements.rb
80 def to_xml
81   taxonomy = LibXML::XML::Node.new('taxonomy')
82   taxonomy["type"] = @type if (defined? @type) && @type
83   taxonomy["id_source"] = @id_source if (defined? @id_source) && @id_source
84 
85   PhyloXML::Writer.generate_xml(taxonomy, self, [[:complex, 'id', (defined? @taxonomy_id) ? @taxonomy_id : nil],
86     [:pattern, 'code', (defined? @code) ? @code : nil, Regexp.new("^[a-zA-Z0-9_]{2,10}$")],
87     [:simple, 'scientific_name', (defined? @scientific_name) ? @scientific_name : nil],
88     [:simple, 'authority', (defined? @authority) ? @authority : nil],
89     [:simplearr, 'common_name', (defined? @common_names) ? @common_names : nil],
90     [:simplearr, 'synonym', (defined? @synonyms) ? @synonyms : nil],
91     [:simple, 'rank', (defined? @rank) ? @rank : nil],
92     [:complex, 'uri',(defined? @uri) ? @uri : nil]])
93     #@todo anything else
94 
95 
96   return taxonomy
97 end