#!/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 * 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') treeImproveObjRef = registryWrapper.getServiceOrExit(CipresIDL_api1.TreeImprove) try: _LOG.debug('about to set matrix') treeImproveObjRef.setMatrix(mat) _LOG.debug('startingTree = %s' % startingTree) treeImproveObjRef.setTree(startingTree) cmd = 'default hs swap = nni;' _LOG.debug('configuration command = "%s"' % cmd) treeImproveObjRef.execute(cmd) _LOG.debug('about to improveTree') returnedTree = treeImproveObjRef.improveTree(CORBA.Object._nil) tAndScore = 'returnedTree = %s\n score = %s' %(returnedTree.m_newick, str(returnedTree.m_score)) _LOG.debug(tAndScore) print tAndScore finally: treeImproveObjRef.remove()