18
|
1 import os
|
|
2 import unittest
|
|
3 from commons.tools.TEclassifierPE import TEclassifierPE
|
|
4 from commons.core.utils.FileUtils import FileUtils
|
|
5 from commons.core.sql.DbFactory import DbFactory
|
|
6
|
|
7 class Test_F_TEclassifierPE(unittest.TestCase):
|
|
8
|
|
9 def test_run(self):
|
|
10 projectName = "dummy"
|
|
11 configFileName = "dummy.cfg"
|
|
12 self.writeConfigFile(configFileName, projectName)
|
|
13 inputFileName = "dummy.fa"
|
|
14 with open(inputFileName, "w") as f:
|
|
15 f.write(">dummySSR\n")
|
|
16 f.write("AGTTACCATGCCCAGCATTAACCCCCCTCAACAACCACCTCCGCCTATGAAGCCCGCCCG\n")
|
|
17 f.write("AGTTACCATGCCCAGCATTAACCCCCCTCAACAACCACCTCCGCCTATGAAGCCCGCCCG\n")
|
|
18 expFileName = "exp.classif"
|
|
19 with open(expFileName, "w") as f:
|
|
20 f.write("dummySSR\t120\t.\tok\tNA\tSSR\tNA\tCI=100; struct=(TElength: <150bps; SSRCoverage=0.00)\n")
|
|
21 obsFileName = "%s.classif" % projectName
|
|
22 statsFileName = "%s.classif_stats.txt" % projectName
|
|
23 analysisFileName = "%s.SSR.set" % inputFileName
|
|
24
|
|
25 iTEclassifierPE = TEclassifierPE(inputFileName, configFileName, doClean = True)
|
|
26 iTEclassifierPE.run()
|
|
27
|
|
28 self.assertTrue(FileUtils.are2FilesIdentical(expFileName, obsFileName))
|
|
29
|
|
30 iDb = DbFactory.createInstance()
|
|
31 iDb.dropTable("%s_TR_set" % projectName)
|
|
32 iDb.dropTable("%s_polyA_set" % projectName)
|
|
33 iDb.dropTable("%s_ORF_map" % projectName)
|
|
34 iDb.dropTable("%s_SSR_set" % projectName)
|
|
35 iDb.close()
|
|
36 os.remove(configFileName)
|
|
37 os.remove(inputFileName)
|
|
38 os.remove(expFileName)
|
|
39 os.remove(obsFileName)
|
|
40 os.remove(statsFileName)
|
|
41 os.remove(analysisFileName)
|
|
42
|
|
43 def writeConfigFile(self, fileName, projectName):
|
|
44 with open(fileName, "w") as f:
|
|
45 f.write("[repet_env]\n")
|
|
46 f.write("repet_host: %s\n" % os.environ["REPET_HOST"])
|
|
47 f.write("repet_user: %s\n" % os.environ["REPET_USER"])
|
|
48 f.write("repet_pw: %s\n" % os.environ["REPET_PW"])
|
|
49 f.write("repet_db: %s\n" % os.environ["REPET_DB"])
|
|
50 f.write("repet_port: %s\n" % os.environ["REPET_PORT"])
|
|
51 f.write("\n")
|
|
52 f.write("[project]\n")
|
|
53 f.write("project_name: %s\n" % projectName)
|
|
54 f.write("project_dir: %s\n" % os.getcwd())
|
|
55 f.write("\n")
|
|
56 f.write("[detect_features]\n")
|
|
57 f.write("clean: yes\n")
|
|
58 f.write("blast: ncbi\n")
|
|
59 f.write("term_rep: no\n")
|
|
60 f.write("polyA: no\n")
|
|
61 f.write("tand_rep: yes\n")
|
|
62 f.write("orf: no\n")
|
|
63 f.write("TE_HMMER: no\n")
|
|
64 f.write("TE_BLRtx: no\n")
|
|
65 f.write("TE_BLRn: no\n")
|
|
66 f.write("TE_BLRx: no\n")
|
|
67 f.write("HG_BLRn: no\n")
|
|
68 f.write("rDNA_BLRn: no\n")
|
|
69 f.write("tRNA_scan: no\n")
|
|
70 f.write("TRFmaxPeriod: 15\n")
|
|
71 f.write("\n")
|
|
72 f.write("[classif_consensus]\n")
|
|
73 f.write("max_profiles_evalue: 1e-3\n")
|
|
74 f.write("min_TE_profiles_coverage: 20\n")
|
|
75 f.write("min_HG_profiles_coverage: 75\n")
|
|
76 f.write("max_helitron_extremities_evalue: 1e-3\n")
|
|
77 f.write("min_TE_bank_coverage: 5\n")
|
|
78 f.write("min_HG_bank_coverage: 95\n")
|
|
79 f.write("min_rDNA_bank_coverage: 95\n")
|
|
80 f.write("min_HG_bank_identity: 90\n")
|
|
81 f.write("min_rDNA_bank_identity: 90\n")
|
|
82 f.write("min_SSR_coverage: 0.75\n")
|
|
83 f.write("max_SSR_size: 150\n")
|
|
84 f.write("clean: yes\n")
|
|
85
|
|
86 if __name__ == "__main__":
|
|
87 unittest.main() |