mailr18491 - in /trunk: generic_fns/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 February 18, 2013 - 18:57:
Author: bugman
Date: Mon Feb 18 18:57:13 2013
New Revision: 18491

URL: http://svn.gna.org/viewcvs/relax?rev=18491&view=rev
Log:
Implemented the structure.rmsd user function.


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

Modified: trunk/generic_fns/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/main.py?rev=18491&r1=18490&r2=18491&view=diff
==============================================================================
--- trunk/generic_fns/structure/main.py (original)
+++ trunk/generic_fns/structure/main.py Mon Feb 18 18:57:13 2013
@@ -37,6 +37,7 @@
 from generic_fns.structure.api_base import Displacements
 from generic_fns.structure.internal import Internal
 from generic_fns.structure.scientific import Scientific_data
+from generic_fns.structure.statistics import atomic_rmsd
 from generic_fns.structure.superimpose import fit_to_first, fit_to_mean, 
Pivot_finder
 from relax_errors import RelaxError, RelaxFileError, RelaxNoPdbError, 
RelaxNoSequenceError
 from relax_io import get_file_path, open_write_file, write_data, 
write_spin_data
@@ -609,6 +610,42 @@
     cdp.structure.load_xyz(file_path, read_mol=read_mol, 
set_mol_name=set_mol_name, read_model=read_model, 
set_model_num=set_model_num, verbosity=verbosity)
 
 
+def rmsd(atom_id=None, models=None):
+    """Calculate the RMSD between the loaded models.
+
+    @keyword atom_id:   The molecule, residue, and atom identifier string.  
Only atoms matching this selection will be used.
+    @type atom_id:      str or None
+    @keyword models:    The list of models to calculate the RMDS of.  If set 
to None, then all models will be used.
+    @type models:       list of int or None
+    @return:            The RMSD value.
+    @rtype:             float
+    """
+
+    # Test if the current data pipe exists.
+    pipes.test()
+
+    # 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(atom_id=atom_id, model_num=model, 
pos_flag=True):
+            coord[-1].append(pos[0])
+        coord[-1] = array(coord[-1])
+
+    # Calculate the RMSD.
+    cdp.structure.rmsd = atomic_rmsd(coord)
+    print("RMSD:  %s" % cdp.structure.rmsd)
+
+    # Return the RMSD.
+    return cdp.structure.rmsd
+
+
 def rotate(R=None, origin=None, model=None, atom_id=None):
     """Rotate the structural data about the origin by the specified forwards 
rotation.
 

Modified: trunk/user_functions/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/user_functions/structure.py?rev=18491&r1=18490&r2=18491&view=diff
==============================================================================
--- trunk/user_functions/structure.py (original)
+++ trunk/user_functions/structure.py Mon Feb 18 18:57:13 2013
@@ -672,6 +672,31 @@
 uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + 'read_xyz.png'
 
 
+# The structure.rmsd user function.
+uf = uf_info.add_uf('structure.rmsd')
+uf.title = "Determine the RMSD between the models."
+uf.title_short = "Structural RMSD."
+uf.add_keyarg(
+    name = "atom_id",
+    py_type = "str",
+    desc_short = "atom identification string",
+    desc = "The atom identification string.",
+    can_be_none = True
+)
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("This allows the root mean squared deviation 
(RMSD) between all models to be calculated.")
+uf.desc[-1].add_paragraph("The atom ID, which uses the same notation as the 
spin ID strings, can be used to restrict the RMSD calculation to certain 
molecules, residues, or atoms.")
+# Prompt examples.
+uf.desc.append(Desc_container("Prompt examples"))
+uf.desc[-1].add_paragraph("To determine the RMSD, simply type:")
+uf.desc[-1].add_prompt("relax> structure.rmsd()")
+uf.backend = generic_fns.structure.main.rmsd
+uf.menu_text = "&rmsd"
+uf.wizard_size = (700, 500)
+uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png'
+
+
 # The structure.rotate user function.
 uf = uf_info.add_uf('structure.rotate')
 uf.title = "Rotate the internal structural object about the given origin by 
the rotation matrix."




Related Messages


Powered by MHonArc, Updated Mon Feb 18 19:20:02 2013