annotate commons/tools/tests/Test_F_TEclassifierPE.py @ 18:94ab73e8a190

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