-
-
Save zeffii/2ddf35134d9f1026ead2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kdArrange | |
import bpy | |
from collections import defaultdict | |
''' | |
[x] step 01: first store atoms as {element_name: [co,..], } | |
[ ] step 02: generate singular ordered mesh by adding vertices | |
in clumps of element types. (H,H,H,H,H,H,O,O,O,O,O,O..) | |
[ ] step 03: track start and end index for each element into mapper_obj | |
[ ] step 04: get surface mesh. | |
[ ] step 05: for every vertex on surface mesh find closest | |
vertex in proxy_ob, and MLP value | |
''' | |
# step 01 | |
# attrs = [a for a in dir(o) if a.startswith('bb2')] | |
attrs = [ | |
'bb2_objectType', | |
'bb2_outputOptions', | |
'bb2_pdbID', | |
'bb2_pdbPath', | |
'bb2_subID' | |
] | |
proxy_obj = defaultdict(list) | |
nstr = '_4GE.001' | |
objs = bpy.data.objects[nstr].children | |
for o in objs: | |
# for a in attrs: | |
# print(a, ':', getattr(o, a)) | |
# coincides and is a relatively fast lookup | |
element_name = o.active_material.name | |
co = o.location[:] | |
proxy_obj[element_name].append(co) | |
# step 03 | |
mapper_obj = {} | |
verts = [] | |
for key in sorted(proxy_obj.keys()): | |
start = len(verts) | |
verts.extend(proxy_obj[key]) | |
end = len(verts)-1 | |
mapper_obj[key] = (start, end) | |
# print(mapper_obj) | |
# {'C': (0, 97), 'N': (98, 124), 'O': (125, 153)} | |
# step 02 | |
mesh = bpy.data.meshes.new("mesh_name") | |
mesh.from_pydata(verts, edges=[], faces=[]) | |
mesh.update() | |
obj = bpy.data.objects.new("obj_name", mesh) | |
scene = bpy.context.scene | |
scene.objects.link(obj) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please forgve my insistence: the element type (C, O, N, H, P...) is not the relevant property.
The properties of each atom depend on its connections. Luckily, there are a relatively small number of possible combinations (at least in first approximation, in biological setting), and these can be attributed to each atom on the basis of the aminoacid to which they belong.
Take for example the case of Nitrogen (N):
The way to identify each atom is by ithe aminoacid name (ARG, LYS, ALA, GLY ecc in the file pdb), and the atom name (N, NE, NH1 ...)
If you need better explanation, just let me know, I'll try to be clearer: feel free to ask!