Package pipe_control :: Package structure :: Module checks
[hide private]
[frames] | no frames]

Source Code for Module pipe_control.structure.checks

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2003-2014 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # relax module imports. 
23  from lib.checks import Check 
24  from lib.errors import RelaxError 
25  from pipe_control.pipes import cdp_name, get_pipe 
26   
27   
28 -def check_structure_func(pipe_name=None):
29 """Test if structural data is present. 30 31 @return: The initialised RelaxError object or nothing. 32 @rtype: None or RelaxError instance 33 """ 34 35 # Defaults. 36 if pipe_name == None: 37 pipe_name = cdp_name() 38 39 # Get the data pipe. 40 dp = get_pipe(pipe_name) 41 42 # Test if the structure exists. 43 if not hasattr(dp, 'structure'): 44 return RelaxError("No structural data is present in the current data pipe.") 45 46 # Check for models: 47 if not dp.structure.num_models(): 48 return RelaxError("The structural object in the current data pipe contains no models.") 49 50 # Check for molecules. 51 if not dp.structure.num_molecules(): 52 return RelaxError("The structural object in the current data pipe contains no molecules.")
53 54 # Create the checking object. 55 check_structure = Check(check_structure_func) 56