org.biojava.bio.structure.io
Class PDBFileReader

java.lang.Object
  extended by org.biojava.bio.structure.io.PDBFileReader
All Implemented Interfaces:
StructureIO, StructureIOFile

public class PDBFileReader
extends Object
implements StructureIOFile

The wrapper class for parsing a PDB file.

Several flags can be set for this class

Example

Q: How can I get a Structure object from a PDB file?

A:

 public Structure loadStructure(String pathToPDBFile){
                PDBFileReader pdbreader = new PDBFileReader();

                Structure structure = null;
                try{
                        structure = pdbreader.getStructure(pathToPDBFile);
                        System.out.println(structure);
                } catch (IOException e) {
                        e.printStackTrace();
                }
                return structure;
        }
 
Access PDB files from a directory, take care of compressed PDB files
 public Structure loadStructureById() {
                String path = "/path/to/PDB/directory/";

                PDBFileReader pdbreader = new PDBFileReader();
                pdbreader.setPath(path);
                Structure structure = null;
                try {
                        structure = pdbreader.getStructureById("5pti");
                } catch (IOException e){
                        e.printStackTrace();
                }
                return structure;

        }
        

Author:
Andreas Prlic

Field Summary
static String DEFAULT_PDB_FILE_SERVER
           
static String lineSplit
           
static String LOAD_CHEM_COMP_PROPERTY
           
