Пример #1
0
 def test_marking_trees(self):
     TREE_PATH = ETEPATH + '/examples/evol/data/S_example/'
     tree = EvolTree (TREE_PATH + 'measuring_S_tree.nw')
     self.assertEqual(tree.write(),
                      '((Hylobates_lar,(Gorilla_gorilla,Pan_troglodytes)),Papio_cynocephalus);')
     tree.mark_tree ([1, 3, 7] + [2, 6], marks=['#1']*3 + ['#2']*2, verbose=True)
     self.assertEqual(tree.write().replace(' ', ''),
                      '((Hylobates_lar#2,(Gorilla_gorilla#1,Pan_troglodytes#1)#1)#2,Papio_cynocephalus);')
     tree.mark_tree (map (lambda x: x.node_id, tree.get_descendants()),
                     marks=[''] * len (tree.get_descendants()), verbose=False)
     self.assertEqual(tree.write().replace(' ', ''),
                      '((Hylobates_lar,(Gorilla_gorilla,Pan_troglodytes)),Papio_cynocephalus);')
Пример #2
0
                                      hlines_col=['black','grey'])
T.show(histfaces = ['M1', 'M2'])


###
# mark tree functionality
print T.write(format=10)
name = None
while name not in T.get_leaf_names():
    name = raw_input('         ====> As you need to mark some branches to run branch\n\
    models, type the name of one leaf: ')

idname = T.get_leaves_by_name(name)[0].node_id

print '         ----> you want to mark:',name,'that has this idname: ', idname
T.mark_tree([idname]) # by default will mark with '#1'
print 'have a look to the mark: '
print re.sub('#','|',re.sub('[0-9a-zA-Z_(),;]',' ',T.write(format=10)))
print re.sub('#','v',re.sub('[0-9a-zA-Z_(),;]',' ',T.write(format=10)))
print T.write(format=10)
print '\n You have marked the tree with a command like:  T.mark_tree([%d])\n' % (idname)
print '\n%s\n%s\n%s\n' % ('*'*10 + ' doc ' + '*'*10, T.mark_tree.func_doc, \
                                                                      '*'*30)

print '\n\n\n         ----> We are now going to run branch-site models bsA and bsA1:\n\n'
raw_input("         ====> hit some key to start computation with our marked tree")
for model in ['bsA','bsA1']:
    print 'running model ' + model
    T.run_model(model)