mailr26185 - in /branches/frame_order_cleanup: ./ specific_analyses/relax_disp/api.py specific_analyses/relax_disp/optimisation.py


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

Header


Content

Posted by edward on October 07, 2014 - 14:33:
Author: bugman
Date: Tue Oct  7 14:33:32 2014
New Revision: 26185

URL: http://svn.gna.org/viewcvs/relax?rev=26185&view=rev
Log:
Merged revisions 26167-26174 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r26167 | tlinnet | 2014-10-06 17:07:49 +0200 (Mon, 06 Oct 2014) | 3 lines
  
  In the dispersion API calculate(), used the API function model_loop() to 
loop over the clusters instead.
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........
  r26168 | tlinnet | 2014-10-06 17:07:54 +0200 (Mon, 06 Oct 2014) | 5 lines
  
  Removed then function loop_cluster_ids() from dispersion API().
  
  This should be implemented elsewhere.
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........
  r26169 | tlinnet | 2014-10-06 17:07:55 +0200 (Mon, 06 Oct 2014) | 3 lines
  
  Updated the API set_param_values() function to use model_loop() to get the 
spin_ids from the cluster.
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........
  r26170 | tlinnet | 2014-10-06 17:07:57 +0200 (Mon, 06 Oct 2014) | 11 lines
  
  Initial try to fix unit test test_value_set_r1_rit().
  
  The problem is, that no spin-id can be generated, since the spins are 
created manually,
  
  "
  File 
"/sbinlab2/tlinnet/software/NMR-relax/relax_trunk/pipe_control/mol_res_spin.py",
 line 1498, in generate_spin_id_unique
  if res and res.name != None and mol._res_name_count[res.name] > 1:
  AttributeError: 'MoleculeContainer' object has no attribute 
'_res_name_count'
  "
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........
  r26171 | tlinnet | 2014-10-06 17:21:32 +0200 (Mon, 06 Oct 2014) | 3 lines
  
  Removed the checking of MODEL_LIST_MMQ, and spin.isotope from 
optimisation.back_calc_r2eff(), since this check is already covered.
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........
  r26172 | tlinnet | 2014-10-06 18:03:28 +0200 (Mon, 06 Oct 2014) | 3 lines
  
  Fix for references to "spin" in optimisation.back_calc_r2eff().
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........
  r26173 | tlinnet | 2014-10-06 18:03:30 +0200 (Mon, 06 Oct 2014) | 3 lines
  
  Fix for looping performed twice in relax_disp API model_loop().
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........
  r26174 | tlinnet | 2014-10-06 18:03:32 +0200 (Mon, 06 Oct 2014) | 10 lines
  
  Removed unused proton reference in relax_disp API calculate().
  
  There is though some problems with these tests:
  F     1.93 s for Relax_disp.test_korzhnev_2005_15n_dq_data
  F     2.01 s for Relax_disp.test_korzhnev_2005_1h_mq_data
  F     1.93 s for Relax_disp.test_korzhnev_2005_1h_sq_data
  
  It is unsure where these comes from.
  
  Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.
........

Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/specific_analyses/relax_disp/api.py
    branches/frame_order_cleanup/specific_analyses/relax_disp/optimisation.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Oct  7 14:33:32 2014
@@ -1 +1 @@
-/trunk:1-26139,26142-26166
+/trunk:1-26139,26142-26174

Modified: branches/frame_order_cleanup/specific_analyses/relax_disp/api.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/relax_disp/api.py?rev=26185&r1=26184&r2=26185&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/relax_disp/api.py    
(original)
+++ branches/frame_order_cleanup/specific_analyses/relax_disp/api.py    Tue 
Oct  7 14:33:32 2014
@@ -261,9 +261,6 @@
         check_mol_res_spin_data()
         check_model_type()
 
-        # Get the looping list over cluster ids.
-        cluster_ids, cluster_spin_list, cluster_spin_id_list, 
cluster_spin_sel_list, clust_contain_spin_id_list = 
self.loop_cluster_ids(spin_id=spin_id)
-
         # Special exponential curve-fitting for the R2eff model.
         if cdp.model_type == MODEL_R2EFF:
             calculate_r2eff()
@@ -273,48 +270,30 @@
             # 1H MMQ flag.
             proton_mmq_flag = has_proton_mmq_cpmg()
 
