Author: bugman Date: Wed Feb 8 15:33:34 2012 New Revision: 15326 URL: http://svn.gna.org/viewcvs/relax?rev=15326&view=rev Log: Implemented the rdc.delete and pcs.delete user function backends. This code previously did not exist, although the front ends were exposed to the user! Modified: 1.3/generic_fns/pcs.py 1.3/generic_fns/rdc.py 1.3/prompt/pcs.py 1.3/prompt/rdc.py Modified: 1.3/generic_fns/pcs.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pcs.py?rev=15326&r1=15325&r2=15326&view=diff ============================================================================== --- 1.3/generic_fns/pcs.py (original) +++ 1.3/generic_fns/pcs.py Wed Feb 8 15:33:34 2012 @@ -24,6 +24,7 @@ """Module for the manipulation of pseudocontact shift data.""" # Python module imports. +from copy import deepcopy from math import pi, sqrt from numpy import array, float64, ones, zeros from numpy.linalg import norm @@ -313,6 +314,54 @@ # The main data. grace.write_xy_data(data=data, file=file, graph_type=graph_type) + + +def delete(align_id=None): + """Delete the PCS data corresponding to the alignment ID. + + @keyword align_id: The alignment tensor ID string. If not specified, all data will be deleted. + @type align_id: str or None + """ + + # Test if the current data pipe exists. + pipes.test() + + # Test if sequence data exists. + if not exists_mol_res_spin_data(): + raise RelaxNoSequenceError + + # Check that the ID exists. + if align_id and not align_id in cdp.pcs_ids: + raise RelaxError("The PCS alignment id '%s' does not exist" % align_id) + + # The IDs. + if not align_id: + ids = deepcopy(cdp.pcs_ids) + else: + ids = [align_id] + + # Loop over the alignments, removing all the corresponding data. + for id in ids: + # The PCS ID. + cdp.pcs_ids.pop(cdp.pcs_ids.index(id)) + + # The data type. + if hasattr(cdp, 'pcs_data_types') and cdp.pcs_data_types.has_key(id): + cdp.pcs_data_types.pop(id) + + # The spin data. + for spin in spin_loop(): + # The data. + if hasattr(spin, 'pcs') and spin.pcs.has_key(id): + spin.pcs.pop(id) + + # The error. + if hasattr(spin, 'pcs_err') and spin.pcs_err.has_key(id): + spin.pcs_err.pop(id) + + # Clean the global data. + if not hasattr(cdp, 'rdc_ids') or id not in cdp.rdc_ids: + cdp.align_ids.pop(id) def display(align_id=None, bc=False): Modified: 1.3/generic_fns/rdc.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/rdc.py?rev=15326&r1=15325&r2=15326&view=diff ============================================================================== --- 1.3/generic_fns/rdc.py (original) +++ 1.3/generic_fns/rdc.py Wed Feb 8 15:33:34 2012 @@ -24,6 +24,7 @@ """Module for the manipulation of RDC data.""" # Python module imports. +from copy import deepcopy from math import pi, sqrt from numpy import float64, ones, zeros from numpy.linalg import norm @@ -240,6 +241,54 @@ # The main data. grace.write_xy_data(data=data, file=file, graph_type=graph_type) + + +def delete(align_id=None): + """Delete the RDC data corresponding to the alignment ID. + + @keyword align_id: The alignment tensor ID string. If not specified, all data will be deleted. + @type align_id: str or None + """ + + # Test if the current data pipe exists. + pipes.test() + + # Test if sequence data exists. + if not exists_mol_res_spin_data(): + raise RelaxNoSequenceError + + # Check that the ID exists. + if align_id and not align_id in cdp.rdc_ids: + raise RelaxError("The RDC alignment id '%s' does not exist" % align_id) + + # The IDs. + if not align_id: + ids = deepcopy(cdp.rdc_ids) + else: + ids = [align_id] + + # Loop over the alignments, removing all the corresponding data. + for id in ids: + # The RDC ID. + cdp.rdc_ids.pop(cdp.rdc_ids.index(id)) + + # The data type. + if hasattr(cdp, 'rdc_data_types') and cdp.rdc_data_types.has_key(id): + cdp.rdc_data_types.pop(id) + + # The spin data. + for spin in spin_loop(): + # The data. + if hasattr(spin, 'rdc') and spin.rdc.has_key(id): + spin.rdc.pop(id) + + # The error. + if hasattr(spin, 'rdc_err') and spin.rdc_err.has_key(id): + spin.rdc_err.pop(id) + + # Clean the global data. + if not hasattr(cdp, 'pcs_ids') or id not in cdp.pcs_ids: + cdp.align_ids.pop(id) def display(align_id=None, bc=False): Modified: 1.3/prompt/pcs.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/pcs.py?rev=15326&r1=15325&r2=15326&view=diff ============================================================================== --- 1.3/prompt/pcs.py (original) +++ 1.3/prompt/pcs.py Wed Feb 8 15:33:34 2012 @@ -231,7 +231,7 @@ print(text) # The argument checks. - arg_check.is_str(align_id, 'alignment ID string') + arg_check.is_str(align_id, 'alignment ID string', can_be_none=True) # Execute the functional code. pcs.delete(align_id=align_id) Modified: 1.3/prompt/rdc.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/rdc.py?rev=15326&r1=15325&r2=15326&view=diff ============================================================================== --- 1.3/prompt/rdc.py (original) +++ 1.3/prompt/rdc.py Wed Feb 8 15:33:34 2012 @@ -231,7 +231,7 @@ print(text) # The argument checks. - arg_check.is_str(align_id, 'alignment ID string') + arg_check.is_str(align_id, 'alignment ID string', can_be_none=True) # Execute the functional code. rdc.delete(align_id=align_id)