Atomic Blender (PDB/XYZ) - for Blender 2.8 and higher

thanks a lot for your reply, here it is:

Cu.pdb (58 Bytes)

I would like to build up a model of a cubic phase of metallic copper composed of copper atom cluster, which i exported from VESTA as you mentioned before. Is there any problem with this file? I could see “create” button in the right side currently, but once I import this Cu pdb file into Blender, it will say:

"Python: Traceback (most recent call last):
File “D:\blender\3.1\scripts\addons\io_mesh_atomic\pdb_gui.py”, line 214, in execute
import_pdb(self.ball,
File “D:\blender\3.1\scripts\addons\io_mesh_atomic\pdb_import.py”, line 1407, in import_pdb
sum_vec = sum_vec / Number_of_total_atoms
ZeroDivisionError: Vector division: divide by zero error

location: :-1"

Dear Xuefepan.

What I have found in your file is the following:

COMPND    New structure
COMPND   1Created by VESTA
END

No wonder that you see nothing because there are no atomic structures described inside! The file is also only 58 bytes large.

You have to deal with VESTA and its export, during which something strange happened. See the manual of VESTA.

Many thanks, bro! Finally I made it by importing xyz file. And make like this:

Picture1.tif (80.5 KB)

It is quite fun anyway.

best,
Xuefeng

1 Like

@Blendphys first off, thanks for developing this add-on, it’s an amazing tool!
let me explain a bit here since I have the same need. The following is from one PDB file I borrowed from RCSB website. As you can see, the 2nd column is the atom numbers, the 3rd column is the atom name, 4th column is the residue name, 7th, 8th and 9th columns are the coordinates.

I’m thinking about using different styles/colors for different residue/atom names. Is there a way to select in Blender by names? (e.g. I could have many lysine residues in a protein and want to select them not by hand if possible)

ATOM      1  N   GLN H   1     106.670 138.421 203.253  1.00114.51           N  
ATOM      2  CA  GLN H   1     106.686 138.107 201.795  1.00114.44           C  
ATOM      3  C   GLN H   1     107.546 136.866 201.553  1.00114.40           C  
ATOM      4  O   GLN H   1     108.268 136.771 200.557  1.00114.26           O  
ATOM      5  CB  GLN H   1     107.238 139.302 201.014  1.00170.79           C  
ATOM      6  CG  GLN H   1     107.093 139.188 199.509  1.00170.79           C  
ATOM      7  CD  GLN H   1     107.487 140.463 198.793  1.00170.79           C  
ATOM      8  OE1 GLN H   1     106.886 141.518 199.002  1.00170.79           O  
ATOM      9  NE2 GLN H   1     108.503 140.374 197.942  1.00170.79           N
1 Like

Hi wenchangyu2006.

So far, it is not possible … . I will see what I can do the next days, please wait. I will probably create a temp. ‘pdb_import.py’ file which you have to manually copy into the folder, where the add-on is located in. I will post the file here … .

Please, meanwhile, send me your PDB file. Furthermore, search for the file ‘pdb_import.py’. It is located in a sub-folder named ‘…/blender_addons/rio_mesh_atomic/’, have a look.

Read you soon …

EDIT: 1) Just that I understand correctly: ‘GLN’ is the residue, right? They are all the same here, so, there is no difference, right?
2) I think I have to attach the residue ‘name’ to the atom name. With this, Blender will not anymore recognize the C, N, O, etc. atoms … I hope that this is not a problem … . Otherwise, the entire code needs a tough re-coding … I’m quite busy atm. :wink:

@Blendphys Thanks!

