Package org.biojava.nbio.structure.chem
Class DownloadChemCompProvider
java.lang.Object
org.biojava.nbio.structure.chem.DownloadChemCompProvider
- All Implemented Interfaces:
ChemCompProvider
This provider of chemical components can download and cache chemical component definition files from the RCSB PDB web
site. It is the default way to access these definitions. If this provider is called he first time, it will download
and install all chemical component definitions in a local directory. Once the definition files have been installed,
it has quick startup time and low memory requirements.
An alternative provider, that keeps all definitions in memory is the
AllChemCompProvider
. Another provider,
that does not require any network access, but only can support a limited set of chemical component definitions, is
the ReducedChemCompProvider
.- Author:
- Andreas Prlic
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static String
The base URL to which the full path specified viasetChemCompPathUrlTemplate(String)
is appended. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks if the chemical components already have been installed into the PDB directory.getChemComp
(String recordName) Loads the definitions for thisChemComp
from a local file and instantiates a new object.static String
getLocalFileName
(String recordName) Returns the file name that contains the definition for thisChemComp
static File
getPath()
Get this provider's cache pathboolean
By default this provider will download only some of theChemComp
files.static void
setChemCompPathUrlTemplate
(String chemCompPathUrlTemplate) Set the path to append to the serverBaseUrl (settable insetServerBaseUrl(String)
).void
setDownloadAll
(boolean downloadAll) By default this provider will download only some of theChemComp
files.static void
setServerBaseUrl
(String serverBaseUrl) Set the base URL for the location of all chemical component CIF files, to which the chemCompPathUrlTemplate is appended, settable insetChemCompPathUrlTemplate(String)
.
-
Field Details
-
CHEM_COMP_CACHE_DIRECTORY
- See Also:
-
DEFAULT_SERVER_URL
- See Also:
-
DEFAULT_CHEMCOMP_PATHURL_TEMPLATE
- See Also:
-
serverBaseUrl
The base URL to which the full path specified viasetChemCompPathUrlTemplate(String)
is appended. It is assumed that it has a trailing slash.
-
-
Constructor Details
-
DownloadChemCompProvider
public DownloadChemCompProvider() -
DownloadChemCompProvider
-
-
Method Details
-
setServerBaseUrl
Set the base URL for the location of all chemical component CIF files, to which the chemCompPathUrlTemplate is appended, settable insetChemCompPathUrlTemplate(String)
. A trailing slash is appended if not present. -
setChemCompPathUrlTemplate
Set the path to append to the serverBaseUrl (settable insetServerBaseUrl(String)
). The string can contain placeholders that will be expanded at runtime:- "{ccd_id}" to be replaced by the chemical component identifier, in capitals
- "{ccd_id:beginIndex-endIndex}" to be replaced by a substring of the chemical component identifier in capitals,
with indices following the same convention as
String.substring(int, int)
- "{ccd_id:index}" to be replaced by a substring of the chemical component identifier in capitals, with index either a positive or negative integer to substring from left or right of the string respectively.
-
getPath
Get this provider's cache path- Returns:
-
checkDoFirstInstall
Checks if the chemical components already have been installed into the PDB directory. If not, will download the chemical components definitions file and split it up into small subfiles. -
getChemComp
Loads the definitions for thisChemComp
from a local file and instantiates a new object.- Specified by:
getChemComp
in interfaceChemCompProvider
- Parameters:
recordName
- the ID of theChemComp
- Returns:
- a new
ChemComp
definition.
-
getLocalFileName
Returns the file name that contains the definition for thisChemComp
- Parameters:
recordName
- the ID of theChemComp
- Returns:
- full path to the file
-
isDownloadAll
By default this provider will download only some of theChemComp
files. The user has to request that all files should be downloaded by setting this parameter to true.- Returns:
- flag if the all components should be downloaded and installed at startup. (default: false)
-
setDownloadAll
By default this provider will download only some of theChemComp
files. The user has to request that all files should be downloaded by setting this parameter to true.- Parameters:
downloadAll
- if the all components should be downloaded and installed at startup. (default: false)
-