Skip to content
Snippets Groups Projects
Verified Commit 90d361f2 authored by Xavier Robin's avatar Xavier Robin
Browse files

fix: clean error message for missing compound lib

Until now, the actions were failing with somewhat cryptic messages
raised from arbitrary locations. This one should be more user-friendly.
parent 3839133a
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,7 @@ and "unassigned_reference_ligands". ...@@ -56,6 +56,7 @@ and "unassigned_reference_ligands".
import argparse import argparse
import json import json
import os import os
import sys
import traceback import traceback
import ost import ost
...@@ -295,6 +296,16 @@ def _ParseArgs(): ...@@ -295,6 +296,16 @@ def _ParseArgs():
return parser.parse_args() return parser.parse_args()
def _CheckCompoundLib():
clib = ost.conop.GetDefaultLib()
if not clib:
ost.LogError("A compound library is required for this action. "
"Please refer to the OpenStructure website: "
"https://openstructure.org/docs/conop/compoundlib/.")
sys.tracebacklimit = 0
raise RuntimeError("No compound library found")
def _GetStructureFormat(structure_path, sformat=None): def _GetStructureFormat(structure_path, sformat=None):
"""Get the structure format and return it as "pdb" or "mmcif". """Get the structure format and return it as "pdb" or "mmcif".
""" """
...@@ -580,6 +591,7 @@ def _Process(model, model_ligands, reference, reference_ligands, args): ...@@ -580,6 +591,7 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
def _Main(): def _Main():
args = _ParseArgs() args = _ParseArgs()
_CheckCompoundLib()
ost.PushVerbosityLevel(args.verbosity) ost.PushVerbosityLevel(args.verbosity)
try: try:
# Load structures # Load structures
......
...@@ -80,6 +80,7 @@ ost compare-structures -m model.pdb -r reference.cif -c A:B B:A ...@@ -80,6 +80,7 @@ ost compare-structures -m model.pdb -r reference.cif -c A:B B:A
import argparse import argparse
import os import os
import json import json
import sys
import traceback import traceback
import math import math
...@@ -526,6 +527,15 @@ def _ParseArgs(): ...@@ -526,6 +527,15 @@ def _ParseArgs():
return parser.parse_args() return parser.parse_args()
def _CheckCompoundLib():
clib = ost.conop.GetDefaultLib()
if not clib:
ost.LogError("A compound library is required for this action. "
"Please refer to the OpenStructure website: "
"https://openstructure.org/docs/conop/compoundlib/.")
sys.tracebacklimit = 0
raise RuntimeError("No compound library found")
def _RoundOrNone(num, decimals = 3): def _RoundOrNone(num, decimals = 3):
""" Helper to create valid JSON output """ Helper to create valid JSON output
""" """
...@@ -852,6 +862,7 @@ def _Process(model, reference, args, model_format, reference_format): ...@@ -852,6 +862,7 @@ def _Process(model, reference, args, model_format, reference_format):
def _Main(): def _Main():
args = _ParseArgs() args = _ParseArgs()
_CheckCompoundLib()
try: try:
compute_cad = args.cad_score or args.local_cad_score compute_cad = args.cad_score or args.local_cad_score
if compute_cad and not args.residue_number_alignment: if compute_cad and not args.residue_number_alignment:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment