Author: bugman Date: Mon Oct 24 15:34:04 2011 New Revision: 14901 URL: http://svn.gna.org/viewcvs/relax?rev=14901&view=rev Log: The structure.read_pdb user function can now handle bzip2 or gzip compressed PDB files. Modified: 1.3/generic_fns/structure/main.py 1.3/prompt/structure.py Modified: 1.3/generic_fns/structure/main.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/main.py?rev=14901&r1=14900&r2=14901&view=diff ============================================================================== --- 1.3/generic_fns/structure/main.py (original) +++ 1.3/generic_fns/structure/main.py Mon Oct 24 15:34:04 2011 @@ -295,10 +295,14 @@ # The file path. file_path = get_file_path(file, dir) - # Try adding '.pdb' to the end of the file path, if the file can't be found. + # Try adding file extensions to the end of the file path, if the file can't be found. + file_path_orig = file_path if not access(file_path, F_OK): - file_path_orig = file_path - file_path = file_path + '.pdb' + # List of possible extensions. + for ext in ['.pdb', '.gz', '.pdb.gz', '.bz2', '.pdb.bz2']: + # Add the extension if the file can be found. + if access(file_path+ext, F_OK): + file_path = file_path + ext # Test if the file exists. if not access(file_path, F_OK): Modified: 1.3/prompt/structure.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/structure.py?rev=14901&r1=14900&r2=14901&view=diff ============================================================================== --- 1.3/prompt/structure.py (original) +++ 1.3/prompt/structure.py Mon Oct 24 15:34:04 2011 @@ -300,6 +300,8 @@ Setting the molecule name allows the molecule within the PDB (within one model) to have a custom name. If not set, then the molecules will be named after the file name, with the molecule number appended if more than one exists. Note that relax will complain if it cannot work out what to do. + + This is able to handle uncompressed, bzip2 compressed files, or gzip compressed files automatically. The full file name including extension can be supplied, however, if the file cannot be found, this function will search for the file name with '.bz2' appended followed by the file name with '.gz' appended. """ read_pdb._doc_examples = """ To load all structures from the PDB file 'test.pdb' in the directory '~/pdb', including all