Class PDBFileReader

java.lang.Object
org.biojava.nbio.structure.io.LocalPDBDirectory
org.biojava.nbio.structure.io.PDBFileReader
All Implemented Interfaces:
StructureIOFile, StructureProvider

public class PDBFileReader extends LocalPDBDirectory

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 Details

    • PDB_SPLIT_DIR

      public static final String[] PDB_SPLIT_DIR
    • PDB_OBSOLETE_DIR

      public static final String[] PDB_OBSOLETE_DIR
  • Constructor Details

    • PDBFileReader

      public PDBFileReader()
      Constructs a new PDBFileReader, initializing the extensions member variable. The path is initialized in the same way as UserConfiguration, i.e. to system property/environment variable UserConfiguration.PDB_DIR. Both autoFetch and splitDir are initialized to false
    • PDBFileReader

      public PDBFileReader(String path)
      Constructs a new PDBFileReader, initializing the extensions member variable. The path is initialized to the given path, both autoFetch and splitDir are initialized to false.

      If path is null, initialize using the system property/environment variable UserConfiguration.PDB_DIR.

      Parameters:
      path - Path to the PDB file directory
  • Method Details

    • main

      public static void main(String[] args)
    • downloadPDB

      @Deprecated public void downloadPDB(String pdbId) throws IOException
      Deprecated.
      Throws:
      IOException
    • setFetchFileEvenIfObsolete

      @Deprecated public void setFetchFileEvenIfObsolete(boolean fetchFileEvenIfObsolete)
      Deprecated.
      Use FileParsingParameters#setObsoleteBehavior(ObsoleteBehavior)
      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

      @Deprecated public boolean isFetchFileEvenIfObsolete()
      Deprecated.
      Use FileParsingParameters#getObsoleteBehavior()
      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

      @Deprecated public void setFetchCurrent(boolean fetchNewestCurrent)
      Deprecated.
      Use FileParsingParameters#setObsoleteBehavior(ObsoleteBehavior)
      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:
    • isFetchCurrent

      @Deprecated public boolean isFetchCurrent()
      Deprecated.
      Use FileParsingParameters#getObsoleteBehavior()
      N.B. This feature won't work unless the structure wasn't found & autoFetch is set to true.
      Returns:
      the fetchCurrent
    • getFilename

      protected String getFilename(String pdbId)
      Description copied from class: LocalPDBDirectory
      Converts a PDB ID into a filename with the proper extension
      Specified by:
      getFilename in class LocalPDBDirectory
      Returns:
      The filename, e.g. "4hhb.pdb.gz"
    • getStructure

      public Structure getStructure(InputStream inStream) throws IOException
      Description copied from class: LocalPDBDirectory
      Handles the actual parsing of the file into a Structure object.
      Specified by:
      getStructure in class LocalPDBDirectory
      Returns:
      Throws:
      IOException
    • getSplitDirPath

      protected String[] getSplitDirPath()
      Description copied from class: LocalPDBDirectory
      Location of split files within the directory, as an array of paths. These will be joined with either slashes (for the URL) or the file separator (for directories). The returned results should be constant, to allow for caching.
      Specified by:
      getSplitDirPath in class LocalPDBDirectory
      Returns:
      A list of directories, relative to the /pub/pdb directory on the server
    • getObsoleteDirPath

      protected String[] getObsoleteDirPath()
      Description copied from class: LocalPDBDirectory
      Location of obsolete files within the directory, as an array of paths. These will be joined with either slashes (for the URL) or the file separator (for directories). The returned results should be constant, to allow for caching.
      Specified by:
      getObsoleteDirPath in class LocalPDBDirectory
      Returns:
      A list of directories, relative to the /pub/pdb directory on the server