[Biopython-dev] [Biopython - Feature #3427] (New) Cache paths in Bio.Phylo trees for later use
redmine at redmine.open-bio.org
redmine at redmine.open-bio.org
Mon Apr 15 14:29:45 UTC 2013
Issue #3427 has been reported by Ben Morris.
----------------------------------------
Feature #3427: Cache paths in Bio.Phylo trees for later use
https://redmine.open-bio.org/issues/3427
Author: Ben Morris
Status: New
Priority: Normal
Assignee:
Category:
Target version:
URL:
I'm doing some analyses using Bio.Phylo in which I need to find many distances between pairs of taxa, and have found that this can be quite slow as currently implemented.
My current solution is to extend Newick.Tree objects and cache the result of the get_path function. This way, after finding the distance between species A and B, finding the distance between A and C doesn't require recomputing the path from A to the root. Example:
<pre>
class CachingTree(bp.Newick.Tree):
_paths = {}
def __init__(self, tree):
self.__dict__.update(tree.__dict__)
def get_path(self, target, **kwargs):
if not target in self._paths:
self._paths[target] = bp.Newick.Tree.get_path(self, target=target,
**kwargs)
return self._paths[target]
</pre>
Should this functionality be incorporated into the BaseTree class itself?
----------------------------------------
You have received this notification because this email was added to the New Issue Alert plugin
--
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here and login: http://redmine.open-bio.org
More information about the Biopython-dev
mailing list