Package lib :: Package structure :: Module files
[hide private]
[frames] | no frames]

Source Code for Module lib.structure.files

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 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  # Module docstring. 
23  """Module for handling different structural file formats.""" 
24   
25  # Python module imports. 
26  from os import F_OK, access, sep 
27   
28   
29 -def find_pdb_files(path=None, file_root=None):
30 """Find all PDB files in the given path corresponding to the file root. 31 32 This will find all *.pdb, *.pdb.gz, and *.pdb.bz2 files, package them into a list, and return the list. 33 34 35 @keyword path: The file system path to search for the files in. 36 @type path: str 37 @keyword file_root: The file root of the files to find. For example if the file is 'test.pdb.gz', then the file root is 'test'. 38 @type file_root: str 39 """ 40 41 # Initialise. 42 files = [] 43 44 # The uncompressed version. 45 file = path+sep+file_root+'.pdb' 46 if access(file, F_OK): 47 files.append(file) 48 49 # The gzipped version. 50 file = path+sep+file_root+'.pdb.gz' 51 if access(file, F_OK): 52 files.append(file) 53 54 # The bzipped version. 55 file = path+sep+file_root+'.pdb.bz2' 56 if access(file, F_OK): 57 files.append(file) 58 59 # Return the file list. 60 return files
61