Author: bugman
Date: Thu Dec 11 19:37:46 2014
New Revision: 27101

URL: http://svn.gna.org/viewcvs/relax?rev=27101&view=rev
Log:
Added the displace_id argument to the structure.align and structure.superimpose 
user functions.

This gives both of these user functions finer control over which atoms are 
translated and rotated by
the algorithm.  This allows, for example, to align structures based on a set of 
backbone heavy atoms
while the protons and side chains are displaced by default.  Or if a domain is 
aligned, then just
that domain can be displaced.


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=27101&r1=27100&r2=27101&view=diff
==============================================================================
--- trunk/pipe_control/structure/main.py        (original)
+++ trunk/pipe_control/structure/main.py        Thu Dec 11 19:37:46 2014
@@ -106,7 +106,7 @@
     print("Created the empty model number %s." % model_num)
 
 
-def align(pipes=None, models=None, molecules=None, atom_id=None, method='fit 
to mean', centre_type="centroid", centroid=None):
+def align(pipes=None, models=None, molecules=None, atom_id=None, 
displace_id=None, method='fit to mean', centre_type="centroid", centroid=None):
     """Superimpose a set of related, but not identical structures.
 
     @keyword pipes:         The data pipes to include in the alignment and 
superimposition.
@@ -117,6 +117,8 @@
     @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 displace_id:   The atom ID string for restricting the 
displacement to a subset of all atoms.  If not set, then all atoms will be 
translated and rotated.
+    @type displace_id:      str or None
     @keyword method:        The superimposition method.  It must be one of 
'fit to mean' or 'fit to first'.
     @type method:           str
     @keyword centre_type:   The type of centre to superimpose over.  This can 
either be the standard centroid superimposition or the CoM could be used 
instead.
@@ -151,8 +153,15 @@
     # Loop over all pipes, models, and molecules.
     i = 0
     for pipe_index, model_num, mol_name in structure_loop(pipes=pipes, 
molecules=molecules, models=models, atom_id=atom_id):
-        # The atom ID from the molecule name.
-        id = '#%s' % mol_name
+        # Add the molecule name to the displacement ID if required.
+        id = displace_id
+        if molecules != None:
+            if displace_id == None:
+                id = '#%s' % mol_name
+            elif not search('#', displace_id):
+                id = '#%s' % mol_name
+            else:
+                id = '#%s%s' % (mol_name, displace_id)
 
         # Translate the molecule first (the rotational pivot is defined in the 
first model).
         translate(T=T[i], model=model_num, pipe_name=pipes[pipe_index], 
atom_id=id)
@@ -1110,7 +1119,7 @@
         yield pipe_index, model_num, mol_name
 
 
-def superimpose(models=None, method='fit to mean', atom_id=None, 
centre_type="centroid", centroid=None):
+def superimpose(models=None, method='fit to mean', atom_id=None, 
displace_id=None, centre_type="centroid", 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.
@@ -1119,6 +1128,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 displace_id:   The atom ID string for restricting the 
displacement to a subset of all atoms.  If not set, then all atoms will be 
translated and rotated.
+    @type displace_id:      str or None
     @keyword centre_type:   The type of centre to superimpose over.  This can 
either be the standard centroid superimposition or the CoM could be used 
instead.
     @type centre_type:      str
     @keyword centroid:      An alternative position of the centroid to allow 
for different superpositions, for example of pivot point motions.
@@ -1151,10 +1162,10 @@
     # Update to the new coordinates.
     for i in range(len(models)):
         # Translate the molecule first (the rotational pivot is defined in the 
first model).
-        translate(T=T[i], model=models[i])
+        translate(T=T[i], model=models[i], atom_id=displace_id)
 
         # Rotate the molecule.
-        rotate(R=R[i], origin=pivot[i], model=models[i])
+        rotate(R=R[i], origin=pivot[i], model=models[i], atom_id=displace_id)
 
 
 def translate(T=None, model=None, atom_id=None, pipe_name=None):

Modified: trunk/user_functions/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/user_functions/structure.py?rev=27101&r1=27100&r2=27101&view=diff
==============================================================================
--- trunk/user_functions/structure.py   (original)
+++ trunk/user_functions/structure.py   Thu Dec 11 19:37:46 2014
@@ -46,6 +46,7 @@
 # Text for the multi-structure paragraph.
 paragraph_multi_struct = "Support for multiple structures is provided by the 
data pipes, model numbers and molecule names arguments.  Each data pipe, model 
and molecule combination will be treated as a separate structure.  As only 
atomic coordinates with the same residue name and number and atom name will be 
assembled, structures with slightly different atomic structures can be 
compared.  If the list of models is not supplied, then all models of all data 
pipes will be used.  If the optional molecules list is supplied, each molecule 
in the list will be considered as a separate structure for comparison between 
each other."
 paragraph_atom_id = "The atom ID string, which uses the same notation as the 
spin ID, can be used to restrict the coordinates compared to a subset of 
molecules, residues, or atoms.  For example to only use backbone heavy atoms in 
a protein, set the atom ID to '@N,C,CA,O', assuming those are the names of the 
atoms in the 3D structural file."
+paragraph_displace_id = "The displacement ID string, which is similar to the 
atom ID, gives finer control over which atoms are translated and rotated by the 
algorithm.  When not set this allows, for example, to align structures based on 
a set of backbone heavy atoms and the backbone protons and side-chains are 
displaced by default.  Or if set to the same as the atom ID, if a single domain 
is aligned, then just that domain will be displaced."
 
 
 # The user function class.
@@ -195,6 +196,13 @@
     can_be_none = True
 )
 uf.add_keyarg(
+    name = "displace_id",
+    py_type = "str",
+    desc_short = "displacement ID string",
+    desc = "The atom identification string for restricting the displacement to 
a subset of all atoms.  If not set, then all atoms will be translated and 
rotated.",
+    can_be_none = True
+)
+uf.add_keyarg(
     name = "method",
     default = "fit to mean",
     py_type = "str",
@@ -229,6 +237,7 @@
 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(paragraph_multi_struct)
 uf.desc[-1].add_paragraph(paragraph_atom_id)
+uf.desc[-1].add_paragraph(paragraph_displace_id)
 # Prompt examples.
 uf.desc.append(Desc_container("Prompt examples"))
 uf.desc[-1].add_paragraph("To superimpose all sets of models, exactly as in 
the structure.superimpose user function, type one of:")
@@ -1178,6 +1187,13 @@
     can_be_none = True
 )
 uf.add_keyarg(
+    name = "displace_id",
+    py_type = "str",
+    desc_short = "displacement ID string",
+    desc = "The atom identification string for restricting the displacement to 
a subset of all atoms.  If not set, then all atoms will be translated and 
rotated.",
+    can_be_none = True
+)
+uf.add_keyarg(
     name = "centre_type",
     py_type = "str",
     default = "centroid",
@@ -1201,6 +1217,7 @@
 uf.desc[-1].add_item_list_element("'fit to first'", "This is quicker but is 
not as accurate for an ensemble description.  The Kabsch algorithm is used to 
rotate and translate each model to be superimposed onto the first model.")
 uf.desc[-1].add_paragraph("If the list of models is not supplied, then all 
models will be superimposed.")
 uf.desc[-1].add_paragraph(paragraph_atom_id)
+uf.desc[-1].add_paragraph(paragraph_displace_id)
 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.")
 # Prompt examples.
 uf.desc.append(Desc_container("Prompt examples"))


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@gna.org

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits

Reply via email to