nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
664 stars 169 forks source link

NGL error displaying some mmCIF files #999

Closed brucelab closed 10 months ago

brucelab commented 10 months ago

Lately I've noticed that many mmCIF files do not display in NGL and give an error: 'TypeError: s.name.trim is not a function.' For example the file 32c2.cif is one that causes the error and is not displayed on the NGL web application at https://nglviewer.org/ngl/.

On close inspection, I have found that mmCIF files that contain _chem_comp_atom, entries seem to cause the problem. When I delete that section of an mmCIF file, or even just rename the _chem_comp_atom. entries '_chem_comp_atom2.' the file is displayed in NGL without a problem.

Do you know about this issue? Is it possible to enable mmCIF files with the _chem_comp_atom. entries to be displayed?

hainm commented 10 months ago

We got the issue in nglview too (not able to show .CIF file): https://github.com/nglviewer/nglview/issues/1082#issuecomment-1811176285

ppillot commented 10 months ago

@brucelab @hainm For the record this was due to an assumption that when this property is defined, the cif file is not a mmCif file and most probably the kind of cif file that can be dowloaded from the PDB ligand repository. As you've noticed this assumption can be false in some mmCIF files. In that case, this cif loop contains the list of amino acids which causes an error in the code execution. The fix done is to check if the struct property is set, to switch to the proper parsing routine.