mailr3311 - in /1.2: ./ sample_scripts/full_analysis.py


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

Header


Content

Posted by edward on June 24, 2007 - 17:38:
Author: bugman
Date: Sun Jun 24 17:37:48 2007
New Revision: 3311

URL: http://svn.gna.org/viewcvs/relax?rev=3311&view=rev
Log:
Merged revisions 3309 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3

........
  r3309 | bugman | 2007-06-24 17:28:28 +0200 (Sun, 24 Jun 2007) | 8 lines
  
  Automatic looping in the full_analysis.py script.
  
  In response to the post by Douglas Kojetin <douglas dot kojetin att gmail 
dot com> at
  https://mail.gna.org/public/relax-users/2007-06/msg00002.html, I have added 
the ability to
  automatically loop over the optimisation rounds of the full_analysis.py 
script until convergence.
  This is not turned on automatically by default as it is likely to require a 
bit of debugging.
........

Modified:
    1.2/   (props changed)
    1.2/sample_scripts/full_analysis.py

Propchange: 1.2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Jun 24 17:37:48 2007
@@ -1,1 +1,1 @@
-/1.3:1-2505,2941,2947,2950,2974,2976,2979,2984,2988,3076,3083-3084,3087,3117,3299
+/1.3:1-2505,2941,2947,2950,2974,2976,2979,2984,2988,3076,3083-3084,3087,3117,3299,3309

Modified: 1.2/sample_scripts/full_analysis.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/sample_scripts/full_analysis.py?rev=3311&r1=3310&r2=3311&view=diff
==============================================================================
--- 1.2/sample_scripts/full_analysis.py (original)
+++ 1.2/sample_scripts/full_analysis.py Sun Jun 24 17:37:48 2007
@@ -132,6 +132,8 @@
 # The number of Monte Carlo simulations to be used for error analysis at the 
end of the analysis.
 MC_NUM = 200
 
+# Automatic looping over all rounds until convergence.
+CONV_LOOP = 0
 
 
 class Main:
@@ -163,84 +165,89 @@
         #############################
 
         elif DIFF_MODEL == 'sphere' or DIFF_MODEL == 'prolate' or DIFF_MODEL 
