class ForQuiverService(object): """ Uses SortService, LoadPulsesService, RepackService to post process a cmp.h5 file so that the file can be used by quiver directly. """ @property def name(self): """Name of ForQuiverService.""" return "ForQuiverService" def __init__(self, fileNames, options): """Initialize a ForQuiverService object. Input: fileNames : pbalign file names options : pbalign options """ self.fileNames = fileNames self.options = options self._loadpulsesService = LoadPulsesService( self.fileNames.pulseFileName, self.fileNames.outputFileName, self.options) self._sortService = SortService( self.fileNames.outputFileName, self.options) self._repackService = RepackService( self.fileNames.outputFileName, self.fileNames.outputFileName + ".TMP") def run(self): """ Run the ForQuiver service.""" logging.info(self.name + ": Sort.") self._sortService.checkAvailability() self._sortService.run() logging.info(self.name + ": LoadPulses.") self._loadpulsesService.checkAvailability() self._loadpulsesService.run() logging.info(self.name + ": Repack.") self._repackService.checkAvailability() self._repackService.run()
class Test_RepackService(unittest.TestCase): """Test pbtools.pbalign.forquiverservice.repack.""" def setUp(self): """Set up the tests.""" self.rootDir = "/mnt/secondary-siv/secondarytest/" + \ "testdata/BlasrTestData/pbalign" self.inCmpFile = path.join(self.rootDir, "data/testrepack.cmp.h5") #self.outCmpFile = path.join(self.rootDir, "out/testrepack.cmp.h5") self.outCmpFile = mkstemp(suffix=".cmp.h5")[1] self.tmpCmpFile = self.outCmpFile + ".tmp" #self.tmpCmpFile = path.join(self.rootDir, "out/testrepack.cmp.h5.tmp") copyfile(self.inCmpFile, self.outCmpFile) self.options = {} self.obj = RepackService(self.outCmpFile, self.tmpCmpFile) def tearDown(self): remove(self.outCmpFile) def test_run(self): """Test LoadPulsesService.__init__().""" print self.obj.cmd _output, errCode, _errMsg = self.obj.run() self.assertEqual(errCode, 0)