Skip to content

Commit 30104ec

Browse files
committed
updated system test to look for Python dependencies
1 parent 9937198 commit 30104ec

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

libpython/qtmetadraft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def f(a, b, c):
411411
#self.widgetButtonPanel()
412412

413413
# setup
414-
self.appwindow.setWindowTitle('MetaDraft {} - Brett G. Olivier (b.g.olivier@vu.nl)'.format(metadraft_version))
414+
self.appwindow.setWindowTitle('CBMPy MetaDraft {}'.format(metadraft_version))
415415
self.initDBs()
416416
self._loading_ = False
417417

systemtest.py

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
"""
2+
MetaToolkit: MetaDraft
3+
======================
4+
5+
MetaDraft: for the reconstruction of Genome Scale Models
6+
7+
MetaToolkit: MetaDraft (https://github.com/SystemsBioinformatics/cbmpy-metadraft)
8+
Copyright (C) 2016-2018 Brett G. Olivier, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands
9+
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program. If not, see <http://www.gnu.org/licenses/>
22+
23+
Author: Brett G. Olivier
24+
25+
"""
26+
127
import os, subprocess, platform
228

329
cDir = os.path.dirname(os.path.abspath(os.sys.argv[0]))
@@ -38,7 +64,7 @@ def test_perl_xml(output_msg):
3864
}
3965
"""
4066
try:
41-
PF = file('_test.pl', 'w')
67+
PF = open('_test.pl', 'w')
4268
PF.write(p_script)
4369
PF.close()
4470
out = int(subprocess.call(['perl', '_test.pl']))
@@ -79,12 +105,43 @@ def test_blast(output_msg):
79105

80106
return BLAST_OK, BLAST_HAVE_LOCAL, pth, output_msg
81107

82-
def print_test_results(JAVA_OK, PERL_OK, PERL_XML_OK, BLAST_OK, BLAST_HAVE_LOCAL, pth, output_msg):
108+
def test_python_dependencies(output_msg):
109+
PYTHON_DEP_OK = True
110+
HAVE_QT4 = HAVE_QT5 = False
111+
try:
112+
import PyQt4
113+
HAVE_QT4 = True
114+
except ImportError:
115+
pass
116+
#output_msg.append('PyQt4 not found, see README.md for details.')
117+
try:
118+
import PyQt5
119+
HAVE_QT5 = True
120+
except ImportError:
121+
pass
122+
#output_msg.append('PyQt5 not found, see README.md for details.')
123+
if not (HAVE_QT4 or HAVE_QT5):
124+
output_msg.append('PyQt not found, please install before running MetaDraft, see README.md for details.')
125+
PYTHON_DEP_OK = False
126+
127+
try:
128+
import libsbml
129+
import cbmpy
130+
import Bio
131+
import xlrd, xlwt
132+
except ImportError:
133+
output_msg.append('MetaDraft requires CBMPy, libSBML and BioPython to be installed. Please install before running MetaDraft, see README.md for details.')
134+
PYTHON_DEP_OK = False
135+
136+
return PYTHON_DEP_OK, output_msg
137+
138+
def print_test_results(JAVA_OK, PERL_OK, PERL_XML_OK, BLAST_OK, BLAST_HAVE_LOCAL, PYTHON_DEP_OK, pth, output_msg):
83139
print('\n\nSystem check results:\n=====================')
84140
print('Java test passed: {}'.format(JAVA_OK))
85141
print('Perl test passed: {}'.format(PERL_OK))
86142
print('Perl XML test passed: {}'.format(PERL_XML_OK))
87143
print('BLAST test passed: {}'.format(BLAST_OK))
144+
print('Python dependency test passed: {}'.format(PYTHON_DEP_OK))
88145
if not BLAST_OK:
89146
print('BLAST can use built-in test passed: {}'.format(BLAST_HAVE_LOCAL))
90147

@@ -102,10 +159,14 @@ def print_test_results(JAVA_OK, PERL_OK, PERL_XML_OK, BLAST_OK, BLAST_HAVE_LOCAL
102159
PERL_OK, output_msg = test_perl(output_msg)
103160
PERL_XML_OK, output_msg = test_perl_xml(output_msg)
104161
BLAST_OK, BLAST_HAVE_LOCAL, pth, output_msg = test_blast(output_msg)
105-
print_test_results(JAVA_OK, PERL_OK, PERL_XML_OK, BLAST_OK, BLAST_HAVE_LOCAL, pth, output_msg)
106-
if JAVA_OK and PERL_OK and PERL_XML_OK and ( BLAST_OK or BLAST_HAVE_LOCAL ):
162+
PYTHON_DEP_OK, output_msg = test_python_dependencies(output_msg)
163+
164+
print_test_results(JAVA_OK, PERL_OK, PERL_XML_OK, BLAST_OK, BLAST_HAVE_LOCAL, PYTHON_DEP_OK, pth, output_msg)
165+
if JAVA_OK and PERL_OK and PERL_XML_OK and ( BLAST_OK or BLAST_HAVE_LOCAL ) and PYTHON_DEP_OK:
166+
print('\nCongratulations you are ready to run MetaDraft! (python metadraft.py)\n')
107167
os.sys.exit(0)
108168
else:
169+
print('\nYou need to install a few more things before you are ready to run MetaDraft.\n')
109170
os.sys.exit(1)
110171

111172

0 commit comments

Comments
 (0)