mailr16945 - in /branches/interatomic: generic_fns/mol_res_spin.py user_functions/spin.py


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

Header


Content

Posted by edward on June 19, 2012 - 10:54:
Author: bugman
Date: Tue Jun 19 10:54:07 2012
New Revision: 16945

URL: http://svn.gna.org/viewcvs/relax?rev=16945&view=rev
Log:
Created the spin.isotope user function.

This is designed to be a permanent replacement for the specific analysis API 
'heteronuc_type' and
'proton_type' parameters.


Modified:
    branches/interatomic/generic_fns/mol_res_spin.py
    branches/interatomic/user_functions/spin.py

Modified: branches/interatomic/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/interatomic/generic_fns/mol_res_spin.py?rev=16945&r1=16944&r2=16945&view=diff
==============================================================================
--- branches/interatomic/generic_fns/mol_res_spin.py (original)
+++ branches/interatomic/generic_fns/mol_res_spin.py Tue Jun 19 10:54:07 2012
@@ -2679,13 +2679,49 @@
     if element not in valid_names:
         raise(RelaxError("The element name '%s' is not valid and should be 
one of the IUPAC names %s." % (element, valid_names)))
 
-
     # Set the element name for the matching spins.
     for spin, id in spin_loop(spin_id, return_id=True):
         if hasattr(spin, 'element') and spin.element and not force:
             warn(RelaxWarning("The element type of the spin '%s' is already 
set.  Set the force flag to True to rename." % id))
         else:
             spin.element = element
+
+
+def set_spin_isotope(spin_id=None, isotope=None, force=False):
+    """Set the nuclear isotope type of the spins.
+
+    @keyword spin_id:   The spin identification string.
+    @type spin_id:      str
+    @keyword isotope:   The nuclear isotope type.
+    @type isotope:      str
+    @keyword force:     A flag which if True will cause the isotope type to 
be changed.
+    @type force:        bool
+    """
+
+    # Types currently supported in relax.
+    supported_types = [
+        '1H',
+        '2H',
+        '13C',
+        '14N',
+        '15N',
+        '17O',
+        '19F',
+        '23Na',
+        '31P',
+        '113Cd'
+    ]
+
+    # Check.
+    if isotope not in supported_types:
+        raise(RelaxError("The nuclear isotope type '%s' is currently not 
supported." % isotope))
+
+    # Set the isotope type for the matching spins.
+    for spin, id in spin_loop(spin_id, return_id=True):
+        if hasattr(spin, 'isotope') and spin.isotope and not force:
+            warn(RelaxWarning("The nuclear isotope type of the spin '%s' is 
already set.  Change the force flag to True to reset." % id))
+        else:
+            spin.isotope = isotope
 
 
 def spin_id_to_data_list(id):

Modified: branches/interatomic/user_functions/spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/interatomic/user_functions/spin.py?rev=16945&r1=16944&r2=16945&view=diff
==============================================================================
--- branches/interatomic/user_functions/spin.py (original)
+++ branches/interatomic/user_functions/spin.py Tue Jun 19 10:54:07 2012
@@ -24,7 +24,7 @@
 """The spin user function definitions."""
 
 # relax module imports.
-from generic_fns.mol_res_spin import copy_spin, create_pseudo_spin, 
create_spin, delete_spin, display_spin, get_molecule_names, get_residue_ids, 
get_residue_names, get_residue_nums, get_spin_ids, id_string_doc, name_spin, 
number_spin, set_spin_element
+from generic_fns.mol_res_spin import copy_spin, create_pseudo_spin, 
create_spin, delete_spin, display_spin, get_molecule_names, get_residue_ids, 
get_residue_names, get_residue_nums, get_spin_ids, id_string_doc, name_spin, 
number_spin, set_spin_element, set_spin_isotope
 from generic_fns import pipes
 from graphics import WIZARD_IMAGE_PATH
 from user_functions.data import Uf_info; uf_info = Uf_info()
@@ -326,6 +326,53 @@
 uf.wizard_image = WIZARD_IMAGE_PATH + 'spin.png'
 
 
+# The spin.isotope user function.
+uf = uf_info.add_uf('spin.isotope')
+uf.title = "Set the spins' nuclear isotope type."
+uf.title_short = "Nuclear isotope type."
+uf.add_keyarg(
+    name = "isotope",
+    py_type = "str",
+    desc_short = "nuclear isotope name",
+    desc = "The nuclear isotope name in the AE notation - the atomic mass 
number followed by the element symbol.",
+    wiz_element_type = "combo",
+    wiz_combo_choices = ["1H", "2H", "13C", "14N", "15N", "17O", "19F", 
"23Na", "31P", "113Cd"],
+    wiz_read_only = False
+)
+uf.add_keyarg(
+    name = "spin_id",
+    py_type = "str",
+    desc_short = "spin ID string",
+    desc = "The spin identification string corresponding to one or more 
spins.",
+    wiz_element_type = 'combo',
+    wiz_combo_iter = get_spin_ids,
+    can_be_none = True
+)
+uf.add_keyarg(
+    name = "force",
+    default = False,
+    py_type = "bool",
+    arg_type = "force flag",
+    desc_short = "force flag",
+    desc = "A flag which if True will cause the nuclear isotope to be 
changed."
+)
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("This allows the nuclear isotope type of the spins 
to be set.")
+uf.desc.append(id_string_doc)
+# Prompt examples.
+uf.desc.append(Desc_container("Prompt examples"))
+uf.desc[-1].add_paragraph("The set all spins of residue 1 to the '13C' 
nuclear isotope, type one of:")
+uf.desc[-1].add_prompt("relax> spin.isotope('@1', '13C', force=True)")
+uf.desc[-1].add_prompt("relax> spin.isotope(spin_id='@1', isotope='13C', 
force=True)")
+uf.backend = set_spin_isotope
+uf.menu_text = "&isotope"
+uf.gui_icon = "relax.nuclear_symbol"
+uf.wizard_height_desc = 500
+uf.wizard_size = (1000, 750)
+uf.wizard_image = WIZARD_IMAGE_PATH + 'nuclear_symbol.png'
+
+
 # The spin.name user function.
 uf = uf_info.add_uf('spin.name')
 uf.title = "Name the spins."




Related Messages


Powered by MHonArc, Updated Tue Jun 19 11:20:02 2012