Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing local .CIF and .MOL file formats #626

Open
julioarvellos opened this issue Sep 30, 2024 · 1 comment
Open

Error when importing local .CIF and .MOL file formats #626

julioarvellos opened this issue Sep 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@julioarvellos
Copy link

I'm getting an error when I try to import a small molecule using the local method using a file format different from PDB.
The CIF and MOL files were created using Open Babel with the following settings:

  • Input PDB > Output CIF | custom setting: "Write bonds using _geom_bond_etc fields"
  • Input PDB > Output MOL

The error when Importing CIF file:

bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
Deleted 2 object(s)
bpy.context.space_data.context = 'SCENE'
bpy.context.space_data.system_bookmarks_active = 1
bpy.context.scene.MN_panel_import = 'local'
bpy.context.space_data.system_bookmarks_active = 1
bpy.ops.mn.import_protein_local()

Python: Traceback (most recent call last):
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\ui.py", line 39, in parse
    molecule = parser[suffix](filepath)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\pdbx.py", line 262, in __init__
    self.array = self.get_structure()
                 ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\pdbx.py", line 43, in get_structure
    array = pdbx.get_structure(self.file, extra_fields=extra_fields)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\.local\lib\python3.11\site-packages\biotite\structure\io\pdbx\convert.py", line 270, in get_structure
    raise InvalidFileError("Missing 'atom_site' category in file")
biotite.InvalidFileError: Missing 'atom_site' category in file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\ensemble\cif.py", line 32, in _get_structure
    array = pdbx.get_structure(self.file, extra_fields=extra_fields)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\.local\lib\python3.11\site-packages\biotite\structure\io\pdbx\convert.py", line 270, in get_structure
    raise InvalidFileError("Missing 'atom_site' category in file")
biotite.InvalidFileError: Missing 'atom_site' category in file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\.local\lib\python3.11\site-packages\biotite\structure\io\pdbx\convert.py", line 1128, in get_component
    atom_category = block["chem_comp_atom"]
                    ~~~~~^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\.local\lib\python3.11\site-packages\biotite\structure\io\pdbx\cif.py", line 647, in __getitem__
    category = self._categories[key]
               ~~~~~~~~~~~~~~~~^^^^^
KeyError: 'chem_comp_atom'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\ui.py", line 41, in parse
    molecule = OldCIF(filepath)
               ^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\ensemble\cif.py", line 16, in __init__
    self.array = self._get_structure(
                 ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\ensemble\cif.py", line 45, in _get_structure
    array = pdbx.get_component(self.file)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\.local\lib\python3.11\site-packages\biotite\structure\io\pdbx\convert.py", line 1130, in get_component
    raise InvalidFileError("Missing 'chem_comp_atom' category in file")
biotite.InvalidFileError: Missing 'chem_comp_atom' category in file

The error when Importing MOL file:

bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
Deleted 2 object(s)
bpy.context.space_data.context = 'SCENE'
bpy.context.scene.MN_panel_import = 'alphafold'
bpy.context.scene.MN_panel_import = 'local'
bpy.context.space_data.system_bookmarks_active = 1
bpy.ops.mn.import_protein_local()
Python: Traceback (most recent call last):
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\ui.py", line 407, in invoke
    return self.execute(context)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\ui.py", line 391, in execute
    mol = load_local(
          ^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\ui.py", line 93, in load_local
    mol.create_object(
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\molecule.py", line 201, in create_object
    obj, frames = _create_object(
                  ^^^^^^^^^^^^^^^
  File "C:\Users\Julio Arvellos\AppData\Roaming\Blender Foundation\Blender\4.2\extensions\blender_org\molecularnodes\entities\molecule\molecule.py", line 307, in _create_object
    centre_array(atom_array, centre)
                 ^^^^^^^^^^
UnboundLocalError: cannot access local variable 'atom_array' where it is not associated with a value

To Reproduce

  • Convert the PDB file to CIF or MOL using Open Babel and the settings above mentioned;
  • Import the files using MN

Desktop (please complete the following information):

  • Windows 11
  • Blender 4.2.2 LTS
  • Molecular Nodes 4.2.7

FILES:
bodipy_ar_opt_v2.zip

@julioarvellos julioarvellos added the bug Something isn't working label Sep 30, 2024
@BradyAJohnston
Copy link
Owner

Thanks for reporting this! I won't have time for another week or so to look into this but should definitely be able to get something working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants