#!/usr/bin/python import CORBA from raxml_wrap import * from PIPRes.cipres_types import * from PIPRes.nexus.primitives import * import unittest, re, copy from PIPRes.basic import * import unittest, re, copy from PIPRes.util.cipres import getCipresProperty from cStringIO import StringIO from PIPRes.util.cipres_registry_from_xml import composeRegistryQuery _LOG = cipresGetLogger('test.service_impl.paup_wrap_tree_infer') _registry = cipresDefaultRegistry() pathToRaxml = False and getCipresProperty('raxmlPath') or os.environ.get('RAXML_EXE', '') class RAxMLWrapTest(unittest.TestCase): registry = cipresDefaultRegistry() def setUp(self): regEnt = composeRegistryQuery(interface='TreeImprove', applicationName='raxml') directCall = pathToRaxml and os.path.exists(pathToRaxml) if directCall: _LOG.debug("testing with direct call") self.tiObjRef = RaxmlWrap(RAxMLWrapTest.registry, pathToRaxml) else: self.tiObjRef = RAxMLWrapTest.registry.getServiceOrThrow(CipresIDL_api1.TreeImprove, registryEntry=regEnt) def testStoredFile(self): matrix = CipresIDL_api1.DataMatrix('ACGT?', 4, 10, [[0], [1], [2], [3], [-1,0,1,2,3]], [ [0,1,2,3,4,0,1,2,3,4], [2,3,4,0,1,2,3,4,0,1], [0,1,2,3,4,0,1,2,3,3], [2,3,4,0,1,2,3,4,1,1], ], CipresIDL_api1.DNA_DATATYPE) startTree = CipresTree('(1,2,(3,4))') addScore(startTree, None) expectedTree = numberedLeafTree('(1,3,(2,4))') self.do_test(matrix, startTree, expectedTree) def testMultiExecute(self): self.assertEqual(self.tiObjRef.execute("-m GTRCAT"), (True, "")) self.assertEqual(self.tiObjRef.execute("-i 10"), (True, "")) self.testStoredFile() def do_test(self, matrix, startTree, expectedTree): try: self.tiObjRef.setMatrix(matrix) self.tiObjRef.setTree(startTree) rTree = CipresTree(self.tiObjRef.improveTree(CORBA.Object._nil)) _LOG.debug(str(expectedTree)) _LOG.debug(str(rTree)) self.assertEqual(expectedTree, rTree) finally: self.tiObjRef.remove() if __name__ == '__main__': unittest.main()