-            # Loop over the cluster ids.
-            for i, cluster_id in enumerate(cluster_ids):
-                # Get the spins, ids and if the cluster contains the spin of 
interest.
-                cluster_spins = cluster_spin_list[i]
-                cluster_spin_ids = cluster_spin_id_list[i]
-                spin_of_interest = clust_contain_spin_id_list[i]
-
-                # If spin of interest is present:
-                if spin_of_interest:
-                    # If it is a free free spin, then calculate per spin.
-                    if cluster_id == 'free spins':
-                        for si, spin in enumerate(cluster_spins):
-                            cur_spin_id = cluster_spin_ids[si]
-
-                            # Skip protons for MMQ data.
-                            if spin.model in MODEL_LIST_MMQ and spin.isotope 
== '1H':
-                                continue
-
-                            # Get the attached proton.
-                            proton = None
-                            if proton_mmq_flag:
-                                proton = 
return_attached_protons(cur_spin_id)[0]
-
-                            # The back calculated values.
-                            back_calc = back_calc_r2eff(spins=[spin], 
spin_ids=[cur_spin_id], store_chi2=True)
-
-                            # Pack the data.
-                            pack_back_calc_r2eff(spin=spin, 
spin_id=cur_spin_id, si=0, back_calc=back_calc, 
proton_mmq_flag=proton_mmq_flag)
-
-                    else:
-                        # The back calculated values.
-                        back_calc = back_calc_r2eff(spins=cluster_spins, 
spin_ids=cluster_spin_ids, store_chi2=True)
-
-                        # Pack the data.
-                        for si, spin in enumerate(cluster_spins):
-                            cur_spin_id = cluster_spin_ids[si]
-
-                            # Skip protons for MMQ data.
-                            if spin.model in MODEL_LIST_MMQ and spin.isotope 
== '1H':
-                                continue
-
-                            pack_back_calc_r2eff(spin=spin, 
spin_id=cur_spin_id, si=si, back_calc=back_calc, 
proton_mmq_flag=proton_mmq_flag)
+            # Loop over the spin blocks.
+            model_index = -1
+            for spin_ids in self.model_loop():
+                # Increment the model index.
+                model_index += 1
+
+                # The spin containers.
+                spins = spin_ids_to_containers(spin_ids)
+
+                # Skip deselected clusters.
+                skip = True
+                for spin in spins:
+                    if spin.select:
+                        skip = False
+                if skip:
+                    continue
+
+                # The back calculated values.
+                back_calc = back_calc_r2eff(spins=spins, spin_ids=spin_ids, 
store_chi2=True)
+
+                # Pack the data.
+                for i, spin_id in enumerate(spin_ids):
+                    spin = spins[i]
+                    pack_back_calc_r2eff(spin=spin, spin_id=spin_id, si=i, 
back_calc=back_calc, proton_mmq_flag=proton_mmq_flag)
 
 
     def constraint_algorithm(self):
