def setUp(self): self.inCmpFile = path.join(DATA_DIR, "testforquiver.cmp.h5") self.outCmpFile = mkstemp(suffix=".cmp.h5")[1] copyfile(self.inCmpFile, self.outCmpFile) self.basFile = path.join(DATA_DIR, "lambda_bax.fofn") refpath = "/pbi/dept/secondary/siv/references/lambda/" self.fileNames = PBAlignFiles() self.fileNames.SetInOutFiles(self.basFile, refpath, self.outCmpFile, None, None) self.options = Opt() self.obj = ForQuiverService(self.fileNames, self.options)
def test_setInOutFiles(self): """Test PBAlignFiles.SetInOutFiles().""" p = PBAlignFiles() self.assertIsNone(p.inputFileName) self.assertIsNone(p.outputFileName) self.assertIsNone(p.referencePath) p.SetInOutFiles(self.inputFileName, self.referenceFile, self.outputFileName, None) self.assertTrue(filecmp.cmp(p.inputFileName, self.inputFileName)) self.assertTrue(filecmp.cmp(p.referencePath, self.referenceFile)) self.assertTrue(filecmp.cmp(p.targetFileName, self.referenceFile)) self.assertTrue(filecmp.cmp(p.outputFileName, self.outputFileName)) self.assertIsNone(p.regionTable)
def __init__(self, args=None, argumentList=(), output_dataset_type=AlignmentSet): """Initialize a PBAlignRunner object. argumentList is a list of arguments, such as: ['--debug', '--maxHits', '10', 'in.fasta', 'ref.fasta', 'out.sam'] """ desc = "Utilities for aligning PacBio reads to reference sequences." if args is None: # FIXME unit testing hack args = get_contract_parser().arg_parser.parser.parse_args( argumentList) self.args = args # args.verbosity is computed by counting # of 'v's in '-vv...'. # However in parseOptions, arguments are parsed twice to import config # options and then overwrite them with argumentList (e.g. command-line) # options. #self.args.verbosity = 1 if (self.args.verbosity is None) else \ # (int(self.args.verbosity) / 2 + 1) super(PBAlignRunner, self).__init__(desc) self._output_dataset_type = output_dataset_type self._alnService = None self._filterService = None self.fileNames = PBAlignFiles() self._tempFileManager = TempFileManager()
def test_init_region_table(self): """Test PBAlignFiles.__init__() with a region table.""" # With an artifical region table regionTable = path.join(self.rootDir, "data/lambda.rgn.h5") p = PBAlignFiles(self.inputFileName, self.referenceFile, self.outputFileName, regionTable) self.assertTrue(filecmp.cmp(p.regionTable, regionTable))
def test_init(self): """Test PBAlignFiles.__init__().""" # Without region table p = PBAlignFiles(self.inputFileName, self.referenceFile, self.outputFileName) self.assertTrue(filecmp.cmp(p.inputFileName, self.inputFileName)) self.assertTrue(filecmp.cmp(p.referencePath, self.referenceFile)) self.assertTrue(filecmp.cmp(p.targetFileName, self.referenceFile)) self.assertTrue(filecmp.cmp(p.outputFileName, self.outputFileName)) self.assertIsNone(p.regionTable)
def test_init(self): """Test PBAlignFiles.__init__() with a reference repository.""" # Without region table p = PBAlignFiles(self.inputFileName, self.referencePath, self.outputFileName) self.assertTrue(filecmp.cmp(p.inputFileName, self.inputFileName)) self.assertTrue(p.referencePath, path.abspath(path.expanduser(self.referencePath))) self.assertTrue(filecmp.cmp(p.targetFileName, self.targetFileName)) self.assertTrue(filecmp.cmp(p.outputFileName, self.outputFileName)) self.assertIsNone(p.regionTable)
def test_gmapCreateDB_case1(self): """Test _gmapCreateDB(refFile, isWithinRepository, tempRootDir). Condition: the reference is not within a reference repository. """ # Case 1: the reference is not within a reference repository files = PBAlignFiles() parser = argparse.ArgumentParser() argumentList = [ self.queryFofn, self.refFa, self.outSam, '--algorithm', 'gmap' ] parser, options, _info = parseOptions(argumentList=argumentList, parser=parser) service = GMAPService(options, files) dbRoot, dbName = service._gmapCreateDB(self.refFa, False, self.outDir) self.assertTrue(path.exists(dbRoot)) self.assertTrue(path.exists(path.join(dbRoot, dbName)))
def test_gmapCreateDB_case2(self): """Test _gmapCreateDB(refFile, isWithinRepository, tempRootDir). Condition: the reference is within a reference repository. """ # Case 2: the reference is within a reference repository files = PBAlignFiles() parser = argparse.ArgumentParser() argumentList = [ self.queryFofn, self.repoPath, self.outSam, '--algorithm', 'gmap' ] parser, options, _info = parseOptions(argumentList=argumentList, parser=parser) service = GMAPService(options, files) dbRoot, dbName = service._gmapCreateDB(files.targetFileName, True, self.outDir) self.assertEqual(path.abspath(dbRoot), path.abspath(self.repoPath)) self.assertEqual(dbName, "gmap_db")
class Test_ForQuiverService(unittest.TestCase): """Test pbalign.forquiverservice.forquiver.""" def setUp(self): self.inCmpFile = path.join(DATA_DIR, "testforquiver.cmp.h5") self.outCmpFile = mkstemp(suffix=".cmp.h5")[1] copyfile(self.inCmpFile, self.outCmpFile) self.basFile = path.join(DATA_DIR, "lambda_bax.fofn") refpath = "/pbi/dept/secondary/siv/references/lambda/" self.fileNames = PBAlignFiles() self.fileNames.SetInOutFiles(self.basFile, refpath, self.outCmpFile, None, None) self.options = Opt() self.obj = ForQuiverService(self.fileNames, self.options) def tearDown(self): remove(self.outCmpFile) def test_run(self): """Test ForQuiverService.__init__().""" self.obj.run()