-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathmuscle.py
67 lines (54 loc) · 1.54 KB
/
muscle.py
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
'''
The MUSCLE aligner
http://www.drive5.com/muscle
'''
import tools
import util.file
import util.misc
import os
import os.path
import subprocess
import logging
TOOL_NAME = "muscle"
TOOL_VERSION = '3.8.1551'
CONDA_TOOL_VERSION = '3.8.1551'
_log = logging.getLogger(__name__)
class MuscleTool(tools.Tool):
def __init__(self, install_methods=None):
if install_methods is None:
install_methods = []
install_methods.append(tools.CondaPackage(TOOL_NAME, version=CONDA_TOOL_VERSION))
tools.Tool.__init__(self, install_methods=install_methods)
def version(self):
return TOOL_VERSION
# pylint: disable=W0221
def execute(
self,
inFasta,
outFasta,
maxiters=None,
maxhours=None,
fmt='fasta',
diags=None,
quiet=True,
logFile=None
):
tool_cmd = [self.install_and_get_path(), '-in', inFasta, '-out', outFasta]
if fmt in ('html', 'msf', 'clw', 'clwstrict'):
tool_cmd.append('-' + fmt)
else:
if fmt != 'fasta':
raise Exception()
if quiet:
tool_cmd.append('-quiet')
if diags:
tool_cmd.append('-diags')
if maxiters:
tool_cmd.extend(('-maxiters', str(maxiters)))
if maxhours:
tool_cmd.extend(('-maxhours', str(maxhours)))
if logFile:
tool_cmd.extend(('-log', logFile))
_log.debug(' '.join(tool_cmd))
subprocess.check_call(tool_cmd)
# pylint: enable=W0221