mailr13661 - in /branches/gui_testing: ./ generic_fns/mol_res_spin.py generic_fns/structure/main.py


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

Header


Content

Posted by edward on July 15, 2011 - 19:52:
Author: bugman
Date: Fri Jul 15 19:52:04 2011
New Revision: 13661

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

........
  r13660 | bugman | 2011-07-15 19:50:44 +0200 (Fri, 15 Jul 2011) | 6 lines
  
  Bug fix for pseudo-atom support when only a single structure is loaded.
  
  Pseudo-atom support was only working correctly for when multiple models 
were loaded and atomic
  positions were not averaged.
........

Modified:
    branches/gui_testing/   (props changed)
    branches/gui_testing/generic_fns/mol_res_spin.py
    branches/gui_testing/generic_fns/structure/main.py

Propchange: branches/gui_testing/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jul 15 19:52:04 2011
@@ -1,1 +1,1 @@
-/1.3:1-13655
+/1.3:1-13660

Modified: branches/gui_testing/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/generic_fns/mol_res_spin.py?rev=13661&r1=13660&r2=13661&view=diff
==============================================================================
--- branches/gui_testing/generic_fns/mol_res_spin.py (original)
+++ branches/gui_testing/generic_fns/mol_res_spin.py Fri Jul 15 19:52:04 2011
@@ -36,7 +36,7 @@
 """
 
 # Python module imports.
-from numpy import array
+from numpy import array, float64
 from re import split
 from string import count, replace, strip, upper
 from textwrap import fill
@@ -999,10 +999,19 @@
         if not hasattr(spin, 'pos') or spin.pos == None:
             raise RelaxError("Positional information is not available for 
the atom '%s'." % atom)
 
+        # Alias the position.
+        pos = spin.pos
+
+        # Convert to a list of lists if not already.
+        multi_model = True
+        if type(pos[0]) in [float, float64]:
+            multi_model = False
+            pos = [pos]
+
         # Store the position.
         positions.append([])
-        for i in range(len(spin.pos)):
-            positions[-1].append(spin.pos[i].tolist())
+        for i in range(len(pos)):
+            positions[-1].append(pos[i].tolist())
 
     # Now add the pseudo-spin name to the spins belonging to it (after the 
tests).
     for atom in members:
@@ -1024,7 +1033,14 @@
     spin.averaging = averaging
     spin.members = members
     if averaging == 'linear':
-        spin.pos = linear_ave(positions)
+        # Average pos.
+        ave = linear_ave(positions)
+
+        # Convert to the correct structure.
+        if multi_model:
+            spin.pos = ave
+        else:
+            spin.pos = ave[0]
 
 
 def create_spin(spin_num=None, spin_name=None, res_num=None, res_name=None, 
mol_name=None):
@@ -1644,9 +1660,7 @@
 def linear_ave(positions):
     """Perform linear averaging of the atomic positions.
 
-    @param positions:   The atomic positions.  The first index is that of 
the positions to be
-                        averaged over.  The second index is over the 
different models.  The last
-                        index is over the x, y, and z coordinates.
+    @param positions:   The atomic positions.  The first index is that of 
the positions to be averaged over.  The second index is over the different 
models.  The last index is over the x, y, and z coordinates.
     @type positions:    list of lists of numpy float arrays
     @return:            The averaged positions as a list of vectors.
     @rtype:             list of numpy float arrays

Modified: branches/gui_testing/generic_fns/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/generic_fns/structure/main.py?rev=13661&r1=13660&r2=13661&view=diff
==============================================================================
--- branches/gui_testing/generic_fns/structure/main.py (original)
+++ branches/gui_testing/generic_fns/structure/main.py Fri Jul 15 19:52:04 
2011
@@ -131,14 +131,30 @@
                 if not hasattr(subspin, 'pos') or not subspin.pos:
                     raise RelaxError("Positional information is not 
available for the atom '%s'." % atom)
 
+                # Alias the position.
+                pos = subspin.pos
+
+                # Convert to a list of lists if not already.
+                multi_model = True
+                if type(pos[0]) in [float, float64]:
+                    multi_model = False
+                    pos = [pos]
+
                 # Store the position.
                 positions.append([])
-                for i in range(len(subspin.pos)):
-                    positions[-1].append(subspin.pos[i].tolist())
+                for i in range(len(pos)):
+                    positions[-1].append(pos[i].tolist())
 
             # The averaging.
             if spin.averaging == 'linear':
-                spin.pos = linear_ave(positions)
+                # Average pos.
+                ave = linear_ave(positions)
+
+                # Convert to the correct structure.
+                if multi_model:
+                    spin.pos = ave
+                else:
+                    spin.pos = ave[0]
 
 
 def load_spins(spin_id=None, str_id=None, combine_models=True, 
ave_pos=False):




Related Messages


Powered by MHonArc, Updated Fri Jul 15 20:00:02 2011