mailr21356 - in /branches/relax_disp: specific_analyses/relax_disp/disp_data.py user_functions/relax_disp.py


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

Header


Content

Posted by edward on October 31, 2013 - 10:53:
Author: bugman
Date: Thu Oct 31 10:53:53 2013
New Revision: 21356

URL: http://svn.gna.org/viewcvs/relax?rev=21356&view=rev
Log:
Redesigned the relax_disp.r2eff_read and relax_disp.r2eff_read_spin user 
functions.

These now no longer set the metadata (spectrometer frequency and experiment 
type) themselves.
Instead an experiment ID string must be supplied.  The spectrometer.frequency 
and
relax_disp.exp_type user functions will therefore need to be called before 
these R2eff functions.


Modified:
    branches/relax_disp/specific_analyses/relax_disp/disp_data.py
    branches/relax_disp/user_functions/relax_disp.py

Modified: branches/relax_disp/specific_analyses/relax_disp/disp_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/disp_data.py?rev=21356&r1=21355&r2=21356&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Thu Oct 31 
10:53:53 2013
@@ -49,8 +49,8 @@
 from pipe_control.mol_res_spin import check_mol_res_spin_data, 
exists_mol_res_spin_data, generate_spin_id_unique, return_spin, spin_loop
 from pipe_control.result_files import add_result_file
 from pipe_control.selection import desel_spin
-from pipe_control.spectrum import add_spectrum_id, check_spectrum_id, get_ids
-from pipe_control.spectrometer import set_frequency
+from pipe_control.spectrum import add_spectrum_id, get_ids
+from pipe_control.spectrometer import check_frequency, get_frequency, 
set_frequency
 from specific_analyses.relax_disp.checks import check_exp_type, 
check_mixed_curve_types
 from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG, 
EXP_TYPE_DESC_CPMG, EXP_TYPE_DESC_DQ_CPMG, EXP_TYPE_DESC_R1RHO, 
EXP_TYPE_DESC_MQ_CPMG, EXP_TYPE_DESC_MQ_R1RHO, EXP_TYPE_DESC_ZQ_CPMG, 
EXP_TYPE_DQ_CPMG, EXP_TYPE_LIST, EXP_TYPE_LIST_CPMG, EXP_TYPE_LIST_R1RHO, 
EXP_TYPE_MQ_CPMG, EXP_TYPE_MQ_R1RHO, EXP_TYPE_R1RHO, EXP_TYPE_ZQ_CPMG
 from stat import S_IRWXU, S_IRGRP, S_IROTH
@@ -272,7 +272,7 @@
     """
 
     # Data check.
-    check_exp_type()
+    check_exp_type(id=id)
 
     # All data.
     if id == None:
@@ -293,6 +293,22 @@
 
     # Return the type.
     return curve_type
+
+
+def get_exp_type(id=None):
+    """Return the experiment type for the given ID.
+
+    @keyword id:    The spectrum ID.
+    @type id:       str
+    @return:        The experiment type corresponding to the ID.
+    @rtype:         str
+    """
+
+    # Data check.
+    check_exp_type(id=id)
+
+    # Return the type.
+    return cdp.exp_type[id]
 
 
 def has_cpmg_exp_type():
@@ -1056,17 +1072,15 @@
     add_result_file(type='grace', label='Grace', file=file_path)
 
 
-def r2eff_read(file=None, dir=None, exp_type=None, frq=None, disp_frq=None, 
spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, 
spin_num_col=None, spin_name_col=None, data_col=None, error_col=None, 
sep=None):
+def r2eff_read(id=None, file=None, dir=None, disp_frq=None, 
spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, 
spin_num_col=None, spin_name_col=None, data_col=None, error_col=None, 
sep=None):
     """Read R2eff/R1rho values directly from a file whereby each row 
corresponds to a different spin.
 
