Author: bugman Date: Mon Apr 7 14:00:11 2008 New Revision: 5350 URL: http://svn.gna.org/viewcvs/relax?rev=5350&view=rev Log: Renamed the generic_fns.structure.structure module to generic_fns.structure.main. Added: 1.3/generic_fns/structure/main.py - copied unchanged from r5348, 1.3/generic_fns/structure/structure.py Removed: 1.3/generic_fns/structure/structure.py Removed: 1.3/generic_fns/structure/structure.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/structure.py?rev=5349&view=auto ============================================================================== --- 1.3/generic_fns/structure/structure.py (original) +++ 1.3/generic_fns/structure/structure.py (removed) @@ -1,166 +1,0 @@ -############################################################################### -# # -# Copyright (C) 2003-2008 Edward d'Auvergne # -# # -# This file is part of the program relax. # -# # -# relax is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 2 of the License, or # -# (at your option) any later version. # -# # -# relax is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with relax; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# # -############################################################################### - -# Python module imports. -from os import F_OK, access -from warnings import warn - -# relax module imports. -from data import Data as relax_data_store -from generic_fns import molmol -from generic_fns.sequence import load_PDB_sequence -from generic_fns.selection import exists_mol_res_spin_data, spin_loop -from relax_errors import RelaxError, RelaxFileError, RelaxNoPipeError, RelaxNoSequenceError, RelaxPdbError -from relax_io import get_file_path -from relax_warnings import RelaxNoPDBFileWarning - - - -def read_pdb(run=None, file=None, dir=None, model=None, load_seq=1, fail=1, verbosity=1): - """The pdb loading function.""" - - # Tests. - ######## - - # Test if the current data pipe exists. - if not relax_data_store.current_pipe: - raise RelaxNoPipeError - - # Alias the current data pipe. - cdp = relax_data_store[relax_data_store.current_pipe] - - # Test if PDB data corresponding to the run already exists. - if hasattr(cdp, 'struct'): - raise RelaxPdbError - - # Test if sequence data is loaded. - if not load_seq and not exists_mol_res_spin_data(): - raise RelaxNoSequenceError - - # The file path. - file_path = get_file_path(file, dir) - - # Test if the file exists. - if not access(file_path, F_OK): - if fail: - raise RelaxFileError, ('PDB', file_path) - else: - warn(RelaxNoPDBFileWarning(file_path)) - return - - - # Data creation. - ################ - - # File name. - cdp.structure.file_name = file_path - - # Model. - cdp.structure.model = model - - - # Load the structures. - ###################### - - load_structures(file_path, model, verbosity) - - - # Finish. - ######### - - # Sequence loading. - if load_seq and not exists_mol_res_spin_data(): - load_PDB_sequence() - - # Load into Molmol (if running). - molmol.open_pdb() - - -def set_vector(spin=None, xh_vect=None): - """Place the XH unit vector into the spin container object. - - @keyword spin: The spin container object. - @type spin: SpinContainer instance - @keyword xh_vect: The unit vector parallel to the XH bond. - @type xh_vect: array of len 3 - """ - - # Place the XH unit vector into the container. - spin.xh_vect = xh_vect - - -def vectors(heteronuc=None, proton=None, spin_id=None, verbosity=1): - """Function for calculating/extracting the XH unit vector from the loaded structure. - - @param heteronuc: The name of the heteronucleus. - @type heteronuc: str - @param proton: The name of the proton. - @type proton: str - @param spin_id: The molecule, residue, and spin identifier string. - @type spin_id: str - @param verbosity: The higher the value, the more information is printed to screen. - @type verbosity: int - """ - - # Alias the current data pipe. - cdp = relax_data_store[relax_data_store.current_pipe] - - # Test if the PDB file has been loaded. - if not hasattr(cdp, 'structure'): - raise RelaxPdbError - - # Test if sequence data is loaded. - if not exists_mol_res_spin_data(): - raise RelaxNoSequenceError - - # Test that the nuclei have been correctly set. - if heteronuc == proton: - raise RelaxError, "The proton and heteronucleus are set to the same atom." - - # Number of structures. - num_str = len(cdp.structure.structures) - - # Print out. - if verbosity: - if num_str > 1: - print "\nCalculating and averaging the unit XH vectors from all structures." - else: - print "\nCalculating the unit XH vectors from the structure." - - # Loop over the sequence. - for spin in spin_loop(spin_id): - # Skip unselected residues. - if not spin.select: - continue - - # Set the proton and heteronucleus names. - spin.proton = proton - spin.heteronuc = heteronuc - - # Calculate the vector. - vector = xh_vector(spin) - - # Set the vector and deselect the spin if the vector doesn't exist. - if vector != None: - spin.xh_vect = vector - else: - spin.select = False