Author: bugman Date: Thu Jun 21 10:13:22 2012 New Revision: 17012 URL: http://svn.gna.org/viewcvs/relax?rev=17012&view=rev Log: The structure.get_pos user function now prints out all data and fails if nothing was extracted. This is to prevent the user from going too far without realising that something is wrong. Modified: branches/interatomic/generic_fns/structure/main.py Modified: branches/interatomic/generic_fns/structure/main.py URL: http://svn.gna.org/viewcvs/relax/branches/interatomic/generic_fns/structure/main.py?rev=17012&r1=17011&r2=17012&view=diff ============================================================================== --- branches/interatomic/generic_fns/structure/main.py (original) +++ branches/interatomic/generic_fns/structure/main.py Thu Jun 21 10:13:22 2012 @@ -40,7 +40,7 @@ from generic_fns.structure.scientific import Scientific_data from generic_fns.structure.superimpose import fit_to_first, fit_to_mean, Pivot_finder from relax_errors import RelaxError, RelaxFileError, RelaxNoPdbError, RelaxNoSequenceError -from relax_io import get_file_path, open_write_file, write_spin_data +from relax_io import get_file_path, open_write_file, write_data, write_spin_data from relax_warnings import RelaxWarning, RelaxNoPDBFileWarning, RelaxZeroVectorWarning @@ -250,6 +250,7 @@ # Loop over all atoms of the spin_id selection. model_index = -1 last_model = None + data = [] for model_num, mol_name, res_num, res_name, atom_num, atom_name, element, pos in cdp.structure.atom_loop(atom_id=spin_id, str_id=str_id, model_num_flag=True, mol_name_flag=True, res_num_flag=True, res_name_flag=True, atom_num_flag=True, atom_name_flag=True, element_flag=True, pos_flag=True, ave=ave_pos): # Update the model info. if last_model != model_num: @@ -265,7 +266,7 @@ atom_name = replace(atom_name, '+', '') # The spin identification string. The residue name and spin num is not included to allow molecules with point mutations to be used as different models. - id = generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=None, spin_name=atom_name) + id = generate_spin_id(res_num=res_num, res_name=None, spin_name=atom_name) # Get the spin container. spin_cont = return_spin(id) @@ -281,6 +282,13 @@ if not hasattr(spin_cont, 'pos'): spin_cont.pos = [] spin_cont.pos.append(pos) + + # Store the data for a printout at the end. + data.append([id, repr(pos)]) + + # No positions found. + if not len(data): + raise RelaxError("No positional information matching the spin ID '%s' could be found." % spin_id) # Update pseudo-atoms. for spin in spin_loop(): @@ -323,6 +331,9 @@ spin.pos = ave else: spin.pos = ave[0] + + # Print out. + write_data(out=sys.stdout, headings=["Spin_ID", "Position"], data=data) def load_spins(spin_id=None, str_id=None, ave_pos=False):