[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2606] contrib/py/scripts/addons/ io_import_pdb_atomic_blender.py: The Phyton script Atomic Blender can be used to load PDB ( Protein Data Base) files into Blender.

Clemens Barth barth at root-1.de
Sun Nov 13 16:32:39 CET 2011


Revision: 2606
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2606
Author:   blendphys
Date:     2011-11-13 15:32:38 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
The Phyton script Atomic Blender can be used to load PDB (Protein Data Base) files into Blender. It reads the coordinates of all atoms in the PDB file (<file name.pdb>) and represents the atoms as balls in the Blender scene. Also the sticks, which connect atoms, are shown if this option is chosen and if the sticks are listed in the PDB file.

Only atoms as balls and corresponding sticks are shown in the Blender scene but no complex structures.

Atomic Blender opens a panel in Blender, which can be found in the tab physics (see image on the right). Many options can be chosen, which help to well-represent the atoms and sticks. For instance, after loading a PDB file the radius of one type of atom can be explicitly changed after. 
Atomic Blender is interesting for scientists, who want to visualize their molecules, crystal structures, surfaces, etc. with Blender. The PDB format is widely distributed and can be produced by many programs including programs like CrystalMaker or Vesta. Thanks to Blender, fancy graphics of molecules, crystal structures, surfaces and complex atomic arrangements can be obtained. Such graphics meet the standards of top-level journals, which have an high impact factor.
More details can be found here: http://development.root-1.de/Atomic_Blender.php

Added Paths:
-----------
    contrib/py/scripts/addons/io_import_pdb_atomic_blender.py

