public class PDBFileReader extends java.lang.Object implements StructureIOFile
The wrapper class for parsing a PDB file.
Several flags can be set for this class
setAutoFetch(boolean)
- if the PDB file can not be found locally, should it be fetched
from the PDB ftp servers? (default:false)setFileParsingParameters(FileParsingParameters)
Q: How can I get a Structure object from a PDB file?
A:
publicAccess PDB files from a directory, take care of compressed PDB filesStructure
loadStructure(String pathToPDBFile){PDBFileReader
pdbreader = newPDBFileReader
();Structure
structure = null; try{ structure = pdbreader.getStructure(pathToPDBFile); System.out.println(structure); } catch (IOException e) { e.printStackTrace(); } return structure; }
publicStructure
loadStructureById() { String path = "/path/to/PDB/directory/";PDBFileReader
pdbreader = newPDBFileReader
(); pdbreader.setPath(path);Structure
structure = null; try { structure = pdbreader.getStructureById("5pti"); } catch (IOException e){ e.printStackTrace(); } return structure; }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_PDB_FILE_SERVER |
static long |
lastRemediationDate |
static java.lang.String |
lineSplit |
static java.lang.String |
LOAD_CHEM_COMP_PROPERTY |
static java.lang.String |
PDB_FILE_SERVER_PROPERTY |
Constructor and Description |
---|
PDBFileReader() |
Modifier and Type | Method and Description |
---|---|
void |
addExtension(java.lang.String s)
define supported file extensions
compressed extensions .Z,.gz do not need to be specified
they are dealt with automatically.
|
boolean |
checkFileExists(java.lang.String pdbId) |
void |
clearExtensions()
clear the supported file extensions
|
void |
downloadPDB(java.lang.String pdbId) |
FileParsingParameters |
getFileParsingParameters()
Get the parameters that should be used for file parsing
|
java.io.InputStream |
getInputStream(java.lang.String pdbId)
try to find the file in the filesystem and return a filestream in order to parse it
rules how to find file
- first check: if file is in path specified by PDBpath
- second check: if not found check in PDBpath/xy/ where xy is second and third char of PDBcode.
|
java.io.InputStream |
getInputStreamBioAssembly(java.lang.String pdbId)
Returns an input stream for a biological assembly file based on the passed in pdbId and
the biological assembly id
setBioAssemblyId(int) . |
java.lang.String |
getPath()
Returns the path value.
|
Structure |
getStructure(java.io.File filename)
opens filename, parses it and returns a Structure object
|
Structure |
getStructure(java.lang.String filename)
opens filename, parses it and returns
aStructure object .
|
Structure |
getStructure(java.net.URL u) |
Structure |
getStructureById(java.lang.String pdbId)
load a structure from local file system and return a PDBStructure object
|
boolean |
isAutoFetch()
Fetch files automatically from FTP server.
|
boolean |
isFetchCurrent()
N.B. This feature won't work unless the structure wasn't found & autoFetch is set to
true . |
boolean |
isFetchFileEvenIfObsolete()
forces the reader to fetch the file if its status is OBSOLETE.
|
boolean |
isPdbDirectorySplit()
Flag that defines if the PDB directory is containing all PDB files or is split into sub dirs (like the FTP site).
|
static void |
main(java.lang.String[] args) |
void |
setAutoFetch(boolean autoFetch)
Tell the parser to fetch missing PDB files from the FTP server automatically.
|
void |
setBioAssemblyFallback(boolean bioAssemblyFallback)
Set bioAssemblyFallback to true, to download the original PDB file in cases that a biological assembly file is not available.
|
void |
setBioAssemblyId(int bioAssemblyId)
Sets the ID of the biological assembly to be loaded.
|
void |
setFetchCurrent(boolean fetchNewestCurrent)
if enabled, the reader searches for the newest possible PDB ID, if not present in he local installation.
|
void |
setFetchFileEvenIfObsolete(boolean fetchFileEvenIfObsolete)
N.B. This feature won't work unless the structure wasn't found & autoFetch is set to
true . |
void |
setFileParsingParameters(FileParsingParameters params)
Set the parameters that should be used for file parsing
|
void |
setPath(java.lang.String p)
directory where to find PDB files
|
void |
setPdbDirectorySplit(boolean pdbDirectorySplit)
Flag that defines if the PDB directory is containing all PDB files or is split into sub dirs (like the FTP site).
|
public static final java.lang.String LOAD_CHEM_COMP_PROPERTY
public static final java.lang.String lineSplit
public static final java.lang.String DEFAULT_PDB_FILE_SERVER
public static final java.lang.String PDB_FILE_SERVER_PROPERTY
public static final long lastRemediationDate
public static void main(java.lang.String[] args)
public void setPath(java.lang.String p)
setPath
in interface StructureIOFile
p
- a String specifying the path valuepublic java.lang.String getPath()
getPath
in interface StructureIOFile
setPath(java.lang.String)
public void addExtension(java.lang.String s)
addExtension
in interface StructureIOFile
s
- a String ...public void clearExtensions()
clearExtensions
in interface StructureIOFile
public boolean isPdbDirectorySplit()
isPdbDirectorySplit
in interface StructureIOFile
public void setPdbDirectorySplit(boolean pdbDirectorySplit)
setPdbDirectorySplit
in interface StructureIOFile
pdbDirectorySplit
- boolean. If set to false all files are in one directory.public void setBioAssemblyId(int bioAssemblyId)
bioAssemblyId
- ID of the biological assembly to be loadedpublic void setBioAssemblyFallback(boolean bioAssemblyFallback)
bioAssemblyFallback
- if true, tries reading original PDB file in case the biological assembly file is not availablepublic java.io.InputStream getInputStream(java.lang.String pdbId) throws java.io.IOException
java.io.IOException
public java.io.InputStream getInputStreamBioAssembly(java.lang.String pdbId) throws java.io.IOException
setBioAssemblyId(int)
. Files are cached in a local directory.pdbId
- java.io.IOException
public boolean checkFileExists(java.lang.String pdbId)
public void downloadPDB(java.lang.String pdbId)
public Structure getStructureById(java.lang.String pdbId) throws java.io.IOException
getStructureById
in interface StructureIO
getStructureById
in interface StructureIOFile
pdbId
- a String specifying the id value (PDB code)java.io.IOException
- ...public Structure getStructure(java.lang.String filename) throws java.io.IOException
getStructure
in interface StructureIOFile
filename
- a Stringjava.io.IOException
- ...public Structure getStructure(java.io.File filename) throws java.io.IOException
getStructure
in interface StructureIOFile
filename
- a File objectjava.io.IOException
- ...public Structure getStructure(java.net.URL u) throws java.io.IOException
java.io.IOException
public void setFileParsingParameters(FileParsingParameters params)
StructureIOFile
setFileParsingParameters
in interface StructureIOFile
params
- FileParsingParameterspublic FileParsingParameters getFileParsingParameters()
StructureIOFile
getFileParsingParameters
in interface StructureIOFile
public boolean isAutoFetch()
StructureIOFile
isAutoFetch
in interface StructureIOFile
public void setAutoFetch(boolean autoFetch)
StructureIOFile
setAutoFetch
in interface StructureIOFile
autoFetch
- flag.public void setFetchFileEvenIfObsolete(boolean fetchFileEvenIfObsolete)
true
.fetchFileEvenIfObsolete
- the fetchFileEvenIfObsolete to setpublic boolean isFetchFileEvenIfObsolete()
setFetchCurrent(boolean)
. true
.fetchCurrent
public void setFetchCurrent(boolean fetchNewestCurrent)
setFetchFileEvenIfObsolete(boolean)
function has a higher priority than this function. true
.fetchCurrent
- the fetchCurrent to setsetFetchFileEvenIfObsolete(boolean)
public boolean isFetchCurrent()
true
.