mailRe: r13165 - in /branches/xyz: data/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 d'Auvergne on June 22, 2011 - 17:51:
Hi,

I would suggest we do this a bit differently.  This change could break
other parts of relax, and the issue is simply in the
generic_fns.structure.main.load_spins() function.  This function is
not very well designed.  What needs to be done is to have a similar
check as was done with the molecule:

        # Get the molecule container corresponding to the molecule name.
        mol_cont = None
        if mol_name:
            # Update the ID string.
            id = id + '#' + mol_name

            # The container.
            mol_cont = return_molecule(id)

This is the idea for the residue container as well.  Then the unnamed
residue container will be returned, and again similar checks to
rename/renumber it can be performed as in the molecule container case:

        # Add the molecule if it doesn't exist.
        if mol_cont == None:
            # Get the unnamed molecule, assuming there is only one.
            mol_cont = return_molecule()

            # Got something!
            if mol_cont != None:
                # Rename the molecule container if the mol name is
given and the sole container is unnamed.
                if mol_cont.name == None and mol_name:
                    # Print out.
                    print(("Renaming the unnamed sole molecule
container to '%s'." % mol_name))

                    # Set the name.
                    mol_cont.name = mol_name

            # Nothing exists yet.
            else:
                # Add the molecule.
                cdp.mol.add_item(mol_name=mol_name)

                # Get the container.
                mol_cont = cdp.mol[-1]


The same idea can be applied to the residue container.  Note that in
relax, the spin data is structured as mol-res-spin.  If there is no
residues, then all the spins will be in the first residue container
which has no name or number.  I have noticed that some organic
molecules in certain 3D structure formats are defined as having
different residues for different parts of the molecule.  So in most
cases, organic molecules will have no residues and fit into the
undefined residue container, but sometimes also be spread across a
number of residue containers.  In the XYZ structure file as there are
no residues, all spins will be in this initial unnamed and unnumbered
residue container.

If you would like to try redesigning load_spins() rather than this
modification, you will first need to revert this change.  You can do
that by typing:

$ svn merge -r13165:13164 .

This needs to be done on a clean copy of the branch (svn st shows
nothing changed), and then you commit the change.  See
https://mail.gna.org/public/relax-commits/2011-01/msg00329.html for an
example commit message (it only goes up to the 'Modified' line).  Note
the repetition of the 'svn merge' command.  This is important to be
sure that the correct revision has been reverted.

Cheers,

Edward





On 22 June 2011 17:11,  <hasu@xxxxxxxxxxxxxxxxx> wrote:
Author: han87
Date: Wed Jun 22 17:11:05 2011
New Revision: 13165

URL: http://svn.gna.org/viewcvs/relax?rev=13165&view=rev
Log:
Debugging the user function load_spins() and add_item().

In the function load_spins() in generic_fns/structure/main.py a parameter 
'res_num_exist' was added to check whether in the structural data the 
residue number exists or not. Normally in the pdb file there is a residue 
number and in the xyz file not. And then this parameter was used as a flag 
in the add_item() to avoid the Error message 'RelaxError("The residue 
number '" + repr(res_num) + "' already exists in the sequence.")' in case 
for xyz file when residue number does not exist.

Modified:
   branches/xyz/data/mol_res_spin.py
   branches/xyz/generic_fns/structure/main.py

Modified: branches/xyz/data/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/xyz/data/mol_res_spin.py?rev=13165&r1=13164&r2=13165&view=diff
==============================================================================
--- branches/xyz/data/mol_res_spin.py (original)
+++ branches/xyz/data/mol_res_spin.py Wed Jun 22 17:11:05 2011
@@ -458,7 +458,7 @@
        return text


-    def add_item(self, res_name=None, res_num=None):
+    def add_item(self, res_name=None, res_num=None, res_num_exist=None):
        """Append an empty ResidueContainer to the ResidueList."""

        # If no residue data exists, replace the empty first residue with 
this residue.
@@ -478,7 +478,8 @@
                # No residue numbers.
                else:
                    if self[i].name == res_name:
-                        raise RelaxError("The unnumbered residue name '" + 
repr(res_name) + "' already exists.")
+                        if res_num_exist==False:
+                            raise RelaxError("The unnumbered residue name 
'" + repr(res_name) + "' already exists.")

            # Append a new ResidueContainer.
            self.append(ResidueContainer(res_name, res_num))

Modified: branches/xyz/generic_fns/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/xyz/generic_fns/structure/main.py?rev=13165&r1=13164&r2=13165&view=diff
==============================================================================
--- branches/xyz/generic_fns/structure/main.py (original)
+++ branches/xyz/generic_fns/structure/main.py Wed Jun 22 17:11:05 2011
@@ -175,6 +175,7 @@
    res_names = []
    spin_nums = []
    spin_names = []
+    res_num_exist = False

    # Loop over all atoms of the spin_id selection.
    model_index = -1
@@ -185,6 +186,10 @@
            model_index = model_index + 1
            last_model = model_num

+        # Check whether the res_num exists
+        if not res_num:
+            res_num_exist = True
+
        # Remove the '+' regular expression character from the mol, res, 
and spin names!
        if mol_name and search('\+', mol_name):
            mol_name = replace(mol_name, '+', '')
@@ -237,7 +242,7 @@
        # Add the residue if it doesn't exist.
        if res_cont == None:
            # Add the residue.
-            mol_cont.res.add_item(res_name=res_name, res_num=res_num)
+            mol_cont.res.add_item(res_name=res_name, res_num=res_num, 
res_num_exist=res_num_exist)

            # Get the container.
            res_cont = mol_cont.res[-1]


_______________________________________________
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 Jun 22 18:00:15 2011