forked from GarmanGroup/RIDL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runRIDL.py
executable file
·169 lines (142 loc) · 6.49 KB
/
runRIDL.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import sys
import os
FULL_PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
sys.path.insert(0, FULL_PATH+'/lib')
from checkDependencies import checkDependencies
import argparse
import sys
from errors import error
# an outer layer for the pipeline scripts. This allows
# the pipeline to be run from the command line by simply
# calling:
#
# python runRIDL.py -i [inputfilename.txt] -pc
#
# or:
#
# python runRIDL.py -i [inputfilename.txt] -pco
#
# This is the recommended run mode for the scripts.
ln = 'Run the RIDL pipeline from the command line.'
parser = argparse.ArgumentParser(description=ln)
h = 'Check RIDL dependencies are accessible and flag if not'
parser.add_argument('--dependencies',
dest='checkDependencies', action='store_const',
default=False, const=True,
help='Check RIDL dependencies are ' +
'accessible and flag if not')
parser.add_argument('--rigid',
dest='performRigidBodyRefine', action='store_const',
default=False, const=True,
help='Perform REFMAC rigid body refinement using initial' +
' coordinate model to generate higher dose models')
parser.add_argument('-i',
type=str, dest='inputFile', action='store',
help='An input file containing pdb and mtz file ' +
'names, as well as relevant mtz column labels.')
parser.add_argument('-p',
dest='makeMaps', action='store_const',
default=False, const=True,
help='Generate electron density difference maps.')
parser.add_argument('-c',
dest='calcMetrics', action='store_const',
default=False, const=True,
help='Calculate damage metrics per atom. Will output ' +
'csv-format files of metric per atom upon completion')
parser.add_argument('-t',
type=int, dest='template',
action='store', default=0,
help='Create a template input file to be ' +
'completed by the user.')
parser.add_argument('-j',
dest='inputFileHelp', action='store_const',
default=False, const=True,
help='Provide information to help user ' +
'complete input file.')
parser.add_argument('-r',
dest='cleanUpFinalFiles', action='store_const',
default=True, const=False,
help='Do not clean up output directory at end of full ' +
'run. If not included, intermediate map files (e.g.' +
' atom-tagged maps) will be included for each ' +
'dataset within damage series.')
parser.add_argument('--remove_maps',
dest='removeMaps', action='store_const',
default=False, const=True,
help='Remove the RIDL-maps/ subdirectory that is ' +
'created following a standard run.')
parser.add_argument('-o',
dest='output', action='store_const',
default=False, const=True,
help='Create output hmtl file and graphical analysis. ' +
'If included, it is assumed that -c step of RIDL ' +
'has already been performed and that a _data.pkl ' +
'file is available to retrieve the data from ' +
'this step.')
parser.add_argument('-s',
dest='suppressOutput', action='store_const',
default=True, const=False,
help='Suppress all output to command line. All output ' +
'text will be printed directly to log file and ' +
'not command line.')
parser.add_argument('-v',
dest='verboseOutput', action='store_const',
default=False, const=True,
help='Print verbose output to command line.')
args = parser.parse_args()
# check RIDL dependencies are present
if args.checkDependencies:
checkDependencies(checkAll=True)
sys.exit()
# these are here so that they don't interfere with dependency checks
from rigidBodyRefine import reRefine
from runRIDL_class import process
# create a template input file to be filled in manually by the user
if args.template != 0:
p = process(inputFile='templateInputFile.txt')
p.writeTemplateInputFile(numHigherDoseDatasets=args.template)
print('Can use -j command for help on how to ' +
'complete the generated input file')
# call the help information
if args.inputFileHelp:
p = process()
p.howToWriteInputFile()
inputFileToUse = args.inputFile
# check that the specified input file exists here
if inputFileToUse is not None:
if not os.path.exists(inputFileToUse):
error(text='input file "{}" not found'.format(inputFileToUse),
type='error')
# decide whether rigid body refinement must be run
# first to generate higher dose coordinate models
if args.performRigidBodyRefine:
if inputFileToUse is None:
error(text='Must specify input file with ' +
'-i tag to perform rigid body refinement job',
type='error')
else:
r = reRefine(inputFile=inputFileToUse)
inputFileToUse = r.newInputFile
if args.makeMaps or args.calcMetrics or args.output:
print('\nUsing newly generated RIDL input file ' +
'for remainder of pipeline')
else:
print('\nUse this newly generated RIDL input ' +
'file on next RIDL run')
if args.makeMaps or args.calcMetrics or args.output:
# run the pipeline, including generating density and atom-tagged
# maps from input pdb and mtz files (in a damage series), as
# specified within an input file
if inputFileToUse is None:
print('\nRIDL run error:\nMust specify input file with ' +
'-i tag to when using either -p or -c flags')
sys.exit()
p = process(inputFile=inputFileToUse,
makeMaps=args.makeMaps,
makeMetrics=args.calcMetrics,
cleanUpFinalFiles=args.cleanUpFinalFiles,
printverboseOutput=args.verboseOutput,
printOutput=args.suppressOutput,
makeSummaryFile=args.output,
keepMapDir=not args.removeMaps)
p.run()