cctbx_project
cctbx_project copied to clipboard
Error handling with bad cif
The CSD API generates an incomplete cif for the ETEBEM structure, leaving an open loop for _geom_bond_atom_site_xxx.
Most errors I have been able to with try/except statements; however, attempting to read this file produces a segmentation fault with a call to iotbx.cif.reader()
. Although this is problem with the cif generation in the CSD API, I figured I would flag the issue of error handling with unexpected end of file in a cif.
I've attached the cif in question and a stack trace. stack_trace.txt ETEBEM.txt
Have you tried following the suggestion in the traceback about setting an environmental variable to suppress the seg. fault? It works some of the time.
Will take a look at this at some point.
Have you reported this issue to CSD API developers and what was their response? Looks like rather straightforward fix: don't output loop header if there is nothing to put in it.
On Tue, Nov 27, 2018 at 5:27 PM Nigel W. Moriarty [email protected] wrote:
Have you tried following the suggestion in the traceback about setting an environmental variable to suppress the seg. fault? It works some of the time.
Will take a look at this at some point.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cctbx/cctbx_project/issues/264#issuecomment-442283044, or mute the thread https://github.com/notifications/unsubscribe-auth/ATDxDKEhYEl0aT2Zvd_Q4Nafky9Q4va1ks5uzeZvgaJpZM4Y1VQT .
Thanks for the reply! The segmentation fault stoped the process even after setting the environmental variables.
I've also started a thread with the CSD API, and am awaiting a response. As for a workaround, I naturally just removed the excess header.
Do you have a small script that reads the file? Would save me some time.
This will produce Segmentation fault: 11
import os
os.environ["BOOST_ADAPTBX_FPE_DEFAULT"]="1"
os.environ["BOOST_ADAPTBX_SIGNALS_DEFAULT"]="1"
import iotbx.cif
def load_cif(fname):
try:
struct_loader = iotbx.cif.reader(file_path=fname).build_crystal_structures()
except:
return
struct = struct_loader.values()[0]
data['structure'] = struct
data['space_group'] = '{0!s}'.format(struct.space_group().info())
if(__name__=="__main__"):
data = load_cif('ETEBEM.txt')
print(data['space_group'])