@@ -641,90 +620,6 @@
 
         # Minimisation.
         self.minimise(min_algor='grid', lower=lower, upper=upper, inc=inc, 
scaling_matrix=scaling_matrix, constraints=constraints, verbosity=verbosity, 
sim_index=sim_index)
-
-
-    def loop_cluster_ids(self, spin_id=None):
-        """Create list of cluster ids, its associated list of spin 
containers,  its associated list of spin_ids, the selection string for the 
cluster id and bool to determine if spin of interest is in the cluster.
-
-        @param spin_id:     The spin identification string.
-        @type spin_id:      None
-        @return:            The list of cluster ids, the nested list of spin 
container instances, the nested list of spin ids, the selection string for 
the cluster and list of boolean if spin_id is contained in cluster_id.
-        @rtype:             list of str, list of list of spin container, 
list of list of spin ids, list of str, list of bool
-        """
-
-        # Initialise cluster ids.
-        cluster_ids = ['free spins']
-
-        # Add the defined cluster IDs.
-        if hasattr(cdp, 'clustering'):
-            for key in list(cdp.clustering.keys()):
-                if key not in cluster_ids:
-                    cluster_ids.append(key)
-
-        # Now collect spins and spin_id per cluster ids.
-        cluster_spin_list = []
-        cluster_spin_id_list = []
-        cluster_spin_sel_list = []
-        clust_contain_spin_id_list = []
-
-        # Loop over the cluster ids
-        if hasattr(cdp, 'clustering'):
-            # Now loop over the cluster_ids in the list, and collect per id.
-            for cluster_id in cluster_ids:
-                cluster_id_spin_list = []
-                cluster_id_spin_id_list = []
-                # Now loop through spins in the clustered id, and collect
-                col_sel_str = ''
-                mol_token = None
-                for clust_spin_id in cdp.clustering[cluster_id]:
-                    clust_spin = return_spin(clust_spin_id)
-
-                    # Skip de-selected
-                    if not clust_spin.select:
-                        continue
-
-                    # Add to list.
-                    cluster_id_spin_list.append(clust_spin)
-                    cluster_id_spin_id_list.append(clust_spin_id)
-
-                    # Add id to string
-                    mol_token, res_token, spin_token = 
tokenise(clust_spin_id)
-                    col_sel_str += '%s,' % (res_token)
-
-                # Make selection for molecule.
-                if mol_token == None:
-                    col_sel_str = ':' + col_sel_str
-                else:
-                    col_sel_str = '#%s:' % mol_token + col_sel_str
-
-                # Make a selection object, based on the cluster id.
-                select_obj = Selection(col_sel_str)
-                # Does the current cluster id contain the spin of interest.
-                clust_contain_spin_id = select_obj.contains_spin_id(spin_id)
-                # If the spin_id is set to None, then we calculate for all:
-                if spin_id == None:
-                    clust_contain_spin_id = True
-
-                cluster_spin_list.append(cluster_id_spin_list)
-                cluster_spin_id_list.append(cluster_id_spin_id_list)
-                cluster_spin_sel_list.append(col_sel_str)
-                clust_contain_spin_id_list.append(clust_contain_spin_id)
-
-        # If clustering has not been specified, then collect for free spins, 
according to selection.
-        else:
-            # Now loop over selected spins.
-            free_spin_list = []
-            free_spin_id_list = []
-            for cur_spin, cur_spin_id in spin_loop(selection=spin_id, 
return_id=True, skip_desel=True):
-                free_spin_list.append(cur_spin)
-                free_spin_id_list.append(cur_spin_id)
-
-            cluster_spin_list.append(free_spin_list)
-            cluster_spin_id_list.append(free_spin_id_list)
-            cluster_spin_sel_list.append(None)
-            clust_contain_spin_id_list.append(True)
-
-        return cluster_ids, cluster_spin_list, cluster_spin_id_list, 
cluster_spin_sel_list, clust_contain_spin_id_list
 
 
     def map_bounds(self, param, spin_id=None):
@@ -951,7 +846,24 @@
         """
 
         # Loop over individual spins for the R2eff model.
-        if cdp.model_type == MODEL_R2EFF:
+        if hasattr(cdp, 'model_type'):
+            if cdp.model_type == MODEL_R2EFF:
+                # The spin loop.
+                for spin, spin_id in spin_loop(return_id=True):
+                    # Skip deselected spins
+                    if not spin.select:
+                        continue
+
+                    # Yield the spin ID as a list.
+                    yield [spin_id]
+
+             # The cluster loop.
+            else:
+                for spin_ids in loop_cluster(skip_desel=False):
+                    yield spin_ids
+
+        # If no model is present, then set the values.
+        else:
             # The spin loop.
             for spin, spin_id in spin_loop(return_id=True):
                 # Skip deselected spins
@@ -960,11 +872,6 @@
 
                 # Yield the spin ID as a list.
                 yield [spin_id]
-
-         # The cluster loop.
-        else:
-            for spin_ids in loop_cluster(skip_desel=False):
-                yield spin_ids
 
 
     def model_statistics(self, model_info=None, spin_id=None, 
global_stats=None):
@@ -1270,46 +1177,42 @@
         is_str_list(param, 'parameter name')
         is_list(value, 'parameter value')
 
-        # Get the looping list over cluster ids.
-        cluster_ids, cluster_spin_list, cluster_spin_id_list, 
cluster_spin_sel_list, clust_contain_spin_id_list = 
self.loop_cluster_ids(spin_id=spin_id)
-
-        # Loop over the cluster ids.
-        for j, cluster_id in enumerate(cluster_ids):
-            # Get the spins, ids and if the cluster contains the spin of 
interest.
-            cluster_spins = cluster_spin_list[j]
-            cluster_spin_ids = cluster_spin_id_list[j]
-            spin_of_interest = clust_contain_spin_id_list[j]
-            cluster_spin_sel = cluster_spin_sel_list[j]
-
-            # If spin of interest is present:
-            if spin_of_interest:
-                # If it is a free free spin, then calculate per spin.
-                if cluster_id == 'free spins':
-                    select_string = spin_id
+        # Loop over the spin blocks.
+        model_index = -1
+        for spin_ids in self.model_loop():
+            # Increment the model index.
+            model_index += 1
+
+            # The spin containers.
+            spins = spin_ids_to_containers(spin_ids)
+
+            # Skip deselected clusters.
+            skip = True
+            for spin in spins:
+                if spin.select:
+                    skip = False
+            if skip:
+                continue
+
+            # Loop over the parameters.
+            for i in range(len(param)):
+                param_i = param[i]
+                value_i = value[i]
+
+                # Is the parameter is valid?
+                if not self._PARAMS.contains(param_i):
+                    raise RelaxError("The parameter '%s' is not valid for 
this data pipe type." % param_i)
+
+                # If the parameter is a global parameter, then change for 
all spins part of the cluster.
+                if param_i in ['pA', 'kex', 'tex', 'kB', 'kC', 'kex_AB', 
'kex_BC', 'kex_AC']:
+                    selection_list = spin_ids
                 else:
-                    select_string = cluster_spin_sel
-
-                # Loop over the parameters.
-                for i in range(len(param)):
-                    param_i = param[i]
-                    value_i = value[i]
-
-                    # Is the parameter is valid?
-                    if not self._PARAMS.contains(param_i):
-                        raise RelaxError("The parameter '%s' is not valid 
for this data pipe type." % param_i)
-
-                    # If the parameter is a global parameter, then change 
for all spins part of the cluster.
-                    if param_i in ['pA', 'kex', 'tex', 'kB', 'kC', 'kex_AB', 
'kex_BC', 'kex_AC']:
-                        loop_select_string = select_string
-                    else:
-                        loop_select_string = spin_id
-
+                    selection_list = [spin_id]
+
+                # Now loop over selections in the list.
+                for selection in selection_list:
                     # Spin loop.
-                    for spin in spin_loop(selection=loop_select_string):
-                        # Skip deselected spins.
-                        if not spin.select:
-                            continue
-        
+                    for spin in spin_loop(selection=selection):
                         # The object name.
                         obj_name = param_i
                         if error:

Modified: 
branches/frame_order_cleanup/specific_analyses/relax_disp/optimisation.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/relax_disp/optimisation.py?rev=26185&r1=26184&r2=26185&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/relax_disp/optimisation.py 
  (original)
+++ branches/frame_order_cleanup/specific_analyses/relax_disp/optimisation.py 
  Tue Oct  7 14:33:32 2014
@@ -133,11 +133,6 @@
     @rtype:                     numpy rank-1 float array
     """
 
