rcsb.workflow 0.64__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rcsb/__init__.py +1 -0
- rcsb/workflow/__init__.py +1 -0
- rcsb/workflow/bcif/__init__.py +0 -0
- rcsb/workflow/bcif/task_functions.py +333 -0
- rcsb/workflow/chem/ChemCompFileWorkflow.py +96 -0
- rcsb/workflow/chem/ChemCompImageWorkflow.py +133 -0
- rcsb/workflow/chem/ChemCompSearchIndexWorkflow.py +99 -0
- rcsb/workflow/chem/__init__.py +0 -0
- rcsb/workflow/cli/BcifExec.py +179 -0
- rcsb/workflow/cli/ChemSearchIndexExec.py +65 -0
- rcsb/workflow/cli/ExDbExec.py +240 -0
- rcsb/workflow/cli/ImgExec.py +64 -0
- rcsb/workflow/cli/__init__.py +0 -0
- rcsb/workflow/targets/ProteinTargetSequenceExecutionWorkflow.py +361 -0
- rcsb/workflow/targets/ProteinTargetSequenceWorkflow.py +615 -0
- rcsb/workflow/targets/__init__.py +0 -0
- rcsb/workflow/wuw/BcifWorkflow.py +87 -0
- rcsb/workflow/wuw/ExDbWorkflow.py +505 -0
- rcsb/workflow/wuw/PdbCsmImageWorkflow.py +198 -0
- rcsb/workflow/wuw/WuwUtils.py +23 -0
- rcsb/workflow/wuw/__init__.py +0 -0
- rcsb_workflow-0.64.dist-info/METADATA +77 -0
- rcsb_workflow-0.64.dist-info/RECORD +26 -0
- rcsb_workflow-0.64.dist-info/WHEEL +4 -0
- rcsb_workflow-0.64.dist-info/entry_points.txt +5 -0
- rcsb_workflow-0.64.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
##
|
|
2
|
+
# File: BcifExec.py
|
|
3
|
+
# Author: James Smith
|
|
4
|
+
# Date: 21-Feb-2025
|
|
5
|
+
##
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Entry point for bcif command line interface.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__docformat__ = "google en"
|
|
12
|
+
__author__ = "James Smith"
|
|
13
|
+
__email__ = "james.smith@rcsb.org"
|
|
14
|
+
__license__ = "Apache 2.0"
|
|
15
|
+
|
|
16
|
+
import argparse
|
|
17
|
+
import os
|
|
18
|
+
import logging
|
|
19
|
+
import time
|
|
20
|
+
from rcsb.workflow.wuw.BcifWorkflow import BcifWorkflow
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def main():
|
|
26
|
+
|
|
27
|
+
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
|
|
28
|
+
# paths
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--listFileBase",
|
|
31
|
+
default="/tmp",
|
|
32
|
+
required=True,
|
|
33
|
+
help="path for input lists",
|
|
34
|
+
)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"--listFileName",
|
|
37
|
+
default="pdbx_core_ids-1.txt",
|
|
38
|
+
required=True,
|
|
39
|
+
help="name of list file to read",
|
|
40
|
+
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"--remotePath",
|
|
43
|
+
default="http://prereleaseftp-external-east.rcsb.org/pdb/data/structures/divided/mmCIF/",
|
|
44
|
+
required=True,
|
|
45
|
+
help="url or directory for cif files",
|
|
46
|
+
)
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
"--outputPath",
|
|
49
|
+
default="/mnt/vdb1/out",
|
|
50
|
+
required=True,
|
|
51
|
+
help="output directory for bcif files",
|
|
52
|
+
)
|
|
53
|
+
# settings
|
|
54
|
+
parser.add_argument(
|
|
55
|
+
"--contentType",
|
|
56
|
+
default="pdb",
|
|
57
|
+
required=True,
|
|
58
|
+
choices=["pdb", "csm", "ihm"],
|
|
59
|
+
help="which type of experiment was performed",
|
|
60
|
+
)
|
|
61
|
+
parser.add_argument(
|
|
62
|
+
"--nfiles",
|
|
63
|
+
default=0,
|
|
64
|
+
required=False,
|
|
65
|
+
help="set 0 for all files, set less than N for a test run, will not produce exactly n files",
|
|
66
|
+
)
|
|
67
|
+
parser.add_argument(
|
|
68
|
+
"--outfileSuffix",
|
|
69
|
+
default=".bcif.gz",
|
|
70
|
+
required=False,
|
|
71
|
+
choices=[".bcif", ".bcif.gz"],
|
|
72
|
+
help="whether to use additional gzip compression",
|
|
73
|
+
)
|
|
74
|
+
parser.add_argument(
|
|
75
|
+
"--batchSize",
|
|
76
|
+
default=1,
|
|
77
|
+
required=False,
|
|
78
|
+
help="optional subdivisions of sublists for pdb list and csm list",
|
|
79
|
+
)
|
|
80
|
+
# output folder structure, default none (save all output files in one folder)
|
|
81
|
+
parser.add_argument(
|
|
82
|
+
"--outputContentType",
|
|
83
|
+
action="store_true",
|
|
84
|
+
default=False,
|
|
85
|
+
required=False,
|
|
86
|
+
help="whether output paths should include a directory for the content type (pdb, csm)",
|
|
87
|
+
)
|
|
88
|
+
parser.add_argument(
|
|
89
|
+
"--outputHash",
|
|
90
|
+
action="store_true",
|
|
91
|
+
default=False,
|
|
92
|
+
required=False,
|
|
93
|
+
help="whether output paths should include the hash for the entry",
|
|
94
|
+
)
|
|
95
|
+
# input folder structure, default none (read all input files from one folder)
|
|
96
|
+
parser.add_argument(
|
|
97
|
+
"--inputHash",
|
|
98
|
+
action="store_true",
|
|
99
|
+
default=False,
|
|
100
|
+
required=False,
|
|
101
|
+
help="whether local input paths should include the hash for the entry",
|
|
102
|
+
)
|
|
103
|
+
# config
|
|
104
|
+
parser.add_argument(
|
|
105
|
+
"--pdbxDict",
|
|
106
|
+
default="https://raw.githubusercontent.com/wwpdb-dictionaries/mmcif_pdbx/master/dist/mmcif_pdbx_v5_next.dic",
|
|
107
|
+
required=False,
|
|
108
|
+
)
|
|
109
|
+
parser.add_argument(
|
|
110
|
+
"--maDict",
|
|
111
|
+
default="https://raw.githubusercontent.com/ihmwg/ModelCIF/master/dist/mmcif_ma_ext.dic",
|
|
112
|
+
required=False,
|
|
113
|
+
)
|
|
114
|
+
parser.add_argument(
|
|
115
|
+
"--rcsbDict",
|
|
116
|
+
default="https://raw.githubusercontent.com/rcsb/py-rcsb_exdb_assets/master/dictionary_files/dist/rcsb_mmcif_ext.dic",
|
|
117
|
+
required=False,
|
|
118
|
+
)
|
|
119
|
+
parser.add_argument(
|
|
120
|
+
"--ihmDict",
|
|
121
|
+
default="https://raw.githubusercontent.com/rcsb/py-rcsb_exdb_assets/master/dictionary_files/reference/mmcif_ihm_ext.dic",
|
|
122
|
+
required=False,
|
|
123
|
+
)
|
|
124
|
+
parser.add_argument(
|
|
125
|
+
"--flrDict",
|
|
126
|
+
default="https://raw.githubusercontent.com/ihmwg/flrCIF/refs/heads/master/dist/mmcif_ihm_flr_ext.dic",
|
|
127
|
+
required=False,
|
|
128
|
+
)
|
|
129
|
+
# logging
|
|
130
|
+
parser.add_argument("--log_file_path", required=False)
|
|
131
|
+
parser.add_argument("--debug", action="store_true", default=False, required=False)
|
|
132
|
+
|
|
133
|
+
args = parser.parse_args()
|
|
134
|
+
|
|
135
|
+
logFilePath = args.log_file_path
|
|
136
|
+
debugFlag = args.debug
|
|
137
|
+
if debugFlag:
|
|
138
|
+
logger.setLevel(logging.DEBUG)
|
|
139
|
+
else:
|
|
140
|
+
logger.setLevel(logging.INFO)
|
|
141
|
+
if logFilePath:
|
|
142
|
+
logDir = os.path.dirname(logFilePath)
|
|
143
|
+
if not os.path.isdir(logDir):
|
|
144
|
+
os.makedirs(logDir)
|
|
145
|
+
handler = logging.FileHandler(logFilePath, mode="a")
|
|
146
|
+
if debugFlag:
|
|
147
|
+
handler.setLevel(logging.DEBUG)
|
|
148
|
+
else:
|
|
149
|
+
handler.setLevel(logging.INFO)
|
|
150
|
+
formatter = logging.Formatter(
|
|
151
|
+
fmt="%(asctime)s @%(process)s [%(levelname)s]-%(module)s: %(message)s"
|
|
152
|
+
)
|
|
153
|
+
handler.setFormatter(formatter)
|
|
154
|
+
logger.addHandler(handler)
|
|
155
|
+
else:
|
|
156
|
+
handler = logging.StreamHandler()
|
|
157
|
+
formatter = logging.Formatter(
|
|
158
|
+
fmt="%(asctime)s @%(process)s [%(levelname)s]-%(module)s: %(message)s"
|
|
159
|
+
)
|
|
160
|
+
handler.setFormatter(formatter)
|
|
161
|
+
logger.addHandler(handler)
|
|
162
|
+
|
|
163
|
+
logger.info("bcif workflow initialized")
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
(BcifWorkflow(args))()
|
|
167
|
+
except RuntimeError as e:
|
|
168
|
+
raise Exception(str(e)) from e
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if __name__ == "__main__":
|
|
172
|
+
t = time.time()
|
|
173
|
+
try:
|
|
174
|
+
main()
|
|
175
|
+
except Exception as e:
|
|
176
|
+
logger.exception(str(e))
|
|
177
|
+
raise e
|
|
178
|
+
t2 = time.time() - t
|
|
179
|
+
logger.info("completed in %.2f s", t2)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
from rcsb.workflow.chem.ChemCompSearchIndexWorkflow import ChemCompSearchIndexWorkflow
|
|
3
|
+
import argparse
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
|
|
7
|
+
logger = logging.getLogger()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
"""Build indices and configuration files required to support the chemical search service."""
|
|
12
|
+
parser = argparse.ArgumentParser()
|
|
13
|
+
parser.add_argument("--cachePath", required=True, help="Cache path.")
|
|
14
|
+
parser.add_argument("--ccUrlTarget", required=True, help="Chem comp url target.")
|
|
15
|
+
parser.add_argument("--birdUrlTarget", required=True, help="Bird url target.")
|
|
16
|
+
parser.add_argument("--channel", required=True, help="Channel.")
|
|
17
|
+
parser.add_argument("--useCache", action="store_true", default=False, required=True, help="Should it use the cache.")
|
|
18
|
+
parser.add_argument("--ccFileNamePrefix", required=True, help="Chem comp file name prefix.")
|
|
19
|
+
parser.add_argument("--numProc", required=True, help="Number of procs for makeIndices.")
|
|
20
|
+
parser.add_argument("--blHostName", required=True, help="Build locker host name.")
|
|
21
|
+
parser.add_argument("--blUploadPathUnsynced", required=True, help="Build locker upload path unsynced.")
|
|
22
|
+
parser.add_argument("--sftpUserName", required=True, help="SFTP username.")
|
|
23
|
+
parser.add_argument("--sftpUserPassword", required=True, help="SFTP user password.")
|
|
24
|
+
args = parser.parse_args()
|
|
25
|
+
|
|
26
|
+
# Build chemical indices -
|
|
27
|
+
logger.info("Using cache path %r", args.cachePath)
|
|
28
|
+
logger.info("Using ccFileNamePrefix %s", args.ccFileNamePrefix)
|
|
29
|
+
ccidxWf = ChemCompSearchIndexWorkflow(cachePath=args.cachePath, ccFileNamePrefix=args.ccFileNamePrefix)
|
|
30
|
+
okI = ccidxWf.makeIndices(
|
|
31
|
+
args.ccUrlTarget, args.birdUrlTarget, numProc=int(args.numProc), useCache=args.useCache
|
|
32
|
+
)
|
|
33
|
+
logger.info("Chemical search index build completed with status %r", okI)
|
|
34
|
+
#
|
|
35
|
+
okS = False
|
|
36
|
+
if okI:
|
|
37
|
+
# Store chemical indices for future use -
|
|
38
|
+
sftpHost = args.blHostName
|
|
39
|
+
okS = ccidxWf.stashIndices(
|
|
40
|
+
"sftp://" + sftpHost,
|
|
41
|
+
args.blUploadPathUnsynced,
|
|
42
|
+
bundleLabel=args.channel.upper(),
|
|
43
|
+
userName=args.sftpUserName,
|
|
44
|
+
pw=args.sftpUserPassword,
|
|
45
|
+
)
|
|
46
|
+
logger.info("Chemical search index stashed with status %r", okS)
|
|
47
|
+
else:
|
|
48
|
+
msg = "Chemical search index completed with status %r" % okI
|
|
49
|
+
raise ValueError(msg)
|
|
50
|
+
#
|
|
51
|
+
|
|
52
|
+
if not okS:
|
|
53
|
+
error_msg = "Failed to stash chemical search index data"
|
|
54
|
+
raise ValueError(error_msg)
|
|
55
|
+
|
|
56
|
+
message = "Chemical Search Index completed with status %r stash status %r" % (okI, okS)
|
|
57
|
+
logger.info("Completion message is %s", message)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
try:
|
|
62
|
+
main()
|
|
63
|
+
except Exception as err:
|
|
64
|
+
fail_msg = f"Run failed {err}"
|
|
65
|
+
raise RuntimeError(fail_msg) from err
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
##
|
|
2
|
+
# File: ExDbExec.py
|
|
3
|
+
# Date: 22-Apr-2019 jdw
|
|
4
|
+
#
|
|
5
|
+
# Execution wrapper -- for extract and load operations -
|
|
6
|
+
#
|
|
7
|
+
# Updates:
|
|
8
|
+
# 4-Sep-2019 jdw add Tree and Drugbank loaders
|
|
9
|
+
# 14-Feb-2020 jdw change over to ReferenceSequenceAnnotationProvider/Adapter
|
|
10
|
+
# 9-Mar-2023 dwp Lower refChunkSize to 10 (UniProt API having trouble streaming XML responses)
|
|
11
|
+
# 25-Apr-2024 dwp Add arguments and logic to support CLI usage from weekly-update workflow;
|
|
12
|
+
# Add support for logging output to a specific file
|
|
13
|
+
# 20-Aug-2024 dwp Add load_target_cofactors operation; change name of upd_targets_cofactors to upd_targets
|
|
14
|
+
# 22-Oct-2024 dwp Add ccd_img_gen and ccd_file_gen operations
|
|
15
|
+
# (latter will only be used briefly, as will stop generating SDF and Mol2 files in Dec 2024)
|
|
16
|
+
# 31-Jan-2025 mjt Moved this script from rcsb.exdb (to remove circluar dependencies)
|
|
17
|
+
##
|
|
18
|
+
__docformat__ = "google en"
|
|
19
|
+
__author__ = "John Westbrook"
|
|
20
|
+
__email__ = "jwest@rcsb.rutgers.edu"
|
|
21
|
+
__license__ = "Apache 2.0"
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
import sys
|
|
25
|
+
import argparse
|
|
26
|
+
import logging
|
|
27
|
+
|
|
28
|
+
from rcsb.utils.config.ConfigUtil import ConfigUtil
|
|
29
|
+
from rcsb.workflow.wuw.ExDbWorkflow import ExDbWorkflow
|
|
30
|
+
|
|
31
|
+
HERE = os.path.abspath(os.path.dirname(__file__))
|
|
32
|
+
TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
|
|
33
|
+
|
|
34
|
+
# logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s", stream=sys.stdout)
|
|
35
|
+
logger = logging.getLogger()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def main():
|
|
39
|
+
parser = argparse.ArgumentParser()
|
|
40
|
+
#
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"--op",
|
|
43
|
+
default=None,
|
|
44
|
+
required=True,
|
|
45
|
+
help="Loading operation to perform",
|
|
46
|
+
choices=[
|
|
47
|
+
"etl_chemref", # ETL integrated chemical reference data
|
|
48
|
+
"etl_uniprot_core", # ETL UniProt core reference data
|
|
49
|
+
"etl_tree_node_lists", # ETL tree node lists
|
|
50
|
+
"upd_ref_seq", # Update reference sequence assignments
|
|
51
|
+
"upd_neighbor_interactions",
|
|
52
|
+
"upd_uniprot_taxonomy",
|
|
53
|
+
"upd_targets",
|
|
54
|
+
"load_target_cofactors",
|
|
55
|
+
"upd_pubchem",
|
|
56
|
+
"upd_entry_info",
|
|
57
|
+
"upd_glycan_idx",
|
|
58
|
+
"upd_resource_stash",
|
|
59
|
+
"ccd_img_gen",
|
|
60
|
+
"ccd_file_gen",
|
|
61
|
+
]
|
|
62
|
+
)
|
|
63
|
+
parser.add_argument(
|
|
64
|
+
"--load_type",
|
|
65
|
+
default="full",
|
|
66
|
+
help="Type of load ('full' for complete and fresh single-worker load, 'replace' for incremental and multi-worker load)",
|
|
67
|
+
choices=["full", "replace"],
|
|
68
|
+
)
|
|
69
|
+
#
|
|
70
|
+
parser.add_argument("--config_path", default=None, help="Path to configuration options file")
|
|
71
|
+
parser.add_argument("--config_name", default="site_info_remote_configuration", help="Configuration section name")
|
|
72
|
+
parser.add_argument("--cache_path", default=None, help="Cache path for resource files")
|
|
73
|
+
parser.add_argument("--num_proc", default=2, help="Number of processes to execute (default=2)")
|
|
74
|
+
parser.add_argument("--chunk_size", default=10, help="Number of files loaded per process")
|
|
75
|
+
parser.add_argument("--max_step_length", default=500, help="Maximum subList size (default=500)")
|
|
76
|
+
parser.add_argument("--db_type", default="mongo", help="Database server type (default=mongo)")
|
|
77
|
+
parser.add_argument("--document_limit", default=None, help="Load document limit for testing")
|
|
78
|
+
#
|
|
79
|
+
parser.add_argument("--rebuild_cache", default=False, action="store_true", help="Rebuild cached resource files")
|
|
80
|
+
parser.add_argument("--rebuild_sequence_cache", default=False, action="store_true", help="Rebuild cached resource files for reference sequence updates")
|
|
81
|
+
parser.add_argument("--provider_types_exclude", default=None, help="Resource provider types to exclude")
|
|
82
|
+
parser.add_argument("--use_filtered_tax_list", default=False, action="store_true", help="Use filtered list for taxonomy tree loading")
|
|
83
|
+
parser.add_argument("--disable_read_back_check", default=False, action="store_true", help="Disable read back check on all documents")
|
|
84
|
+
parser.add_argument("--debug", default=False, action="store_true", help="Turn on verbose logging")
|
|
85
|
+
parser.add_argument("--mock", default=False, action="store_true", help="Use MOCK repository configuration for testing")
|
|
86
|
+
parser.add_argument("--log_file_path", default=None, help="Path to runtime log file output.")
|
|
87
|
+
#
|
|
88
|
+
# Arguments specific for op == 'upd_ref_seq'
|
|
89
|
+
parser.add_argument("--ref_chunk_size", default=10, help="Max chunk size for reference sequence updates (for op 'upd_ref_seq')")
|
|
90
|
+
parser.add_argument("--min_missing", default=0, help="Minimum number of allowed missing reference sequences (for op 'upd_ref_seq')")
|
|
91
|
+
parser.add_argument("--min_match_primary_percent", default=None, help="Minimum reference sequence match percentage (for op 'upd_ref_seq')")
|
|
92
|
+
parser.add_argument("--test_mode", default=False, action="store_true", help="Test mode for reference sequence updates (for op 'upd_ref_seq')")
|
|
93
|
+
#
|
|
94
|
+
# Arguments specific for op == 'ccd_img_gen' or 'ccd_file_gen'
|
|
95
|
+
parser.add_argument("--cc_output_path", default=None, help="The base local directory path where chemical component files (image, coordinates) are written (for op 'ccd_img_gen')")
|
|
96
|
+
parser.add_argument("--cc_cache_path", default=None, help="The base local directory path where chemical component cache data are written (for op 'ccd_img_gen')")
|
|
97
|
+
parser.add_argument("--oe_license_path", default=None, help="Path to OpenEye license file")
|
|
98
|
+
#
|
|
99
|
+
# Arguments buildExdbResources
|
|
100
|
+
parser.add_argument("--rebuild_all_neighbor_interactions", default=False, action="store_true", help="Rebuild all neighbor interactions from scratch (default is incrementally)")
|
|
101
|
+
parser.add_argument("--cc_file_prefix", default="cc-full", help="File name discriminator for index sets")
|
|
102
|
+
parser.add_argument("--cc_url_target", default=None, help="target url for chemical component dictionary resource file (default: None=all public)")
|
|
103
|
+
parser.add_argument("--bird_url_target", default=None, help="target url for bird dictionary resource file (cc format) (default: None=all public)")
|
|
104
|
+
#
|
|
105
|
+
args = parser.parse_args()
|
|
106
|
+
#
|
|
107
|
+
try:
|
|
108
|
+
op, commonD, loadD = processArguments(args)
|
|
109
|
+
except Exception as err:
|
|
110
|
+
logger.exception("Argument processing problem %s", str(err))
|
|
111
|
+
raise ValueError("Argument processing problem") from err
|
|
112
|
+
#
|
|
113
|
+
#
|
|
114
|
+
# Log input arguments
|
|
115
|
+
loadLogD = {k: v for d in [commonD, loadD] for k, v in d.items() if k != "inputIdCodeList"}
|
|
116
|
+
logger.info("running load op %r on loadLogD %r:", op, loadLogD)
|
|
117
|
+
#
|
|
118
|
+
# Run the operation
|
|
119
|
+
okR = False
|
|
120
|
+
exWf = ExDbWorkflow(**commonD)
|
|
121
|
+
if op in ["etl_chemref", "etl_uniprot_core", "etl_tree_node_lists", "upd_ref_seq"]:
|
|
122
|
+
okR = exWf.load(op, **loadD)
|
|
123
|
+
elif op in [
|
|
124
|
+
"upd_neighbor_interactions",
|
|
125
|
+
"upd_uniprot_taxonomy",
|
|
126
|
+
"upd_targets",
|
|
127
|
+
"load_target_cofactors",
|
|
128
|
+
"upd_pubchem",
|
|
129
|
+
"upd_entry_info",
|
|
130
|
+
"upd_glycan_idx",
|
|
131
|
+
"upd_resource_stash",
|
|
132
|
+
]:
|
|
133
|
+
okR = exWf.buildExdbResource(op, **loadD)
|
|
134
|
+
elif op in [
|
|
135
|
+
"ccd_img_gen",
|
|
136
|
+
"ccd_file_gen",
|
|
137
|
+
]:
|
|
138
|
+
okR = exWf.generateCcdFiles(op, **loadD)
|
|
139
|
+
else:
|
|
140
|
+
logger.error("Unsupported op %r", op)
|
|
141
|
+
#
|
|
142
|
+
logger.info("Operation %r completed with status %r", op, okR)
|
|
143
|
+
#
|
|
144
|
+
if not okR:
|
|
145
|
+
logger.error("Operation %r failed with status %r", op, okR)
|
|
146
|
+
raise ValueError("Operation %r failed" % op)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def processArguments(args):
|
|
150
|
+
# Logging details
|
|
151
|
+
logFilePath = args.log_file_path
|
|
152
|
+
debugFlag = args.debug
|
|
153
|
+
if debugFlag:
|
|
154
|
+
logger.setLevel(logging.DEBUG)
|
|
155
|
+
else:
|
|
156
|
+
logger.setLevel(logging.INFO)
|
|
157
|
+
if logFilePath:
|
|
158
|
+
logDir = os.path.dirname(logFilePath)
|
|
159
|
+
if not os.path.isdir(logDir):
|
|
160
|
+
os.makedirs(logDir)
|
|
161
|
+
handler = logging.FileHandler(logFilePath, mode="a")
|
|
162
|
+
if debugFlag:
|
|
163
|
+
handler.setLevel(logging.DEBUG)
|
|
164
|
+
else:
|
|
165
|
+
handler.setLevel(logging.INFO)
|
|
166
|
+
formatter = logging.Formatter("%(asctime)s [%(levelname)s]-%(module)s.%(funcName)s: %(message)s")
|
|
167
|
+
handler.setFormatter(formatter)
|
|
168
|
+
logger.addHandler(handler)
|
|
169
|
+
#
|
|
170
|
+
# Configuration details
|
|
171
|
+
configPath = args.config_path
|
|
172
|
+
configName = args.config_name
|
|
173
|
+
if not (configPath and configName):
|
|
174
|
+
logger.error("Config path and/or name not provided: %r, %r", configPath, configName)
|
|
175
|
+
raise ValueError("Config path and/or name not provided: %r, %r" % (configPath, configName))
|
|
176
|
+
mockTopPath = os.path.join(TOPDIR, "rcsb", "mock-data") if args.mock else None
|
|
177
|
+
logger.info("Using configuration file %r (section %r)", configPath, configName)
|
|
178
|
+
cfgOb = ConfigUtil(configPath=configPath, defaultSectionName=configName, mockTopPath=mockTopPath)
|
|
179
|
+
cfgObTmp = cfgOb.exportConfig()
|
|
180
|
+
logger.info("Length of config object (%r)", len(cfgObTmp))
|
|
181
|
+
if len(cfgObTmp) == 0:
|
|
182
|
+
logger.error("Missing or access issue for config file %r", configPath)
|
|
183
|
+
raise ValueError("Missing or access issue for config file %r" % configPath)
|
|
184
|
+
else:
|
|
185
|
+
del cfgObTmp
|
|
186
|
+
#
|
|
187
|
+
# Do any additional argument checking
|
|
188
|
+
op = args.op
|
|
189
|
+
if not op:
|
|
190
|
+
raise ValueError("Must supply a value to '--op' argument")
|
|
191
|
+
#
|
|
192
|
+
cachePath = args.cache_path if args.cache_path else "."
|
|
193
|
+
cachePath = os.path.abspath(cachePath)
|
|
194
|
+
|
|
195
|
+
if args.db_type != "mongo":
|
|
196
|
+
logger.error("Unsupported database type %r (must be 'mongo')", args.db_type)
|
|
197
|
+
raise ValueError("Unsupported database type %r (must be 'mongo')" % args.db_type)
|
|
198
|
+
|
|
199
|
+
# Now collect arguments into dictionaries
|
|
200
|
+
commonD = {
|
|
201
|
+
"configPath": configPath,
|
|
202
|
+
"configName": configName,
|
|
203
|
+
"cachePath": cachePath,
|
|
204
|
+
"mockTopPath": mockTopPath,
|
|
205
|
+
"debugFlag": debugFlag,
|
|
206
|
+
"rebuildCache": args.rebuild_cache,
|
|
207
|
+
"providerTypeExcludeL": args.provider_types_exclude,
|
|
208
|
+
}
|
|
209
|
+
loadD = {
|
|
210
|
+
"loadType": args.load_type,
|
|
211
|
+
"numProc": int(args.num_proc),
|
|
212
|
+
"chunkSize": int(args.chunk_size),
|
|
213
|
+
"maxStepLength": int(args.max_step_length),
|
|
214
|
+
"dbType": args.db_type,
|
|
215
|
+
"documentLimit": int(args.document_limit) if args.document_limit else None,
|
|
216
|
+
"readBackCheck": not args.disable_read_back_check,
|
|
217
|
+
"rebuildSequenceCache": args.rebuild_sequence_cache,
|
|
218
|
+
"useFilteredLists": args.use_filtered_tax_list,
|
|
219
|
+
"refChunkSize": int(args.ref_chunk_size),
|
|
220
|
+
"minMissing": int(args.min_missing),
|
|
221
|
+
"minMatchPrimaryPercent": float(args.min_match_primary_percent) if args.min_match_primary_percent else None,
|
|
222
|
+
"testMode": args.test_mode,
|
|
223
|
+
"rebuildAllNeighborInteractions": args.rebuild_all_neighbor_interactions,
|
|
224
|
+
"ccFileNamePrefix": args.cc_file_prefix,
|
|
225
|
+
"ccUrlTarget": args.cc_url_target,
|
|
226
|
+
"birdUrlTarget": args.bird_url_target,
|
|
227
|
+
"ccOutputPath": args.cc_output_path,
|
|
228
|
+
"ccCachePath": args.cc_cache_path,
|
|
229
|
+
"licenseFilePath": args.oe_license_path,
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return op, commonD, loadD
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
if __name__ == "__main__":
|
|
236
|
+
try:
|
|
237
|
+
main()
|
|
238
|
+
except Exception as e:
|
|
239
|
+
logger.exception("Run failed %s", str(e))
|
|
240
|
+
sys.exit(1)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Cli parser for jpg generation. This is a portion of imgs workflow which takes bcif images and generates these jpgs as well as chem images."""
|
|
2
|
+
##
|
|
3
|
+
# File: ImgExec.py
|
|
4
|
+
# Date: 11-Dec-2024 mjt
|
|
5
|
+
#
|
|
6
|
+
# Execution wrapper -- for jpg generation -
|
|
7
|
+
#
|
|
8
|
+
# Updates:
|
|
9
|
+
#
|
|
10
|
+
##
|
|
11
|
+
__docformat__ = "google en"
|
|
12
|
+
__author__ = "Michael Trumbull"
|
|
13
|
+
__email__ = "michael.trumbull@rcsb.org"
|
|
14
|
+
__license__ = "Apache 2.0"
|
|
15
|
+
|
|
16
|
+
import argparse
|
|
17
|
+
from rcsb.workflow.wuw.PdbCsmImageWorkflow import PdbCsmImageWorkflow
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main() -> None:
|
|
21
|
+
"""Cli parser for images workflow."""
|
|
22
|
+
parser = argparse.ArgumentParser()
|
|
23
|
+
parser.add_argument(
|
|
24
|
+
"--op",
|
|
25
|
+
required=True,
|
|
26
|
+
help="which function to call",
|
|
27
|
+
choices=[
|
|
28
|
+
"genJpgs",
|
|
29
|
+
],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
parser.add_argument("--baseDir", help="Base path for experimental or computational bcif file.")
|
|
33
|
+
parser.add_argument("--idListFilePath", help="List of ids to generate images for.")
|
|
34
|
+
parser.add_argument("--molrenderExe", default="/opt/modules/node_modules/molrender/build/bin/molrender.js", help="Molrender executable location.")
|
|
35
|
+
parser.add_argument("--jpgsOutDir", help="Where to put the complete jpg images.")
|
|
36
|
+
parser.add_argument("--jpgHeight", default=500, help="Height of generated jpg.")
|
|
37
|
+
parser.add_argument("--jpgWidth", default=500, help="Width of generated jpg.")
|
|
38
|
+
parser.add_argument("--jpgFormat", default="jpeg", help="Output image format.")
|
|
39
|
+
parser.add_argument("--jpgXvfbExecutable", default="/usr/bin/xvfb-run", help="Linux executable that allows this gui application to run in cli.")
|
|
40
|
+
parser.add_argument("--jpgScreen", default="1280x1024x24", help="Screen dimensions image will be rendered for.")
|
|
41
|
+
parser.add_argument("--jpgRender", default="all", help="Which elements of the potein do you want to render.")
|
|
42
|
+
parser.add_argument("--checkFileAppend", default="_model-1.jpeg", help="What jpg file do you want to check exists after the process runs.")
|
|
43
|
+
parser.add_argument("--numProcs", default=1, help="How many processors are available for parallel execution.")
|
|
44
|
+
parser.add_argument("--holdingsFilePath", help="Path (including filename) to holdings file .json file (csm, pdb, ihm)")
|
|
45
|
+
parser.add_argument("--targetFileSuffix", default="_model-1.jpeg", help="string that follows the ID in the jpg file name for comparing timestamps.")
|
|
46
|
+
parser.add_argument("--csmHoldingsFileSubstring", default="computed-models-holdings-list", help="substring in csm holdings file path to determine if we are working with CSMs.")
|
|
47
|
+
parser.add_argument("--baseUrl", help="Base url for model file. This will supercede any local bcif.")
|
|
48
|
+
parser.add_argument("--modelFileExtension", default=".bcif.gz", help="Model file type (.bcif.gz, .bcif, .cif).")
|
|
49
|
+
parser.add_argument("--tmpDir", default="/tmp", help="Temporary dir for downloading model file over url.")
|
|
50
|
+
args = vars(parser.parse_args())
|
|
51
|
+
|
|
52
|
+
imgWF = PdbCsmImageWorkflow()
|
|
53
|
+
if args["op"] == "genJpgs":
|
|
54
|
+
imgWF.imagesGenJpgs(**args)
|
|
55
|
+
else:
|
|
56
|
+
raise ValueError("CLI --op flag error: not available option %r" % args.op)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
try:
|
|
61
|
+
main()
|
|
62
|
+
except Exception as err:
|
|
63
|
+
msg = f"Run failed {err}"
|
|
64
|
+
raise RuntimeError(msg) from err
|
|
File without changes
|