Author: bugman Date: Tue Mar 1 18:16:32 2011 New Revision: 12661 URL: http://svn.gna.org/viewcvs/relax?rev=12661&view=rev Log: Converted the relax_data.delete() user function back and front end to the new design. Modified: branches/relax_data/generic_fns/relax_data.py branches/relax_data/prompt/relax_data.py Modified: branches/relax_data/generic_fns/relax_data.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_data/generic_fns/relax_data.py?rev=12661&r1=12660&r2=12661&view=diff ============================================================================== --- branches/relax_data/generic_fns/relax_data.py (original) +++ branches/relax_data/generic_fns/relax_data.py Tue Mar 1 18:16:32 2011 @@ -494,13 +494,11 @@ return names -def delete(ri_label=None, frq_label=None): - """Delete relaxation data corresponding to the Ri and frequency labels. - - @param ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. - @type ri_label: str - @param frq_label: The field strength label. - @type frq_label: str +def delete(ri_id=None): + """Delete relaxation data corresponding to the relaxation data ID. + + @keyword ri_id: The relaxation data ID string. + @type ri_id: str """ # Test if the current pipe exists. @@ -510,52 +508,15 @@ if not exists_mol_res_spin_data(): raise RelaxNoSequenceError - # Test if data corresponding to 'ri_label' and 'frq_label' exists. - if not test_labels(ri_label, frq_label): - raise RelaxNoRiError(ri_label, frq_label) + # Test if data exists. + if not hasattr(cdp, 'ri_ids') or ri_id not in cdp.ri_ids: + raise RelaxNoRiError(ri_id) # Loop over the spins. for spin in spin_loop(): - # Global data flag. - global_flag = False - - # Find the index corresponding to 'ri_label' and 'frq_label'. - index = find_ri_index(spin, ri_label, frq_label) - - # Catch any problems. - if index == None: - continue - # Relaxation data and errors. - spin.relax_data.pop(index) - spin.relax_error.pop(index) - - # Update the number of relaxation data points. - spin.num_ri = spin.num_ri - 1 - - # Delete ri_label from the data types. - spin.ri_labels.pop(index) - - # Update the remap table. - spin.remap_table.pop(index) - - # Find if there is other data corresponding to 'frq_label' - frq_index = spin.frq_labels.index(frq_label) - if not frq_index in spin.remap_table: - # Update the number of frequencies. - spin.num_frq = spin.num_frq - 1 - - # Update the frequency labels. - spin.frq_labels.pop(frq_index) - - # Update the frequency array. - spin.frq.pop(frq_index) - - # Update the NOE R1 translation table. - spin.noe_r1_table.pop(index) - for j in xrange(spin.num_ri): - if spin.noe_r1_table[j] > index: - spin.noe_r1_table[j] = spin.noe_r1_table[j] - 1 + del spin.relax_data[ri_id] + del spin.relax_error[ri_id] def display(ri_label=None, frq_label=None): Modified: branches/relax_data/prompt/relax_data.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_data/prompt/relax_data.py?rev=12661&r1=12660&r2=12661&view=diff ============================================================================== --- branches/relax_data/prompt/relax_data.py (original) +++ branches/relax_data/prompt/relax_data.py Tue Mar 1 18:16:32 2011 @@ -124,38 +124,34 @@ relax_data.copy(pipe_from=pipe_from, pipe_to=pipe_to, ri_id=ri_id) - def delete(self, ri_label=None, frq_label=None): - """Function for deleting the relaxation data corresponding to ri_label and frq_label. - - Keyword Arguments - ~~~~~~~~~~~~~~~~~ - - ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. - - frq_label: The field strength label. + def delete(self, ri_id=None): + """Delete the relaxation data corresponding to the relaxation data ID string. + + Keyword Arguments + ~~~~~~~~~~~~~~~~~ + + ri_id: The relaxation data ID string. Examples ~~~~~~~~ - To delete the relaxation data corresponding to ri_label='NOE', frq_label='600', type: - - relax> relax_data.delete('NOE', '600') + To delete the relaxation data corresponding to the ID 'NOE_600', type: + + relax> relax_data.delete('NOE_600') """ # Function intro text. if self._exec_info.intro: text = self._exec_info.ps3 + "relax_data.delete(" - text = text + "ri_label=" + repr(ri_label) - text = text + ", frq_label=" + repr(frq_label) + ")" - print(text) - - # The argument checks. - arg_check.is_str(ri_label, 'relaxation label') - arg_check.is_str(frq_label, 'frequency label') - - # Execute the functional code. - relax_data.delete(ri_label=ri_label, frq_label=frq_label) + text = text + "ri_id=" + repr(ri_id) + ")" + print(text) + + # The argument checks. + arg_check.is_str(ri_id, 'relaxation data ID string') + + # Execute the functional code. + relax_data.delete(ri_id=ri_id) def display(self, ri_label=None, frq_label=None):