Mercurial > repos > yufei-luo > s_mart
view commons/launcher/tests/Test_F_LaunchRefalign.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 from commons.core.utils.FileUtils import FileUtils from commons.launcher.LaunchRefAlign import LaunchRefAlign from shutil import rmtree class Test_F_LaunchRefAlign(unittest.TestCase): def setUp(self): self._curTestDir = os.getcwd() self._testPrefix = 'test_LRA' try: os.makedirs(self._testPrefix) except:pass os.chdir(self._testPrefix) self._inputFastaFileName = "%s_input.fa" % self._testPrefix self._obsOutputFileName = self._inputFastaFileName +'.fa_aln' self._expOutputFileName = "%s_exp.fa_aln" % self._testPrefix self._writeInputFile() def tearDown(self): os.chdir(self._curTestDir) try: rmtree(self._testPrefix) except:pass def test_run(self): self._writeExpOutputFile_wo_refseq() ilauncher = LaunchRefAlign(self._inputFastaFileName,verbosity=5) ilauncher.run() self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName)) def test_run_KeepRefSeq(self): self._writeExpOutputFile_with_refseq() ilauncher = LaunchRefAlign(self._inputFastaFileName,verbosity=5, keepRefseq=True) ilauncher.run() self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName)) def test_run_as_script(self): self._writeExpOutputFile_wo_refseq() cmd = 'LaunchRefAlign.py -i %s -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName) os.system(cmd) self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName)) def test_run_as_script_KeepRefSeq(self): self._writeExpOutputFile_with_refseq() cmd = 'LaunchRefAlign.py -i %s -r -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName) os.system(cmd) self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName)) def _writeInputFile(self): InputFile = open(self._inputFastaFileName, 'w') InputFile.write('>sequence\n') InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n') InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n') InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n') InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n') InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n') InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n') InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n') InputFile.write('>sequence2\n') InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n') InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n') InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n') InputFile.close() def _writeExpOutputFile_wo_refseq(self): with open(self._expOutputFileName,'w') as expOutputFile: expOutputFile.write(""">sequence2 GGGCAGC-CGGTGGTGCGGT--TTAGCGCTGTTGGCCCAGGGCGTGATGGACCCGGGATC GATCCCACATCGGG--------------CTCCCTGCATGGAGCCTGC---TTCTCCCTCT GCCTGTGTCTCTTCTCTC------------------------------------------ ------------------------------------------------------------ ----------TCTCTCTGTGTCTCTCATGA-ATAAA------------------------ ------------------------------------------------------------ ----------- """) def _writeExpOutputFile_with_refseq(self): with open(self._expOutputFileName,'w') as expOutputFile: expOutputFile.write(""">sequence GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCGCAAGCGGTAGAAAGTGAG TGAGTGAGTGA >sequence2 GGGCAGC-CGGTGGTGCGGT--TTAGCGCTGTTGGCCCAGGGCGTGATGGACCCGGGATC GATCCCACATCGGG--------------CTCCCTGCATGGAGCCTGC---TTCTCCCTCT GCCTGTGTCTCTTCTCTC------------------------------------------ ------------------------------------------------------------ ----------TCTCTCTGTGTCTCTCATGA-ATAAA------------------------ ------------------------------------------------------------ ----------- """) if __name__ == "__main__": unittest.main()