Mercurial > repos > yufei-luo > s_mart
view commons/tools/tests/Test_F_TEclassifierPE.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line source
import os import unittest from commons.tools.TEclassifierPE import TEclassifierPE from commons.core.utils.FileUtils import FileUtils from commons.core.sql.DbFactory import DbFactory class Test_F_TEclassifierPE(unittest.TestCase): def test_run(self): projectName = "dummy" configFileName = "dummy.cfg" self.writeConfigFile(configFileName, projectName) inputFileName = "dummy.fa" with open(inputFileName, "w") as f: f.write(">dummySSR\n") f.write("AGTTACCATGCCCAGCATTAACCCCCCTCAACAACCACCTCCGCCTATGAAGCCCGCCCG\n") f.write("AGTTACCATGCCCAGCATTAACCCCCCTCAACAACCACCTCCGCCTATGAAGCCCGCCCG\n") expFileName = "exp.classif" with open(expFileName, "w") as f: f.write("dummySSR\t120\t.\tok\tNA\tSSR\tNA\tCI=100; struct=(TElength: <150bps; SSRCoverage=0.00)\n") obsFileName = "%s.classif" % projectName statsFileName = "%s.classif_stats.txt" % projectName analysisFileName = "%s.SSR.set" % inputFileName iTEclassifierPE = TEclassifierPE(inputFileName, configFileName, doClean = True) iTEclassifierPE.run() self.assertTrue(FileUtils.are2FilesIdentical(expFileName, obsFileName)) iDb = DbFactory.createInstance() iDb.dropTable("%s_TR_set" % projectName) iDb.dropTable("%s_polyA_set" % projectName) iDb.dropTable("%s_ORF_map" % projectName) iDb.dropTable("%s_SSR_set" % projectName) iDb.close() os.remove(configFileName) os.remove(inputFileName) os.remove(expFileName) os.remove(obsFileName) os.remove(statsFileName) os.remove(analysisFileName) def writeConfigFile(self, fileName, projectName): with open(fileName, "w") as f: f.write("[repet_env]\n") f.write("repet_host: %s\n" % os.environ["REPET_HOST"]) f.write("repet_user: %s\n" % os.environ["REPET_USER"]) f.write("repet_pw: %s\n" % os.environ["REPET_PW"]) f.write("repet_db: %s\n" % os.environ["REPET_DB"]) f.write("repet_port: %s\n" % os.environ["REPET_PORT"]) f.write("\n") f.write("[project]\n") f.write("project_name: %s\n" % projectName) f.write("project_dir: %s\n" % os.getcwd()) f.write("\n") f.write("[detect_features]\n") f.write("clean: yes\n") f.write("blast: ncbi\n") f.write("term_rep: no\n") f.write("polyA: no\n") f.write("tand_rep: yes\n") f.write("orf: no\n") f.write("TE_HMMER: no\n") f.write("TE_BLRtx: no\n") f.write("TE_BLRn: no\n") f.write("TE_BLRx: no\n") f.write("HG_BLRn: no\n") f.write("rDNA_BLRn: no\n") f.write("tRNA_scan: no\n") f.write("TRFmaxPeriod: 15\n") f.write("\n") f.write("[classif_consensus]\n") f.write("max_profiles_evalue: 1e-3\n") f.write("min_TE_profiles_coverage: 20\n") f.write("min_HG_profiles_coverage: 75\n") f.write("max_helitron_extremities_evalue: 1e-3\n") f.write("min_TE_bank_coverage: 5\n") f.write("min_HG_bank_coverage: 95\n") f.write("min_rDNA_bank_coverage: 95\n") f.write("min_HG_bank_identity: 90\n") f.write("min_rDNA_bank_identity: 90\n") f.write("min_SSR_coverage: 0.75\n") f.write("max_SSR_size: 150\n") f.write("clean: yes\n") if __name__ == "__main__": unittest.main()