Beispiel #1
0
    def tree_collection(self,
                        niters=5,
                        keep_topology=False,
                        quiet=True,
                        tmpdir=None,
                        taxon_set=None,
                        guide_tree=None,
                        set_as_record_tree=True):

        import tree_collection

        if tmpdir is not None:
            tmpdir = tmpdir
        elif self.tmpdir is not None:
            tmpdir = self.tmpdir
        else:
            tmpdir = TMPDIR

        gt = None

        if guide_tree is not None:
            gt = guide_tree

        elif self.tree is not None:
            gt = self.tree

        else:
            self.bionj(tmpdir)
            gt = self.tree

        if gt is None:
            raise Exception('Couldn\'t generate a guide tree')

        if self.dv <= []:
            self.dv_matrix(tmpdir)

        if not gt.is_rooted:
            gt.reroot_at_midpoint()
        if not gt.is_rooted:
            raise Exception('Couldn\'t root the guide tree' )

        dv, gm, lab = self._get_tree_collection_strings()
        output_tree, score = tree_collection.compute(dv, gm, lab, gt.newick,
                                                     niters, keep_topology,
                                                     quiet)
        if taxon_set is not None:
            result = TrClTree(output_tree, score, program='tree_collection',
                              name=self.name, output='',
                              taxon_set=taxon_set)
        else:
            result = TrClTree(output_tree, score, program='tree_collection',
                              name=self.name, output='')

        if set_as_record_tree:
            self.tree = result

        return result
Beispiel #2
0
#!/usr/bin/env python
from __future__ import print_function
import tree_collection

mat = open('/Users/kgori/git_repos/gitolite/treesoflife/data/DistVar.txt').read()
map_ = open('/Users/kgori/git_repos/gitolite/treesoflife/data/GenomeMap.txt').read()
lab = open('/Users/kgori/git_repos/gitolite/treesoflife/data/Labels.txt').read()
tre = open('/Users/kgori/git_repos/gitolite/treesoflife/data/Tree.nwk').read()

print('Running test 1 - fit initial tree...')
result = tree_collection.compute(mat, map_, lab, tre,
                                 iter=8,
                                 keep_topology=True,
                                 quiet=False)
print(type(result))
print(result[0])
print(result[1])

print('Running test 2 - optimise tree...')
result = tree_collection.compute(mat, map_, lab, tre,
                                 iter=8,
                                 keep_topology=False,
                                 quiet=False)
print(type(result))
print(result[0])
print(result[1])
#!/usr/bin/env python

import tree_collection
import sys

folder_name = sys.argv[1]

mat = open(folder_name + 'DistVar.txt').read()
map_ = open(folder_name + 'Map.txt').read()
lab = open(folder_name + "Labels.txt").read()
tre = open(folder_name + 'initial_tree.txt').read()

result = tree_collection.compute(mat, map_, lab, tre, 8, False)
with open(r'%s' % folder_name + "tree.txt", 'w') as tree_coll_tree:
    tree_coll_tree.write(result[0])


Beispiel #4
0
def minsq_task(dv, gm, lab, tree, niters=10):
    tree, sse = tree_collection.compute(dv, gm, lab, tree, niters, False, True)
    tree = Tree(tree)
    tree.deroot()
    return dict(tree=tree.newick, sse=sse)
Beispiel #5
0
def minsq_task(dv, gm, lab, tree, niters=10, keep_topology=False):
    tree, lk = tree_collection.compute(dv, gm, lab, tree, niters, True, keep_topology, False)
    tree = Tree(tree)
    tree.deroot()
    return dict(tree=tree.newick, score=lk)
Beispiel #6
0
def minsq_task(dv, gm, lab, tree, niters=10):
    tree, sse = tree_collection.compute(dv, gm, lab, tree, niters, False, True)
    tree = Tree(tree)
    tree.deroot()
    return dict(tree=tree.newick, sse=sse)