BradyAJohnston / MolecularNodes

Toolbox for molecular animations in Blender, powered by Geometry Nodes.
https://bradyajohnston.github.io/MolecularNodes/
MIT License
836 stars 81 forks source link

How can I debug Molecular Nodes? (Cannot load some PDBs and mmCIFs) #19

Open RodenLuo opened 2 years ago

RodenLuo commented 2 years ago

Hi Brady,

I have a local PDB file, attached as CTD.zip. It is self-generated so that it has nothing else but only the atom position information. It can be opened in PyMol or ChimeraX. But when I load it via Molecular Nodes, it tells the following error.

Python: Traceback (most recent call last):
  File "C:\Users\luod\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\molecular_nodes\__init__.py", line 1491, in execute
    sna_func_import_structure_EE5B6(
  File "C:\Users\luod\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\molecular_nodes\__init__.py", line 907, in sna_func_import_structure_EE5B6
    n_atoms = len(first_model.atoms())
AttributeError: 'File' object has no attribute 'atoms'

location: <unknown location>:-1

My ultimate goal is to convert this CTD.pdb into mmCIF (with more than one instance of the protein in mmCIF, and hence with transformation info) and then combine multiple proteins' mmCIFs into one big mmCIF. The final mmCIF will have more than 99,999 atoms for sure. So I can only rely on mmCIF format. I tried several tools (mmcif.pdbj.org converter, export from PyMol/ChimeraX, gemmi, pdb-tools). None of them give me a successful loading. The mmcif.pdbj.org converter does seem promising in my case, as the converted file (CTD.pdb.zip) gives the same error as above. And I also noticed that if I convert in this way for 1bna, the converted mmCIF can indeed be loaded via Molecular Nodes. However, I do want to rely on a command-line tool to finish the format conversion as I have a handful of PDBs to be converted.

My guess is there is some metadata that is required to be in the PDB/mmCIF either from the Molecular Nodes side or from the Atomium side. But this info might not actually be that necessary.

Anyways, it would be great and be appreciated if you can help with the debugging. But I would also like to set up a debugging/dev environment. This is the first time I use both Blender and its python addons. But I have some experience using PyCharm/VS/VS code. Could you please guide me shortly on how to set up the dev env? Thanks.

RodenLuo commented 2 years ago

Here are all files for 1bna for later references for this issue. 1bna.zip

Name Source Can be loaded?
1bna.pdb the original pdb file Y
1bna.pdb.cif converted from mmcif.pdbj.org converter Y
1bna.gemmi.cif converted from gemmi N
1bna.pdbtools.cif converted from pdb-tools N
BradyAJohnston commented 2 years ago

I will have a look at the different structures in terms of where things might be breaking and what can be done. It's good to be testing a variety of structures. May take a few days for me to get a chance to look at it though.

In terms of setting up your own dev environment, everything you need is inside of the git repo, so if you clone it you will have all of the required files.

I have been building the addon however with the serpens addon which makes it much easier to iterate without having to write as much boilerplate code myself.

To be able to build the addon, you will need the addon (there is a free + paid version) and you open the serpens_plugin_file.blend. I may need to move away from this method, to a more pure-code based method for allowing better collaboration, but for the time being with mostly just myself working on it this method allows me to work quickly and efficiently.

BradyAJohnston commented 1 year ago

All of the supplied files (except the one generated by gemmi can now be parsed with MolecularNodes 2.0. It is also structured now in a way to enabled debugging and interactive building via VS Code if you'd like to try and sort out the issue. The underlying python library is now Biotite so there is some parsing issue for the file generated by gemmi. I don't currently have time to look too deep into it, but would of course always appreciate pull requests!