## org.biojava.bio.structure.io
Class PDBFileReader

    java.lang.Object
      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

- `setParseCAOnly(boolean)` - parse only the Atom records for C-alpha atoms (default:false)
- `setParseSecStruc(boolean)` - a flag if the secondary structure information from the PDB file (author's assignment) should be parsed. If true the assignment can be accessed through `AminoAcid`.getSecStruc(); (default:false)
- `setAlignSeqRes(boolean)` - should the AminoAcid sequences from the SEQRES and ATOM records of a PDB file be aligned? (default:true)
- `setAutoFetch(boolean)` - if the PDB file can not be found locally, should it be fetched from the EBI - ftp server? (default:false)

## 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

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
`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` `getStructureById(String pdbId)` load a structure from local file system and return a PDBStructure object
`boolean` `isAlignSeqRes()` get the flag if the SEQRES and ATOM amino acids are going to be aligned
`boolean` `isAutoFetch()` should the parser to fetch missing PDB files from the EBI FTP server automatically? default is false
`boolean` `isParseCAOnly()` return the flag if only the CA atoms should be parsed
`boolean` `isParseSecStruc()`
`static void` `main(String[] args)`
`void` `setAlignSeqRes(boolean alignSeqRes)` set the flag if the SEQRES and ATOM amino acids should be aligned and linked
`void` `setAutoFetch(boolean autoFetch)` tell the parser to fetch missing PDB files from the EBI FTP server automatically.
`void` `setParseCAOnly(boolean parseCAOnly)` only the CA atoms should be parsed from the PDB file
`void` `setParseSecStruc(boolean parseSecStruc)`
`void` `setPath(String p)` directory where to find PDB files

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PDBFileReader

    public PDBFileReader()

Method Detail

### main

    public static void main(String[] args)

### isParseCAOnly

    public boolean isParseCAOnly()

  return the flag if only the CA atoms should be parsed

  Returns:
    flag if CA only should be read

### setParseCAOnly

    public void setParseCAOnly(boolean parseCAOnly)

  only the CA atoms should be parsed from the PDB file

  Parameters:
    `parseCAOnly` -

### isAlignSeqRes

    public boolean isAlignSeqRes()

  get the flag if the SEQRES and ATOM amino acids are going to be aligned

  Returns:
    flag

### setAlignSeqRes

    public void setAlignSeqRes(boolean alignSeqRes)

  set the flag if the SEQRES and ATOM amino acids should be aligned and linked

  Parameters:
    `alignSeqRes` -

### isAutoFetch

    public boolean isAutoFetch()

  should the parser to fetch missing PDB files from the EBI FTP server automatically? default is false

  Specified by:
    `isAutoFetch` in interface `StructureIOFile`
  Returns:
    flag

### setAutoFetch

    public void setAutoFetch(boolean autoFetch)

  tell the parser to fetch missing PDB files from the EBI 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` -

### isParseSecStruc

    public boolean isParseSecStruc()

### setParseSecStruc

    public void setParseSecStruc(boolean parseSecStruc)

### 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`

### 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`
  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` - ...