#!/usr/bin/python from PIPRes.testing import * _LOG = cipresGetLogger('test_clustal_wrap.py') # We'll try to create a noew ClustalWrap instance from the # module (not via the CIPRES registry) is this script gets an # argument specfying the path to clustal. This can be a little faster # (and means that we don't need to keep the registry entry up to date if # we change clustal_wrap to add debugging code. factoryMethod = None if len(sys.argv) > 1: try: import clustal_wrap clustalPath = clustal_wrap._getPathToClustalFromArgv(sys.argv) factoryMethod = lambda self, reg : clustal_wrap.ClustalWrap(reg, clustalPath) sys.argv = [sys.argv[0]] except: pass class ClustalWrapTest(CipresTestingClient): serviceRegistryEntry = composeRegistryQuery(interface='MatrixAlign', applicationName='clustalW') serviceType = CipresIDL_api1.MatrixAlign serviceFactory = factoryMethod def cipresTestimple(self): m = dnaToCipresMatrix([ 'RCGTCACGTG', 'ACGTACTTC', 'ATGCAG?TTC', 'ATGACGNTC' ], aligned=False) t = CipresTree('(1:0.2,2:.04,(3:0.03,4:0.02):0.01)') addScore(t, None) self.testedService.setTaxa(['a', 'b', 'c', 'd']) self.testedService.setInputMatrix(m) self.testedService.setGuideTree(t) self.testedService.execute('') # This is workaround to allow Alex's implementation to work alignedMat = self.testedService.getAlignedMatrix() expectedMat = dnaToCipresMatrix(['RCGTCACGTG', 'ACGTACTTC-', 'ATGCAGNTTC', 'ATGACGNTC-', ] , aligned=True) self.assertEqual(alignedMat, expectedMat) if __name__ == '__main__': addCipresTests(ClustalWrapTest) main()