mailr15009 - in /1.3: generic_fns/structure/main.py generic_fns/structure/superimpose.py prompt/structure.py


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

Header


Content

Posted by edward on November 22, 2011 - 18:27:
Author: bugman
Date: Tue Nov 22 18:27:21 2011
New Revision: 15009

URL: http://svn.gna.org/viewcvs/relax?rev=15009&view=rev
Log:
Added the centroid argument to the structure.superimpose user function.

This allows for the superimposition of structures assuming a pivoted motion.


Modified:
    1.3/generic_fns/structure/main.py
    1.3/generic_fns/structure/superimpose.py
    1.3/prompt/structure.py

Modified: 1.3/generic_fns/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/main.py?rev=15009&r1=15008&r2=15009&view=diff
==============================================================================
--- 1.3/generic_fns/structure/main.py (original)
+++ 1.3/generic_fns/structure/main.py Tue Nov 22 18:27:21 2011
@@ -545,7 +545,7 @@
     spin.xh_vect = xh_vect
 
 
-def superimpose(models=None, method='fit to mean', atom_id=None):
+def superimpose(models=None, method='fit to mean', atom_id=None, 
centroid=None):
     """Superimpose a set of structural models.
 
     @keyword models:    The list of models to superimpose.  If set to None, 
then all models will be used.
@@ -554,6 +554,8 @@
     @type method:       str
     @keyword atom_id:   The molecule, residue, and atom identifier string.  
This matches the spin ID string format.
     @type atom_id:      str or None
+    @keyword centroid:  An alternative position of the centroid to allow for 
different superpositions, for example of pivot point motions.
+    @type centroid:     list of float or numpy rank-1, 3D array
     """
 
     # Check the method.
@@ -577,9 +579,9 @@
 
     # The different algorithms.
     if method == 'fit to mean':
-        T, R, pivot = fit_to_mean(models=models, coord=coord)
+        T, R, pivot = fit_to_mean(models=models, coord=coord, 
centroid=centroid)
     elif method == 'fit to first':
-        T, R, pivot = fit_to_first(models=models, coord=coord)
+        T, R, pivot = fit_to_first(models=models, coord=coord, 
centroid=centroid)
 
 
     # Update to the new coordinates.

Modified: 1.3/generic_fns/structure/superimpose.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/superimpose.py?rev=15009&r1=15008&r2=15009&view=diff
==============================================================================
--- 1.3/generic_fns/structure/superimpose.py (original)
+++ 1.3/generic_fns/structure/superimpose.py Tue Nov 22 18:27:21 2011
@@ -76,13 +76,15 @@
     return centroid
 
 
-def fit_to_first(models=None, coord=None):
+def fit_to_first(models=None, coord=None, centroid=None):
     """Superimpose a set of structural models using the fit to first 
algorithm.
 
     @keyword models:    The list of models to superimpose.
     @type models:       list of int
     @keyword coord:     The list of coordinates of all models to 
superimpose.  The first index is the models, the second is the atomic 
positions, and the third is the xyz coordinates.
     @type coord:        list of numpy rank-2, Nx3 arrays
+    @keyword centroid:  An alternative position of the centroid to allow for 
different superpositions, for example of pivot point motions.
+    @type centroid:     list of float or numpy rank-1, 3D array
     @return:            The lists of translation vectors, rotation matrices, 
and rotation pivots.
     @rtype:             list of numpy rank-1 3D arrays, list of numpy rank-2 
3D arrays, list of numpy rank-1 3D arrays
     """
@@ -98,7 +100,7 @@
     # Loop over the ending models.
     for i in range(1, len(models)):
         # Calculate the displacements (Kabsch algorithm).
-        trans_vect, trans_dist, R, axis, angle, pivot = 
kabsch(name_from='model %s'%models[0], name_to='model %s'%models[i], 
coord_from=coord[i], coord_to=coord[0])
+        trans_vect, trans_dist, R, axis, angle, pivot = 
kabsch(name_from='model %s'%models[0], name_to='model %s'%models[i], 
coord_from=coord[i], coord_to=coord[0], centroid=centroid)
 
         # Store the transforms.
         T_list.append(trans_vect)
@@ -109,13 +111,15 @@
     return T_list, R_list, pivot_list
 
 
