#!/usr/bin/python '''Exercises the tree improve service. Uses nexus file -filename arg pair to get the matrix and starting tree from a NEXUS file.''' from PIPRes.util.client_import import * from PIPRes.basic import * import unittest, re, copy from cStringIO import StringIO if __name__ == '__main__': _LOG = cipresGetLogger('pipres.service_impl.client.tree_improve') registryWrapper, mat, startingTree = cipresClientInit(sys.argv, returnMatrix = True, returnTree = True) if not (mat and startingTree): sys.exit('must specify a NEXUS file with a data matrix and tree using -filename arguments') treeInferObjRef = registryWrapper.getServiceOrExit(CipresIDL_api1.TreeInfer) try: _LOG.debug('about to set matrix') treeInferObjRef.setMatrix(mat) cmd = 'default hs swap = nni;' _LOG.debug('configuration command = "%s"' % cmd) treeInferObjRef.execute(cmd) _LOG.debug('about to inferTree') returnedTree = treeInferObjRef.inferTree(CORBA.Object._nil) tAndScore = 'returnedTree = %s\n score = %s' %(returnedTree.m_newick, str(returnedTree.m_score)) _LOG.debug(tAndScore) print tAndScore finally: treeInferObjRef.remove()