nglviewer/nglview

Wrong mode in MrcParser with MRC density map file

Closed this issue · 12 comments

jeesay commented

Hi all,

When I try to run the script below in jupyterlab, the MRC file wasn't loaded and the browser console displays the following error message:

MrcParser unknown mode 1010723949                                                     664.8a35b9da8e921c96bddb.js:2:1362848
STAGE LOG error loading file: 'TypeError: r[a[1]] is undefined'                       664.8a35b9da8e921c96bddb.js:2:1109224
Uncaught (in promise) error loading file: 'TypeError: r[a[1]] is undefined'           49.13801d0d3acfe1244269.js:1:80728


  • I checked with the Python package mrcfile and the file is correctly read with a MRC mode of 2 (float32)
  • I tried with a swap-byte file but the error message is the same (wrong mode).
  • I reproduced the error with other MRC files (downloaded from the EMDB databank).

Thanks in advance, Jean-Christophe.

Here is the script:

import nglview as nv

view = nv.NGLWidget()

# Parameters of viewport
view.background = '#333'
view.parameters = {'clip_near': 0, 'clip_far': 10000}

# https://scipion.cnb.csic.es/downloads/scipion/data/tests/resmap/
view.add_component('data/map/betaGal.mrc')

print(view.n_components)
# Display 0

# Display...
view

Versions

jupyterlab                4.0.6                    pypi_0    pypi
nglview                   3.0.8                    pypi_0    pypi
hainm commented

hi @jeesay: thanks for your report.
Would you mind trying with the NGL (that nglview uses) to see if you can view your file?
https://nglviewer.org/ngl/?script=showcase/ferredoxin

If yes, it's nglview issue. We will try to fix.
If no, it's NGL issue, and please help file a case in https://github.com/nglviewer/ngl

thanks.

jeesay commented

Hi @hainm,

  1. Works perfectly in NGL.

  2. I don't know if it can help. I tested several scripts:

  • The function add_component(url) returns the wrong MODE only if the url is set like:
view.add_component('http://localhost:8888/lab/data/map/betaGal.mrc',ext="mrc")
  • . The add_component(path/filename) returns a 'Not found file'. For example,
view.add_component('data/map/betaGal.mrc',ext="mrc")

Thanks. Jean-Christophe

hainm commented

Hi @hainm,

  1. Works perfectly in NGL.
  2. I don't know if it can help. I tested several scripts:
  • The function add_component(url) returns the wrong MODE only if the url is set like:
view.add_component('http://localhost:8888/lab/data/map/betaGal.mrc',ext="mrc")
  • . The add_component(path/filename) returns a 'Not found file'. For example,
view.add_component('data/map/betaGal.mrc',ext="mrc")

Thanks. Jean-Christophe

oh then it's an issue for nglview with jupyterlab then.
If possible, please try with traditional notebook since it (notebook) will accept data/map/betaGal.mrc path.

jeesay commented

Hi @hainm,

  1. Works perfectly in NGL.
  2. I don't know if it can help. I tested several scripts:
  • The function add_component(url) returns the wrong MODE only if the url is set like:
view.add_component('http://localhost:8888/lab/data/map/betaGal.mrc',ext="mrc")
  • . The add_component(path/filename) returns a 'Not found file'. For example,
view.add_component('data/map/betaGal.mrc',ext="mrc")

Thanks. Jean-Christophe

oh then it's an issue for nglview with jupyterlab then. If possible, please try with traditional notebook since it (notebook) will accept data/map/betaGal.mrc path.

jupyter notebook finds the file with path but I got the same wrong MODE message:

MrcParser unknown mode   171863149                 664.8a35b9da8e921c96bddb.js:2:1362848
    _parse        http://localhost:8888/lab/extensions/nglview-js-widgets/static/664.8a35b9da8e921c96bddb.js?v=8a35b9da8e921c96bddb:2
    parse         http://localhost:8888/lab/extensions/nglview-js-widgets/static/664.8a35b9da8e921c96bddb.js?v=8a35b9da8e921c96bddb:2
hainm commented

noted. thanks @jeesay.

Do you have a .mcr file to share to reproduce it here? thanks.

jeesay commented

noted. thanks @jeesay.

Do you have a .mcr file to share to reproduce it here? thanks.

The test map betaGal.mrc in ngl repository at https://github.com/nglviewer/ngl/blob/master/data/betaGal.mrc

hainm commented

thanks @jeesay

jeesay commented

Hi @hainm,

Did you reproduce the bug?

Jean-Christophe

hainm commented

Hi @hainm,

Did you reproduce the bug?

Jean-Christophe

Dear @jeesay
I don't have a chance to test yet, get stuck with my daily work now. Sorry.

The issue is resolved in #1100 (available in nglview 3.1.1)

@jeesay Sorry for my super late fix. Cheers.

@hainm Thanks a lot. I'll try as soon as possible.
I tried. Works perfectly.
Jean-Christophe.