Added: contrib/py/scripts/addons/io_import_pdb_atomic_blender.py
===================================================================
--- contrib/py/scripts/addons/io_import_pdb_atomic_blender.py	                        (rev 0)
+++ contrib/py/scripts/addons/io_import_pdb_atomic_blender.py	2011-11-13 15:32:38 UTC (rev 2606)
@@ -0,0 +1,1332 @@
+import bpy
+import io
+import sys
+import os
+from math import *
+import mathutils, math
+from mathutils import Vector
+#
+PDBFILE   = "/media/Daten/Data/X -- 2011/Programming/Python/Blender/Load_PDB/PDB files/cyano-[5]-Helicene.pdb"
+DATAFILE  = "/media/Daten/Data/X -- 2011/Programming/Python/Blender/Load_PDB/Atomic_Blender_CB.dat"
+#
+#
+#
+#  ____                   _   _                             _       _   
+# |  _ \ _   _ _ __      | |_| |__   ___      ___  ___ _ __(_)_ __ | |_ 
+# | |_) | | | | '_ \     | __| '_ \ / _ \    / __|/ __| '__| | '_ \| __|
+# |  _ <| |_| | | | |    | |_| | | |  __/    \__ \ (__| |  | | |_) | |_ 
+# |_| \_\\__,_|_| |_|     \__|_| |_|\___|    |___/\___|_|  |_| .__/ \__|
+#                                                            |_|        
+#		
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#		
+# 
+Atomic_Blender_string     = "Atomic Blender 1.1 -- Dr. Clemens Barth -- November 2011\n======================================================="
+Atomic_Blender_panel_name = "Atomic Blender 1.1"
+
+
+bl_info = {
+  "name": "Atomic Blender",
+  "description": "Loading and manipulating atoms from PDB files",
+  "author": "Dr. Clemens Barth (barth at root-1.de)",
+  "version": (1,1),
+  "blender": (2,6),
+  "api": 31236,
+  "location": "Properties > Physics => Panel Atomic Blender",
+  "warning": "",
+  "wiki_url": "http://development.root-1.de/Atomic_Blender.php",
+  "tracker_url": "",
+  "category": "Physicss"
+}
+
+
+class OBJECT_PDB_Panel(bpy.types.Panel):
+    bl_label       = Atomic_Blender_panel_name
+    bl_space_type  = "PROPERTIES"
+    bl_region_type = "WINDOW"
+    bl_context     = "physics"
+
+    def draw(self, context):
+        layout = self.layout
+        scn    = bpy.context.scene
+
+
+        layout.operator( "fp.button_delete_all" )
+        row = layout.row()
+        layout.operator( "fp.button_delete_atoms" )
+        layout.operator( "fp.button_delete_camlamp" )
+        row = layout.row()
+        layout.prop(scn, "pdb_filepath")
+        layout.prop(scn, "data_filepath")
+        row = layout.row()
+
+        row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+
+        row = layout.row()
+        row.prop(scn, "entry_group_atoms_yesno")
+        row = layout.row()
+        row.prop(scn, "entry_group_atoms_dn")
+        row = layout.row()
+
+        row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+        row = layout.row()
+        
+        row.prop(scn, "entry_mesh_yesno")
+        row = layout.row()
+        row.prop(scn, "entry_sectors_azimuth")
+        row.prop(scn, "entry_sectors_zenith")
+        
+        row = layout.row()
+        row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+        row = layout.row()
+
+        row.label(text="Scaling factors")
+        row = layout.row()
+        row.prop(scn, "entry_ball_radius")
+        row.prop(scn, "entry_distances")
+
+        row = layout.row()
+        row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+        row = layout.row()
+        
+        row.prop(scn, "entry_sticks_yesno")
+        row = layout.row()
+        row.prop(scn, "entry_sticks_sectors")
+        row.prop(scn, "entry_sticks_radius")
+
+        row = layout.row()
+        row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+        row = layout.row()
+        
+        row.prop(scn, "entry_center_yesno")
+        row = layout.row()    
+        row = layout.row()
+        row.label(text="Now, use an offset for all objects")
+        row = layout.row()
+        row.prop(scn, "entry_scene_x")
+        row.prop(scn, "entry_scene_y")
+        row.prop(scn, "entry_scene_z")
+       
+        row = layout.row()
+        row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+        row = layout.row()
+        
+        row.prop(scn, "entry_cam_yesno")
+        row.prop(scn, "entry_lamp_yesno")
+        row = layout.row()  
+        layout.operator( "fp.button_start" )
+        row = layout.row()  
+        row.label(text="No. of atoms: ")
+        row.prop(scn, "entry_start_number_atoms")
+        
+        if scn.entry_group_atoms_yesno == False:        
+           row = layout.row()       
+           row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+           row = layout.row()
+           row.prop(scn, "entry_distance")
+           layout.operator( "fp.button_distance" )        
+           row = layout.row()       
+           row.label("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
+           row = layout.row()
+           row.label(text="Modification of the radii of one type of atom")
+           row = layout.row()
+           row.prop(scn, "entry_mod_atomname")
+           row = layout.row()
+           row.prop(scn, "entry_mod_pm_yesno")
+           row.prop(scn, "entry_mod_pm_radius")
+           row = layout.row()
+           row.prop(scn, "entry_mod_rel_yesno")
+           row.prop(scn, "entry_mod_rel_radius")
+           layout.operator( "fp.button_modify" )
+           row = layout.row()
+           row.label(text="Modification of all atom radii")
+           row = layout.row()
+           row.prop(scn, "entry_mod_all_radii")
+           layout.operator( "fp.button_modify_2" )
+
+
+
+
+class CLASS_Distance_Button(bpy.types.Operator):
+    bl_idname = "fp.button_distance"
+    bl_label = "Measure ..."
+
+    def execute(self, context):
+        dist   = Measure_distance_in_scene()
+
+        if dist != "-1.0":
+           # The string length gets cut. Cut 3 digits after the '.' the string. 
+           pos    = str.find(dist, ".")
+           dist   = dist[:pos+4] 
+
+        # Actualization of the distance in the string input.
+        scn                = bpy.context.scene
+        scn.entry_distance = dist
+        return {'FINISHED'}
+
+class CLASS_Deleteall_Button(bpy.types.Operator):
+    bl_idname = "fp.button_delete_all"
+    bl_label = "Delete all in the scene ..."
+
+    def execute(self, context):
+        Delete_all_in_scene()
+        return {'FINISHED'}
+        
+class CLASS_Delete_atoms_Button(bpy.types.Operator):
+    bl_idname = "fp.button_delete_atoms"
+    bl_label = "Delete all atoms ..."
+
+    def execute(self, context):
+        Delete_atoms_in_scene()
+        return {'FINISHED'}      
+        
+class CLASS_Delete_camlamp_Button(bpy.types.Operator):
+    bl_idname = "fp.button_delete_camlamp"
+    bl_label = "Delete cameras and lamps ..."
+
+    def execute(self, context):
+        Delete_camlamp_in_scene()
+        return {'FINISHED'}   
+  
+class CLASS_Modify_Button(bpy.types.Operator):
+    bl_idname = "fp.button_modify"
+    bl_label = "Modify ..."
+
+    def execute(self, context):
+        scn = bpy.context.scene
+        atomname   = scn.entry_mod_atomname
+        radius_pm  = scn.entry_mod_pm_radius
+        radius_rel = scn.entry_mod_rel_radius
+        check_pm   = scn.entry_mod_pm_yesno
+        check_rel  = scn.entry_mod_rel_yesno
+        Modify_atom_radii_scene(atomname, radius_pm, check_pm, radius_rel, check_rel)
+        return {'FINISHED'}
+
+class CLASS_Modify_Button_2(bpy.types.Operator):
+    bl_idname = "fp.button_modify_2"
+    bl_label = "Modify ..."
+
+    def execute(self, context):
+        scn = bpy.context.scene
+        scale   = scn.entry_mod_all_radii
+        Modify_atom_radii_scene_2(scale)
+        return {'FINISHED'}
+
+class CLASS_Start_Button(bpy.types.Operator):
+    bl_idname = "fp.button_start"
+    bl_label = "DRAW THE OBJECT ..."
+    
+    def execute(self, context):
+        scn = bpy.context.scene
+
+        azimuth   = scn.entry_sectors_azimuth
+        zenith    = scn.entry_sectors_zenith 
+        bradius   = scn.entry_ball_radius
+        bdistance = scn.entry_distances
+        center    = scn.entry_center_yesno 
+        x         = scn.entry_scene_x
+        y         = scn.entry_scene_y
+        z         = scn.entry_scene_z
+        yn        = scn.entry_sticks_yesno 
+        ssector   = scn.entry_sticks_sectors
+        sradius   = scn.entry_sticks_radius
+        pdb       = scn.pdb_filepath
+        data      = scn.data_filepath
+        cam       = scn.entry_cam_yesno 
+        lamp      = scn.entry_lamp_yesno
+        mesh      = scn.entry_mesh_yesno 
+        group     = scn.entry_group_atoms_yesno
+        dn        = scn.entry_group_atoms_dn
+        
+        # This here is just to study this strange 'relative path' thing in the file dialog.
+        # Sometimes it doesn't work.
+        #print(scn.pdb_filepath)
+        #return {'FINISHED'}
+        
+        atom_number                  = Draw_scene(group,dn,mesh,azimuth,zenith,bradius,bdistance,x,y,z,yn,ssector,sradius,center,cam,lamp,pdb,data)
+        scn.entry_start_number_atoms = atom_number
+
+        return {'FINISHED'}
+
+
+def register():

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list