org.proteinshader.structure.io
Class PDBAtomFieldExtractor

java.lang.Object
  extended by org.proteinshader.structure.io.PDBAtomFieldExtractor

public class PDBAtomFieldExtractor
extends Object

Extracts fields from a PDB ATOM or HETATM record.

The line must be a PDB ATOM record as specified in the PDB Contents Guide (Version 2.2, 20 Dec 1996).

The column numbers specified in the PDB guide start at 1 rather than at 0, so a field written as (name field: 13-16) would be in columns 12 to 15 in a String.


Constructor Summary
PDBAtomFieldExtractor()
          Constructs a PDBFieldExtractor.
 
Method Summary
 String extractAltLocation(String line)
          Obtains the alternate location from (altLoc field: 17), or returns an empty String if it is not found (this field is usually blank).
 String extractAtomID(String line)
          Obtains the atomID from (name field: 13-16).
 int extractAtomSerialNo(String line)
          Obtains the atom serial number from (serial field: 7-11).
 AtomEnum extractAtomType(String line)
          Obtains the atom type (chemical element) from an ATOM or HETATM record.
 String extractChainID(String line)
          Obtains the chainID from (chainID field: 22 ) if it is present.
 int extractCharge(String line)
          Obtains the charge from (charge field: 79-80), or sets it to 0 if the field is only whitespace.
 double extractOccupancy(String line)
          Obtains the occupancy from (occupancy field: 55-60).
 String extractResidueID(String line)
          Obtains the residueID by combining (resName field: 18-20), (resSeq field: 23-26), and the optional (icode field: 27).
 String extractResidueName(String line)
          Obtains the Residue name from (resName field: 18-20).
 double extractTemperature(String line)
          Obtains the temperature from (tempFactor field: 61-66).
 double extractX(String line)
          Obtains the x-coordinate from (x field: 31-38 ).
 double extractY(String line)
          extractY() - obtains the y-coordinate from (y field: 39-46 ).
 double extractZ(String line)
          extractZ() - obtains the z-coordinate from (z field: 47-54 ).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDBAtomFieldExtractor

public PDBAtomFieldExtractor()
Constructs a PDBFieldExtractor.

Method Detail

extractAtomSerialNo

public int extractAtomSerialNo(String line)
                        throws PDBFieldExtractorException
Obtains the atom serial number from (serial field: 7-11).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The atom serial number as an int.
Throws:
PDBFieldExtractorException - if the atom serial number field cannot be converted to an int.

extractAtomType

public AtomEnum extractAtomType(String line)
                         throws PDBFieldExtractorException
Obtains the atom type (chemical element) from an ATOM or HETATM record. The (element field: 77-78), which was added in 1996 will be used first, but if that fails the first 2 characters of (name field: 13-16) will be used. A possible complication in using the name field is that some atoms may have a number (for example, "2H" of "2HCB" is used to indicate the 2nd hydrogen of the beta carbon).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The atom type as an AtomEnum.
Throws:
PDBFieldExtractorException - if an AtomEnum type cannot be determined.

extractAtomID

public String extractAtomID(String line)
                     throws PDBFieldExtractorException
Obtains the atomID from (name field: 13-16). Leading and trailing whitespace are removed.

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The atomID as a String.
Throws:
PDBFieldExtractorException - if the line is too short.

extractResidueName

public String extractResidueName(String line)
                          throws PDBFieldExtractorException
Obtains the Residue name from (resName field: 18-20). Leading and trailing whitespace are removed.

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The residue name as a String.
Throws:
PDBFieldExtractorException - if the line is too short.

extractResidueID

public String extractResidueID(String line)
                        throws PDBFieldExtractorException
Obtains the residueID by combining (resName field: 18-20), (resSeq field: 23-26), and the optional (icode field: 27). A blank space is placed between these fields, and leading and trailing whitespace are removed.

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The residue ID as a String.
Throws:
PDBFieldExtractorException - if the line is too short.

extractChainID

public String extractChainID(String line)
                      throws PDBFieldExtractorException
Obtains the chainID from (chainID field: 22 ) if it is present. Otherwise, the DEFAULT_CHAIN_ID from the PDBLineParser is used.

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The chain ID as a String.
Throws:
PDBFieldExtractorException - if the line is too short.

extractTemperature

public double extractTemperature(String line)
                          throws PDBFieldExtractorException
Obtains the temperature from (tempFactor field: 61-66).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The temperature as a double.
Throws:
PDBFieldExtractorException - if the tempFactor field cannot be converted to a double.

extractCharge

public int extractCharge(String line)
                  throws PDBFieldExtractorException
Obtains the charge from (charge field: 79-80), or sets it to 0 if the field is only whitespace.

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The charge as an int.
Throws:
PDBFieldExtractorException - if the charge field contains non-whitespace characters, but cannot be converted to an int.

extractOccupancy

public double extractOccupancy(String line)
                        throws PDBFieldExtractorException
Obtains the occupancy from (occupancy field: 55-60).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The occupancy as a double.
Throws:
PDBFieldExtractorException - if the occupancy field cannot be converted to a double.

extractAltLocation

public String extractAltLocation(String line)
                          throws PDBFieldExtractorException
Obtains the alternate location from (altLoc field: 17), or returns an empty String if it is not found (this field is usually blank).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The alternate location name as a String.
Throws:
PDBFieldExtractorException - if the line is too short.

extractX

public double extractX(String line)
                throws PDBFieldExtractorException
Obtains the x-coordinate from (x field: 31-38 ).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The x-coordinate as a double.
Throws:
PDBFieldExtractorException - if the x-coordinate field cannot be converted to a double.

extractY

public double extractY(String line)
                throws PDBFieldExtractorException
extractY() - obtains the y-coordinate from (y field: 39-46 ).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The y-coordinate as a double.
Throws:
PDBFieldExtractorException - if the y-coordinate field cannot be converted to a double.

extractZ

public double extractZ(String line)
                throws PDBFieldExtractorException
extractZ() - obtains the z-coordinate from (z field: 47-54 ).

Parameters:
line - an ATOM or HETATM record (80 characters in length).
Returns:
The z-coordinate as a double.
Throws:
PDBFieldExtractorException - if the z-coordinate field cannot be converted to a double.


Copyright © 2007-2008