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