Class: BioInterchange::Phylogenetics::TreeSet
- Defined in:
- lib/biointerchange/phylogenetics/tree_set.rb
Overview
A phylogenetic tree set that can contain multiple phylogenetic trees.
Instance Method Summary collapse
-
#add(tree) ⇒ Object
Add a tree to the tree set.
-
#contents ⇒ Object
Returns the contents of the tree set.
-
#date ⇒ Object
If a date was provided, then this method returns its value.
-
#initialize ⇒ TreeSet
constructor
Create a new instance of a tree set.
-
#prune ⇒ Object
Removes all features from the set, but keeps additional data (e.g., the date).
-
#set_date(date) ⇒ Object
Sets a date that is associated with the trees in this model (e.g., annotation date, creation date, etc.).
-
#uri ⇒ Object
Returns an URI for this particular tree set, which is a not necessarily globally unique SHA1 hash.
Constructor Details
#initialize ⇒ TreeSet
Create a new instance of a tree set. A tree set can contain multiple phylogenetic trees.
9 10 11 12 |
# File 'lib/biointerchange/phylogenetics/tree_set.rb', line 9 def initialize # Trees are stored as the keys of a hash map to increase performance: @set = {} end |
Instance Method Details
#add(tree) ⇒ Object
Add a tree to the tree set.
treeBioRuby tree instance that is added to the contents of this tree set
39 40 41 |
# File 'lib/biointerchange/phylogenetics/tree_set.rb', line 39 def add(tree) @set[tree] = true end |
#contents ⇒ Object
Returns the contents of the tree set.
15 16 17 |
# File 'lib/biointerchange/phylogenetics/tree_set.rb', line 15 def contents @set.keys end |
#date ⇒ Object
If a date was provided, then this method returns its value.
20 21 22 |
# File 'lib/biointerchange/phylogenetics/tree_set.rb', line 20 def date @date end |
#prune ⇒ Object
Removes all features from the set, but keeps additional data (e.g., the date).
44 45 46 |
# File 'lib/biointerchange/phylogenetics/tree_set.rb', line 44 def prune @set.clear end |
#set_date(date) ⇒ Object
Sets a date that is associated with the trees in this model (e.g., annotation date, creation date, etc.).
datean instance of Date that is associated with all trees in the model
27 28 29 |
# File 'lib/biointerchange/phylogenetics/tree_set.rb', line 27 def set_date(date) @date = date end |
#uri ⇒ Object
Returns an URI for this particular tree set, which is a not necessarily globally unique SHA1 hash.
32 33 34 |
# File 'lib/biointerchange/phylogenetics/tree_set.rb', line 32 def uri "biointerchange://phylogenetics/treeset/self/#{Digest::SHA1.hexdigest(Time.now.to_s)}" end |