mailr27066 - in /trunk: pipe_control/structure/main.py user_functions/structure.py


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

Header


Content

Posted by edward on December 11, 2014 - 08:41:
Author: bugman
Date: Thu Dec 11 08:41:07 2014
New Revision: 27066

URL: http://svn.gna.org/viewcvs/relax?rev=27066&view=rev
Log:
Implemented the molecules argument for the structure.find_pivot user function.

This allows the motional pivot optimisation between different molecules 
rather than different
models.


Modified:
    trunk/pipe_control/structure/main.py
    trunk/user_functions/structure.py

Modified: trunk/pipe_control/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/structure/main.py?rev=27066&r1=27065&r2=27066&view=diff
==============================================================================
--- trunk/pipe_control/structure/main.py        (original)
+++ trunk/pipe_control/structure/main.py        Thu Dec 11 08:41:07 2014
@@ -591,11 +591,13 @@
                 cdp.structure.displacements._calculate(model_from=i, 
model_to=j, coord_from=array(coord_from), coord_to=array(coord_to), 
centroid=centroid)
 
 
-def find_pivot(models=None, atom_id=None, init_pos=None, func_tol=1e-5, 
box_limit=200):
-    """Superimpose a set of structural models.
+def find_pivot(models=None, molecules=None, atom_id=None, init_pos=None, 
func_tol=1e-5, box_limit=200):
+    """Find the pivoted motion of a set of structural models or structures.
 
     @keyword models:    The list of models to use.  If set to None, then all 
models will be used.
     @type models:       list of int or None
+    @keyword molecules: The list of molecules to find the pivoted motion 
for.  This overrides the models.
+    @type molecules:    None or list of 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 init_pos:  The starting pivot position for the pivot point 
optimisation.
@@ -614,26 +616,60 @@
         init_pos = zeros(3, float64)
     init_pos = array(init_pos)
 
-    # Validate the models.
-    cdp.structure.validate_models()
-
-    # Create a list of all models.
-    if models == None:
-        models = []
-        for model in cdp.structure.model_loop():
-            models.append(model.num)
-
     # The selection object.
     selection = cdp.structure.selection(atom_id=atom_id)
 
-    # Assemble the atomic coordinates of all models.
-    coord = []
-    for model in models:
-        coord.append([])
-        for pos in cdp.structure.atom_loop(selection=selection, 
model_num=model, pos_flag=True):
+    # Motional pivot between models.
+    if molecules == None:
+        # Validate the models.
+        cdp.structure.validate_models()
+
+        # Create a list of all models.
+        if models == None:
+            models = []
+            for model in cdp.structure.model_loop():
+                models.append(model.num)
+
+        # Assemble the atomic coordinates of all models.
+        coord = []
+        for model in models:
+            coord.append([])
+            for pos in cdp.structure.atom_loop(selection=selection, 
model_num=model, pos_flag=True):
+                coord[-1].append(pos[0])
+            coord[-1] = array(coord[-1])
+        coord = array(coord)
+
+    # Motional pivot between molecules.
+    else:
+        # No models allowed.
+        if cdp.structure.num_models() > 1:
+            raise RelaxError("When calculating the RMSD between different 
molecules, no models are allowed to be present.")
+
+        # Assemble the atomic coordinates of all models.
+        coord = []
+        current_mol = ''
+        for mol_name, pos in cdp.structure.atom_loop(selection=selection, 
mol_name_flag=True, pos_flag=True):
+            # No molecule match, so skip.
+            if mol_name not in molecules:
+                continue
+
+            # A new molecule.
+            if mol_name != current_mol:
+                # Change the current molecule name.
+                current_mol = mol_name
+
+                # Extend the coordinates.
+                coord.append([])
+
+            # Append the coordinate.
             coord[-1].append(pos[0])
-        coord[-1] = array(coord[-1])
-    coord = array(coord)
+
+        # Numpy conversion.
+        for i in range(len(coord)):
+            coord[i] = array(coord[i])
+
+        # The models list.
+        models = list(range(len(molecules)))
 
     # Linear constraints for the pivot position (between -1000 and 1000 
Angstrom).
     A = zeros((6, 3), float64)

Modified: trunk/user_functions/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/user_functions/structure.py?rev=27066&r1=27065&r2=27066&view=diff
==============================================================================
--- trunk/user_functions/structure.py   (original)
+++ trunk/user_functions/structure.py   Thu Dec 11 08:41:07 2014
@@ -672,6 +672,13 @@
     can_be_none = True
 )
 uf.add_keyarg(
+    name = "molecules",
+    py_type = "str_list",
+    desc_short = "molecule list",
+    desc = "The optional molecule list to perform the optimisation on rather 
than the models.  Only atoms with identical residue name and number and atom 
name will be used.",
+    can_be_none = True
+)
+uf.add_keyarg(
     name = "atom_id",
     py_type = "str",
     desc_short = "atom ID string",
@@ -704,6 +711,7 @@
 uf.desc[-1].add_paragraph("This is used to find pivot point of motion 
between a set of structural models.  If the list of models is not supplied, 
then all models will be used.")
 uf.desc[-1].add_paragraph("The atom ID, which uses the same notation as the 
spin ID strings, can be used to restrict the search to certain molecules, 
residues, or atoms.  For example to only use 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.")
 uf.desc[-1].add_paragraph("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.")
+uf.desc[-1].add_paragraph("If the optional molecules list is supplied, then 
the optimisation will be performed on molecules in the list rather than the 
models.  Therefore no models are allowed to be present in the current data 
pipe.")
 uf.backend = pipe_control.structure.main.find_pivot
 uf.menu_text = "&find_pivot"
 uf.wizard_height_desc = 400




Related Messages


Powered by MHonArc, Updated Thu Dec 11 09:00:03 2014