mailr20160 - in /trunk: lib/selection.py pipe_control/mol_res_spin.py pipe_control/selection.py


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

Header


Content

Posted by edward on June 16, 2013 - 19:09:
Author: bugman
Date: Sun Jun 16 19:09:19 2013
New Revision: 20160

URL: http://svn.gna.org/viewcvs/relax?rev=20160&view=rev
Log:
Shifted the spin_id_to_data_list() function from pipe_control.selection to 
lib.selection.

This is because the selection object requires this function, and the function 
has nothing to do with
the relax data store.


Modified:
    trunk/lib/selection.py
    trunk/pipe_control/mol_res_spin.py
    trunk/pipe_control/selection.py

Modified: trunk/lib/selection.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/selection.py?rev=20160&r1=20159&r2=20160&view=diff
==============================================================================
--- trunk/lib/selection.py (original)
+++ trunk/lib/selection.py Sun Jun 16 19:09:19 2013
@@ -276,6 +276,78 @@
     return mol_token, res_token, spin_token
 
 
+def spin_id_to_data_list(id):
+    """Convert the single spin ID string into a list of the mol, res, and 
spin names and numbers.
+
+    @param id:  The spin ID string.
+    @type id:   str
+    @return:    The molecule name, the residue number and name, and the spin 
number and name.
+    @rtype:     str, int, str, int, str
+    """
+
+    # Split up the spin ID.
+    mol_token, res_token, spin_token = tokenise(id)
+    mol_info = parse_token(mol_token)
+    res_info = parse_token(res_token)
+    spin_info = parse_token(spin_token)
+
+    # Molecule name.
+    mol_name = None
+    if len(mol_info) > 1:
+        raise RelaxError("The single spin ID '%s' should only belong to one 
molecule, not %s." % (id, mol_info))
+    if len(mol_info) == 1:
+        mol_name = mol_info[0]
+
+    # Residue info.
+    res_names = []
+    res_nums = []
+    for i in range(len(res_info)):
+        try:
+            res_nums.append(int(res_info[i]))
+        except ValueError:
+            res_names.append(res_info[i])
+
+    # Residue number.
+    res_num = None
+    if len(res_nums) > 1:
+        raise RelaxError("The single spin ID '%s' should only belong to one 
residue number, not %s." % (id, res_info))
+    elif len(res_nums) == 1:
+        res_num = res_nums[0]
+
+    # Residue name.
+    res_name = None
+    if len(res_names) > 1:
+        raise RelaxError("The single spin ID '%s' should only belong to one 
residue name, not %s." % (id, res_info))
+    elif len(res_names) == 1:
+        res_name = res_names[0]
+
+    # Spin info.
+    spin_names = []
+    spin_nums = []
+    for i in range(len(spin_info)):
+        try:
+            spin_nums.append(int(spin_info[i]))
+        except ValueError:
+            spin_names.append(spin_info[i])
+
+    # Spin number.
+    spin_num = None
+    if len(spin_nums) > 1:
+        raise RelaxError("The single spin ID '%s' should only belong to one 
spin number, not %s." % (id, spin_info))
+    elif len(spin_nums) == 1:
+        spin_num = spin_nums[0]
+
+    # Spin name.
+    spin_name = None
+    if len(spin_names) > 1:
+        raise RelaxError("The single spin ID '%s' should only belong to one 
spin name, not %s." % (id, spin_info))
+    elif len(spin_names) == 1:
+        spin_name = spin_names[0]
+
+    # Return the data.
+    return mol_name, res_num, res_name, spin_num, spin_name
+
+
 
 class Selection(object):
     """An object containing mol-res-spin selections.

Modified: trunk/pipe_control/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/mol_res_spin.py?rev=20160&r1=20159&r2=20160&view=diff
==============================================================================
--- trunk/pipe_control/mol_res_spin.py (original)
+++ trunk/pipe_control/mol_res_spin.py Sun Jun 16 19:09:19 2013
@@ -3087,78 +3087,6 @@
             spin.isotope = isotope
 
 
-def spin_id_to_data_list(id):
-    """Convert the single spin ID string into a list of the mol, res, and 
spin names and numbers.
-
-    @param id:  The spin ID string.
-    @type id:   str
-    @return:    The molecule name, the residue number and name, and the spin 
number and name.
-    @rtype:     str, int, str, int, str
-    """
-
-    # Split up the spin ID.
-    mol_token, res_token, spin_token = tokenise(id)
-    mol_info = parse_token(mol_token)
-    res_info = parse_token(res_token)
-    spin_info = parse_token(spin_token)
-
-    # Molecule name.
-    mol_name = None
-    if len(mol_info) > 1:
-        raise RelaxError("The single spin ID '%s' should only belong to one 
molecule, not %s." % (id, mol_info))
-    if len(mol_info) == 1:
-        mol_name = mol_info[0]
-
-    # Residue info.
-    res_names = []
-    res_nums = []
-    for i in range(len(res_info)):
-        try:
-            res_nums.append(int(res_info[i]))
-        except ValueError:
-            res_names.append(res_info[i])
-
-    # Residue number.
-    res_num = None
-    if len(res_nums) > 1:
-        raise RelaxError("The single spin ID '%s' should only belong to one 
residue number, not %s." % (id, res_info))
-    elif len(res_nums) == 1:
-        res_num = res_nums[0]
-
-    # Residue name.
-    res_name = None
-    if len(res_names) > 1:
-        raise RelaxError("The single spin ID '%s' should only belong to one 
residue name, not %s." % (id, res_info))
-    elif len(res_names) == 1:
-        res_name = res_names[0]
-
-    # Spin info.
-    spin_names = []
-    spin_nums = []
-    for i in range(len(spin_info)):
-        try:
-            spin_nums.append(int(spin_info[i]))
-        except ValueError:
-            spin_names.append(spin_info[i])
-
-    # Spin number.
-    spin_num = None
-    if len(spin_nums) > 1:
-        raise RelaxError("The single spin ID '%s' should only belong to one 
spin number, not %s." % (id, spin_info))
-    elif len(spin_nums) == 1:
-        spin_num = spin_nums[0]
-
-    # Spin name.
-    spin_name = None
-    if len(spin_names) > 1:
-        raise RelaxError("The single spin ID '%s' should only belong to one 
spin name, not %s." % (id, spin_info))
-    elif len(spin_names) == 1:
-        spin_name = spin_names[0]
-
-    # Return the data.
-    return mol_name, res_num, res_name, spin_num, spin_name
-
-
 def spin_id_variants(dp=None, mol_index=None, res_index=None, 
spin_index=None):
     """Generate a list of spin ID variants for the given set of molecule, 
residue and spin indices.
 

Modified: trunk/pipe_control/selection.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/selection.py?rev=20160&r1=20159&r2=20160&view=diff
==============================================================================
--- trunk/pipe_control/selection.py (original)
+++ trunk/pipe_control/selection.py Sun Jun 16 19:09:19 2013
@@ -27,11 +27,11 @@
 
 # relax module imports.
 from pipe_control.interatomic import interatomic_loop
-from pipe_control.mol_res_spin import exists_mol_res_spin_data, 
generate_spin_id_unique, return_spin, spin_id_to_data_list, spin_loop
+from pipe_control.mol_res_spin import exists_mol_res_spin_data, 
generate_spin_id_unique, return_spin, spin_loop
 from pipe_control import pipes
 from lib.errors import RelaxError, RelaxNoDomainError, RelaxNoSequenceError
 from lib.io import read_spin_data
-from lib.selection import Selection
+from lib.selection import Selection, spin_id_to_data_list
 from lib.warnings import RelaxNoSpinWarning
 from user_functions.data import Uf_tables; uf_tables = Uf_tables()
 from user_functions.objects import Desc_container




Related Messages


Powered by MHonArc, Updated Sun Jun 16 20:00:02 2013