[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2595] trunk/py/scripts/addons/ io_mesh_pdb: api and pep8 edits

Campbell Barton ideasman42 at gmail.com
Tue Nov 8 06:41:32 CET 2011


Revision: 2595
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2595
Author:   campbellbarton
Date:     2011-11-08 05:41:31 +0000 (Tue, 08 Nov 2011)
Log Message:
-----------
api and pep8 edits

Modified Paths:
--------------
    trunk/py/scripts/addons/io_mesh_pdb/__init__.py
    trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py

Modified: trunk/py/scripts/addons/io_mesh_pdb/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/__init__.py	2011-11-08 04:45:37 UTC (rev 2594)
+++ trunk/py/scripts/addons/io_mesh_pdb/__init__.py	2011-11-08 05:41:31 UTC (rev 2595)
@@ -16,6 +16,8 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
+# <pep8-80 compliant>
+
 bl_info = {
     "name": "Import/Export: PDB format",
     "author": "Mariusz Maximus & Jong89",
@@ -48,11 +50,12 @@
 
 from bpy_extras.io_utils import ImportHelper
 
+
 class ImportPDB(bpy.types.Operator, ImportHelper):
     """Import from PDB file format (.pdb)"""
     bl_idname = 'import_scene.pdb'
     bl_label = 'Import PDB'
-    bl_options= {'REGISTER', 'UNDO'}
+    bl_options = {'REGISTER', 'UNDO'}
 
     filename_ext = ".pdb"
     filter_glob = StringProperty(default="*.pdb", options={'HIDDEN'})
@@ -60,7 +63,7 @@
     filepath = StringProperty(
             name="File Path",
             description="Filepath used for importing the PDB file",
-            maxlen= 1024,
+            maxlen=1024,
             )
     multi_models = BoolProperty(
             name="Import all models",
@@ -70,14 +73,15 @@
     multimers = BoolProperty(
             name="Import Biomolecules",
             description="Import all file-listed biomolecules and multimers, "
-                        "disable to import default biomolecule with all chains",
+                        "disable to import default biomolecule with "
+                        "all chains",
             default=False,
             )
     retain_alts = BoolProperty(
             name="Retain Alternative Atoms",
             description="Select to retain alternative atoms. "
                         "Some PDB files label coordinates of entries "
-                        "in multiple models as alternates" ,
+                        "in multiple models as alternates",
             default=False,
             )
     atom_subdivisions = IntProperty(
@@ -89,25 +93,20 @@
     atom_size = FloatProperty(
             name="Atom Size",
             description="Multiplier for the van der Waals radius of the atoms",
-            min=0, max=5,
-            default=1,
+            min=0.0, max=5.0,
+            default=1.0,
             )
     scene_scale = FloatProperty(
             name="Scene Scale Factor",
             description="Number of Blender units equivalent to 1 angstrom",
-            min=0, max=10,
-            default=1,
+            min=0.0, max=10.0,
+            default=1.0,
             )
 
     def execute(self, context):
         from . import import_pdb
-        import_pdb.load_pdb(self.filepath, context,
-                            self.atom_size,
-                            self.scene_scale,
-                            self.atom_subdivisions,
-                            self.retain_alts,
-                            self.multi_models,
-                            self.multimers)
+        keywords = self.as_keywords(ignore=("filter_glob", ))
+        import_pdb.load_pdb(context, **keywords)
         return {'FINISHED'}
 
     def invoke(self, context, event):
@@ -115,13 +114,16 @@
         wm.fileselect_add(self)
         return {'RUNNING_MODAL'}
 
+
 def menu_func(self, context):
     self.layout.operator(ImportPDB.bl_idname, text='Protein Databank (.pdb)')
 
+
 def register():
     bpy.utils.register_module(__name__)
     bpy.types.INFO_MT_file_import.append(menu_func)
 
+
 def unregister():
     bpy.utils.unregister_module(__name__)
     bpy.types.INFO_MT_file_import.remove(menu_func)

Modified: trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py	2011-11-08 04:45:37 UTC (rev 2594)
+++ trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py	2011-11-08 05:41:31 UTC (rev 2595)
@@ -16,20 +16,27 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
+# <pep8 compliant>
+
+# TODO, currently imported names are assumed to make valid blender names
+#       this is _not_ assured, so we should use a reliable dict mapping.
+
 import bpy
 
+
 class Element:
-    '''Element class with properties ([R, G, B], cov_radius, vdw_radius, name)'''
+    """Element class with properties ([R, G, B], cov_radius, vdw_radius, name)"""
     def __init__(self, color, cov_radius, vdw_radius, name):
         self.color = color
         self.cov_radius = cov_radius
         self.vdw_radius = vdw_radius
         self.name = name
 
+
 class Atom:
-    '''Atom class with properties (serial, name, altloc, resname,chainid,
-        resseq, icode, x, y, z, occupancy, tempfactor, element, charge)'''
-    
+    """Atom class with properties (serial, name, altloc, resname,chainid,
+        resseq, icode, x, y, z, occupancy, tempfactor, element, charge)"""
+
     def __init__(self, serial, name, altloc, resname, chainid, resseq, icode,
                  x, y, z, occupancy, tempfactor, element, charge):
         self.serial = serial
@@ -47,8 +54,9 @@
         self.element = element
         self.charge = charge
 
-#collection of biomolecules based on model
-#all chains in model stored here
+
+# collection of biomolecules based on model
+# all chains in model stored here
 class Model:
     '''Model class'''
     def __init__(self, model_id):
@@ -56,14 +64,15 @@
         self.atoms = {}
         self.atom_count = 0
         self.vert_list = []
-        #Dictionary of {vert index: [list of vertex groups it belongs to]}
-        #Now element only
+        # Dictionary of {vert index: [list of vertex groups it belongs to]}
+        # Now element only
         self.vert_group_index = {}
-        #Dictionary of {vertex group: number of group members}
+        # Dictionary of {vertex group: number of group members}
         self.vert_group_counts = {}
         self.chains = {}
 
-#new object level class
+
+# new object level class
 class Biomolecule:
     '''Biomolecule'''
     def __init__(self, serial):
@@ -74,137 +83,148 @@
         self.vert_group_counts = {}
         self.chain_transforms = {}
 
-#Atom collection
+
+# Atom collection
 class Chain:
     '''Chain'''
     def __init__(self, chain_id):
         self.chain_id = chain_id
         self.atoms = {}
 
-#Atomic data from http://www.ccdc.cam.ac.uk/products/csd/radii/
-#Color palatte adapted from Jmol
-#"Element symbol":[[Red, Green, Blue], Covalent radius, van der Waals radius,
-#                  Element name]
-#Atomic radii are in angstroms (100 pm)
-#Unknown covalent radii are assigned 1.5 A, unknown van der Waals radiii are
-#assigned 2 A,
+# Atomic data from http://www.ccdc.cam.ac.uk/products/csd/radii/
+# Color palatte adapted from Jmol
+# "Element symbol":[[Red, Green, Blue], Covalent radius, van der Waals radius,
+#                   Element name]
+# Atomic radii are in angstroms (100 pm)
+# Unknown covalent radii are assigned 1.5 A, unknown van der Waals radiii are
+# assigned 2 A,
 
 atom_data = {
-'H' :	Element([1.00000, 1.00000, 1.00000],	0.23,	1.09,	'Hydrogen'  ),
-'HE':	Element([0.85098, 1.00000, 1.00000],	1.5 ,	1.4 ,	'Helium'    ),
-'LI':	Element([0.80000, 0.50196, 1.00000],	1.28,	1.82,	'Lithium'   ),
-'BE':	Element([0.76078, 1.00000, 0.00000],	0.96,	2   ,	'Beryllium' ),
-'B' :	Element([1.00000, 0.70980, 0.70980],	0.83,	2   ,	'Boron'     ),
-'C' :	Element([0.56471, 0.56471, 0.56471],	0.68,	1.7 ,	'Carbon'    ),
-'N' :	Element([0.18824, 0.31373, 0.97255],	0.68,	1.55,	'Nitrogen'  ),
-'O' :   Element([1.00000, 0.05098, 0.05098],	0.68,	1.52,	'Oxygen'    ),
-'F' :	Element([0.56471, 0.87843, 0.31373],	0.64,	1.47,	'Fluorine'  ),
-'NE':	Element([0.70196, 0.89020, 0.96078],	1.5 ,	1.54,	'Neon'      ),
-'NA':	Element([0.67059, 0.36078, 0.94902],	1.66,	2.27,	'Sodium'    ),
-'MG':	Element([0.54118, 1.00000, 0.00000],	1.41,	1.73,	'Magnesium' ),
-'AL':	Element([0.74902, 0.65098, 0.65098],	1.21,	2   ,	'Aluminum'  ),
-'SI':	Element([0.94118, 0.78431, 0.62745],	1.2 ,	2.1 ,	'Silicon'   ),
-'P' :	Element([1.00000, 0.50196, 0.00000],	1.05,	1.8 ,	'Phosphorus'),
-'S' :	Element([1.00000, 1.00000, 0.18824],	1.02,	1.8 ,	'Sulfur'    ),
-'CL':	Element([0.12157, 0.94118, 0.12157],	0.99,	1.75,	'Chlorine'  ),
-'AR':	Element([0.50196, 0.81961, 0.89020],	1.51,	1.88,	'Argon'     ),
-'K' :	Element([0.56078, 0.25098, 0.83137],	2.03,	2.75,	'Potassium' ),
-'CA':	Element([0.23922, 1.00000, 0.00000],	1.76,	2   ,	'Calcium'   ),
-'SC':	Element([0.90196, 0.90196, 0.90196],	1.7 ,	2   ,	'Scandium'  ),
-'TI':	Element([0.74902, 0.76078, 0.78039],	1.6 ,	2   ,	'Titanium'  ),
-'V' :	Element([0.65098, 0.65098, 0.67059],	1.53,	2   ,	'Vanadium'  ),
-'CR':	Element([0.54118, 0.60000, 0.78039],	1.39,	2   ,	'Chromium'  ),
-'MN':	Element([0.61176, 0.47843, 0.78039],	1.61,	2   ,	'Manganese' ),
-'FE':	Element([0.87843, 0.40000, 0.20000],	1.52,	2   ,	'Iron'      ),
-'CO':	Element([0.94118, 0.56471, 0.62745],	1.26,	2   ,	'Cobalt'    ),
-'NI':	Element([0.31373, 0.81569, 0.31373],	1.24,	1.63,	'Nickel'    ),
-'CU':	Element([0.78431, 0.50196, 0.20000],	1.32,	1.4 ,	'Copper'    ),
-'ZN':	Element([0.49020, 0.50196, 0.69020],	1.22,	1.39,	'Zinc'      ),
-'GA':	Element([0.76078, 0.56078, 0.56078],	1.22,	1.87,	'Gallium'   ),
-'GE':	Element([0.40000, 0.56078, 0.56078],	1.17,	2   ,	'Germanium' ),
-'AS':	Element([0.74118, 0.50196, 0.89020],	1.21,	1.85,	'Arsenic'   ),
-'SE':	Element([1.00000, 0.63137, 0.00000],	1.22,	1.9 ,	'Selenium'  ),
-'BR':	Element([0.65098, 0.16078, 0.16078],	1.21,	1.85,	'Bromine'   ),
-'KR':	Element([0.36078, 0.72157, 0.81961],	1.5 ,	2.02,	'Krypton'   ),
-'RB':	Element([0.43922, 0.18039, 0.69020],	2.2 ,	2   ,	'Rubidium'  ),
-'SR':	Element([0.00000, 1.00000, 0.00000],	1.95,	2   ,	'Strontium' ),
-'Y' :	Element([0.58039, 1.00000, 1.00000],	1.9 ,	2   ,	'Yttrium'   ),
-'ZR':	Element([0.58039, 0.87843, 0.87843],	1.75,	2   ,	'Zirconium' ),
-'NB':	Element([0.45098, 0.76078, 0.78824],	1.64,	2   ,	'Niobium'   ),
-'MO':	Element([0.32941, 0.70980, 0.70980],	1.54,	2   ,	'Molybdenum'),
-'TC':	Element([0.23137, 0.61961, 0.61961],	1.47,	2   ,	'Technetium'),
-'RU':	Element([0.14118, 0.56078, 0.56078],	1.46,	2   ,	'Ruthenium' ),
-'RH':	Element([0.03922, 0.49020, 0.54902],	1.45,	2   ,	'Rhodium'   ),
-'PD':	Element([0.00000, 0.41176, 0.52157],	1.39,	1.63,	'Palladium' ),
-'AG':	Element([0.75294, 0.75294, 0.75294],	1.45,	1.72,	'Silver'    ),
-'CD':	Element([1.00000, 0.85098, 0.56078],	1.44,	1.58,	'Cadmium'   ),
-'IN':	Element([0.65098, 0.45882, 0.45098],	1.42,	1.93,	'Indium'    ),

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list