mailr18216 - in /trunk: generic_fns/rdc.py user_functions/rdc.py


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

Header


Content

Posted by edward on January 18, 2013 - 12:14:
Author: bugman
Date: Fri Jan 18 12:14:17 2013
New Revision: 18216

URL: http://svn.gna.org/viewcvs/relax?rev=18216&view=rev
Log:
Implemented the rdc.set_errors user function.


Modified:
    trunk/generic_fns/rdc.py
    trunk/user_functions/rdc.py

Modified: trunk/generic_fns/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/rdc.py?rev=18216&r1=18215&r2=18216&view=diff
==============================================================================
--- trunk/generic_fns/rdc.py (original)
+++ trunk/generic_fns/rdc.py Fri Jan 18 12:14:17 2013
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2003-2012 Edward d'Auvergne                                  
 #
+# Copyright (C) 2003-2013 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -708,6 +708,48 @@
         cdp.rdc_ids.append(align_id)
 
 
+def set_errors(align_id=None, spin_id1=None, spin_id2=None, sd=None):
+    """Set the RDC errors if not already present.
+
+    @keyword align_id:  The optional alignment tensor ID string.
+    @type align_id:     str
+    @keyword spin_id1:  The optional spin ID string of the first spin.
+    @type spin_id1:     None or str
+    @keyword spin_id2:  The optional spin ID string of the second spin.
+    @type spin_id2:     None or str
+    @keyword sd:        The RDC standard deviation in Hz.
+    @type sd:           float or int.
+    """
+
+    # Test if sequence data exists.
+    if not exists_mol_res_spin_data():
+        raise RelaxNoSequenceError
+
+    # Test if data corresponding to 'align_id' exists.
+    if not hasattr(cdp, 'rdc_ids') or (align_id and align_id not in 
cdp.rdc_ids):
+        raise RelaxNoRDCError(align_id)
+
+    # Arg check.
+    if align_id and align_id not in cdp.rdc_ids:
+        raise RelaxError("The alignment ID '%s' is not in the RDC ID list 
%s." % (align_id, cdp.rdc_ids))
+
+    # Convert the align IDs to an array, or take all IDs.
+    if align_id:
+        align_ids = [align_id]
+    else:
+        align_ids = cdp.rdc_ids
+
+    # Loop over the interatomic data.
+    for interatom in interatomic_loop(selection1=spin_id1, 
selection2=spin_id2):
+        # No data structure.
+        if not hasattr(interatom, 'rdc_err'):
+            interatom.rdc_err = {}
+
+        # Set the error.
+        for id in align_ids:
+            interatom.rdc_err[id] = sd
+
+
 def weight(align_id=None, spin_id=None, weight=1.0):
     """Set optimisation weights on the RDC data.
 

Modified: trunk/user_functions/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/user_functions/rdc.py?rev=18216&r1=18215&r2=18216&view=diff
==============================================================================
--- trunk/user_functions/rdc.py (original)
+++ trunk/user_functions/rdc.py Fri Jan 18 12:14:17 2013
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2003-2012 Edward d'Auvergne                                  
 #
+# Copyright (C) 2003-2013 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -32,6 +32,7 @@
 
 # relax module imports.
 from generic_fns import align_tensor, pipes, rdc
+from generic_fns.mol_res_spin import get_spin_ids
 from graphics import WIZARD_IMAGE_PATH
 from user_functions.data import Uf_info; uf_info = Uf_info()
 from user_functions.objects import Desc_container
@@ -385,6 +386,54 @@
 uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
 
 
+# The rdc.set_errors user function.
+uf = uf_info.add_uf('rdc.set_errors')
+uf.title = "Set the errors for the RDCs."
+uf.title_short = "RDC error setting."
+uf.add_keyarg(
+    name = "align_id",
+    py_type = "str",
+    desc_short = "alignment ID string",
+    desc = "The optional alignment ID string.",
+    wiz_element_type = 'combo',
+    wiz_combo_iter = align_tensor.get_ids,
+    wiz_read_only = True,
+    can_be_none = True
+)
+uf.add_keyarg(
+    name = "spin_id1",
+    py_type = "str",
+    arg_type = "spin ID",
+    desc_short = "first spin ID string",
+    desc = "The optional spin ID string of the first spin.",
+    wiz_combo_iter = get_spin_ids,
+    can_be_none = True
+)
+uf.add_keyarg(
+    name = "spin_id2",
+    py_type = "str",
+    arg_type = "spin ID",
+    desc_short = "second spin ID string",
+    desc = "The optional spin ID string of the second spin.",
+    wiz_combo_iter = get_spin_ids,
+    can_be_none = True
+)
+uf.add_keyarg(
+    name = "sd",
+    default = 1.0,
+    py_type = "num",
+    desc_short = "RDC error (Hz)",
+    desc = "The RDC standard deviation value in Hertz."
+)
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("If the RDC errors have not already been read from 
a RDC data file or if they need to be changed, then the errors can be set via 
this user function.")
+uf.backend = rdc.set_errors
+uf.menu_text = "&set_errors"
+uf.gui_icon = "oxygen.actions.edit-rename"
+uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'
+
+
 # The rdc.weight user function.
 uf = uf_info.add_uf('rdc.weight')
 uf.title = "Set optimisation weights on the RDC data."




Related Messages


Powered by MHonArc, Updated Fri Jan 18 12:40:02 2013