Package schrodinger :: Package protein :: Module getpdb
[hide private]
[frames] | no frames]

Module getpdb

Module for downloading PDB files from the web.

The data is retrieved from the following website: http://www.rcsb.org/pdb/files/

Running this module is no different from using a web-browser to access the site - it's just a different type of web client. Therefore this should cause no problems for the maintainers of that site and be within the terms and conditions of use.

Note that certain assumptions are made about the layout of the web site - changes there in future may make this script stop working.

Copyright Schrodinger, LLC. All rights reserved.

Functions [hide private]
 
_temporarize_path(filename)
This function returns a path to a file in a temporary directory that is based on the specified file name.
 
set_opener(opener)
Public function to set an opener, this allows calling code to use a custom URL opener, for example one that will prompt for a password
 
import_pdb(pdb_code, biological_unit=False)
Import the PDB file into the Project Table, using download_pdb() to get the file if it doesn't already exist in the cwd.
 
download_fasta(pdb_code, chain=None)
Attemps to download the fasta file for the given PDB ID and chain.
 
get_pdb(pdbid, source=0, caps_asis=False)
Attempts to get the specified PDB file from either the database or the web, depending on the source option.
 
retrieve_pdb(pdbid, local_repo=None, verbose=False, caps_asis=False)
Attempt to retrieve the PDB from the local repository
str
find_local_repository(verbose=False)
Determine the directory for the local repository.
 
find_local_pdb(pdbid, local_repo=None, verbose=False, caps_asis=False)
Check a series of local directories and filenames for the PDB files.
 
download_pdb(pdb_code, biological_unit=False)
Download the pdb record from NIH into the cwd.
 
download_file(pdb_code, pdb_file, url, biological_unit=False)
Download a file from a given url into the working directory.
 
get_entryimport_opts()
Returns a dictionary that describes the Maestro Import panel state.
 
set_entryimport_opts(entryimport_opts)
Assigns 'entryimport' option dictionary values.
 
import_file(file, format)
Imports a PDB format structure file into maestro, including all entries in the file into the workspace, then resets the entryimport options to the previous settings.
 
retrieve_ent(pdbid)
Retrieves the ENT file for the specified PDB ID from the third-party database and copies it to the CWD.
 
download_ent(pdbid)
Downloads the ENT file for the specified PDB ID from the RCSB web site, and saves it to the CWD.
 
get_ent(pdbid, source=0)
Attempts to get the specified ENT file from either the database or the web, depending on the source option.
Variables [hide private]
  __doc__ = ...
  maestro = None
hash(x)
  _url_opener = None
hash(x)
  AUTO = 0
  DATABASE = 1
  WEB = 2
  __package__ = 'schrodinger.protein'
Function Details [hide private]

import_pdb(pdb_code, biological_unit=False)

 

Import the PDB file into the Project Table, using download_pdb() to get the file if it doesn't already exist in the cwd.

Parameters:
  • pdb_code (string) - Four character alphanumeric string for the PDB id.
  • biological_unit (boolean) - If True, and the file needs to be downloaded, then download the file at the biological unit URL, otherwise use the typical record URL. Default is False, get the typical record.

download_fasta(pdb_code, chain=None)

 

Attemps to download the fasta file for the given PDB ID and chain.

Parameters:
  • pdb_code (str) - PDB ID of the file to download
  • chain (str or None) - The chain name to download. If None, the file will contain all chains

get_pdb(pdbid, source=0, caps_asis=False)

 

Attempts to get the specified PDB file from either the database or the web, depending on the source option. Default is AUTO, which attempts the database first, and then the web.

pdbid - string of 4 characters source - one of: AUTO, DATABASE, WEB.

Parameters:
  • caps_asis (bool) - True if the capitalization of pdbid should be preserved, False (default) if it should be converted to lowercase.

    Raises RuntimeError if file could not be retrieved.

retrieve_pdb(pdbid, local_repo=None, verbose=False, caps_asis=False)

 

Attempt to retrieve the PDB from the local repository

First we look for current files ending in .gz or .Z, then obsolete 
files with the same endings.  The file name we search for is:
    pdbXXXX.ent.Y where XXXX is the PDB code and Y is either gz or Z

