18
|
1 from commons.core.utils.FileUtils import FileUtils
|
|
2 import unittest
|
|
3 import os
|
|
4 import subprocess
|
|
5 from commons.launcher.LaunchMatcher import LaunchMatcher
|
|
6
|
|
7 class Test_F_LaunchMatcher(unittest.TestCase):
|
|
8
|
|
9 def setUp(self):
|
|
10 self._inFileName = "DmelChr4.align"
|
|
11 self._fastaFileName = "DmelChr4.fa"
|
|
12 inFilePath = "%s/Tools/%s" % (os.environ["REPET_DATA"], self._inFileName)
|
|
13 inFastaPath = "%s/Tools/%s" % (os.environ["REPET_DATA"], self._fastaFileName)
|
|
14 try:
|
|
15 os.remove(self._inFileName)
|
|
16 except:
|
|
17 pass
|
|
18 os.symlink(inFilePath, self._inFileName)
|
|
19 os.symlink(inFastaPath, self._fastaFileName)
|
|
20 self._iLaunchMatcher = LaunchMatcher(align=self._inFileName, queryFileName=self._fastaFileName, subjectFileName=self._fastaFileName, doJoin=True, evalue="1e-20", keepConflict=True)
|
|
21 self._iLaunchMatcher.setVerbosity(2)
|
|
22
|
|
23 def tearDown(self):
|
|
24 try:
|
|
25 FileUtils.removeFilesByPattern("%s*" % self._inFileName)
|
|
26 os.remove(self._fastaFileName)
|
|
27 except:
|
|
28 pass
|
|
29
|
|
30 def test_run_as_class_1_file(self):
|
|
31 expPathFileName = "%s/Tools/DmelChr4.align.match.path" % os.environ["REPET_DATA"]
|
|
32 expTabFileName = "%s/Tools/DmelChr4.align.match.tab" % os.environ["REPET_DATA"]
|
|
33
|
|
34 obsPathFileName = "%s.match.path" % self._inFileName
|
|
35 obsTabFileName = "%s.match.tab" % self._inFileName
|
|
36
|
|
37 self._iLaunchMatcher.run()
|
|
38
|
|
39 self.assertTrue(FileUtils.are2FilesIdentical(expPathFileName, obsPathFileName))
|
|
40 self.assertTrue(FileUtils.are2FilesIdentical(expTabFileName, obsTabFileName))
|
|
41
|
|
42 def test_run_as_script(self):
|
|
43 expPathFileName = "%s/Tools/DmelChr4.align.match.path" % os.environ["REPET_DATA"]
|
|
44 expTabFileName = "%s/Tools/DmelChr4.align.match.tab" % os.environ["REPET_DATA"]
|
|
45
|
|
46 cmd = "LaunchMatcher.py "
|
|
47 cmd += "-a %s " % self._inFileName
|
|
48 cmd += "-q %s " % self._fastaFileName
|
|
49 cmd += "-s %s " % self._fastaFileName
|
|
50 cmd += "-o DmelChr4.align "
|
|
51 cmd += "-j "
|
|
52 cmd += "-k "
|
|
53 cmd += "-e 1e-20 "
|
|
54 process = subprocess.Popen(cmd, shell = True)
|
|
55 process.communicate()
|
|
56 obsPathFileName = "%s.match.path" % self._inFileName
|
|
57 obsTabFileName = "%s.match.tab" % self._inFileName
|
|
58
|
|
59 self.assertTrue(FileUtils.are2FilesIdentical(expPathFileName, obsPathFileName))
|
|
60 self.assertTrue(FileUtils.are2FilesIdentical(expTabFileName, obsTabFileName))
|
|
61
|
|
62 if __name__ == "__main__":
|
|
63 unittest.main() |