[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2778] trunk/py/scripts/addons/ io_mesh_pdb:

Clemens Barth barth at root-1.de
Wed Dec 14 17:31:06 CET 2011


Revision: 2778
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2778
Author:   blendphys
Date:     2011-12-14 16:30:51 +0000 (Wed, 14 Dec 2011)
Log Message:
-----------


Dear all.

Some changes in the code, which reads PDB files, have
been done.

If you find bugs, please let me know. Thx. 

Cheers,

Blendphys.

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-12-13 18:12:13 UTC (rev 2777)
+++ trunk/py/scripts/addons/io_mesh_pdb/__init__.py	2011-12-14 16:30:51 UTC (rev 2778)
@@ -464,7 +464,7 @@
 # This is the class for the file dialog.
 class ImportPDB(Operator, ImportHelper):
     bl_idname = "import_mesh.pdb"
-    bl_label  = "Import Protein Data Bank (*.pdb)"
+    bl_label  = "Import Protein Data Bank(*.pdb)"
 
     filename_ext = ".pdb"
     filter_glob  = StringProperty(default="*.pdb", options={'HIDDEN'},)

Modified: trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py	2011-12-13 18:12:13 UTC (rev 2777)
+++ trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py	2011-12-14 16:30:51 UTC (rev 2778)
@@ -557,17 +557,39 @@
         elif "ATOM" in line or "HETATM" in line:
 
             # What follows is due to deviations which appear from PDB to
-            # PDB file. It is very special. PLEASE, DO NOT CHANGE! From here ...
-            short_name = line[13:14]
-            if short_name.isupper() == True:
+            # PDB file. It is very special!
+            # 
+            # PLEASE, DO NOT CHANGE! ............................... from here
+            if line[12:13] == " " or line[12:13].isdigit() == True:
+                short_name = line[13:14]
                 if line[14:15].islower() == True:
-                    short_name = short_name + line[14:15]
+                    short_name = short_name + line[14:15]            
+            elif line[12:13].isupper() == True:
+                short_name = line[12:13]
+                if line[13:14].isalpha() == True:
+                    short_name = short_name + line[13:14]
             else:
-                short_name = line[12:13]
-                if short_name.isupper() == True:
-                    if line[13:14].islower() == True:
-                        short_name = short_name + line[13:14]
-            # ... to here.
+                print("Atomic Blender: Strange error in PDB file.\n" 
+                      "Look for element names at positions 13-16 and 78-79.\n")
+                return -1
+                
+            if len(line) >= 78:
+            
+                if line[76:77] == " ":
+                    short_name2 = line[76:77]
+                else:
+                    short_name2 = line[76:78]
+                
+                if short_name2.isalpha() == True:
+                    FOUND = False
+                    for element in ATOM_PDB_ELEMENTS:
+                        if str.upper(short_name2) == str.upper(element.short_name):
+                            FOUND = True
+                            break
+                    if FOUND == False:
+                        short_name = short_name2
+            # ....................................................... to here.
+            
 
             # Go through all elements and find the element of the current atom.
             FLAG_FOUND = False



More information about the Bf-extensions-cvs mailing list