Opened 7 years ago

Closed 7 years ago

#1365 closed defect (fixed)

Bad geometry can crash graphics on ribbon generation

Reported by: Tristan Croll Owned by: pett
Priority: moderate Milestone:
Component: Graphics Version:
Keywords: Cc: Tom Goddard, Conrad Huang
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description (last modified by pett)

Arising out of working through CASP assessments... one model had a residue (the first, but I don't think that should actually make a difference) in which all the coordinates were zero. This crashes dssp and, by extension, the whole graphics loop on generating the cartoon when first loading the model.

I think the _create_ribbon_graphics code needs to catch the ValueError coming out of get_polymer_spline and do something intelligent, e.g. stopping the ribbon

Attachments (1)

zero.pdb (19.7 KB ) - added by pett 7 years ago.
1gcn with no headers and first residue coords zeroed out

Download all attachments as: .zip

Change History (5)

comment:1 by pett, 7 years ago

Cc: Conrad Huang added
Owner: changed from Conrad Huang to pett

comment:2 by pett, 7 years ago

Cc: pett added; Conrad Huang removed
Owner: changed from pett to Conrad Huang

Okay, assigning this back to Conrad. Testing with a 1gcn with all headers removed and the coordinates of the first residue zeroed out (attached), the crash occurs in the ribbon code, not the dssp code, as per this traceback:

Traceback (most recent call last):
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ChimeraX_main.py", line 694, in init
    commands.run(sess, 'open %s' % arg)
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/commands/run.py", line 31, in run
    results = command.run(text, log=log)
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/commands/cli.py", line 2563, in run
    result = ci.function(session, **kw_args)
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/commands/open.py", line 41, in open
    from_database=from_database, ignore_cache=ignore_cache, **kw))
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/commands/open.py", line 110, in open
    models = handle_unknown_kw(session.models.open, paths, format=format, name=name, **kw)
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/commands/open.py", line 62, in handle_unknown_kw
    return f(*args, **kw)
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/models.py", line 592, in open
    self.add(models)
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/models.py", line 462, in add
    v.initial_camera_view()
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/graphics/view.py", line 571, in initial_camera_view
    b = self.drawing_bounds()
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/graphics/view.py", line 543, in drawing_bounds
    dm.cached_drawing_bounds = b = self.drawing.bounds()
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/graphics/drawing.py", line 849, in bounds
    dbounds = [d.bounds() for d in self.child_drawings()
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/core/graphics/drawing.py", line 850, in <listcomp>
    if d.display and not getattr(d, 'skip_bounds', False)]
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/atomic/structure.py", line 1529, in bounds
    self._update_graphics_if_needed()       # Ribbon bounds computed from graphics
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/atomic/structure.py", line 305, in _update_graphics_if_needed
    self._create_ribbon_graphics()
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/atomic/structure.py", line 479, in _create_ribbon_graphics
    any_display, atoms, coords, guides = rlist.get_polymer_spline()
  File "/Users/pett/src/chimerax/ChimeraX.app/Contents/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/chimerax/atomic/molarray.py", line 1175, in get_polymer_spline
    any_display, atom_pointers, centers, guides = f(self._c_pointers, len(self))
ValueError: Can't normalize if length is zero

by pett, 7 years ago

Attachment: zero.pdb added

1gcn with no headers and first residue coords zeroed out

comment:3 by Conrad Huang, 7 years ago

Owner: changed from Conrad Huang to pett

Ultimately, the ribbon spline code asks for the ribbon orientation of a residue, which depends on its secondary structure type, and triggers a call to structure()->compute_secondary_structure(); in Residue::ss_type(). compute_secondary_structure should catch the normalization error and assign "TURN" for either the bad residue or all residues. The ribbon display code may still choke on the bad coordinates, but that will be in a different section of code.

comment:4 by pett, 7 years ago

Cc: Conrad Huang added; pett removed
Description: modified (diff)
Resolution: fixed
Status: assignedclosed

Instead of throwing an error out of the dssp code, it _logs_ an error (which brings up an error dialog with an actual informative error message) but otherwise keeps going -- assigning all turn to the structure and allowing the ribbon code to function.

Note: See TracTickets for help on using tickets.