mailr5905 - /1.3/generic_fns/structure/scientific.py


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

Header


Content

Posted by edward on April 21, 2008 - 11:40:
Author: bugman
Date: Mon Apr 21 11:40:39 2008
New Revision: 5905

URL: http://svn.gna.org/viewcvs/relax?rev=5905&view=rev
Log:
Modified the attached_atom() method to handle multiple models.


Modified:
    1.3/generic_fns/structure/scientific.py

Modified: 1.3/generic_fns/structure/scientific.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/scientific.py?rev=5905&r1=5904&r2=5905&view=diff
==============================================================================
--- 1.3/generic_fns/structure/scientific.py (original)
+++ 1.3/generic_fns/structure/scientific.py Mon Apr 21 11:40:39 2008
@@ -26,7 +26,7 @@
 
 # Python module imports.
 from math import sqrt
-from numpy import dot, float64, zeros
+from numpy import array, dot, float64, zeros
 from warnings import warn
 
 # Scientific Python import.
@@ -63,7 +63,7 @@
         @type res:              Scientific Python residue instance
         @return:                A tuple of information about the bonded atom.
         @rtype:                 tuple consisting of the atom number (int), 
atom name (str), element
-                                name (str), and atomic position (array of 
len 3, or list of arrays)
+                                name (str), and atomic position (Numeric 
array of len 3)
         """
 
         # Init.
@@ -280,17 +280,24 @@
         @type model:            None or int
         @return:                A tuple of information about the bonded atom.
         @rtype:                 tuple consisting of the atom number (int), 
atom name (str), element
-                                name (str), and atomic position (array of 
len 3, or list of arrays)
+                                name (str), and atomic positions for each 
model (list of numpy
+                                arrays)
         """
 
         # Generate the selection object.
         sel_obj = Selection(atom_id)
 
-        # Init.
-        atom_found = False
+        # Initialise some objects.
+        bonded_num = None
+        bonded_name = None
+        element = None
+        pos_array = []
 
         # Loop over the models.
         for struct in self.structural_data:
+            # Init.
+            atom_found = False
+
             # Skip non-matching models.
             if model != None and model != struct.model:
                 continue
@@ -320,17 +327,16 @@
                         mol_type_match = mol_type
                         res_match = res
 
-        # Found the atom.
-        if atom_found:
-            # Find the atom bonded to this molecule/residue/atom.
-            bonded_num, bonded_name, element, pos = 
self.__find_bonded_atom(attached_atom, mol_type_match, res_match)
-
-            # Return the atom info.
-            return bonded_num, bonded_name, element, pos
-
-        # Nothing found.
-        else:
-            return None, None, None, None
+            # Found the atom.
+            if atom_found:
+                # Find the atom bonded to this model/molecule/residue/atom.
+                bonded_num, bonded_name, element, pos = 
self.__find_bonded_atom(attached_atom, mol_type_match, res_match)
+
+                # Append the position to the position array (converting from 
a Numeric array to a numpy array).
+                pos_array.append(array(pos, float64))
+
+        # Return the atom info.
+        return bonded_num, bonded_name, element, pos_array
 
 
     def load_structures(self, file_path, model=None, verbosity=False):




Related Messages


Powered by MHonArc, Updated Mon Apr 21 12:00:25 2008