Author: bugman Date: Mon Dec 17 10:29:12 2012 New Revision: 18145 URL: http://svn.gna.org/viewcvs/relax?rev=18145&view=rev Log: Created the generic_fns.interatomic.consistent_interatomic_data() function for checking data consistency. Modified: trunk/generic_fns/interatomic.py Modified: trunk/generic_fns/interatomic.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/interatomic.py?rev=18145&r1=18144&r2=18145&view=diff ============================================================================== --- trunk/generic_fns/interatomic.py (original) +++ trunk/generic_fns/interatomic.py Mon Dec 17 10:29:12 2012 @@ -30,7 +30,7 @@ # relax module imports. from generic_fns import pipes from generic_fns.mol_res_spin import Selection, count_spins, return_spin, spin_loop -from relax_errors import RelaxError, RelaxInteratomError, RelaxNoInteratomError, RelaxNoSpinError +from relax_errors import RelaxError, RelaxInteratomError, RelaxInteratomInconsistentError, RelaxNoInteratomError, RelaxNoSpinError from relax_io import write_data @@ -115,6 +115,37 @@ write_data(out=sys.stdout, headings=["Spin_ID_1", "Spin_ID_2"], data=ids) +def consistent_interatomic_data(pipe1=None, pipe2=None): + """Check that the interatomic data is consistent between two data pipes. + + @keyword pipe1: The name of the first data pipe to compare. + @type pipe1: str + @keyword pipe2: The name of the second data pipe to compare. + @type pipe2: str + @raises RelaxError: If the data is inconsistent. + """ + + # Get the data pipes. + dp1 = pipes.get_pipe(pipe1) + dp2 = pipes.get_pipe(pipe2) + + # Check the data lengths. + if len(dp1.interatomic) != len(dp2.interatomic): + raise RelaxInteratomInconsistentError(pipe1, pipe2) + + # Loop over the interatomic data. + for i in range(len(dp1.interatomic)): + # Alias the containers. + interatom1 = dp1.interatomic[i] + interatom2 = dp2.interatomic[i] + + # Check the spin IDs. + if interatom1.spin_id1 != interatom2.spin_id1: + raise RelaxInteratomInconsistentError(pipe1, pipe2) + if interatom1.spin_id2 != interatom2.spin_id2: + raise RelaxInteratomInconsistentError(pipe1, pipe2) + + def create_interatom(spin_id1=None, spin_id2=None, pipe=None): """Create and return the interatomic data container for the two spins.