annotate commons/launcher/tests/Test_F_LaunchMatcher.py @ 19:9bcfa7936eec

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