public abstract class LocalPDBDirectory extends Object implements StructureIOFile
PDBFileReader
and MMCIFFileReader
. The basic
functionality of downloading structure files from the FTP site is gathered
here, making the child classes responsible for only the specific paths and
file formats needed.Modifier and Type | Class and Description |
---|---|
static class |
LocalPDBDirectory.FetchBehavior
Controls when the class should fetch files from the ftp server
|
static class |
LocalPDBDirectory.ObsoleteBehavior
Behaviors for when an obsolete structure is requested.
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PDB_FILE_SERVER
The default server name, prefixed by the protocol string (http:// or ftp://).
|
static long |
LAST_REMEDIATION_DATE
Date of the latest PDB file remediation
|
protected static String |
lineSplit |
static long |
MIN_PDB_FILE_SIZE
Minimum size for a valid structure file (CIF or PDB), in bytes
|
static String |
PDB_FILE_SERVER_PROPERTY |
Constructor and Description |
---|
LocalPDBDirectory() |
LocalPDBDirectory(String path)
Subclasses should provide default and single-string constructors.
|
Modifier and Type | Method and Description |
---|---|
void |
addExtension(String s)
define supported file extensions
compressed extensions .Z,.gz do not need to be specified
they are dealt with automatically.
|
protected boolean |
checkFileExists(String pdbId) |
void |
clearExtensions()
clear the supported file extensions
|
boolean |
deleteStructure(String pdbId)
Attempts to delete all versions of a structure from the local directory.
|
protected File |
downloadStructure(String pdbId)
Downloads an MMCIF file from the PDB to the local path
|
protected File |
getDir(String pdbId,
boolean obsolete)
Gets the directory in which the file for a given MMCIF file would live,
creating it if necessary.
|
List<String> |
getExtensions()
Returns a list of extensions supported by this class
|
LocalPDBDirectory.FetchBehavior |
getFetchBehavior()
Get the behavior for fetching files from the server
|
protected abstract String |
getFilename(String pdbId)
Converts a PDB ID into a filename with the proper extension
|
FileParsingParameters |
getFileParsingParameters()
Get the parameters that should be used for file parsing
|
protected InputStream |
getInputStream(String pdbId)
Load or download the specified structure and return it as an InputStream
for direct parsing.
|
File |
getLocalFile(String pdbId)
Searches for previously downloaded files
|
LocalPDBDirectory.ObsoleteBehavior |
getObsoleteBehavior()
Returns how this instance deals with obsolete entries.
|
protected abstract String[] |
getObsoleteDirPath()
Location of obsolete files within the directory, as an array of paths.
|
String |
getPath()
Returns the path value.
|
static String |
getServerName()
Return the String with the PDB server name, including the leading protocol
String (http:// or ftp://).
|
protected abstract String[] |
getSplitDirPath()
Location of split files within the directory, as an array of paths.
|
Structure |
getStructure(File filename)
Read file from File and returns
a Structure object.
|
abstract Structure |
getStructure(InputStream inStream)
Handles the actual parsing of the file into a Structure object.
|
Structure |
getStructure(String filename)
Open filename and return a Structure object.
|
Structure |
getStructure(URL u) |
Structure |
getStructureById(String pdbId)
Get the structure for a PDB ID
|
protected void |
initPaths()
Should be called whenever any of the path variables change.
|
void |
prefetchStructure(String pdbId)
Download a structure, but don't parse it yet or store it in memory.
|
void |
setFetchBehavior(LocalPDBDirectory.FetchBehavior fetchBehavior)
Set the behavior for fetching files from the server.
|
void |
setFileParsingParameters(FileParsingParameters params)
Set the parameters that should be used for file parsing
|
void |
setObsoleteBehavior(LocalPDBDirectory.ObsoleteBehavior behavior)
[Optional] This method changes the behavior when obsolete entries
are requested.
|
void |
setPath(String p)
Sets the path for the directory where PDB files are read/written
|
public static final String DEFAULT_PDB_FILE_SERVER
public static final String PDB_FILE_SERVER_PROPERTY
public static final long LAST_REMEDIATION_DATE
public static final long MIN_PDB_FILE_SIZE
public LocalPDBDirectory(String path)
addExtension(String)
to add one or more extensions.
If path is null, initialize using the system property/environment variable
UserConfiguration.PDB_DIR
.
path
- Path to the PDB file directorypublic LocalPDBDirectory()
public void setPath(String p)
public String getPath()
setPath(java.lang.String)
public void addExtension(String s)
addExtension
in interface StructureIOFile
s
- a String ...public List<String> getExtensions()
StructureIOFile
getExtensions
in interface StructureIOFile
public void clearExtensions()
public void setFileParsingParameters(FileParsingParameters params)
StructureProvider
setFileParsingParameters
in interface StructureProvider
params
- FileParsingParameterspublic FileParsingParameters getFileParsingParameters()
StructureProvider
getFileParsingParameters
in interface StructureProvider
public void setObsoleteBehavior(LocalPDBDirectory.ObsoleteBehavior behavior)
THROW_EXCEPTION
Throw a StructureException
(the default)
FETCH_OBSOLETE
Load the requested ID from the PDB's obsolete repository
FETCH_CURRENT
Load the most recent version of the requested structure
This setting may be silently ignored by implementations which do not have
access to the server to determine whether an entry is obsolete, such as
if #isAutoFetch()
is false. Note that an obsolete entry may still be
returned even this is FETCH_CURRENT if the entry is found locally.
fetchFileEvenIfObsolete
- Whether to fetch obsolete records#setFetchCurrent(boolean)
public LocalPDBDirectory.ObsoleteBehavior getObsoleteBehavior()
#isAutoFetch()
is false.
For most implementations, the default value is
THROW_EXCEPTION
.
public LocalPDBDirectory.FetchBehavior getFetchBehavior()
public void setFetchBehavior(LocalPDBDirectory.FetchBehavior fetchBehavior)
#setAutoFetch(boolean)
method with a more
extensive set of options.fetchBehavior
- public Structure getStructure(String filename) throws IOException
StructureIOFile
StructureProvider.getStructureById(String)
getStructure
in interface StructureIOFile
filename
- The path to the file. Must be the correct format for the
implementing class.IOException
- ...public Structure getStructure(URL u) throws IOException
IOException
public Structure getStructure(File filename) throws IOException
StructureIOFile
getStructure
in interface StructureIOFile
filename
- file containing the structure. Must be the correct format for
the implementing classIOException
- ...public Structure getStructureById(String pdbId) throws IOException
StructureProvider
getStructureById
in interface StructureProvider
IOException
public abstract Structure getStructure(InputStream inStream) throws IOException
inStream
- IOException
protected InputStream getInputStream(String pdbId) throws IOException
pdbId
- IOException
public void prefetchStructure(String pdbId) throws IOException
pdbId
- IOException
public boolean deleteStructure(String pdbId) throws IOException
pdbId
- IOException
- if the file cannot be deletedprotected File downloadStructure(String pdbId) throws IOException
pdbId
- IOException
- for errors downloading or writing, or if the
fetchBehavior is LocalPDBDirectory.FetchBehavior.LOCAL_ONLY
protected File getDir(String pdbId, boolean obsolete)
pdbId
- obsolete
- Whether the pdbId is obsolete or notpublic File getLocalFile(String pdbId) throws IOException
pdbId
- IOException
- If the file exists but is empty and can't be deletedprotected boolean checkFileExists(String pdbId)
public static String getServerName()
protected void initPaths()
getSplitDirPath()
or getObsoleteDirPath()
depend on anything, they should call this function when that thing
changes (possibly including at the end of the constructor).protected abstract String getFilename(String pdbId)
pdbId
- protected abstract String[] getSplitDirPath()
protected abstract String[] getObsoleteDirPath()
Copyright © 2000–2019 BioJava. All rights reserved.