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".
import argparse
import json
import os
import sys
import traceback
import ost
......@@ -295,6 +296,16 @@ def _ParseArgs():
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):
"""Get the structure format and return it as "pdb" or "mmcif".
"""
......@@ -580,6 +591,7 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
def _Main():
args = _ParseArgs()
_CheckCompoundLib()
ost.PushVerbosityLevel(args.verbosity)
try:
# Load structures
......
......@@ -80,6 +80,7 @@ ost compare-structures -m model.pdb -r reference.cif -c A:B B:A
import argparse
import os
import json
import sys
import traceback
import math
......@@ -526,6 +527,15 @@ def _ParseArgs():
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):
""" Helper to create valid JSON output
"""
......@@ -852,6 +862,7 @@ def _Process(model, reference, args, model_format, reference_format):
def _Main():
args = _ParseArgs()
_CheckCompoundLib()
try:
compute_cad = args.cad_score or args.local_cad_score
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