Author: bugman Date: Fri Jan 18 12:21:25 2013 New Revision: 18217 URL: http://svn.gna.org/viewcvs/relax?rev=18217&view=rev Log: Implemented the pcs.set_error user function. Modified: trunk/generic_fns/pcs.py trunk/user_functions/pcs.py Modified: trunk/generic_fns/pcs.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/pcs.py?rev=18217&r1=18216&r2=18217&view=diff ============================================================================== --- trunk/generic_fns/pcs.py (original) +++ trunk/generic_fns/pcs.py Fri Jan 18 12:21:25 2013 @@ -668,6 +668,54 @@ cdp.pcs_ids.append(align_id) +def set_errors(align_id=None, spin_id=None, sd=None): + """Set the PCS errors if not already present. + + @keyword align_id: The optional alignment tensor ID string. + @type align_id: str + @keyword spin_id: The optional spin ID string. + @type spin_id: None or str + @keyword sd: The PCS standard deviation in ppm. + @type sd: float or int. + """ + + # Test if sequence data exists. + if not exists_mol_res_spin_data(): + raise RelaxNoSequenceError + + # Test if data corresponding to 'align_id' exists. + if not hasattr(cdp, 'pcs_ids') or (align_id and align_id not in cdp.pcs_ids): + raise RelaxNoPCSError(align_id) + + # Arg check. + if align_id and align_id not in cdp.pcs_ids: + raise RelaxError("The alignment ID '%s' is not in the PCS ID list %s." % (align_id, cdp.pcs_ids)) + + # Convert the align IDs to an array, or take all IDs. + if align_id: + align_ids = [align_id] + else: + align_ids = cdp.pcs_ids + + # Loop over the spins. + for spin in spin_loop(spin_id): + # Skip deselected spins. + if not spin.select: + continue + + # Skip spins with no PCSs. + if not hasattr(spin, 'pcs') or (align_id and not align_id in spin.pcs): + continue + + # No data structure. + if not hasattr(spin, 'pcs_err'): + spin.pcs_err = {} + + # Set the error. + for id in align_ids: + spin.pcs_err[id] = sd + + def structural_noise(align_id=None, rmsd=0.2, sim_num=1000, file=None, dir=None, force=False): """Determine the PCS error due to structural noise via simulation. Modified: trunk/user_functions/pcs.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/pcs.py?rev=18217&r1=18216&r2=18217&view=diff ============================================================================== --- trunk/user_functions/pcs.py (original) +++ trunk/user_functions/pcs.py Fri Jan 18 12:21:25 2013 @@ -32,6 +32,7 @@ # relax module imports. from generic_fns import align_tensor, pcs, pipes +from generic_fns.mol_res_spin import get_spin_ids from graphics import WIZARD_IMAGE_PATH from user_functions.data import Uf_info; uf_info = Uf_info() from user_functions.objects import Desc_container @@ -388,6 +389,45 @@ uf.gui_icon = "oxygen.actions.document-open" uf.wizard_height_desc = 250 uf.wizard_size = (1000, 750) +uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' + + +# The pcs.set_errors user function. +uf = uf_info.add_uf('pcs.set_errors') +uf.title = "Set the errors for the PCSs." +uf.title_short = "PCS error setting." +uf.add_keyarg( + name = "align_id", + py_type = "str", + desc_short = "alignment ID string", + desc = "The optional alignment ID string.", + wiz_element_type = 'combo', + wiz_combo_iter = align_tensor.get_ids, + wiz_read_only = True, + can_be_none = True +) +uf.add_keyarg( + name = "spin_id", + py_type = "str", + arg_type = "spin ID", + desc_short = "spin ID string", + desc = "The optional spin ID string.", + #wiz_combo_iter = get_spin_ids, + can_be_none = True +) +uf.add_keyarg( + name = "sd", + default = 0.1, + py_type = "num", + desc_short = "PCS error (ppm)", + desc = "The PCS standard deviation value in ppm." +) +# Description. +uf.desc.append(Desc_container()) +uf.desc[-1].add_paragraph("If the PCS errors have not already been read from a PCS data file or if they need to be changed, then the errors can be set via this user function.") +uf.backend = pcs.set_errors +uf.menu_text = "&set_errors" +uf.gui_icon = "oxygen.actions.edit-rename" uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png'