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  from re import search 
28   
29   
30 -def find_pdb_files(path=None, file_root=None):
31 """Find all PDB files in the given path corresponding to the file root. 32 33 This will find all *.pdb, *.pdb.gz, and *.pdb.bz2 files, package them into a list, and return the list. 34 35 36 @keyword path: The file system path to search for the files in. 37 @type path: str 38 @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'. 39 @type file_root: str 40 """ 41 42 # Initialise. 43 files = [] 44 45 # The uncompressed version. 46 file = path+sep+file_root+'.pdb' 47 if access(file, F_OK): 48 files.append(file) 49 50 # The gzipped version. 51 file = path+sep+file_root+'.pdb.gz' 52 if access(file, F_OK): 53 files.append(file) 54 55 # The bzipped version. 56 file = path+sep+file_root+'.pdb.bz2' 57 if access(file, F_OK): 58 files.append(file) 59 60 # Return the file list. 61 return files
62