mailr3522 - /1.3/generic_fns/residue.py


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

Header


Content

Posted by edward on November 11, 2007 - 23:07:
Author: bugman
Date: Sun Nov 11 23:07:35 2007
New Revision: 3522

URL: http://svn.gna.org/viewcvs/relax?rev=3522&view=rev
Log:
The generic_fns.residue.create() function now allows residues to be added to 
different molecules.


Modified:
    1.3/generic_fns/residue.py

Modified: 1.3/generic_fns/residue.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/residue.py?rev=3522&r1=3521&r2=3522&view=diff
==============================================================================
--- 1.3/generic_fns/residue.py (original)
+++ 1.3/generic_fns/residue.py Sun Nov 11 23:07:35 2007
@@ -102,7 +102,7 @@
         mol_to_container.res[-1].name = res_name_to
 
 
-def create(res_num=None, res_name=None):
+def create(res_num=None, res_name=None, mol_id=None):
     """Function for adding a residue into the relax data store.
 
     @param res_num:     The identification number of the new residue.
@@ -113,26 +113,39 @@
     @type mol_id:       str
     """
 
+    # Split up the selection string.
+    mol_token, res_token, spin_token = tokenise(mol_id)
+
+    # Disallowed selections.
+    if res_token != None:
+        raise RelaxResSelectDisallowError
+    if spin_token != None:
+        raise RelaxSpinSelectDisallowError
+
     # Test if the current data pipe exists.
     if not relax_data_store.current_pipe:
         raise RelaxNoPipeError
 
-    # Alias the current data pipe.
-    cdp = relax_data_store[relax_data_store.current_pipe]
+    # Get the molecule container to add the residue to.
+    mol_to_cont = return_residue(mol_id)
+    if mol_to_cont == None and mol_id:
+        raise RelaxError, "The molecule in " + `mol_id` + " does not exist 
in the current data pipe."
+    elif mol_to_cont == None:
+        mol_to_cont = relax_data_store[relax_data_store.current_pipe].mol[0]
 
     # Test if the residue number already exists.
-    for i in xrange(len(cdp.mol[0].res)):
-        if cdp.mol[0].res[i].num == res_num:
+    for i in xrange(len(mol_to_cont.res)):
+        if mol_to_cont.res[i].num == res_num:
             raise RelaxError, "The residue number '" + `res_num` + "' 
already exists in the sequence."
 
     # If no residue data exists, replace the empty first residue with this 
residue.
-    if cdp.mol[0].res[0].num == None and cdp.mol[0].res[0].name == None and 
len(cdp.mol[0].res) == 1:
-        cdp.mol[0].res[0].num = res_num
-        cdp.mol[0].res[0].name = res_name
+    if mol_to_cont.res[0].num == None and mol_to_cont.res[0].name == None 
and len(mol_to_cont.res) == 1:
+        mol_to_cont.res[0].num = res_num
+        mol_to_cont.res[0].name = res_name
 
     # Append the residue.
     else:
-        cdp.mol[0].res.add_item(res_num=res_num, res_name=res_name)
+        mol_to_cont.res.add_item(res_num=res_num, res_name=res_name)
 
 
 def delete(res_id=None):




Related Messages


Powered by MHonArc, Updated Sun Nov 11 23:40:17 2007