Author: bugman Date: Wed Dec 3 22:30:16 2008 New Revision: 8115 URL: http://svn.gna.org/viewcvs/relax?rev=8115&view=rev Log: The centre_of_mass() function now only throws warnings rather than RelaxErrors. This allows the CoM to be calculated even if a few elements are unknown or if the element record is missing. Modified: 1.3/generic_fns/structure/mass.py Modified: 1.3/generic_fns/structure/mass.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/mass.py?rev=8115&r1=8114&r2=8115&view=diff ============================================================================== --- 1.3/generic_fns/structure/mass.py (original) +++ 1.3/generic_fns/structure/mass.py Wed Dec 3 22:30:16 2008 @@ -22,12 +22,14 @@ # Python module imports. from numpy import float64, zeros +from warnings import warn # relax module imports. from generic_fns.mol_res_spin import return_molecule, return_residue, return_spin from generic_fns import pipes from physical_constants import return_atomic_mass from relax_errors import RelaxError, RelaxNoPdbError +from relax_warnings import RelaxWarning @@ -90,10 +92,13 @@ # No element? if element == None: - raise RelaxError, "The element corresponding to '%s' does not exist in the PDB file. Cannot calculate the centre of mass." % id + warn(RelaxWarning("Skipping the atom '%s' as the element name does not exist in the PDB file." % id)) # Atomic mass. - mass = return_atomic_mass(element) + try: + mass = return_atomic_mass(element) + except RelaxError: + warn(RelaxWarning("Skipping the atom '%s' as the element '%s' is unknown." % (id, element))) # Total mass. M = M + mass