+    @keyword id:            The experiment ID string to associate the data 
with.
+    @type id:               str
     @keyword file:          The name of the file to open.
     @type file:             str
     @keyword dir:           The directory containing the file (defaults to 
the current directory if None).
     @type dir:              str or None
-    @keyword exp_type:      The relaxation dispersion experiment type.
-    @type exp_type:         str
-    @keyword frq:           The spectrometer frequency in Hertz.
-    @type frq:              float
     @keyword disp_frq:      For CPMG-type data, the frequency of the CPMG 
pulse train.  For R1rho-type data, the spin-lock field strength (nu1).  The 
units must be Hertz.
     @type disp_frq:         float
     @keyword spin_id_col:   The column containing the spin ID strings.  If 
supplied, the mol_name_col, res_name_col, res_num_col, spin_name_col, and 
spin_num_col arguments must be none.
@@ -1092,10 +1106,15 @@
     # Data checks.
     pipes.test()
     check_mol_res_spin_data()
-
-    # Create a key for the global data (the pseudo-spectrum ID).
-    spectrum_id = "%s_%s" % (frq, disp_frq)
-    print("Using the pseudo-spectrum ID of '%s'." % spectrum_id)
+    check_frequency(id=id)
+    check_exp_type(id=id)
+
+    # Store the spectrum ID.
+    add_spectrum_id(id)
+
+    # Get the metadata.
+    frq = get_frequency(id=id)
+    exp_type = get_exp_type(id=id)
 
     # Loop over the data.
     data_flag = False
