-
Notifications
You must be signed in to change notification settings - Fork 5
/
ccp4i-dimple.py
executable file
·66 lines (52 loc) · 1.91 KB
/
ccp4i-dimple.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
#!/usr/bin/env ccp4-python
import os
import sys
sys.path.append(os.path.join(os.environ["CCP4"], "share", "smartie"))
import qtrapi
# monkey-patch put() before dimple is imported
import dimple.utils
orig_put = dimple.utils.put
def our_put(text, ansi_code=None):
orig_put(text)
qtrapi_text[0] += text
for n in (1, 2):
if (' blob%dv3.png' % n) in text:
add_blob(n)
report.flush()
dimple.utils.put = our_put
def add_blob(n):
dfiles = qtrapi.Decorations(title=("Blob %d" % n))
for i in range(1, 4):
path = os.path.join(jobdir, "blob%dv%d.png" % (n, i))
dfiles.append(qtrapi.File(key="DECORATION", type="image", path=path))
path = os.path.join(jobdir, "blob%d-coot.py" % n)
coot_view = qtrapi.File(key="COOT_VIEW", type="coot_view", path=path,
title="View in")
vfiles = qtrapi.Files()
vfiles.append(coot_view)
section_output.extend([dfiles, vfiles])
from dimple.main import parse_dimple_commands, main
opt = parse_dimple_commands(sys.argv[1:])
jobdir = os.path.abspath(opt.output_dir)
if not os.path.exists(jobdir):
os.makedirs(jobdir) # it would be created by dimple, but too late
print("_JOB_DIRECTORY: %s" % jobdir)
sys.stdout.flush()
input_files = qtrapi.Files()
input_files.extend([
qtrapi.File(key="HKLIN", title="Reflection Data", type="hkl:hkl",
path=os.path.join(jobdir, opt.mtz)),
qtrapi.File(key="XYZIN", title="Input Model", type="xyz",
path=os.path.join(jobdir, opt.pdbs[0]))
])
qtrapi_text = qtrapi.Text("")
qtrapi_text.append("")
section_info = qtrapi.Section("Output")
section_info.append(qtrapi_text)
section_input = qtrapi.Section("Input Files")
section_input.append(input_files)
section_output = qtrapi.Section("Output Files")
report = qtrapi.Report(title="Dimple", path=jobdir)
report.extend([section_info, section_input, section_output])
report.flush()
main(sys.argv[1:])