BioJava can automatically download and install most of the data files that it needs. Those downloads will happen only once. Future requests for the data file will re-use the local copy.
The main class that provides this functionality is the AtomCache.
It is hidden inside the StructureIO class, that we already encountered earlier.
Structure structure = StructureIO.getStructure("4hhb");
is the same as
AtomCache cache = new AtomCache();
cache.getStructure("4hhb");
By default the AtomCache writes all files into a temporary location (The system temp directory "java.io.tempdir").
If you already have a local PDB installation, or you want to use a more permanent location to store the files, you can configure the AtomCache by setting the PDB_DIR system property
-DPDB_DIR=/wherever/you/want/
An alternative is to hard-code the path in this way (but setting it as a property is better style)
AtomCache cache = new AtomCache();
cache.setPath("/path/to/pdb/files/");
The AtomCache also provides access to configuring various options that are available during the parsing of files. The FileParsingParameters class is the main place to influence the level of detail and as a consequence the speed with which files can be loaded.
This example turns on the use of chemical components when loading a structure. (See also the next chapter)
AtomCache cache = new AtomCache();
cache.setPath("/tmp/");
FileParsingParameters params = cache.getFileParsingParams();
params.setLoadChemCompInfo(true);
StructureIO.setAtomCache(cache);
Structure structure = StructureIO.getStructure("4hhb");