@@ -1122,10 +1141,10 @@
             raise RelaxError("An invalid error value of zero has been 
encountered.")
 
         # Get the corresponding spin container.
-        id = generate_spin_id_unique(mol_name=mol_name, res_num=res_num, 
res_name=res_name, spin_num=spin_num, spin_name=spin_name)
-        spin = return_spin(id)
+        spin_id = generate_spin_id_unique(mol_name=mol_name, 
res_num=res_num, res_name=res_name, spin_num=spin_num, spin_name=spin_name)
+        spin = return_spin(spin_id)
         if spin == None:
-            warn(RelaxNoSpinWarning(id))
+            warn(RelaxNoSpinWarning(spin_id))
             continue
 
         # The dispersion point key.
@@ -1166,35 +1185,24 @@
 
     # Update the global structures.
     if data_flag:
-        # Store the spectrum ID.
-        add_spectrum_id(spectrum_id)
-
-        # Set the spectrometer frequency information.
-        set_frequency(id=spectrum_id, frq=frq)
-
-        # Set the experiment type.
-        set_exp_type(spectrum_id=spectrum_id, exp_type=exp_type)
-
         # Set the dispersion point frequency.
         if exp_type in EXP_TYPE_LIST_CPMG:
-            cpmg_frq(spectrum_id=spectrum_id, cpmg_frq=disp_frq)
+            cpmg_frq(spectrum_id=id, cpmg_frq=disp_frq)
         else:
-            spin_lock_field(spectrum_id=spectrum_id, field=disp_frq)
-
-
-def r2eff_read_spin(spin_id=None, file=None, dir=None, exp_type=None, 
frq=None, disp_point_col=None, data_col=None, error_col=None, sep=None):
+            spin_lock_field(spectrum_id=id, field=disp_frq)
+
+
+def r2eff_read_spin(id=None, spin_id=None, file=None, dir=None, 
disp_point_col=None, data_col=None, error_col=None, sep=None):
     """Read R2eff/R1rho values from file whereby each row is a different 
dispersion point.
 
+    @keyword id:                The experiment ID string to associate the 
data with.  This will be modified to include the dispersion point data as 
"%s_%s" % (id, disp_point).
+    @type id:                   str
     @keyword spin_id:           The spin ID string.
     @type spin_id:              str
     @keyword file:              The name of the file to open.
     @type file:                 str
     @keyword dir:               The directory containing the file (defaults 
to the current directory if None).
     @type dir:                  str or None
-    @keyword exp_type:          The relaxation dispersion experiment type.
-    @type exp_type:             str
-    @keyword frq:               The spectrometer frequency in Hertz.
-    @type frq:                  float
     @keyword disp_point_col:    The column containing the dispersion point 
information.  For CPMG-type data, this is the frequency of the CPMG pulse 
train.  For R1rho-type data, this is the spin-lock field strength (nu1).  The 
units must be Hertz.
     @type disp_point_col:       int
     @keyword data_col:          The column containing the R2eff/R1rho data 
in Hz.
@@ -1219,6 +1227,7 @@
 
     # Loop over the data.
     data = []
+    new_ids = []
     for line in file_data:
         # Invalid columns.
         if disp_point_col > len(line):
@@ -1267,8 +1276,20 @@
         if error == 0.0:
             raise RelaxError("An invalid error value of zero has been 
encountered.")
 
-        # Create a key for the global data (the pseudo-spectrum ID).
-        spectrum_id = "%s_%s" % (frq, disp_point)
+        # Generate a new spectrum ID.
+        new_id = "%s_%s" % (id, disp_point)
+        new_ids.append(new_id)
+
+        # Data checks.
+        check_frequency(id=new_id)
+        check_exp_type(id=new_id)
+
+        # Store the spectrum ID.
+        add_spectrum_id(new_id)
+
+        # Get the metadata.
+        frq = get_frequency(id=new_id)
+        exp_type = get_exp_type(id=new_id)
 
         # The dispersion point key.
         point_key = return_param_key_from_data(frq=frq, point=disp_point)
@@ -1291,25 +1312,15 @@
             # Store.
             spin.r2eff_err[point_key] = error
 
-        # Update the global structures.
-        if not spectrum_id in get_ids():
-            # Store the spectrum ID.
-            add_spectrum_id(spectrum_id)
-
-            # Set the spectrometer frequency information.
-            set_frequency(id=spectrum_id, frq=frq)
-
-            # Set the experiment type.
-            set_exp_type(spectrum_id=spectrum_id, exp_type=exp_type)
-
-            # Set the dispersion point frequency.
-            if exp_type in EXP_TYPE_LIST_CPMG:
-                cpmg_frq(spectrum_id=spectrum_id, cpmg_frq=disp_point)
-            else:
-                spin_lock_field(spectrum_id=spectrum_id, field=disp_point)
+        # Set the dispersion point frequency.
+        if exp_type in EXP_TYPE_LIST_CPMG:
+            cpmg_frq(spectrum_id=new_id, cpmg_frq=disp_point)
+        else:
+            spin_lock_field(spectrum_id=new_id, field=disp_point)
 
         # Append the data for printout.
         data.append(["%20.15f" % disp_point, "%20.15f" % value, "%20.15f" % 
error])
+
         # Data added.
         data_flag = True
 
@@ -1318,6 +1329,7 @@
         raise RelaxError("No R2eff/R1rho data could be extracted.")
 
     # Print out.
+    print("Using the experiment IDs %s." % new_ids)
     print("The following R2eff/R1rho data has been loaded into the relax 
data store:\n")
     write_data(out=sys.stdout, headings=["Disp_point", "R2eff", 
"R2eff_error"], data=data)
 
@@ -1898,7 +1910,9 @@
 
     # Data checks.
     pipes.test()
-    check_spectrum_id(spectrum_id)
+
+    # Add the spectrum ID to the data store if needed.
+    add_spectrum_id(spectrum_id)
 
     # Check the experiment type.
     if exp_type not in EXP_TYPE_LIST:

Modified: branches/relax_disp/user_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/relax_disp.py?rev=21356&r1=21355&r2=21356&view=diff
==============================================================================
--- branches/relax_disp/user_functions/relax_disp.py (original)
+++ branches/relax_disp/user_functions/relax_disp.py Thu Oct 31 10:53:53 2013
@@ -524,6 +524,15 @@
 uf.title = "Read R2eff/R1rho values and errors from a file."
 uf.title_short = "R2eff/R1rho value reading."
 uf.add_keyarg(
+    name = "id",
+    py_type = "str",
+    desc_short = "partial experiment ID string",
+    desc = "The partial experiment ID string to identify this data with.  
The full ID string will be constructed as this ID followed by an underscore 
and then the dispersion point value from the file.",
+    wiz_element_type = 'combo',
+    wiz_combo_iter = spectrum.get_ids,
+    wiz_read_only = True
+)
+uf.add_keyarg(
     name = "file",
     py_type = "str",
     arg_type = "file sel",
@@ -540,35 +549,6 @@
     can_be_none = True
 )
 uf.add_keyarg(
-    name = "exp_type",
-    default = "CPMG",
-    py_type = "str",
-    desc_short = "experiment type",
-    desc = "The type of relaxation dispersion experiment performed.",
-    wiz_element_type = "combo",
-    wiz_combo_choices = [
-        "Single quantum (SQ) CPMG-type data",
-        "Zero quantum (ZQ) CPMG-type data",
-        "Double quantum (DQ) CPMG-type data",
-        "Multiple quantum (MQ) CPMG-type data",
-        "%s-type data" % r1rho
-    ],
-    wiz_combo_data = [
-        EXP_TYPE_CPMG,
-        EXP_TYPE_ZQ_CPMG,
-        EXP_TYPE_DQ_CPMG,
-        EXP_TYPE_MQ_CPMG,
-        EXP_TYPE_R1RHO
-    ],
-    wiz_read_only = True
-)
-uf.add_keyarg(
-    name = "frq",
-    py_type = "num",
-    desc_short = "spectrometer frequency",
-    desc = "The spectrometer frequency in Hertz.  See the 'sfrq' parameter 
in the Varian procpar file or the 'SFO1' parameter in the Bruker acqus file."
-)
-uf.add_keyarg(
     name = "disp_frq",
     py_type = "num",
     desc_short = "CPMG frequency or spin-lock field strength (Hz)",
@@ -649,11 +629,12 @@
 )
 # Description.
 uf.desc.append(Desc_container())
-uf.desc[-1].add_paragraph("This will read R2eff/R1rho data directly from a 
file.  The format of this text file must be that each row corresponds to a 
unique spin system and that there is one file per dispersion point (i.e. per 
CPMG frequency nu_CPMG or per spin-lock field strength n1).  The file must be 
in columnar format and information to identify the spin must be in columns of 
the file.")
+uf.desc[-1].add_paragraph("This will read R2eff/R1rho data directly from a 
file.  The data will be associated with an experiment ID string.  A partial 
ID is to be supplied and then the full ID string will be constructed as this 
ID followed by an underscore and then the dispersion point value from the 
file (as '%s_%s' % (id, disp_point)).  The full IDs must already exist and 
have been used to set the type of dispersion experiment the data is from, 
spectrometer proton frequency of the data, and if needed the time of the 
relaxation period.")
+uf.desc[-1].add_paragraph("The format of this text file must be that each 
row corresponds to a unique spin system and that there is one file per 
dispersion point (i.e. per CPMG frequency nu_CPMG or per spin-lock field 
strength n1).  The file must be in columnar format and information to 
identify the spin must be in columns of the file.")
 uf.backend = r2eff_read
 uf.menu_text = "&r2eff_read"
 uf.gui_icon = "oxygen.actions.document-open"
-uf.wizard_size = (900, 600)
+uf.wizard_size = (1000, 600)
 uf.wizard_image = ANALYSIS_IMAGE_PATH + 'relax_disp_200x200.png'
 
 
@@ -662,6 +643,15 @@
 uf.title = "Read R2eff/R1rho values and errors for a single spin from a 
file."
 uf.title_short = "Spin R2eff/R1rho value reading."
 uf.add_keyarg(
+    name = "id",
+    py_type = "str",
+    desc_short = "experiment ID string",
+    desc = "The experiment ID string to identify this data with.",
+    wiz_element_type = 'combo',
+    wiz_combo_iter = spectrum.get_ids,
+    wiz_read_only = True
+)
+uf.add_keyarg(
     name = "spin_id",
     py_type = "str",
     arg_type = "spin ID",
@@ -686,37 +676,9 @@
     can_be_none = True
 )
 uf.add_keyarg(
-    name = "exp_type",
-    default = "CPMG",
-    py_type = "str",
-    desc_short = "experiment type",
-    desc = "The type of relaxation dispersion experiment performed.",
-    wiz_element_type = "combo",
-    wiz_combo_choices = [
-        "Single quantum (SQ) CPMG-type data",
-        "Zero quantum (ZQ) CPMG-type data",
-        "Double quantum (DQ) CPMG-type data",
-        "Multiple quantum (MQ) CPMG-type data",
-        "%s-type data" % r1rho
-    ],
-    wiz_combo_data = [
-        EXP_TYPE_CPMG,
-        EXP_TYPE_ZQ_CPMG,
-        EXP_TYPE_DQ_CPMG,
-        EXP_TYPE_MQ_CPMG,
-        EXP_TYPE_R1RHO
-    ],
-    wiz_read_only = True
-)
-uf.add_keyarg(
-    name = "frq",
-    py_type = "num",
-    desc_short = "spectrometer frequency",
-    desc = "The spectrometer frequency in Hertz.  See the 'sfrq' parameter 
in the Varian procpar file or the 'SFO1' parameter in the Bruker acqus file."
-)
-uf.add_keyarg(
     name = "disp_point_col",
     default = 1,
+    min = 1,
     py_type = "int",
     desc_short = "dispersion point column",
     desc = "The column containing the CPMG frequency or spin-lock field 
strength (Hz)."
@@ -724,6 +686,7 @@
 uf.add_keyarg(
     name = "data_col",
     default = 2,
+    min = 1,
     py_type = "int",
     desc_short = "R2eff/R1rho data column",
     desc = "The column containing the R2eff or R1rho data."
@@ -731,6 +694,7 @@
 uf.add_keyarg(
     name = "error_col",
     default = 3,
+    min = 1,
     py_type = "int",
     desc_short = "R2eff/R1rho error column",
     desc = "The column containing the R2eff or R1rho error."
@@ -746,11 +710,12 @@
 )
 # Description.
 uf.desc.append(Desc_container())
-uf.desc[-1].add_paragraph("This will read R2eff/R1rho data for a single spin 
directly from a file.  The format of this text file must be that each row 
corresponds to a  dispersion point (i.e. per CPMG frequency nu_CPMG or per 
spin-lock field strength n1) and that there is one file per unique spin 
system.  The file must be in columnar format.")
+uf.desc[-1].add_paragraph("This will read R2eff/R1rho data for a single spin 
directly from a file.  The data will be associated with an experiment ID 
string.  This ID can be used for setting the type of dispersion experiment 
the data is from, spectrometer proton frequency of the data, and the time of 
the relaxation period.")
+uf.desc[-1].add_paragraph("The format of this text file must be that each 
row corresponds to a  dispersion point (i.e. per CPMG frequency nu_CPMG or 
per spin-lock field strength n1) and that there is one file per unique spin 
system.  The file must be in columnar format.")
 uf.backend = r2eff_read_spin
 uf.menu_text = "&r2eff_read_spin"
 uf.gui_icon = "oxygen.actions.document-open"
-uf.wizard_size = (900, 600)
+uf.wizard_size = (900, 700)
 uf.wizard_image = ANALYSIS_IMAGE_PATH + 'relax_disp_200x200.png'
 
 




Related Messages


Powered by MHonArc, Updated Thu Oct 31 11:00:02 2013