view commons/launcher/tests/Test_F_LaunchMap.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
line wrap: on
line source

import unittest
import os
import subprocess
from commons.core.utils.FileUtils import FileUtils
from commons.launcher.LaunchMap import LaunchMap

class Test_F_LaunchMap(unittest.TestCase):

    def setUp(self):
        self._fastaFileName = "LaunchMap_seqCluster1.fa"
        fastaFilePath = "%s/Tools/%s" % (os.environ["REPET_DATA"], self._fastaFileName)
        os.symlink(fastaFilePath, self._fastaFileName)
        self._obsFileName = "%s.fa_aln" % self._fastaFileName

    def tearDown(self):
        os.remove(self._fastaFileName)
        try:
            os.remove(self._obsFileName)
        except: pass

    def test_run_as_script(self):
        expFileName = "%s/Tools/expLaunchMap_seqCluster1.fa.fa_aln" % os.environ["REPET_DATA"]
        obsFileName = "obs.fa_aln"
        cmd = "LaunchMap.py "
        cmd += "-i %s " % self._fastaFileName
        cmd += "-o %s " % obsFileName
        cmd += "-c "
        process = subprocess.Popen(cmd, shell = True)
        process.communicate()
        self.assertTrue(FileUtils.are2FilesIdentical(expFileName, obsFileName))
        os.remove(obsFileName)
        
    def test_run(self):
        expFileName = "%s/Tools/expLaunchMap_seqCluster1.fa.fa_aln" % os.environ["REPET_DATA"]
        iLaunchMap = LaunchMap(self._fastaFileName)
        iLaunchMap.setDoClean(True)
        iLaunchMap.run()
        self.assertTrue(FileUtils.are2FilesIdentical(expFileName, self._obsFileName))
        
if __name__ == "__main__":
    unittest.main()