-    # Skip protons for MMQ data.
-    for spin in spins:
-        if spin.model in MODEL_LIST_MMQ and spin.isotope == '1H':
-            return
-
     # Create the initial parameter vector.
     param_vector = assemble_param_vector(spins=spins)
 
@@ -155,7 +150,7 @@
     r1_setup()
     offsets, spin_lock_fields_inter, chemical_shifts, tilt_angles, 
Delta_omega, w_eff = return_offset_data(spins=spins, spin_ids=spin_ids, 
field_count=field_count, spin_lock_offset=spin_lock_offset, 
fields=spin_lock_nu1)
     r1 = return_r1_data(spins=spins, spin_ids=spin_ids, 
field_count=field_count)
-    r1_fit = is_r1_optimised(spin.model)
+    r1_fit = is_r1_optimised(spins[0].model)
 
     # The relaxation times.
     if relax_times_new != None:
@@ -223,7 +218,7 @@
                         missing[ei][si][mi].append(zeros(num, int32))
 
     # Initialise the relaxation dispersion fit functions.
-    model = Dispersion(model=spin.model, num_params=param_num(spins=spins), 
num_spins=len(spins), num_frq=field_count, exp_types=exp_types, 
values=values, errors=errors, missing=missing, frqs=frqs, frqs_H=frqs_H, 
cpmg_frqs=cpmg_frqs, spin_lock_nu1=spin_lock_nu1, 
chemical_shifts=chemical_shifts, offset=offsets, tilt_angles=tilt_angles, 
r1=r1, relax_times=relax_times, recalc_tau=recalc_tau, r1_fit=r1_fit)
+    model = Dispersion(model=spins[0].model, 
num_params=param_num(spins=spins), num_spins=len(spins), num_frq=field_count, 
exp_types=exp_types, values=values, errors=errors, missing=missing, 
frqs=frqs, frqs_H=frqs_H, cpmg_frqs=cpmg_frqs, spin_lock_nu1=spin_lock_nu1, 
chemical_shifts=chemical_shifts, offset=offsets, tilt_angles=tilt_angles, 
r1=r1, relax_times=relax_times, recalc_tau=recalc_tau, r1_fit=r1_fit)
 
     # Make a single function call.  This will cause back calculation and the 
data will be stored in the class instance.
     chi2 = model.func(param_vector)




Related Messages


Powered by MHonArc, Updated Tue Oct 07 14:40:02 2014