cctbx_project icon indicating copy to clipboard operation
cctbx_project copied to clipboard

Error handling with bad cif

Open maffettone opened this issue 5 years ago • 5 comments

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

maffettone avatar Nov 27 '18 11:11 maffettone

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.

nwmoriarty avatar Nov 28 '18 01:11 nwmoriarty

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 .

olegsobolev avatar Nov 28 '18 01:11 olegsobolev

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.

maffettone avatar Nov 28 '18 13:11 maffettone

Do you have a small script that reads the file? Would save me some time.

nwmoriarty avatar Nov 28 '18 18:11 nwmoriarty

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'])

maffettone avatar Nov 29 '18 11:11 maffettone