== 'oblate' or DIFF_MODEL == 'ellipsoid':
-            # Determine which round of optimisation to do (init, round_1, 
round_2, etc).
-            self.round = self.determine_rnd(model=DIFF_MODEL)
-
-
-            # Inital round of optimisation for diffusion models MII to MV.
-            if self.round == 0:
-                # Base directory to place files into.
-                self.base_dir = DIFF_MODEL + '/init/'
-
-                # Run name.
-                name = DIFF_MODEL
-
-                # Create the run.
-                run.create(name, 'mf')
-
-                # Load the local tm diffusion model MI results.
-                results.read(run=name, file='results', dir='local_tm/aic')
-
-                # Remove the tm parameter.
-                model_free.remove_tm(run=name)
-
-                # Load the PDB file.
-                pdb(name, PDB_FILE)
-
-                # Add an arbitrary diffusion tensor which will be optimised.
-                if DIFF_MODEL == 'sphere':
-                    diffusion_tensor.init(name, 10e-9, fixed=0)
-                    inc = 11
-                elif DIFF_MODEL == 'prolate':
-                    diffusion_tensor.init(name, (10e-9, 0, 0, 0), 
spheroid_type='prolate', fixed=0)
-                    inc = 11
-                elif DIFF_MODEL == 'oblate':
-                    diffusion_tensor.init(name, (10e-9, 0, 0, 0), 
spheroid_type='oblate', fixed=0)
-                    inc = 11
-                elif DIFF_MODEL == 'ellipsoid':
-                    diffusion_tensor.init(name, (10e-09, 0, 0, 0, 0, 0), 
fixed=0)
-                    inc = 6
-
-                # Minimise just the diffusion tensor.
-                fix(name, 'all_res')
-                grid_search(name, inc=inc)
-                minimise(MIN_ALGOR, run=name)
-
-                # Write the results.
-                results.write(run=name, file='results', dir=self.base_dir, 
force=1)
-
-
-            # Normal round of optimisation for diffusion models MII to MV.
-            else:
-                # Base directory to place files into.
-                self.base_dir = DIFF_MODEL + '/round_' + `self.round` + '/'
-
-                # Load the optimised diffusion tensor from either the 
previous round.
-                self.load_tensor()
-
-                # Sequential optimisation of all model-free models (function 
must be modified to suit).
-                self.multi_model()
-
-                # Create the final run (for model selection and final 
optimisation).
-                name = 'final'
-                run.create(name, 'mf')
-
-                # Model selection.
-                self.model_selection(run=name, dir=self.base_dir + 'aic')
-
-                # Final optimisation of all diffusion and model-free 
parameters.
-                fix(name, 'all', fixed=0)
-
-                # Minimise all parameters.
-                minimise(MIN_ALGOR, run=name)
-
-                # Write the results.
-                dir = self.base_dir + 'opt'
-                results.write(run=name, file='results', dir=dir, force=1)
-
-                # Test for convergence.
-                self.convergence(run=name)
-
+            # Loop until convergence if CONV_LOOP is set, otherwise just 
loop once.
+            # This looping could be made much cleaner by removing the 
dependence on the determine_rnd() function.
+            while 1:
+                # Determine which round of optimisation to do (init, 
round_1, round_2, etc).
+                self.round = self.determine_rnd(model=DIFF_MODEL)
+
+                # Inital round of optimisation for diffusion models MII to 
MV.
+                if self.round == 0:
+                    # Base directory to place files into.
+                    self.base_dir = DIFF_MODEL + '/init/'
+
+                    # Run name.
+                    name = DIFF_MODEL
+
+                    # Create the run.
+                    run.create(name, 'mf')
+
+                    # Load the local tm diffusion model MI results.
+                    results.read(run=name, file='results', 
dir='local_tm/aic')
+
+                    # Remove the tm parameter.
+                    model_free.remove_tm(run=name)
+
+                    # Load the PDB file.
+                    pdb(name, PDB_FILE)
+
+                    # Add an arbitrary diffusion tensor which will be 
optimised.
+                    if DIFF_MODEL == 'sphere':
+                        diffusion_tensor.init(name, 10e-9, fixed=0)
+                        inc = 11
+                    elif DIFF_MODEL == 'prolate':
+                        diffusion_tensor.init(name, (10e-9, 0, 0, 0), 
spheroid_type='prolate', fixed=0)
+                        inc = 11
+                    elif DIFF_MODEL == 'oblate':
+                        diffusion_tensor.init(name, (10e-9, 0, 0, 0), 
spheroid_type='oblate', fixed=0)
+                        inc = 11
+                    elif DIFF_MODEL == 'ellipsoid':
+                        diffusion_tensor.init(name, (10e-09, 0, 0, 0, 0, 0), 
fixed=0)
+                        inc = 6
+
+                    # Minimise just the diffusion tensor.
+                    fix(name, 'all_res')
+                    grid_search(name, inc=inc)
+                    minimise(MIN_ALGOR, run=name)
+
+                    # Write the results.
+                    results.write(run=name, file='results', 
dir=self.base_dir, force=1)
+
+
+                # Normal round of optimisation for diffusion models MII to 
MV.
+                else:
+                    # Base directory to place files into.
+                    self.base_dir = DIFF_MODEL + '/round_' + `self.round` + 
'/'
+
+                    # Load the optimised diffusion tensor from either the 
previous round.
+                    self.load_tensor()
+
+                    # Sequential optimisation of all model-free models 
(function must be modified to suit).
+                    self.multi_model()
+
+                    # Create the final run (for model selection and final 
optimisation).
+                    name = 'final'
+                    run.create(name, 'mf')
+
+                    # Model selection.
+                    self.model_selection(run=name, dir=self.base_dir + 'aic')
+
+                    # Final optimisation of all diffusion and model-free 
parameters.
+                    fix(name, 'all', fixed=0)
+
+                    # Minimise all parameters.
+                    minimise(MIN_ALGOR, run=name)
+
+                    # Write the results.
+                    dir = self.base_dir + 'opt'
+                    results.write(run=name, file='results', dir=dir, force=1)
+
+                    # Test for convergence.
+                    converged = self.convergence(run=name)
+
+                    # Break out of the infinite while loop if automatic 
looping is not activated or if convergence has occurred.
+                    if converged or not CONV_LOOP:
+                        break
 
 
         # Final run.
@@ -436,8 +443,10 @@
         print "\nConvergence:"
         if chi2_converged and models_converged and params_converged:
             print "    [ Yes ]"
+            return 1
         else:
             print "    [ No ]"
+            return 0
 
 
     def determine_rnd(self, model=None):




Related Messages


Powered by MHonArc, Updated Sun Jun 24 22:40:04 2007