diff --git a/AUTHORS b/AUTHORS index e6a986236a2ccc1215b3e8fb53036f8ed2d73505..7236e8939d41be4157e063796c475fd62341e96c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ +Leiden University Medical Center department of Human Genetics <humgen@lumc.nl> Jeroen Laros <j.f.j.laros@lumc.nl> Gerben Stouten Gerard Schaafsma <g.c.p.schaafsma@lumc.nl> diff --git a/README b/README index a64f8f5130b4ec53edc890f7890e3583bc654dd2..72193b94e370cb6ff29d53ab22d43a6e7eb217fb 100644 --- a/README +++ b/README @@ -56,6 +56,7 @@ Todo: * Develop a large test suite. * Create a web interface url to watch the progress of a batch job. * Use virtualenv? +* Perhaps the WSGI file should be somewhere else and be called mutalyzer.wsgi? Notes for server setup (Europium VM copy): diff --git a/bin/find_log_bugs b/bin/find_log_bugs index 253be3d76f73d66e609868d3ed2f7b0264f6f38d..cea38c2e667cb8ebf0fa3abd5fcf69845b6923d7 100755 --- a/bin/find_log_bugs +++ b/bin/find_log_bugs @@ -10,15 +10,6 @@ crashed. import os -import site - -# Todo: Get this from the configuration file -root_dir = os.path.split(os.path.dirname(__file__))[0] -site.addsitedir(root_dir) -# Todo: Fix Mutalyzer to not depend on working directory -if not __name__ == '__main__': - os.chdir(root_dir) - from mutalyzer.config import Config diff --git a/bin/mutalyzer-batchd b/bin/mutalyzer-batchd index 3df71c5b8ba42253962ed51eb8ee0fcf07afbd37..c7bd01759acf86c1e03d674ef74765cc215361b8 100755 --- a/bin/mutalyzer-batchd +++ b/bin/mutalyzer-batchd @@ -19,11 +19,8 @@ from daemon import pidlockfile, DaemonContext from lockfile import LockTimeout import signal import time -import site import traceback -site.addsitedir(os.getcwd()) - from mutalyzer.config import Config from mutalyzer.Db import Batch from mutalyzer.Scheduler import Scheduler diff --git a/extras/config.example b/extras/config.example index b1d1bc40b854e2efb7103b9fff25942259258254..89c500b02604da1be65961b5681e8631934f52fe 100644 --- a/extras/config.example +++ b/extras/config.example @@ -110,7 +110,7 @@ mailSubject = "Result of Mutalyzer batch check." resultsDir = "/var/cache/mutalyzer" # Location of the PID file. -PIDfile = "/var/run/mutalyzer/batchd.pid" +PIDfile = "/var/run/mutalyzer/mutalyzer-batchd.pid" # Maximum size for uploaded batch input files in megabytes. batchInputMaxSize = 5 diff --git a/extras/init.d/mutalyzer-batchd b/extras/init.d/mutalyzer-batchd index cc1f0e2b5c7fcfc48f37a1e2eb71a6be90890ba9..9c559f2427f89b7c2dadff17468eaaf6c3002b28 100755 --- a/extras/init.d/mutalyzer-batchd +++ b/extras/init.d/mutalyzer-batchd @@ -16,10 +16,10 @@ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Mutalyzer batch deamon" -DAEMON=/home/martijn/projects/mutalyzer/svn/branches/refactor-mutalyzer-branch/bin/batch_daemon +DAEMON=/home/martijn/projects/mutalyzer/svn/branches/refactor-mutalyzer-branch/bin/mutalyzer-batchd DIR=/home/martijn/projects/mutalyzer/svn/branches/refactor-mutalyzer-branch NAME=mutalyzer-batchd -PIDFILE=/var/run/mutalyzer/batchd.pid +PIDFILE=/var/run/mutalyzer/mutalyzer-batchd.pid PIDDIR=/var/run/mutalyzer SCRIPTNAME=/etc/init.d/mutalyzer-batchd USER=www-data diff --git a/mutalyzer/webservice.py b/mutalyzer/webservice.py index 6348138babe778158d53984cac7154c4675ce674..2562fa41890c0b5bc5aa6acea63a63c0b6875acf 100644 --- a/mutalyzer/webservice.py +++ b/mutalyzer/webservice.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - """ Mutalyzer webservices. @@ -24,6 +22,7 @@ Be sure to have this line first if you also define a / alias, like this: and we should not create it on every request. """ + # WSGI applications should never print anything to stdout. We redirect to # stderr, but eventually Mutalyzer should be fixed to never just 'print' # anything. @@ -47,16 +46,8 @@ from soaplib.core.model.clazz import Array from soaplib.core.model.exception import Fault from soaplib.core.server import wsgi import os -import site from operator import itemgetter, attrgetter -# Todo: Get this from the configuration file -root_dir = os.path.split(os.path.dirname(__file__))[0] -site.addsitedir(root_dir) -# Todo: Fix Mutalyzer to not depend on working directory -if not __name__ == '__main__': - os.chdir(root_dir) - from mutalyzer.config import Config from mutalyzer.grammar import Grammar from mutalyzer import variantchecker @@ -892,15 +883,23 @@ class MutalyzerService(DefinitionBase) : #sliceChromosome #MutalyzerService + # WSGI application for use with e.g. Apache/mod_wsgi soap_application = Application([MutalyzerService], 'http://mutalyzer.nl/2.0/services', # namespace 'Mutalyzer') application = wsgi.Application(soap_application) + +# Todo: Fix Mutalyzer to not depend on working directory +if not __name__ == '__main__': + os.chdir(os.path.dirname(__file__)) + + # We can also use the built-in webserver by executing this file directly if __name__ == '__main__': - # Todo: Setting the working directory probably doesn't work + # Todo: add a main() function or something, and create an executable + # wrapper in bin/. from wsgiref.simple_server import make_server print 'Listening to http://localhost:8081/' print 'WDSL file is at http://localhost:8081/?wsdl' diff --git a/mutalyzer/wsgi.py b/mutalyzer/wsgi.py index 1a937b3e00ab956c669178118186a75a123e59fc..311dd6e76d36d2cf7a1f26ab7eca2ce05c0909e1 100644 --- a/mutalyzer/wsgi.py +++ b/mutalyzer/wsgi.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - """ General WSGI interface. @@ -57,20 +55,12 @@ import os import bz2 import web import urllib -import site from lxml import etree from cStringIO import StringIO from simpletal import simpleTALES from simpletal import simpleTAL -# Todo: Get this from the configuration file -root_dir = os.path.split(os.path.dirname(__file__))[0] -site.addsitedir(root_dir) -# Todo: Fix Mutalyzer to not depend on working directory -if not __name__ == '__main__': - os.chdir(root_dir) - import mutalyzer from mutalyzer import util from mutalyzer.config import Config @@ -203,7 +193,7 @@ class render_tal: # TAL template render -render = render_tal(os.path.join(root_dir, 'templates'), globals={ +render = render_tal('templates', globals={ 'version': mutalyzer.__version__, 'nomenclatureVersion': mutalyzer.NOMENCLATURE_VERSION, 'releaseDate': mutalyzer.__date__, @@ -1109,10 +1099,13 @@ class Static: if __name__ == '__main__': - # Todo: Setting the working directory probably doesn't work + # Todo: add a main() function or something, and create an executable + # wrapper in bin/. # Usage: # ./src/wsgi.py [port] app.run() else: # WSGI application + # Todo: Fix Mutalyzer to not depend on working directory + os.chdir(os.path.dirname(__file__)) application = app.wsgifunc() diff --git a/setup.py b/setup.py index ccefce08738947af14313a38e337d4a10f6409ee..4dcd083b1a7aa636c1c9a0b23ea05f57f761c51c 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( author_email=distmeta.__contact__, url=distmeta.__homepage__, license='Not distributable', - platform=['any'], + platforms=['any'], packages=find_packages(exclude=['doc', 'extras', 'tests']), include_package_data=True, scripts=['bin/mutalyzer-batchd'], @@ -24,7 +24,7 @@ setup( # Things not handled by this setup.py: # - Copy extras/config.example to /etc/mutalyzer/config # - Database setup -# - Chown /var/log/mutalyzer.log +# - Chown /var/log/mutalyzer.log and /var/cache/mutalyzer # - Copy extras/init.d/mutalyzer-batchd to /etc/init.d/mutalyzer-batchd # - Copy doc to /usr/share/doc # Perhaps as a postinstall script? diff --git a/tests/test_grammar.py b/tests/test_grammar.py index e0292170c94b8840bc95a8894841838d629d22bb..85ab8276a695d6904938742c3066e8a47408026c 100644 --- a/tests/test_grammar.py +++ b/tests/test_grammar.py @@ -2,23 +2,21 @@ Tests for the mutalyzer.grammar module. """ + #import logging; logging.basicConfig() import os -import site from nose.tools import * -# Todo: Get this from the configuration file -root_dir = os.path.split(os.path.dirname(__file__))[0] -site.addsitedir(root_dir) -# Todo: Fix Mutalyzer to not depend on working directory -if not __name__ == '__main__': - os.chdir(root_dir) - from mutalyzer.config import Config from mutalyzer.grammar import Grammar from mutalyzer.output import Output +# Todo: Fix Mutalyzer to not depend on working directory +root_dir = os.path.split(os.path.dirname(__file__))[0] +os.chdir(os.path.join(root_dir, 'mutalyzer')) + + class TestGrammar(): """ Test the mytalyzer.grammar module. diff --git a/tests/test_mutalyzer.py b/tests/test_mutalyzer.py index fee26626ce14a4c25e9d3c21c62b17888f4716e1..5304bb170237a467b4cc24af7b9f4d6877d0037d 100644 --- a/tests/test_mutalyzer.py +++ b/tests/test_mutalyzer.py @@ -2,26 +2,24 @@ Tests for the Mutalyzer module. """ + #import logging; logging.basicConfig() import re import os import random -import site from nose.tools import * from Bio.Seq import Seq -# Todo: Get this from the configuration file -root_dir = os.path.split(os.path.dirname(__file__))[0] -site.addsitedir(root_dir) -# Todo: Fix Mutalyzer to not depend on working directory -if not __name__ == '__main__': - os.chdir(root_dir) - from mutalyzer.config import Config from mutalyzer.output import Output from mutalyzer.variantchecker import check_variant +# Todo: Fix Mutalyzer to not depend on working directory +root_dir = os.path.split(os.path.dirname(__file__))[0] +os.chdir(os.path.join(root_dir, 'mutalyzer')) + + class TestMutalyzer(): """ Test the Mutalyzer module. diff --git a/tests/test_mutator.py b/tests/test_mutator.py index dc9a344923ed92283094970b768a1d30af8bac42..766270d44703de14984d2877cf056cf935b17e58 100644 --- a/tests/test_mutator.py +++ b/tests/test_mutator.py @@ -2,26 +2,24 @@ Tests for the mutalyzer.mutator module. """ + #import logging; logging.basicConfig() import re import os import random -import site from nose.tools import * from Bio.Seq import Seq -# Todo: Get this from the configuration file -root_dir = os.path.split(os.path.dirname(__file__))[0] -site.addsitedir(root_dir) -# Todo: Fix Mutalyzer to not depend on working directory -if not __name__ == '__main__': - os.chdir(root_dir) - from mutalyzer.config import Config from mutalyzer.output import Output from mutalyzer import mutator +# Todo: Fix Mutalyzer to not depend on working directory +root_dir = os.path.split(os.path.dirname(__file__))[0] +os.chdir(os.path.join(root_dir, 'mutalyzer')) + + def _seq(length): """ Return random DNA sequence of given length. @@ -180,7 +178,7 @@ class TestMutator(): sites = [4, 9, 14, 17, 25, 27] m = self._mutator(_seq(l)) m.delM(17, 17) # g.17del - assert_equal(m.newSplice(sites), [4, 9, 14, 16, 24, 26]) + assert_equal(m.newSplice(sites), [4, 9, 14, 16, 24, 27]) def test_newSplice_don_del_after(self): """ diff --git a/tests/test_wsgi.py b/tests/test_wsgi.py index b57d254763ba2e136c46f26b530240075f18d245..fc8d49643d21f89feec6783ab5030c28c703f46d 100644 --- a/tests/test_wsgi.py +++ b/tests/test_wsgi.py @@ -13,22 +13,19 @@ I just installed webtest by 'easy_install webtest'. #import logging; logging.basicConfig() import os -import site import re import time from nose.tools import * from webtest import TestApp -# Todo: Get this from the configuration file -root_dir = os.path.split(os.path.dirname(__file__))[0] -site.addsitedir(root_dir) -# Todo: Fix Mutalyzer to not depend on working directory -if not __name__ == '__main__': - os.chdir(root_dir) - from mutalyzer.wsgi import application +# Todo: Fix Mutalyzer to not depend on working directory +root_dir = os.path.split(os.path.dirname(__file__))[0] +os.chdir(os.path.join(root_dir, 'mutalyzer')) + + class TestWSGI(): """ Test the Mutalyzer WSGI interface. @@ -510,7 +507,7 @@ facilisi.""" @todo: Test if returned genomic reference can indeed be used now. """ - test_genbank_file = 'tests/data/AB026906.1.gb' + test_genbank_file = '../tests/data/AB026906.1.gb' r = self.app.get('/upload') form = r.forms[0] form['invoermethode'] = 'file'