mailr6819 - in /1.3/generic_fns/structure: internal.py main.py


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

Header


Content

Posted by edward on July 08, 2008 - 01:41:
Author: bugman
Date: Tue Jul  8 01:41:48 2008
New Revision: 6819

URL: http://svn.gna.org/viewcvs/relax?rev=6819&view=rev
Log:
Modified the __find_bonded_atom() and bond_vectors() methods to return more 
data.

This additional data is the name of the attached atom and any warnings when 
trying to find the
attached atom.


Modified:
    1.3/generic_fns/structure/internal.py
    1.3/generic_fns/structure/main.py

Modified: 1.3/generic_fns/structure/internal.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/internal.py?rev=6819&r1=6818&r2=6819&view=diff
==============================================================================
--- 1.3/generic_fns/structure/internal.py (original)
+++ 1.3/generic_fns/structure/internal.py Tue Jul  8 01:41:48 2008
@@ -140,12 +140,12 @@
             for i in matching_list:
                 matching_names.append(struct.atom_name[i])
 
-            # Return nothing.
-            return None, None, None, None
+            # Return nothing but a warning.
+            return None, None, None, None, 'More than one attached atom 
found: ' + `matching_names`
 
         # No attached atoms.
         if num_attached == 0:
-            return None, None, None, None
+            return None, None, None, None, "No attached atom could be found."
 
         # The bonded atom info.
         bonded_num = struct.atom_num[bonded_index]
@@ -154,7 +154,7 @@
         pos = [struct.x[bonded_index], struct.y[bonded_index], 
struct.z[bonded_index]]
 
         # Return the information.
-        return bonded_num, bonded_name, element, pos
+        return bonded_num, bonded_name, element, pos, None
 
 
     def __get_chemical_name(self, hetID):
@@ -635,21 +635,26 @@
                     yield atomic_tuple
 
 
-    def bond_vectors(self, atom_id=None, attached_atom=None, 
struct_index=None):
+    def bond_vectors(self, atom_id=None, attached_atom=None, 
struct_index=None, return_name=False, return_warnings=False):
         """Find the bond vector between the atoms of 'attached_atom' and 
'atom_id'.
 
-        @keyword atom_id:       The molecule, residue, and atom identifier 
string.  This must
-                                correspond to a single atom in the system.
-        @type atom_id:          str
-        @keyword attached_atom: The name of the bonded atom.
-        @type attached_atom:    str
-        @keyword struct_index:  The index of the structure to return the 
vectors from.  If not
-                                supplied and multiple structures/models 
exist, then vectors from all
-                                structures will be returned.
-        @type struct_index:     None or int
-        @type struct_index:     None or int.
-        @return:                The list of bond vectors for each structure.
-        @rtype:                 list of numpy arrays
+        @keyword atom_id:           The molecule, residue, and atom 
identifier string.  This must
+                                    correspond to a single atom in the 
system.
+        @type atom_id:              str
+        @keyword attached_atom:     The name of the bonded atom.
+        @type attached_atom:        str
+        @keyword struct_index:      The index of the structure to return the 
vectors from.  If not
+                                    supplied and multiple structures/models 
exist, then vectors from
+                                    all structures will be returned.
+        @type struct_index:         None or int
+        @keyword return_name:       A flag which if True will cause the name 
of the attached atom to
+                                    be returned together with the bond 
vectors.
+        @type return_name:          bool
+        @keyword return_warnings:   A flag which if True will cause warning 
messages to be returned.
+        @type return_warnings:      bool
+        @return:                    The list of bond vectors for each 
structure.
+        @rtype:                     list of numpy arrays (or a tuple if 
return_name or
+                                    return_warnings are set)
         """
 
         # Generate the selection object.
@@ -687,7 +692,7 @@
             # Found the atom.
             if atom_found:
                 # Find the atom bonded to this 
structure/molecule/residue/atom.
-                bonded_num, bonded_name, element, pos = 
self.__find_bonded_atom(attached_atom, index, i)
+                bonded_num, bonded_name, element, pos, warnings = 
self.__find_bonded_atom(attached_atom, index, i)
 
                 # No bonded atom.
                 if (bonded_num, bonded_name, element) == (None, None, None):
@@ -699,8 +704,15 @@
                 # Append the vector to the vectors array.
                 vectors.append(vector)
 
-        # Return the bond vectors.
-        return vectors
+        # Build the tuple to be yielded.
+        data = (vectors,)
+        if return_name:
+            data = data + (struct.atom_name[index],)
+        if return_warnings:
+            data = data + (warnings,)
+
+        # Return the data.
+        return data
 
 
     def load_pdb(self, file_path, model=None, verbosity=False):

Modified: 1.3/generic_fns/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/main.py?rev=6819&r1=6818&r2=6819&view=diff
==============================================================================
--- 1.3/generic_fns/structure/main.py (original)
+++ 1.3/generic_fns/structure/main.py Tue Jul  8 01:41:48 2008
@@ -304,7 +304,7 @@
             continue
 
         # Get the bond info.
-        bond_vectors = cdp.structure.bond_vectors(atom_id=id, 
attached_atom=attached, struct_index=struct_index)
+        bond_vectors, attached_name, warnings = 
cdp.structure.bond_vectors(atom_id=id, attached_atom=attached, 
struct_index=struct_index, return_name=True, return_warnings=True)
 
         # No attached atom.
         if not bond_vectors:




Related Messages


Powered by MHonArc, Updated Tue Jul 08 02:00:21 2008