Author: bugman
Date: Thu Dec 11 11:20:03 2014
New Revision: 27082
URL: http://svn.gna.org/viewcvs/relax?rev=27082&view=rev
Log:
Converted the structure.rmsd user function to the new
pipes/models/molecules/atom_id design.
This allows the RMSD calculation to work on atomic coordinates from different
data pipes, different
structural models, and different molecules. The user function backend uses the
new
pipe_control.structure.main.assemble_coordinates() function.
The Structure.test_rmsd_molecules system test has been updated for the user
function argument
changes.
Modified:
trunk/pipe_control/structure/main.py
trunk/test_suite/system_tests/structure.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=27082&r1=27081&r2=27082&view=diff
==============================================================================
--- trunk/pipe_control/structure/main.py (original)
+++ trunk/pipe_control/structure/main.py Thu Dec 11 11:20:03 2014
@@ -998,15 +998,17 @@
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, molecules=None):
+def rmsd(pipes=None, models=None, molecules=None, atom_id=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.
+ @keyword pipes: The data pipes to determine the RMSD for.
+ @type pipes: None or list of str
+ @keyword models: The list of models to determine the RMSD for. The
number of elements must match the pipes argument. If set to None, then all
models will be used.
+ @type models: None or list of lists of int
+ @keyword molecules: The list of molecules to determine the RMSD for. The
number of elements must match the pipes argument.
+ @type molecules: None or list of lists of str
+ @keyword atom_id: The atom identification string of the coordinates of
interest. This matches the spin ID string format.
@type atom_id: str or None
- @keyword models: The list of models to calculate the RMSD of. If set
to None, then all models will be used.
- @type models: list of int or None
- @keyword molecules: The list of molecules to calculate the RMSD between.
This overrides the models.
- @type molecules: None or list of str
@return: The RMSD value.
@rtype: float
"""
@@ -1014,53 +1016,8 @@
# Test if the current data pipe exists.
check_pipe()
- # The selection object.
- selection = cdp.structure.selection(atom_id=atom_id)
-
- # RMSD between models.
- if molecules == None:
- # 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])
-
- # RMSD between structures.
- 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 molecules.
- 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])
-
- # Numpy conversion.
- for i in range(len(coord)):
- coord[i] = array(coord[i])
+ # Assemble the atomic coordinates.
+ coord, ids = assemble_coordinates(pipes=pipes, molecules=molecules,
models=models, atom_id=atom_id)
# Calculate the RMSD.
cdp.structure.rmsd = atomic_rmsd(coord, verbosity=1)
Modified: trunk/test_suite/system_tests/structure.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/structure.py?rev=27082&r1=27081&r2=27082&view=diff
==============================================================================
--- trunk/test_suite/system_tests/structure.py (original)
+++ trunk/test_suite/system_tests/structure.py Thu Dec 11 11:20:03 2014
@@ -4262,7 +4262,7 @@
self.interpreter.structure.add_atom(atom_name='A', res_name='UNK',
res_num=3, mol_name='Z', pos=[-1., 20., 1.], element='S')
# Calculate the RMSD.
- self.interpreter.structure.rmsd(molecules=['X', 'Y', 'Z'])
+ self.interpreter.structure.rmsd(molecules=[['X', 'Y', 'Z']])
# Checks.
self.assert_(hasattr(cdp.structure, 'rmsd'))
Modified: trunk/user_functions/structure.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/user_functions/structure.py?rev=27082&r1=27081&r2=27082&view=diff
==============================================================================
--- trunk/user_functions/structure.py (original)
+++ trunk/user_functions/structure.py Thu Dec 11 11:20:03 2014
@@ -1052,30 +1052,46 @@
# The structure.rmsd user function.
uf = uf_info.add_uf('structure.rmsd')
-uf.title = "Determine the RMSD between the models."
+uf.title = "Determine the RMSD between structures."
uf.title_short = "Structural RMSD."
uf.add_keyarg(
+ name = "pipes",
+ py_type = "str_list",
+ desc_short = "data pipes",
+ desc = "The data pipes to determine the RMSD for.",
+ wiz_combo_iter = pipe_names,
+ wiz_read_only = False,
+ can_be_none = True
+)
+uf.add_keyarg(
+ name = "models",
+ py_type = "int_list_of_lists",
+ desc_short = "model list for each data pipe",
+ desc = "The list of models for each data pipe to determine the RMSD for.
The number of elements must match the pipes argument. If no models are given,
then all will be used.",
+ can_be_none = True
+)
+uf.add_keyarg(
+ name = "molecules",
+ py_type = "str_list_of_lists",
+ desc_short = "molecule list for each data pipe",
+ desc = "The list of molecules for each data pipe to determine the RMSD
for. The RMSD will only be calculated for atoms with identical residue name
and number and atom name. The number of elements must match the pipes
argument. If no molecules are given, then all will be used.",
+ can_be_none = True
+)
+uf.add_keyarg(
name = "atom_id",
py_type = "str",
desc_short = "atom identification string",
- desc = "The atom identification string.",
- 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 RMSD calculation on
rather than the models. The RMSD will only be calculated for atoms with
identical residue name and number and atom name.",
+ desc = "The atom identification string of the coordinates of interest.",
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.")
-uf.desc[-1].add_paragraph("If the optional molecules list is supplied, then
the RMSD calculation will be between the molecules in the list rather than the
models. Therefore no models are allowed to be present in the current data
pipe.")
+uf.desc[-1].add_paragraph("If the optional molecules list is supplied, then
the RMSD calculation will be between the molecules in the list.")
# Prompt examples.
uf.desc.append(Desc_container("Prompt examples"))
-uf.desc[-1].add_paragraph("To determine the RMSD, simply type:")
+uf.desc[-1].add_paragraph("To determine the RMSD of all models in the current
data pipe, simply type:")
uf.desc[-1].add_prompt("relax> structure.rmsd()")
uf.backend = pipe_control.structure.main.rmsd
uf.menu_text = "&rmsd"
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
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