-def fit_to_mean(models=None, coord=None):
+def fit_to_mean(models=None, coord=None, centroid=None):
     """Superimpose a set of structural models using the fit to first 
algorithm.
 
     @keyword models:    The list of models to superimpose.
     @type models:       list of int
     @keyword coord:     The list of coordinates of all models to 
superimpose.  The first index is the models, the second is the atomic 
positions, and the third is the xyz coordinates.
     @type coord:        list of numpy rank-2, Nx3 arrays
+    @keyword centroid:  An alternative position of the centroid to allow for 
different superpositions, for example of pivot point motions.
+    @type centroid:     list of float or numpy rank-1, 3D array
     @return:            The lists of translation vectors, rotation matrices, 
and rotation pivots.
     @rtype:             list of numpy rank-1 3D arrays, list of numpy rank-2 
3D arrays, list of numpy rank-1 3D arrays
     """
@@ -150,7 +154,7 @@
         converged = True
         for i in range(len(models)):
             # Calculate the displacements (Kabsch algorithm).
-            trans_vect, trans_dist, R, axis, angle, pivot = 
kabsch(name_from='model %s'%models[0], name_to='mean', coord_from=coord[i], 
coord_to=mean, verbosity=0)
+            trans_vect, trans_dist, R, axis, angle, pivot = 
kabsch(name_from='model %s'%models[0], name_to='mean', coord_from=coord[i], 
coord_to=mean, centroid=centroid, verbosity=0)
 
             # Table print out.
             print("%-10i%25.3g%25.3g" % (i, trans_dist, (angle / 2.0 / pi * 
360.0)))
@@ -181,7 +185,7 @@
     # Perform the fit once from the original coordinates to obtain the full 
transforms.
     for i in range(len(models)):
         # Calculate the displacements (Kabsch algorithm).
-        trans_vect, trans_dist, R, axis, angle, pivot = 
kabsch(name_from='model %s'%models[i], name_to='the mean structure', 
coord_from=orig_coord[i], coord_to=mean)
+        trans_vect, trans_dist, R, axis, angle, pivot = 
kabsch(name_from='model %s'%models[i], name_to='the mean structure', 
coord_from=orig_coord[i], coord_to=mean, centroid=centroid)
 
         # Store the transforms.
         T_list.append(trans_vect)

Modified: 1.3/prompt/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/structure.py?rev=15009&r1=15008&r2=15009&view=diff
==============================================================================
--- 1.3/prompt/structure.py (original)
+++ 1.3/prompt/structure.py Tue Nov 22 18:27:21 2011
@@ -610,22 +610,24 @@
     _build_doc(rotate)
 
 
-    def superimpose(self, models=None, method='fit to mean', atom_id=None):
+    def superimpose(self, models=None, method='fit to mean', atom_id=None, 
centroid=None):
         # Function intro text.
         if self._exec_info.intro:
             text = self._exec_info.ps3 + "structure.superimpose("
             text = text + "models=" + repr(models)
             text = text + ", method=" + repr(method)
-            text = text + ", atom_id=" + repr(atom_id) + ")"
+            text = text + ", atom_id=" + repr(atom_id)
+            text = text + ", centroid=" + repr(centroid) + ")"
             print(text)
 
         # The argument checks.
         arg_check.is_int_list(models, 'model list', can_be_none=True)
         arg_check.is_str(method, 'superimposition method')
         arg_check.is_str(atom_id, 'atom identification string', 
can_be_none=True)
-
-        # Execute the functional code.
-        generic_fns.structure.main.superimpose(models=models, method=method, 
atom_id=atom_id)
+        arg_check.is_float_array(centroid, 'centroid position', 
can_be_none=True)
+
+        # Execute the functional code.
+        generic_fns.structure.main.superimpose(models=models, method=method, 
atom_id=atom_id, centroid=centroid)
 
     # The function doc info.
     superimpose._doc_title = "Superimpose a set of models of the same 
structure."
@@ -634,6 +636,7 @@
         ["models", "The list of models to superimpose."],
         ["method", "The superimposition method."],
         ["atom_id", "The atom identification string."],
+        ["centroid", "The alternative position of the centroid."]
     ]
     superimpose._doc_desc = """
         This allows a set of models of the same structure to be superimposed 
to each other.  Two superimposition methods are currently supported:
@@ -644,6 +647,8 @@
         If the list of models is not supplied, then all models will be 
superimposed.
 
         The atom ID, which uses the same notation as the spin ID strings, 
can be used to restrict the superimpose calculation to certain molecules, 
residues, or atoms.  For example to only superimpose backbone heavy atoms in 
a protein, use the atom ID of '@N,C,CA,O', assuming those are the names of 
the atoms from the structural file.
+
+        By supplying the position of the centroid, an alternative position 
than the standard rigid body centre is used as the focal point of the 
superimposition.  The allows, for example, the superimposition about a pivot 
point.
         """
     superimpose._doc_examples = """
         To superimpose all sets of models, type one of:




Related Messages


Powered by MHonArc, Updated Wed Nov 23 11:00:02 2011