The example I posted is just one of the residues, for a true protein, there are 19 more amino acid types, GLN is the residue called glutamine, there are other names (see here https://pdb101.rcsb.org/learn/guide-to-understanding-pdb-data/primary-sequences-and-the-pdb-format). One residue, as one group, can contains many atoms. Would be great if I can select using a combination of residue name, plus atom name. You can think of different hierarchy, residue is at one level, atom is one level down.

In my case, I also have not just protein, but also lipid molecules, would like to color them differently if I can select them separately. Maybe we can grab all residues from the 4th column, make them unique.

I tried to attach my PDB but it says “new user cannot attach …”, but let me attach a link here for you to check(https://files.rcsb.org/view/7AHK.pdb).

Please take your time, the tips you provided are already very insightful. Thanks.

Re wenchangyu2006.

That will not be possible in a fast solution. What I meant above is something like an addition of the atom name and the residue name. If you have for C two types of residues, Blender will then create two instancing vertex structures. May be, I get it running this evening, mom … . :wink:

Of course, that would be the goal in a long term (e.g., by using several types of collections), but this is not that easy with respect to the programming structure I have once chosen and created. It asks for relatively medium sized changes. The problem of PDB also simply is, that there is not really a standard of how a PDB file shall precisely look like.

Let’s see …

Great, thanks again for helping out, one thing on the PDB file format, there happens to be a description (https://www.wwpdb.org/documentation/file-format-content/format33/v3.3.html). This is a comprehensive description, maybe too comprehensive :slight_smile:

But at least, the portion where the actual atoms are listed, there are designated fields for e.g. atom index, atom names, residue names, residue index, xyz coordinates, occupancy and b factors. (https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html)

All this is nice and helps to load ~80% of the PDB files in the Internet! However, other PDB files differ, and you get an error from Blender when sticking to the above mentioned rules. More precisely, the position of the numbers and IDs (atom number, atom name, residue, X, Y, Z) within a line have to be written at a precise column number in the ASCII file. Some PDB files deviate from this, and this makes parsing the PDB ASCII file difficult … .

got you, yeah, sometimes two adjacent columns can merge into one just because each of the fields are filled up. Maybe PDB ASCII file should be parsed based on fields, not on column number. Take the one I pasted before for example, the last 2nd and 3rd columns are merged together and becomes one column, if we only grab field 55-60 then that is occupancy, field 61-66 would be the b factor,

ATOM      1  N   GLN H   1     106.670 138.421 203.253  1.00114.51           N  
ATOM      2  CA  GLN H   1     106.686 138.107 201.795  1.00114.44           C  
ATOM      3  C   GLN H   1     107.546 136.866 201.553  1.00114.40           C  
ATOM      4  O   GLN H   1     108.268 136.771 200.557  1.00114.26           O  
ATOM      5  CB  GLN H   1     107.238 139.302 201.014  1.00170.79           C  
ATOM      6  CG  GLN H   1     107.093 139.188 199.509  1.00170.79           C  
ATOM      7  CD  GLN H   1     107.487 140.463 198.793  1.00170.79           C  
ATOM      8  OE1 GLN H   1     106.886 141.518 199.002  1.00170.79           O  
ATOM      9  NE2 GLN H   1     108.503 140.374 197.942  1.00170.79           N

So, here it is, a fast solution:

pdb_import.py (66.6 KB)

You have to manually replace the standard ‘pdb_import.py’ file in ‘scripts/addons/Io_mesh_atomic/’ with this new file.

Attention: this is an evil hack! This file is NOT in the standard repository of Blender and only is a fast solution! It is highly probable that other PDB files will not work with this solution. I guarantee for nothing … . :wink:

Attention: due to the changes made in the code, the add-on will not use anymore the radii and material values, which are normally used for each element. In other words, all atoms appear with the same radius and material! You now have to chose the values for the radii and material manually yourself. On the contrary, for each element + residue, a separate container is formed. This helps to distinguish between different types of residues of one element.

I hope that helps … . If it is desired to include a more precise solution, then, please, report it on the Blender developer page. Info: I’m quite busy atm and can work on a serious solution starting from September on … .

Cheers.

EDIT: A ‘like’ would be nice! :wink:

EDIT2: Let me know if it works … .

1 Like

of course! Thank you!

Very good! However, here is a version, where the size and materials of the elements are conserved, have a look.

Cheers.

pdb_import.py (66.6 KB)

1 Like

Hey @Blendphys,

I’m starting slowly to work on my protein, sorry being late to get any update. I got stuck at the PDB loading step, somehow I got such a strange scene after loading my PDB, each atom is showing as cubic instead of spherical shape. I also tried another file from Protein Data Bank but still showing the same.

Hello,

I’ve been running into some issues with getting double bonds to show up when importing a .PDB file. I’ve tried quite a few different converters, manually changing files, etc, and I can’t seem to figure out what I’m doing wrong. The syntax in the plugin seems pretty simple when it comes to parsing this so I’m not sure what I’m misunderstanding.

COMPND      UNNAMED
AUTHOR      GENERATED BY OPEN BABEL 2.3.90
HETATM   1  C   UNL    1   -10.284  -3.608  0.000  1.00  0.00         C
HETATM   2  O   UNL    1   -10.229  -4.826  0.000  1.00  0.00         O
CONECT   1   2   2
CONECT   2   1   1
MASTER      0   0   0   0   0   0   0   0   2   0   2   0
END

Here’s an example file that should have a single double bond. I run into this issue with “Simple” and “Dupliverts” import setting. I haven’t been able to get one double bond to appear.

Is there a converter that would be recommended for ensuring the format is correct? I’m trying to go from a .mol to a .pdb with bonds preserved.

Hi Ezra_Hill.

Take and study this example here, it is a CO2 molecule and it works:

COMPND UNNAMED
AUTHOR GENERATED BY OPEN BABEL 2.2.3
HETATM 1 C LIG 1 -3.327 0.976 0.009 1.00 0.00 C
HETATM 2 O LIG 1 -2.208 0.553 0.042 1.00 0.00 O
HETATM 3 O LIG 1 -4.445 1.400 -0.025 1.00 0.00 O
CONECT 1 2 2 3 3
CONECT 2 1 1
CONECT 3 1 1
MASTER 0 0 0 0 0 0 0 0 3 0 3 0
END

I hope, it helps … . Cheers.

PS: I’m currently almost unavailable … this is the reason why it takes so long with my answers, sry. :wink:

1 Like

Hi wenchangyu2006!

Strange, it seems that the representative ball of a instancing vertex structure is not represented at all the vertices. This is the reason why you see all these dots (vertices) in the viewer.

Which patch file are you using? Can yo give us also the PDB file, plz?

Cheers.

PS: I’m currently almost unavailable … this is the reason why it takes so long with my answers, sry. :wink:

@Blendphys thanks for getting back, no worries if you don’t have time.

Regarding the patch file, I use your latest one where the size and materials of the elements are conserved.

My PDB is here, https://www.dropbox.com/s/9ojwh5dnyhd5vvu/noh.pdb?dl=0

Thanks!

wenchangyu2006,

very strange, here your file works!

Which Blender version are you using? I use a self-compiled Ubuntu 20.04 Blender 3.2.0 Alpha version … .

oh that is strange, I have it on my Mac, version 3.2.1 (2022-07-06), maybe it’s the issue of the Mac version?