+ fixed some issues with the splice site scores and ugly code fragments
[qpalma.git] / tests / test_qpalma_installation.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # Written (W) 2008 Fabio De Bona
10 # Copyright (C) 2008 Max-Planck-Society
11
12 #
13 # This file performs a lot of checks in order to verify the installation of
14 # QPalma
15 #
16
17 import os
18 import sys
19 import unittest
20
21 from test_approximation import TestApproximation
22 from test_qpalma import TestQPalmaPrediction
23 from test_utils import TestSequenceUtils,TestLookupTable
24
25 SUCCESS = True
26
27 def check_for_module(module_name):
28
29 try:
30 exec("import %s"%module_name)
31 except:
32 return False
33 sys.exc_info()
34
35 return True
36
37
38 if __name__ == '__main__':
39 log_fn = 'error.log'
40
41 if os.path.exists(log_fn):
42 os.remove(log_fn)
43
44 out_fh = open(log_fn,'w+')
45
46 print '\nChecking if your installation was successful...'
47
48 print '\nChecking for needed modules...\n'
49
50
51 module_list = ['numpy','DRMAA','Genefinding','pythongrid','QPalmaDP','qpalma']
52
53 for mod in module_list:
54 status = check_for_module(mod)
55 if status:
56 mes = "Successful!"
57 else:
58 mes = "Failed!"
59 SUCCESS = False
60
61 line = 'Status of module %s:\t%s'%(mod,mes)
62 print line
63 out_fh.write(line+'\n')
64
65 print '\nChecking for optional modules...\n'
66
67 module_list = ['pycplex', 'cvxopt', 'pymosek']
68
69 for mod in module_list:
70 line = 'Status of module %s:\t%s'%(mod,str(check_for_module(mod)))
71 print line
72 out_fh.write(line+'\n')
73
74 # after checking the modules we run some simple testcases on QPalma.
75 data_suite = unittest.TestLoader().loadTestsFromTestCase(TestLookupTable)
76 approximation_suite = unittest.TestLoader().loadTestsFromTestCase(TestApproximation)
77 prediction_suite = unittest.TestLoader().loadTestsFromTestCase(TestQPalmaPrediction)
78
79 all_suites = unittest.TestSuite([data_suite, approximation_suite, prediction_suite])
80 unittest.TextTestRunner(verbosity=2).run(all_suites)
81
82 if SUCCESS:
83 print '\n\n--- All checks where successful!! ---\n\n'
84 else:
85 print '\n\n--- Send the file error.log to qpalma@tuebingen.mpg.de ---\n\n'
86 env = os.environ
87 lines = ''
88 for var in ['PATH','LD_LIBRARY_PATH','PYTHONPATH']:
89 lines += '%s=%s\n'%(var,env[var])
90 out_fh.write(lines)
91
92 out_fh.close()