static String PDB_FILE_SERVER_PROPERTY
           
 
Constructor Summary
PDBFileReader()
           
 
Method Summary
 void addExtension(String s)
          define supported file extensions compressed extensions .Z,.gz do not need to be specified they are dealt with automatically.
 void clearExtensions()
          clear the supported file extensions
 FileParsingParameters getFileParsingParameters()
          Get the parameters that should be used for file parsing
 String getPath()
          Returns the path value.
 Structure getStructure(File filename)
          opens filename, parses it and returns a Structure object
 Structure getStructure(String filename)
          opens filename, parses it and returns aStructure object .
 Structure getStructure(URL u)
           
 Structure getStructureById(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(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(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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOAD_CHEM_COMP_PROPERTY

public static final String LOAD_CHEM_COMP_PROPERTY
See Also:
Constant Field Values

lineSplit

public static final String lineSplit

DEFAULT_PDB_FILE_SERVER

public static final String DEFAULT_PDB_FILE_SERVER
See Also:
Constant Field Values

PDB_FILE_SERVER_PROPERTY

public static final String PDB_FILE_SERVER_PROPERTY
See Also:
Constant Field Values
Constructor Detail

PDBFileReader

public PDBFileReader()
Method Detail

main

public static void main(String[] args)

setPath

public void setPath(String p)
directory where to find PDB files

Specified by:
setPath in interface StructureIOFile
Parameters:
p - a String specifying the path value

getPath

public String getPath()
Returns the path value.

Specified by:
getPath in interface StructureIOFile
Returns:
a String representing the path value
See Also:
setPath(java.lang.String)

addExtension

public void addExtension(String s)
define supported file extensions compressed extensions .Z,.gz do not need to be specified they are dealt with automatically.

Specified by:
addExtension in interface StructureIOFile
Parameters:
s - a String ...

clearExtensions

public void clearExtensions()
clear the supported file extensions

Specified by:
clearExtensions in interface StructureIOFile

isPdbDirectorySplit

public boolean isPdbDirectorySplit()
Flag that defines if the PDB directory is containing all PDB files or is split into sub dirs (like the FTP site).

Specified by:
isPdbDirectorySplit in interface StructureIOFile
Returns:
boolean. default is false (all files in one directory)

setPdbDirectorySplit

public 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).

Specified by:
setPdbDirectorySplit in interface StructureIOFile
Parameters:
pdbDirectorySplit - boolean. If set to false all files are in one directory.

setBioAssemblyId

public void setBioAssemblyId(int bioAssemblyId)
Sets the ID of the biological assembly to be loaded. By default, the bioAssemblyId=0, which corresponds to the original PDB file. If an ID > 0 is specified, the corresponding biological assembly file will be loaded. Note, the number of available biological unit files varies. Many entries don't have a biological unit specified (i.e. NMR structures), many entries have only one biological unit (bioAssemblyId=1), and a few structures have multiple biological assemblies.

Parameters:
bioAssemblyId - ID of the biological assembly to be loaded
Since:
3.2

setBioAssemblyFallback

public void setBioAssemblyFallback(boolean bioAssemblyFallback)
Set bioAssemblyFallback to true, to download the original PDB file in cases that a biological assembly file is not available.

Parameters:
bioAssemblyFallback - if true, tries reading original PDB file in case the biological assembly file is not available
Since:
3.2

getStructureById

public Structure getStructureById(String pdbId)
                           throws IOException
load a structure from local file system and return a PDBStructure object

Specified by:
getStructureById in interface StructureIO
Specified by:
getStructureById in interface StructureIOFile
Parameters:
pdbId - a String specifying the id value (PDB code)
Returns:
the Structure object
Throws:
IOException - ...

getStructure

public Structure getStructure(String filename)
                       throws IOException
opens filename, parses it and returns aStructure object .

Specified by:
getStructure in interface StructureIOFile
Parameters:
filename - a String
Returns:
the Structure object
Throws:
IOException - ...

getStructure

public Structure getStructure(File filename)
                       throws IOException
opens filename, parses it and returns a Structure object

Specified by:
getStructure in interface StructureIOFile
Parameters:
filename - a File object
Returns:
the Structure object
Throws:
IOException - ...

getStructure

public Structure getStructure(URL u)
                       throws IOException
Throws:
IOException

setFileParsingParameters

public void setFileParsingParameters(FileParsingParameters params)
Description copied from interface: StructureIOFile
Set the parameters that should be used for file parsing

Specified by:
setFileParsingParameters in interface StructureIOFile
Parameters:
params - FileParsingParameters

getFileParsingParameters

public FileParsingParameters getFileParsingParameters()
Description copied from interface: StructureIOFile
Get the parameters that should be used for file parsing

Specified by:
getFileParsingParameters in interface StructureIOFile
Returns:
the FileParsingParameters that are configuring the behavior of the parser

isAutoFetch

public boolean isAutoFetch()
Description copied from interface: StructureIOFile
Fetch files automatically from FTP server. Default: false

Specified by:
isAutoFetch in interface StructureIOFile
Returns:
flag is true or false.

setAutoFetch

public void setAutoFetch(boolean autoFetch)
Description copied from interface: StructureIOFile
Tell the parser to fetch missing PDB files from the FTP server automatically. default is false. If true, new PDB files will be automatically stored in the Path and gzip compressed.

Specified by:
setAutoFetch in interface StructureIOFile
Parameters:
autoFetch - flag.

setFetchFileEvenIfObsolete

public void setFetchFileEvenIfObsolete(boolean fetchFileEvenIfObsolete)
N.B. This feature won't work unless the structure wasn't found & autoFetch is set to true.

Parameters:
fetchFileEvenIfObsolete - the fetchFileEvenIfObsolete to set

isFetchFileEvenIfObsolete

public boolean isFetchFileEvenIfObsolete()
forces the reader to fetch the file if its status is OBSOLETE. This feature has a higher priority than setFetchCurrent(boolean).
N.B. This feature won't work unless the structure wasn't found & autoFetch is set to true.

Returns:
the fetchFileEvenIfObsolete
Since:
3.0.2
See Also:
fetchCurrent

setFetchCurrent

public void setFetchCurrent(boolean fetchNewestCurrent)
if enabled, the reader searches for the newest possible PDB ID, if not present in he local installation. The setFetchFileEvenIfObsolete(boolean) function has a higher priority than this function.
N.B. This feature won't work unless the structure wasn't found & autoFetch is set to true.

Parameters:
fetchCurrent - the fetchCurrent to set
Since:
3.0.2
See Also:
setFetchFileEvenIfObsolete(boolean)

isFetchCurrent

public boolean isFetchCurrent()
N.B. This feature won't work unless the structure wasn't found & autoFetch is set to true.

Returns:
the fetchCurrent