Local PDB Handlers

This module defines functions for handling local PDB folders.

pathPDBFolder(folder=None, divided=False)[source]

Returns or specify local PDB folder for storing PDB files downloaded from wwPDB servers. Files stored in this folder can be accessed via fetchPDB() from any working directory. To release the current folder, pass an invalid path, e.g. folder=''.

If divided is True, the divided folder structure of wwPDB servers will be assumed when reading from and writing to the local folder. For example, a structure with identifier 1XYZ will be present as pdblocalfolder/yz/pdb1xyz.pdb.gz.

If divided is False, a plain folder structure will be expected and adopted when saving files. For example, the same structure will be present as pdblocalfolder/1xyz.pdb.gz.

Finally, in either case, lower case letters will be used and compressed files will be stored.

pathPDBMirror(path=None, format=None)[source]

Returns or specify PDB mirror path to be used by fetchPDB(). To release the current mirror, pass an invalid path, e.g. path=''. If you are keeping a partial mirror, such as PDB files in /data/structures/divided/pdb/ folder, specify format, which is 'pdb' in this case.

fetchPDB(*pdb, **kwargs)[source]

Returns path(s) to PDB file(s) for specified pdb identifier(s). Files will be sought in user specified folder or current working directory, and then in local PDB folder and mirror, if they are available. If copy is set True, files will be copied into folder. If compressed is False, all files will be decompressed into folder. See pathPDBFolder() and pathPDBMirror() for managing local resources, fetchPDBviaFTP() and fetchPDBviaHTTP() for downloading files from PDB servers.

fetchPDBfromMirror(*pdb, **kwargs)[source]

Returns path(s) to PDB (default), PDBML, or mmCIF file(s) for specified pdb identifier(s). If a folder is specified, files will be copied into this folder. If compressed is False, files will decompressed. format argument can be used to get PDBML and mmCIF files: format='cif' will fetch an mmCIF file, and format='xml' will fetch a PDBML file. If PDBML header file is desired, noatom=True argument will do the job.

iterPDBFilenames(path=None, sort=False, unique=True, **kwargs)[source]

Yield PDB filenames in path specified by the user or in local PDB mirror (see pathPDBMirror()). When unique is True, files one of potentially identical files will be yielded (e.g. 1mkp.pdb and pdb1mkp.ent.gz1). .pdb and .ent extensions, and compressed files are considered.

findPDBFiles(path, case=None, **kwargs)[source]

Returns a dictionary that maps PDB filenames to file paths. If case is specified ('u[pper]' or 'l[ower]'), dictionary keys (filenames) will be modified accordingly. If a PDB filename has pdb prefix, it will be trimmed, for example '1mkp' will be mapped to file path ./pdb1mkp.pdb.gz). If a file is present with multiple extensions, only one of them will be returned. See also iterPDBFilenames().

fetchPDBs(*pdb, **kwargs)[source]

“Wrapper function to fetch multiple files from the PDB. If no format is given, it tries PDB then mmCIF then EMD.

Parameters:pdb – one PDB identifier or filename, or a list of them. If needed, PDB files are downloaded using fetchPDB() function.