brisvag / napari-molecule-reader

BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

Vizualize whole cell pdb file #4

Open sofroniewn opened 2 years ago

sofroniewn commented 2 years ago

I'm trying to visualize this pdb file https://github.com/sofroniewn/MycoplasmaGenitalium/blob/main/Models/cellpack_1189_auto.pdb

but running into the following error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/GitHub/napari/napari/_qt/qt_viewer.py in dropEvent(self=<napari._qt.qt_viewer.QtViewer object>, event=<PyQt5.QtGui.QDropEvent object>)
   1051                 filenames.append(url.toString())
   1052
-> 1053         self.viewer.open(filenames, stack=bool(shift_down))
        self.viewer.open = <bound method ViewerModel.open of Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 0.0, 0.0), zoom=1.0, angles=(0.0, 0.0, 90.0), perspective=0.0, interactive=True), cursor=Cursor(position=(1.0, 1.0), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=2, ndisplay=2, last_used=0, range=((0, 2, 1), (0, 2, 1)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[], scale_bar=ScaleBar(visible=False, colored=False, ticks=True, position=<Position.BOTTOM_RIGHT: 'bottom_right'>, font_size=10.0, unit=None), text_overlay=TextOverlay(visible=False, color=<class 'numpy.ndarray'> (4,) float64, font_size=10.0, position=<TextOverlayPosition.TOP_LEFT: 'top_left'>, text=''), overlays=Overlays(interaction_box=InteractionBox(points=None, show=False, show_handle=False, show_vertices=False, selection_box_drag=None, selection_box_final=None, transform_start=<napari.utils.transforms.transforms.Affine object at 0x7fd09aa3c8d0>, transform_drag=<napari.utils.transforms.transforms.Affine object at 0x7fd09aa3c940>, transform_final=<napari.utils.transforms.transforms.Affine object at 0x7fd09aa3c9b0>, transform=<napari.utils.transforms.transforms.Affine object at 0x7fd09aa3ca20>, allow_new_selection=True, selected_vertex=None)), help='', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_move_callbacks=[<function InteractionBoxMouseBindings.initialize_mouse_events.<locals>.mouse_move at 0x7fd09e6920d0>], mouse_drag_callbacks=[<function InteractionBoxMouseBindings.initialize_mouse_events.<locals>.mouse_drag at 0x7fd09e692048>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x7fd09a704f28>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': <function InteractionBoxMouseBindings.initialize_key_events.<locals>.hold_to_lock_aspect_ratio at 0x7fd09e692620>, 'Control-Shift-R': <function InteractionBoxMouseBindings._reset_active_layer_affine at 0x7fd09d7da840>, 'Control-Shift-A': <function InteractionBoxMouseBindings._transform_active_layer at 0x7fd09d7daea0>})>
        filenames = ['/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb']
        global stack = undefined
        global bool = undefined
        shift_down = <PyQt5.QtCore.Qt.KeyboardModifiers object at 0x7fd087c76ac8>
   1054
   1055     def closeEvent(self, event):

~/GitHub/napari/napari/components/viewer_model.py in open(self=Viewer(axes=Axes(visible=False, labels=True, col...ings._transform_active_layer at 0x7fd09d7daea0>}), path=['/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'], stack=False, plugin=None, layer_type=None, **kwargs={})
    906                 added.extend(
    907                     self._add_layers_with_plugins(
--> 908                         _path, kwargs, plugin=plugin, layer_type=layer_type
        _path = '/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'
        kwargs = {}
        plugin = None
        layer_type = None
    909                     )
    910                 )

~/GitHub/napari/napari/components/viewer_model.py in _add_layers_with_plugins(self=Viewer(axes=Axes(visible=False, labels=True, col...ings._transform_active_layer at 0x7fd09d7daea0>}), path_or_paths='/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb', kwargs={}, plugin=None, layer_type=None)
    951
    952         layer_data, hookimpl = read_data_with_plugins(
--> 953             path_or_paths, plugin=plugin
        path_or_paths = '/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'
        plugin = None
    954         )
    955

~/GitHub/napari/napari/plugins/io.py in read_data_with_plugins(path='/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb', plugin=None)
     59     """
     60     hookimpl: Optional[HookImplementation]
---> 61     res = _npe2.read(path, plugin)
        res = undefined
        global _npe2.read = <function read at 0x7fd09a66d378>
        path = '/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'
        plugin = None
     62     if res is not None:
     63         _ld, hookimpl = res

~/GitHub/napari/napari/plugins/_npe2.py in read(path='/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb', plugin=None)
     59     """Try to return data for `path`, from reader plugins using a manifest."""
     60     with suppress(ValueError):
---> 61         layer_data, reader = read_get_reader(path, plugin_name=plugin)
        layer_data = undefined
        reader = undefined
        global read_get_reader = <function read_get_reader at 0x7fd0989290d0>
        path = '/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'
        global plugin_name = undefined
        plugin = None
     62         return layer_data, _FakeHookimpl(reader.plugin_name)
     63     return None

~/opt/anaconda3/lib/python3.7/site-packages/npe2/io_utils.py in read_get_reader(path='/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb', plugin_name=None)
     41 ) -> Tuple[List[LayerData], ReaderContribution]:
     42     """Variant of `read` that also returns the `ReaderContribution` used."""
---> 43     return _read(path, plugin_name=plugin_name, return_reader=True)
        global _read = <function _read at 0x7fd098929268>
        path = '/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'
        plugin_name = None
        global return_reader = undefined
     44
     45

~/opt/anaconda3/lib/python3.7/site-packages/npe2/io_utils.py in _read(path='/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb', plugin_name=None, return_reader=True, _pm=<npe2._plugin_manager.PluginManager object>)
    128         if read_func is not None:
    129             # if the reader function raises an exception here, we don't try to catch it
--> 130             layer_data = read_func(path)
        layer_data = undefined
        read_func = <function read_molecules at 0x7fd088259b70>
        path = '/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'
    131             if layer_data:
    132                 return (layer_data, rdr) if return_reader else layer_data

~/GitHub/napari-molecule-reader/src/napari_molecule_reader/molecule_reader.py in read_molecules(path=['/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'])
    126     path = [path] if isinstance(path, str) else path
    127
--> 128     return [tup for p_ in path for tup in read_molecule(p_)]
        global tup = undefined
        global p_ = undefined
        path = ['/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb']
        global read_molecule = <function read_molecule at 0x7fd087ca8c80>

~/GitHub/napari-molecule-reader/src/napari_molecule_reader/molecule_reader.py in <listcomp>(.0=<list_iterator object>)
    126     path = [path] if isinstance(path, str) else path
    127
--> 128     return [tup for p_ in path for tup in read_molecule(p_)]
        tup = undefined
        p_ = '/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb'
        global path = undefined
        global read_molecule = <function read_molecule at 0x7fd087ca8c80>

~/GitHub/napari-molecule-reader/src/napari_molecule_reader/molecule_reader.py in read_molecule(path='/Users/nsofroniew/GitHub/MycoplasmaGenitalium/Models/cellpack_1189_auto.pdb')
     26                 atom.het.name if atom.het else '',
     27                 atom.chain.id if atom.chain else '',
---> 28                 atom.covalent_radius,
        atom.covalent_radius = undefined
     29             ])
     30         atoms = pd.DataFrame(atoms, columns=['x', 'y', 'z', *property_columns])

~/opt/anaconda3/lib/python3.7/site-packages/atomium/structures.py in covalent_radius(self=<Atom 52827 (CA)>)
   1163         :rtype: ``float``"""
   1164
-> 1165         return self.__data.COVALENT_RADII.get(self._element.upper(), 0)
        self.__data.COVALENT_RADII.get = undefined
        self._element.upper = undefined
   1166
   1167

AttributeError: 'NoneType' object has no attribute 'upper'

Looks like this is a problem inside atomium directly - but I thought I'd flag here first before making an issue over there as i don't know too much about reading pdb files

brisvag commented 2 years ago

Yeah, that looks like some unintended ungraceful failure in atomium, though it might be that accessing covalent_radius is intended to fail in some circumstances. Did you nail down the offending atom/structure?