mailr9166 - /branches/frame_order/generic_fns/structure/geometric.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on June 30, 2009 - 11:43:
Author: bugman
Date: Tue Jun 30 11:43:31 2009
New Revision: 9166

URL: http://svn.gna.org/viewcvs/relax?rev=9166&view=rev
Log:
Bug fix for the cone PDB generation.

If there were more than 1000 protons, the PDB file was corrupted by the 
proton name being too long.


Modified:
    branches/frame_order/generic_fns/structure/geometric.py

Modified: branches/frame_order/generic_fns/structure/geometric.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order/generic_fns/structure/geometric.py?rev=9166&r1=9165&r2=9166&view=diff
==============================================================================
--- branches/frame_order/generic_fns/structure/geometric.py (original)
+++ branches/frame_order/generic_fns/structure/geometric.py Tue Jun 30 
11:43:31 2009
@@ -134,7 +134,7 @@
         pos = apex+vector*length
 
         # Add the vector as a H atom of the cone residue.
-        mol.atom_add(pdb_record='HETATM', atom_num=atom_num, 
atom_name='H'+`atom_num`, res_name=res_name, res_num=res_num, pos=pos, 
segment_id=None, element='H')
+        mol.atom_add(pdb_record='HETATM', atom_num=atom_num, 
atom_name=get_proton_name(atom_num), res_name=res_name, res_num=res_num, 
pos=pos, segment_id=None, element='H')
 
         # Connect across the radial array (to generate the circular cone 
edge).
         if i != 0:
@@ -531,7 +531,7 @@
             pos = centre + vector
 
             # Add the vector as a H atom of the TNS residue.
-            mol.atom_add(pdb_record='HETATM', atom_num=atom_num, 
atom_name='H'+`atom_num`, res_name=res_name, chain_id=chain_id, 
res_num=res_num, pos=pos, segment_id=None, element='H')
+            mol.atom_add(pdb_record='HETATM', atom_num=atom_num, 
atom_name=get_proton_name(atom_num), res_name=res_name, chain_id=chain_id, 
res_num=res_num, pos=pos, segment_id=None, element='H')
 
             # Connect to the previous atom (to generate the longitudinal 
lines).
             if j > j_min:
@@ -635,6 +635,26 @@
     return res_num
 
 
+def get_proton_name(atom_num):
+    """Return a valid PDB atom name of <4 characters.
+
+    @param atom_num:    The number of the atom.
+    @type atom_num:     int
+    @return:            The atom name to use in the PDB.
+    @rtype:             str
+    """
+
+    # Init the proton first letters and the atom number folding limits.
+    names = ['H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q']
+    lims = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
+
+    # Loop over the proton names.
+    for i in range(len(names)):
+        # In the bounds.
+        if atom_num >= lims[i] and atom_num < lims[i+1]:
+            return names[i] + `atom_num - lims[i]`
+
+
 def stitch_cone_to_edge(mol=None, cone_start=None, edge_start=None, 
max_angle=None, inc=None):
     """Function for stitching the cone dome to its edge, in the PDB 
representations.
 




Related Messages


Powered by MHonArc, Updated Tue Jun 30 12:00:02 2009