Author: bugman Date: Wed Oct 26 11:51:44 2011 New Revision: 14924 URL: http://svn.gna.org/viewcvs/relax?rev=14924&view=rev Log: Shifted the structural API calc_displacement() method into the main module. Modified: 1.3/generic_fns/structure/api_base.py 1.3/generic_fns/structure/internal.py 1.3/generic_fns/structure/main.py Modified: 1.3/generic_fns/structure/api_base.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/api_base.py?rev=14924&r1=14923&r2=14924&view=diff ============================================================================== --- 1.3/generic_fns/structure/api_base.py (original) +++ 1.3/generic_fns/structure/api_base.py Wed Oct 26 11:51:44 2011 @@ -184,21 +184,6 @@ raise RelaxImplementError - def calc_displacement(self, model_from=None, model_to=None, atom_id=None): - """Calculate the rotational and translational displacement between two structural models. - - @keyword model_from: The optional model number for the starting position of the displacement. - @type model_from: int or None - @keyword model_to: The optional model number for the ending position of the displacement. - @type model_to: int or None - @keyword atom_id: The molecule, residue, and atom identifier string. This matches the spin ID string format. - @type atom_id: str or None - """ - - # Raise the error. - raise RelaxImplementError - - def delete(self): """Prototype method stub for deleting all structural data from the current data pipe.""" Modified: 1.3/generic_fns/structure/internal.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/internal.py?rev=14924&r1=14923&r2=14924&view=diff ============================================================================== --- 1.3/generic_fns/structure/internal.py (original) +++ 1.3/generic_fns/structure/internal.py Wed Oct 26 11:51:44 2011 @@ -781,58 +781,6 @@ return data - def calc_displacement(self, model_from=None, model_to=None, atom_id=None, centroid=None): - """Calculate the rotational and translational displacement between two structural models. - - @keyword model_from: The optional model number for the starting position of the displacement. - @type model_from: int or None - @keyword model_to: The optional model number for the ending position of the displacement. - @type model_to: int or None - @keyword atom_id: The molecule, residue, and atom identifier string. This matches the spin ID string format. - @type atom_id: str or None - @keyword centroid: An alternative position of the centroid, used for studying pivoted systems. - @type centroid: list of float or numpy rank-1, 3D array - """ - - # Convert the model_from and model_to args to lists, is supplied. - if model_from != None: - model_from = [model_from] - if model_to != None: - model_to = [model_to] - - # Create a list of all models. - models = [] - for model in self.model_loop(): - models.append(model.num) - - # Set model_from or model_to to all models if None. - if model_from == None: - model_from = models - if model_to == None: - model_to = models - - # Initialise the data structure. - if not hasattr(self, 'displacements'): - self.displacements = Displacements() - - # Loop over the starting models. - for i in range(len(model_from)): - # Assemble the atomic coordinates. - coord_from = [] - for pos in self.atom_loop(atom_id=atom_id, model_num=model_from[i], pos_flag=True): - coord_from.append(pos[0]) - - # Loop over the ending models. - for j in range(len(model_to)): - # Assemble the atomic coordinates. - coord_to = [] - for pos in self.atom_loop(atom_id=atom_id, model_num=model_to[j], pos_flag=True): - coord_to.append(pos[0]) - - # Send to the base container for the calculations. - self.displacements._calculate(model_from=model_from[i], model_to=model_to[j], coord_from=array(coord_from), coord_to=array(coord_to), centroid=centroid) - - def delete(self): """Delete all the structural information.""" Modified: 1.3/generic_fns/structure/main.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/main.py?rev=14924&r1=14923&r2=14924&view=diff ============================================================================== --- 1.3/generic_fns/structure/main.py (original) +++ 1.3/generic_fns/structure/main.py Wed Oct 26 11:51:44 2011 @@ -34,6 +34,7 @@ from generic_fns import molmol, relax_re from generic_fns.mol_res_spin import create_spin, exists_mol_res_spin_data, generate_spin_id, linear_ave, return_molecule, return_residue, return_spin, spin_loop from generic_fns import pipes +from generic_fns.structure.api_base import Displacements from generic_fns.structure.internal import Internal from generic_fns.structure.scientific import Scientific_data from relax_errors import RelaxError, RelaxFileError, RelaxNoPdbError, RelaxNoSequenceError @@ -63,8 +64,6 @@ def displacement(model_from=None, model_to=None, atom_id=None, centroid=None): """Calculate the rotational and translational displacement between two structural models. - - This will just redirect straight to the API. @keyword model_from: The optional model number for the starting position of the displacement. @type model_from: int or None @@ -76,7 +75,43 @@ @type centroid: list of float or numpy rank-1, 3D array """ - cdp.structure.calc_displacement(model_from=model_from, model_to=model_to, atom_id=atom_id, centroid=centroid) + # Convert the model_from and model_to args to lists, is supplied. + if model_from != None: + model_from = [model_from] + if model_to != None: + model_to = [model_to] + + # Create a list of all models. + models = [] + for model in cdp.structure.model_loop(): + models.append(model.num) + + # Set model_from or model_to to all models if None. + if model_from == None: + model_from = models + if model_to == None: + model_to = models + + # Initialise the data structure. + if not hasattr(cdp.structure, 'displacements'): + cdp.structure.displacements = Displacements() + + # Loop over the starting models. + for i in range(len(model_from)): + # Assemble the atomic coordinates. + coord_from = [] + for pos in cdp.structure.atom_loop(atom_id=atom_id, model_num=model_from[i], pos_flag=True): + coord_from.append(pos[0]) + + # Loop over the ending models. + for j in range(len(model_to)): + # Assemble the atomic coordinates. + coord_to = [] + for pos in cdp.structure.atom_loop(atom_id=atom_id, model_num=model_to[j], pos_flag=True): + coord_to.append(pos[0]) + + # Send to the base container for the calculations. + cdp.structure.displacements._calculate(model_from=model_from[i], model_to=model_to[j], coord_from=array(coord_from), coord_to=array(coord_to), centroid=centroid) def get_pos(spin_id=None, str_id=None, ave_pos=False):