mailr22854 - /trunk/specific_analyses/relax_disp/data.py


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

Header


Content

Posted by tlinnet on April 25, 2014 - 15:38:
Author: tlinnet
Date: Fri Apr 25 15:38:01 2014
New Revision: 22854

URL: http://svn.gna.org/viewcvs/relax?rev=22854&view=rev
Log:
Added function to find minimum R2eff value to set as R20 value before grid 
search.

Feature request: #3151, (https://gna.org/support/index.php?3151) - User 
function to set the R20 parameters in the default grid search using the 
minimum R2eff value.

Modified:
    trunk/specific_analyses/relax_disp/data.py

Modified: trunk/specific_analyses/relax_disp/data.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/relax_disp/data.py?rev=22854&r1=22853&r2=22854&view=diff
==============================================================================
--- trunk/specific_analyses/relax_disp/data.py  (original)
+++ trunk/specific_analyses/relax_disp/data.py  Fri Apr 25 15:38:01 2014
@@ -75,9 +75,10 @@
 from pipe_control.sequence import return_attached_protons
 from pipe_control.spectrum import add_spectrum_id
 from pipe_control.spectrometer import check_frequency, get_frequency
+from pipe_control import value
 import specific_analyses
 from specific_analyses.relax_disp.checks import check_exp_type, 
check_mixed_curve_types
-from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_DQ, 
EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, 
EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_DESC_CPMG_DQ, 
EXP_TYPE_DESC_CPMG_MQ, EXP_TYPE_DESC_CPMG_PROTON_MQ, 
EXP_TYPE_DESC_CPMG_PROTON_SQ, EXP_TYPE_DESC_CPMG_SQ, EXP_TYPE_DESC_CPMG_ZQ, 
EXP_TYPE_DESC_R1RHO, EXP_TYPE_LIST, EXP_TYPE_LIST_CPMG, EXP_TYPE_LIST_R1RHO, 
EXP_TYPE_R1RHO, MODEL_DPL94, MODEL_LIST_MMQ, MODEL_LIST_NUMERIC_CPMG, 
MODEL_LIST_R1RHO_FULL, MODEL_MP05, MODEL_NS_R1RHO_2SITE, MODEL_R2EFF, 
MODEL_TAP03, MODEL_TP02
+from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_DQ, 
EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, 
EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_DESC_CPMG_DQ, 
EXP_TYPE_DESC_CPMG_MQ, EXP_TYPE_DESC_CPMG_PROTON_MQ, 
EXP_TYPE_DESC_CPMG_PROTON_SQ, EXP_TYPE_DESC_CPMG_SQ, EXP_TYPE_DESC_CPMG_ZQ, 
EXP_TYPE_DESC_R1RHO, EXP_TYPE_LIST, EXP_TYPE_LIST_CPMG, EXP_TYPE_LIST_R1RHO, 
EXP_TYPE_R1RHO, MODEL_DPL94, MODEL_LIST_MMQ, MODEL_LIST_NUMERIC_CPMG, 
MODEL_LIST_R1RHO_FULL, MODEL_MP05, MODEL_NS_R1RHO_2SITE, MODEL_PARAMS, 
MODEL_R2EFF, MODEL_TAP03, MODEL_TP02, PARAMS_R20
 from stat import S_IRWXU, S_IRGRP, S_IROTH
 from os import chmod, sep
 
@@ -3521,6 +3522,59 @@
     print(text)
 
 
+def set_grid_r20_from_min_r2eff(force=True, verbosity=0):
+    """Set the R20 values to the minimum R2eff values.
+
+    For a 2 field cpmg experiment with model CR72, that would drop number of 
uniform grid search point from gridNr^5 to gridNr^3.
+    For standard 21 grid Nr, it would make the grid search 441 times faster. 
+
+    @keyword force:         A flag forcing the overwriting of current values.
+    @type force:            bool
+    @keyword verbosity:     A flag specifying to print the setting of values.
+    @type verbosity:        int
+    """
+
+    # Number of spectrometer fields.
+    fields = [None]
+    field_count = 1
+    if hasattr(cdp, 'spectrometer_frq_count'):
+        fields = cdp.spectrometer_frq_list
+        field_count = cdp.spectrometer_frq_count
+
+    # Loop over all spins.
+    for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
+        # Nothing to do (the R2eff model has no dispersion curves).
+        if spin.model == MODEL_R2EFF:
+            print("The spin model is %s. The %s model has no dispersion 
curves, so will not set the grid values."%(spin.model, spin.model))
+            continue
+
+        # Get all the data.
+        try:
+            values, errors, missing, frqs, frqs_H, exp_types, relax_times = 
return_r2eff_arrays(spins=[spin], spin_ids=[spin_id], fields=fields, 
field_count=field_count)
+
+        # No R2eff data, so skip the rest.
+        except RelaxError:
+            continue
+
+        # Loop over the experiments, magnetic fields, and offsets.
+        for exp_type, frq, offset, ei, mi, oi in 
loop_exp_frq_offset(return_indices=True):
+            # No data.
+            if not len(values[ei][0][mi][oi]):
+                continue
+
+            # The minimum
+            min_val = values[ei][0][mi][oi].min()
+
+            # Loop over the parameters for the current model
+            for param in MODEL_PARAMS[spin.model]:
+                # Check if the param is r2
+                if param in PARAMS_R20:
+                    # Set the value
+                    value.set(val=min_val, param=param, index=mi, 
spin_id=spin_id, force=force)
+                    if verbosity:
+                        print("For %s, frq=%3.1f, offset=%3.1f, for grid 
search setting initial %s=%3.2f for spin: %s"%(exp_type, frq/1E6, offset, 
param, min_val, spin_id))
+
+
 def spin_has_frq_data(spin=None, frq=None):
     """Determine if the spin has intensity data for the given spectrometer 
frequency.
 




Related Messages


Powered by MHonArc, Updated Fri Apr 25 15:40:02 2014