mailr26152 - /trunk/specific_analyses/relax_disp/api.py


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

Header


Content

Posted by tlinnet on October 06, 2014 - 02:39:
Author: tlinnet
Date: Mon Oct  6 02:39:46 2014
New Revision: 26152

URL: http://svn.gna.org/viewcvs/relax?rev=26152&view=rev
Log:
Made initial preparation to loop over clustered spins and ids for 
minimise.calculate() call.

Bug #22754 (https://gna.org/bugs/index.php?22754): The minimise.calculate() 
does not calculate chi2 value for clustered residues.

Modified:
    trunk/specific_analyses/relax_disp/api.py

Modified: trunk/specific_analyses/relax_disp/api.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/relax_disp/api.py?rev=26152&r1=26151&r2=26152&view=diff
==============================================================================
--- trunk/specific_analyses/relax_disp/api.py   (original)
+++ trunk/specific_analyses/relax_disp/api.py   Mon Oct  6 02:39:46 2014
@@ -37,6 +37,7 @@
 from lib.arg_check import is_list, is_str_list
 from lib.dispersion.variables import EXP_TYPE_CPMG_PROTON_MQ, 
EXP_TYPE_CPMG_PROTON_SQ, MODEL_LIST_MMQ, MODEL_R2EFF, PARAMS_R20
 from lib.errors import RelaxError, RelaxImplementError
+from lib.selection import Selection, tokenise
 from lib.text.sectioning import subsection
 from multi import Processor_box
 from pipe_control import pipes, relax_data, sequence
@@ -260,6 +261,71 @@
         check_mol_res_spin_data()
         check_model_type()
 
+        # 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 = []
+        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)
+
+                    # 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)
+                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)
+            clust_contain_spin_id_list.append(True)
+
         # Special exponential curve-fitting for the R2eff model.
         if cdp.model_type == MODEL_R2EFF:
             calculate_r2eff()
@@ -270,7 +336,7 @@
             proton_mmq_flag = has_proton_mmq_cpmg()
 
             # Loop over all spins.
-            for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
+            for spin, cur_spin_id in spin_loop(selection=spin_id, 
return_id=True, skip_desel=True):
                 # Skip protons for MMQ data.
                 if spin.model in MODEL_LIST_MMQ and spin.isotope == '1H':
                     continue
@@ -278,13 +344,13 @@
                 # Get the attached proton.
                 proton = None
                 if proton_mmq_flag:
-                    proton = return_attached_protons(spin_id)[0]
+                    proton = return_attached_protons(cur_spin_id)[0]
 
                 # The back calculated values.
-                back_calc = back_calc_r2eff(spin=spin, spin_id=spin_id, 
store_chi2=True)
+                back_calc = back_calc_r2eff(spin=spin, spin_id=cur_spin_id, 
store_chi2=True)
 
                 # Pack the data.
-                pack_back_calc_r2eff(spin=spin, spin_id=spin_id, si=0, 
back_calc=back_calc, proton_mmq_flag=proton_mmq_flag)
+                pack_back_calc_r2eff(spin=spin, spin_id=cur_spin_id, si=0, 
back_calc=back_calc, proton_mmq_flag=proton_mmq_flag)
 
 
     def constraint_algorithm(self):




Related Messages


Powered by MHonArc, Updated Mon Oct 06 02:40:02 2014