mailr24788 - /trunk/pipe_control/mol_res_spin.py


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

Header


Content

Posted by edward on July 29, 2014 - 10:11:
Author: bugman
Date: Tue Jul 29 10:11:14 2014
New Revision: 24788

URL: http://svn.gna.org/viewcvs/relax?rev=24788&view=rev
Log:
Implemented the pipe_control.mol_res_spin.format_info_full() function.

This follows from 
http://thread.gmane.org/gmane.science.nmr.relax.scm/22522/focus=6534.

This is a verbose representation of the spin information which can be used 
for presenting to the
user.  Functions for shorter string versions will also be of great use, for 
example as described by
Troels at 
http://thread.gmane.org/gmane.science.nmr.relax.scm/22522/focus=6535.


Modified:
    trunk/pipe_control/mol_res_spin.py

Modified: trunk/pipe_control/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/mol_res_spin.py?rev=24788&r1=24787&r2=24788&view=diff
==============================================================================
--- trunk/pipe_control/mol_res_spin.py  (original)
+++ trunk/pipe_control/mol_res_spin.py  Tue Jul 29 10:11:14 2014
@@ -1249,6 +1249,74 @@
 
     # The first residue number.
     return mol.res[0].num
+
+
+def format_info_full(mol_name=None, res_num=None, res_name=None, 
spin_num=None, spin_name=None):
+    """Format the molecule, residue, and spin information as a string, 
skipping missing information.
+
+    This will be a verbose representation.  If:
+
+        mol_name = 'Ubi'
+        res_name = 'Ala'
+        res_num = '10'
+        spin_num = None
+        spin_name = 'N'
+
+    Then the returned string will be "Molecule Ubi, residue Ala 10, spin N". 
 Any values of None will result in that part of the string being suppressed.
+
+
+    @keyword mol_name:  The molecule name.
+    @type mol_name:     str or None
+    @keyword res_num:   The residue number.
+    @type res_num:      int or None
+    @keyword res_name:  The residue name.
+    @type res_name:     str or None
+    @keyword spin_num:  The spin number.
+    @type spin_num:     int or None
+    @keyword spin_name: The spin name.
+    @type spin_name:    str or None
+    @return:            The formatted string containing all the molecule, 
residue and spin information.
+    @rtype:             str
+    """
+
+    # Init.
+    string = ''
+
+    # The molecule information.
+    if mol_name != None:
+        string += "Molecule %s" % mol_name
+
+    # The residue information.
+    if res_num != None or res_name != None:
+        # Starting string.
+        if not len(string):
+            string += "Residue"
+        else:
+            string += ", residue"
+
+        # The residue name.
+        if res_name != None:
+            string += " %s" % res_name
+
+        # The residue number.
+        if res_num != None:
+            string += " %s" % res_num
+
+    # The spin information.
+    if spin_num != None or spin_name != None:
+        # Starting string.
+        if not len(string):
+            string += "Spin"
+        else:
+            string += ", spin"
+
+        # The spin name.
+        if spin_name != None:
+            string += " %s" % spin_name
+
+        # The spin number.
+        if spin_num != None:
+            string += " %s" % spin_num
 
 
 def generate_spin_id(pipe_cont=None, pipe_name=None, mol_name=None, 
res_num=None, res_name=None, spin_num=None, spin_name=None):




Related Messages


Powered by MHonArc, Updated Tue Jul 29 10:40:02 2014