-
Notifications
You must be signed in to change notification settings - Fork 10
/
inmembrane_scan
executable file
·135 lines (116 loc) · 5.5 KB
/
inmembrane_scan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python
# Copyright (c) 2012, Bosco Ho <[email protected]>
# Copyright (c) 2012, Andrew Perry <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
import sys
import os
import glob
import inmembrane
# from inmembrane import helpers
from inmembrane.helpers import *
# will load all plugins in the plugins/ directory
from inmembrane.plugins import *
import unittest
description = """
inmembrane %s (https://github.com/boscoh/inmembrane)
Inmembrane is a proteome annotation pipeline. It takes
a FASTA file, then carries out sequential analysis of
each sequence with a bunch of third-party programs, and
collates the results.
(c) 2011-2013 Bosco Ho and Andrew Perry
""" % (inmembrane.__version__)
if __name__ == "__main__":
from optparse import OptionParser
usage = "usage: %prog [options] [sequences.fasta]"
parser = OptionParser(usage=usage, \
version="%prog " + inmembrane.__version__ + "\n", )
parser.add_option("-t", "--test",
action="store_true", dest="run_tests", default=False,
help="Run tests to check that each plugin works as expected.\
No sequence file should be specified if this flag is\
used.")
parser.add_option("-n", "--tests-no-network",
action="store_true", dest="no_network", default=False,
help="don't run tests that require a network connection")
parser.add_option("--skip-tests",
action="store", type="string", dest="skip_tests",
help="a comma separated list of tests to skip eg: "
"test_tmhmm_web,test_lipop_web")
(options, args) = parser.parse_args()
log_stderr("inmembrane %s (https://github.com/boscoh/inmembrane)"
% (inmembrane.__version__))
if not options.run_tests:
##
## Setup params and run the analysis
## The high level plugin loop is in inmembrane/__init__.py
##
params = inmembrane.get_params()
if ('fasta' not in params or not params['fasta']) and not args:
print description
parser.print_help()
sys.exit(1)
if 'fasta' not in params or not params['fasta']:
params['fasta'] = args[0]
inmembrane.process(params)
else:
##
## Run unit tests instead of 'normal' analysis
##
log_stderr("Running tests")
skip_list = []
if "--skip-tests" in sys.argv:
skip_list = [tn.strip() for tn in options.skip_tests.split(',')]
log_stderr("Will skip: " + ", ".join(skip_list))
# sys.argv.remove("--skip-tests")
file_tag = os.path.join(inmembrane.module_dir, 'tests', 'test*.py')
test_names = [os.path.basename(f)[:-3] for f in glob.glob(file_tag)]
tests_to_run = []
for test_name in test_names:
if not (options.no_network and (test_name[-4:] == "_web")):
if (test_name not in skip_list):
exec ('from inmembrane.tests.%s import *' % test_name)
tests_to_run.append(test_name)
log_stderr("Will run: " + ", ".join(tests_to_run))
log_stderr("\n")
log_stderr(
"Note that it isn't unusual for some tests to "
"fail - only be concerned with the particular analysis "
"tools you will run, as defined in inmembrane.config. "
"Errors can occur due to a missing locally installed "
"program or a web service being temporarily or permanently "
"offline.\n")
log_stderr("\n")
if ("test_memsat3" in test_names):
log_stderr(
"Note that MEMSAT3 tests will likely fail even when "
"MEMSAT3 is functioning correctly since the results are "
"dependant on a BLAST search and the locally installed "
"BLAST database is unlikely to match the one used to "
"derive the test results. If the numbers are similar it "
"should be okay.\n")
log_stderr("\n")
# by passing in argv we override unittests own commandline option
# detection
unittest.main(argv=[os.path.basename(sys.argv[0])])