mailr2450 - in /1.2: generic_fns/minimise.py specific_fns/relax_data.py


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

Header


Content

Posted by c . a . macraild on April 05, 2006 - 16:20:
Author: macraild
Date: Wed Apr  5 16:20:20 2006
New Revision: 2450

URL: http://svn.gna.org/viewcvs/relax?rev=2450&view=rev
Log:
Fix for bug #5501. Removes all residue selection on read operations, and
impliments protection from underfitting in minimise(), grid_search() and
calc()

Modified:
    1.2/generic_fns/minimise.py
    1.2/specific_fns/relax_data.py

Modified: 1.2/generic_fns/minimise.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/generic_fns/minimise.py?rev=2450&r1=2449&r2=2450&view=diff
==============================================================================
--- 1.2/generic_fns/minimise.py (original)
+++ 1.2/generic_fns/minimise.py Wed Apr  5 16:20:20 2006
@@ -45,6 +45,9 @@
         # Function type.
         function_type = 
self.relax.data.run_types[self.relax.data.run_names.index(run)]
 
+        # Deselect residues lacking data:
+        self.overfit_deselect(run, function_type)
+
         # Specific calculate function setup.
         calculate = self.relax.specific_setup.setup('calculate', 
function_type)
 
@@ -71,6 +74,9 @@
         # Function type.
         function_type = 
self.relax.data.run_types[self.relax.data.run_names.index(run)]
 
+        # Deselect residues lacking data:
+        self.overfit_deselect(run, function_type)
+
         # Specific grid search function.
         grid_search = self.relax.specific_setup.setup('grid_search', 
function_type)
 
@@ -97,6 +103,9 @@
         # Function type.
         function_type = 
self.relax.data.run_types[self.relax.data.run_names.index(run)]
 
+        # Deselect residues lacking data:
+        self.overfit_deselect(run, function_type)
+
         # Specific minimisation function.
         minimise = self.relax.specific_setup.setup('minimise', function_type)
 
@@ -124,6 +133,62 @@
         # Standard minimisation.
         else:
             minimise(run=run, min_algor=min_algor, min_options=min_options, 
func_tol=func_tol, grad_tol=grad_tol, max_iterations=max_iterations, 
constraints=constraints, scaling=scaling, print_flag=print_flag)
+
+
+    def overfit_deselect(self, run, run_type):
+        """Function for deselecting residues without sufficient data to 
support minimisation"""
+
+        # Loop over residue data:
+        for residue in self.relax.data.res[run]:
+
+            # Skip unselected data:
+            if not residue.select:
+                continue
+
+            # Check for sufficient data for mf
+            if run_type == 'mf':
+                if not hasattr(residue, 'relax_data'):
+                    residue.select = 0
+                    continue
+
+                # Require 3 or more data points
+                if len(residue.relax_data) < 3:
+                    residue.select = 0
+                    continue 
+    
+                # Require at least as many data points as params to prevent 
under-fitting
+                if hasattr(residue, 'params'):
+                    if len(residue.params) > len(residue.relax_data):
+                        residue.select = 0
+                        continue
+
+                # Test for structural data if required
+                if self.relax.data.diff[run].type == 'spheroid' or 
self.relax.data.diff[run].type == 'ellipsoid':
+                    if not hasattr(residue, 'xh_vect'):
+                        residue.select = 0
+                        continue
+
+            # Check for sufficient data for jw
+            if run_type == 'jw':
+                if not hasattr(residue, 'relax_data'):
+                    residue.select = 0
+                    continue
+
+                # Require 3 or more data points
+                if len(residue.relax_data) < 3:
+                    residue.select = 0
+                    continue
+
+            # Check for sufficient data for relax_fit run_type
+            elif run_type == 'relax_fit':
+                if not hasattr(residue, 'intensities'):
+                    residue.select = 0
+                    continue
+
+                # Require 3 or more data points
+                if len(residue.intensities) < 3:
+                    residue.select = 0
+                    continue
 
 
     def reset_min_stats(self, run, index=None):

Modified: 1.2/specific_fns/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/specific_fns/relax_data.py?rev=2450&r1=2449&r2=2450&view=diff
==============================================================================
--- 1.2/specific_fns/relax_data.py (original)
+++ 1.2/specific_fns/relax_data.py Wed Apr  5 16:20:20 2006
@@ -627,21 +627,6 @@
             index_list.append(index)
 
 
-        # Selection flag.
-        #################
-
-        # Loop over the sequence.
-        for index in xrange(len(self.relax.data.res[self.run])):
-            # Remap the data structure 
'self.relax.data.res[self.run][index]'.
-            data = self.relax.data.res[self.run][index]
-
-            # No data loaded for this residue.
-            if index not in index_list:
-                # If no relaxation data exists, unselect the residue.
-                if not hasattr(data, 'relax_data'):
-                    data.select = 0
-
-
     def return_value(self, run, i, data_type):
         """Function for returning the value and error corresponding to 
'data_type'."""
 




Related Messages


Powered by MHonArc, Updated Thu Apr 06 18:00:05 2006