Created
February 24, 2015 20:38
-
-
Save anonymous/b87614812f04d5c43d41 to your computer and use it in GitHub Desktop.
test
This file contains hidden or 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 | |
from BioBlender.table_values import values_fi | |
''' | |
[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: preprocess obj.fi_value = BBinfo.get(') | |
[ ] step 05: get surface mesh. | |
[ ] step 06: 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', | |
'BBInfo' | |
] | |
proxy_obj = defaultdict(list) | |
nstr = '_4GE.001' | |
objs = bpy.data.objects[nstr].children | |
count = 0 | |
for o in objs: | |
_name = o.BBInfo[12:16].strip() | |
_amino = o.BBInfo[17:20].strip() | |
o.['fi'] = values_fi[_amino][_name] | |
# coincides and is a relatively fast lookup | |
element_name = o.active_material.name | |
co = o.location[:] | |
proxy_obj[element_name].append(co) | |
count += 1 | |
# 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