mailRe: r13417 - /branches/xyz/generic_fns/structure/internal.py


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

Header


Content

Posted by Edward d'Auvergne on July 05, 2011 - 16:53:
Hi Han,

I've finally have my temporary replacement computer installed and set
up!  The idea behind this code looks good.  One problem that might
arise though is that the spin_loop() method loops over loaded spins,
and not over the atomic data of the loaded structures.  I don't know
if this will fail, but I would suggest looking at the internal
structural object atom_loop() method.  The atom_loop() will take a
spin ID string (i.e. '#a:6@156') and loop over the atoms matching the
ID.  An alternative idea would be to add a method to the internal
structure object called get_atom() which takes the ID string and
returns the atom.  This function could then check that the ID only
matches a single atom, throwing a RelaxError if not the case.  It
could be a simple wrapper around atom_loop().  What do you think?

Regards,

Edward


On 4 July 2011 14:43,  <hasu@xxxxxxxxxxxxxxxxx> wrote:
Author: han87
Date: Mon Jul  4 14:43:10 2011
New Revision: 13417

URL: http://svn.gna.org/viewcvs/relax?rev=13417&view=rev
Log:
Adding code for extracting a vector of a xyz file.

Code for extracting a vector between specified spins in a xyz file has been 
included in the '/generic_fns/structure/internal.py'.

Modified:
   branches/xyz/generic_fns/structure/internal.py

Modified: branches/xyz/generic_fns/structure/internal.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/xyz/generic_fns/structure/internal.py?rev=13417&r1=13416&r2=13417&view=diff
==============================================================================
--- branches/xyz/generic_fns/structure/internal.py (original)
+++ branches/xyz/generic_fns/structure/internal.py Mon Jul  4 14:43:10 2011
@@ -35,6 +35,7 @@
 from api_base import Base_struct_API, ModelList
 from data.relax_xml import fill_object_contents, xml_to_object
 from generic_fns import pipes, relax_re
+from generic_fns.mol_res_spin import spin_loop
 from generic_fns.mol_res_spin import Selection
 from relax_errors import RelaxError, RelaxNoPdbError
 from relax_io import file_root, open_read_file
@@ -107,7 +108,27 @@

        # No attached atoms.
        if num_attached == 0:
-            return None, None, None, None, None, "No attached atom could 
be found"
+            if relax_re.search('@*', attached_atom):
+                matching_list = []
+                bonded_num=[]
+                bonded_name=[]
+                element=[]
+                pos=[]
+                for spin, mol_name, res_num, res_name in 
spin_loop(selection=attached_atom, full_info=True):
+                    bonded_num.append(spin.num)
+                    bonded_name.append(spin.name)
+                    element.append(spin.element)
+                    pos.append(spin.pos)
+                if len(bonded_num) == 1:
+                    return bonded_num[0], bonded_name[0], element[0], 
pos[0], attached_atom, None
+                elif len(bonded_num) > 1:
+                    # Return nothing but a warning.
+                    return None, None, None, None, None, 'More than one 
attached atom found: ' + repr(matching_names)
+                elif len(bonded_num) > 1:
+                    # Return nothing but a warning.
+                    return None, None, None, None, None, "No attached atom 
could be found"
+            else:
+                return None, None, None, None, None, "No attached atom 
could be found"

        # The bonded atom info.
        index = matching_list[0]
@@ -634,7 +655,7 @@
                if index != None:
                    # Get the atom bonded to this 
model/molecule/residue/atom.
                    bonded_num, bonded_name, element, pos, attached_name, 
warnings = self.__bonded_atom(attached_atom, index, mol)
-
+
                    # No bonded atom.
                    if (bonded_num, bonded_name, element) == (None, None, 
None):
                        continue
@@ -1596,7 +1617,7 @@
        @keyword index2:        The index of the second atom.
        @type index2:           int
        """
-
+
        # Update the bonded array structure, if necessary.
        if index2 not in self.bonded[index1]:
            self.bonded[index1].append(index2)


_______________________________________________
relax (http://nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits




Related Messages


Powered by MHonArc, Updated Wed Jul 13 16:20:10 2011