@type pdbid: str
@param pdbid: the PDB code of the desired file

@type local_repo: str
@param local_repo: The location of the local pdb repository.  If not
supplied, it will be determined via find_local_repository.

@type caps_asis: bool
@param caps_asis: True if the capitalization of pdbid should be preserved,
False (default) if it should be converted to lowercase.

@rtype: str
@return: the name of the pdb file or None if a failure occurs

find_local_repository(verbose=False)

 

Determine the directory for the local repository.

Note: the location of the PDB directory can be specified via environment variables; the order of precedence is: * SCHRODINGER_PDB * SCHRODINGER_THIRDPARTY/database/pdb * SCHRODINGER/thirdparty/database/pdb (the default)

Parameters:
  • verbose (bool) - True if debugging messages should be printed to the screen
Returns: str
the path to the parent directory of the local repository. Returns an empty string if the local repository can not be determined from

find_local_pdb(pdbid, local_repo=None, verbose=False, caps_asis=False)

 

Check a series of local directories and filenames for the PDB files.

First we look for current files ending in .gz or .Z, then obsolete 
files with the same endings.  The file name we search for is:
    pdbXXXX.ent.Y where XXXX is the PDB code and Y is either gz or Z

Note: the location of the PDB directory can be specified via environment
variables; the order of precedence is:
* SCHRODINGER_PDB
* SCHRODINGER_THIRDPARTY
* SCHRODINGER/thirdparty (the default)

@type pdbid: str
@param pdbid: the PDB code of the desired file

@type local_repo: str
@param local_repo: The path to the top level of the local PDB repository

@type verbose: bool
@param verbose: True if debug messages should be printed out

@type caps_asis: bool
@param caps_asis: True if the capitalization of pdbid should be preserved,
False (default) if it should be converted to lowercase.

@rtype: str
@return: the path to an existing file ith the desired PDB code

download_pdb(pdb_code, biological_unit=False)

 

Download the pdb record from NIH into the cwd.

Parameters:
  • pdb_code (string) - Four character alphanumeric string for the PDB id.
  • biological_unit (boolean

    Raises RuntimeError if the PDB could not be downloaded.

    ) - If True, and the file needs to be downloaded, then download the file at the biological unit URL, otherwise use the typical record URL. Default is False, get the typical record.

download_file(pdb_code, pdb_file, url, biological_unit=False)

 

Download a file from a given url into the working directory.

Parameters:
  • pdb_code (str) - Four character alphanumeric string for the PDB id.
  • pdb_file (str) - The file name to create
  • url (str) - The url to get the file from
  • biological_unit (bool) - If True, and the file needs to be downloaded, then download the file at the biological unit URL, otherwise use the typical record URL. Default is False, get the typical record.
Raises:
  • RuntimeError - if the PDB could not be downloaded.

get_entryimport_opts()

 

Returns a dictionary that describes the Maestro Import panel state. 'entryimport' option keys for value

set_entryimport_opts(entryimport_opts)

 

Assigns 'entryimport' option dictionary values.

Parameters:
  • entryimport_opts (dictionary) - entryimport option keywords and values.

retrieve_ent(pdbid)

 

Retrieves the ENT file for the specified PDB ID from the third-party database and copies it to the CWD. File path is returned.

Raises RuntimeError on error.

download_ent(pdbid)

 

Downloads the ENT file for the specified PDB ID from the RCSB web site, and saves it to the CWD. File path is returned.

Raises RuntimeError on error.

get_ent(pdbid, source=0)

 

Attempts to get the specified ENT file from either the database or the web, depending on the source option. Default is AUTO, which attempts the database first, and then the web.

pdbid - string of 4 characters source - one of: AUTO, DATABASE, WEB.

Raises RuntimeError if file could not be retrieved.


Variables Details [hide private]

__doc__

Value:
"""
Module for downloading PDB files from the web.

The data is retrieved from the following website:
http://www.rcsb.org/pdb/files/

Running this module is no different from using a web-browser to access
the site - it's just a different type of web client. Therefore this sh\
...