|
The Brookhaven module provides several classes: IntoPDB for the conversion of YUP models to PDB files, FromPDB for
the conversion of PDB files to YUP models, and a few other supporting
classes. A conversion in either direction goes through an intermediate
representation: a
hierarchy of Atom objects contained in Residue contained in Chain, which in turn is contained in a PDBModel object.
Classes
The Brookhaven
module is located in Yup.Tools. Thus, the required
import statement is:
from
Yup.Tools.Brookhaven import *.
Converting a PDB file to a YUP model
Use the FromPDB class to convert the data in a PDB file to a YUP model. Derive a new class from FromPDB (say _PDBtoYUP), thus inheriting the ReadFile() and Convert()
methods, and replace the second method with code that is specific to
the YUP model type. Then, define a function that does this conversion.
For example:
from Yup.Tools.Brookhaven import FromPDB
class _PDBtoYUP( FromPDB ):
def __init__( self, pdbkeys = list-of-PDB-keywords ): FromPDB.__init__( self, pdbkeys )
def Convert( self, yupmodel ): ...code to convert the data hierarchy constructed by ReadFile() to yupmodel
def PDB2YUP( pdbfilename ): p = _PDBtoYUP() p.ReadFile( pdbfilename ) p.Convert( yupmodel ) return yupmodel
|
Now, to obtain a YUP model (M) from a PDB file (1BNA.pdb) is as simple as writing:
>>> M = PDB2YUP( '1BNA.pdb' )
|
Details below.
Converting a YUP model to a PDB file
Use the IntoPDB class to convert a YUP model into a PDB file. Derive a new class from IntoPDB (say _YUPtoPDB), thus inheriting the Convert() and WriteFile()
methods, and replace the first method with code that is specific to
the YUP model type. Then, define a function that does this conversion.
For example:
from Yup.Tools.Brookhaven import IntoPDB
class _YUPtoPDB( IntoPDB ):
def __init__( self ): IntoPDB.__init__( self )
def Convert( self, yupmodel ): ...code to convert the yupmode into a data hierarchy that WriteFile() can convert to a PDB file
def YUP2PDB( yupmodel, pdbfilename ): p = _YUPtoPDB() p.Convert( yupmodel ) p.WriteFile( pdbfilename )
|
Now, to write out the current YUP model (M) to a PDB file (ymodel.pdb) is as simple as writing:
>>> YUP2PDB( M, 'ymodel.pdb' )
|
Details below.
Online Help and Examples
The Brookhaven module contains documentation strings that may be enough to get you started. For example:
>>> from Yup.Tools import Brookhaven >>> help( Brookhaven )
|
The Yup.Models.Null.PDBPartMap module uses the FromPDB, IntoPDB and other classes from this module.
A straightforward example of the use of IntoPDB to convert a YUP model to a PDB file in the WritePDB() function in the Yup.Models.rrDNAv1.Analyzer module.
The Brookhaven Classes
The following is a detailed explanation of the classes in the Brookhaven module.
This module is not designed to read and write PDB files strictly. (It has
to accommodate imperfectly formed files.) The PDB specification
also has many contradictions that arises from the need to graft new
record types and fields on what was originally a punch-card format. If
you want to process PDB files strictly and completely, we recommend you try the PDB module from the PDB2PQR package.
The authors are: Baker, N.A. & Dolinksy, T., Center for
Computational Biology, Washington University, St. Louis and Nielsen,
J., University College, Dublin. [ Index ]
The Atom Class
The Atom
class is used to represent an atom. It can store atom properties as
well as the interactions that the subject atom may have with other atoms.
The constructor function Atom() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| serialnumber |
integer |
|
Serial number of the atom |
| atomname |
string |
|
Name of the atom |
| altlocind |
character |
|
Alternate location indicator |
| x |
float |
|
X coordinate value |
| y |
float |
|
Y coordinate value |
| z |
float |
|
Z coordinate value |
| parent |
Residue |
|
The residue that encloses this atom |
| occupancy |
float or None |
None |
Occupancy |
| tempfactor |
float or None |
None |
Temperature factor |
| segID |
float or None |
None |
Segment identifier |
| element |
float or None |
None |
Element |
| charge |
float or None |
None |
Charge |
The __str__()
method is defined for this class. It will return the data for this atom
formatted as (a PDB) ATOM or HETATM record, depending on a setting in
the parent class.
The attributes of the Atom class are:
| Attribute |
Type |
Restrictions |
Description |
| serialnumber |
integer |
>-10,000 & <100,000 |
Serial number of the atom |
| label |
string |
up to four characters |
Name of the atom |
| altlocind |
character |
one character |
Alternate location indicator |
| x |
float |
none imposed |
X coordinate value |
| y |
float |
none imposed |
Y coordinate value |
| z |
float |
none imposed |
Z coordinate value |
| occupancy |
float or None |
none |
Occupancy |
| tempfactor |
float or None |
none |
Temperature factor |
| segmentidentifier |
string |
up to four characters |
Segment identifier |
| element |
string |
up to two characters |
Element |
| charge |
string |
up to two characters |
Charge |
| residue |
Residue |
none |
The residue that contains this atom |
| bonds |
list of Atom objects |
none |
Partner atoms that are connected to this atom |
| saltbridges |
list of Atom objects |
none |
Partner atoms that are salt-bridged to this atom |
| hydrogenbonds |
list of Atom objects |
none |
Partner atoms that are hydrogen-bonded to this atom |
The methods of the Atom class are:
| Method |
Argument |
Type |
Description |
| AddConnection |
partner |
Atom |
The partner Atom is added to bonds if it is not already in the list |
| AddBridge |
partner |
Atom |
The partner Atom is added to saltbridges if it is not already in the list |
| AddHBond |
partner |
Atom |
The partner Atom is added to hydrogenbonds if it is not already in the list |
| PrintConect |
dest |
file |
The above lists are written out (to dest) as one or more CONECT lines if at least one list is not empty. |
Both ATOM and HETATM entities from a PDB file are represented by the Atom class. [ Index ]
The Residue Class
The Residue class
is used to represent a residue. A Residue object contains the
properties of a residue and a table and dictionary of the Atom objects
representing the atoms that are contained within this residue.
The constructor function Residue() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| residuename |
string |
|
Name of the residue |
| sequencenumber |
integer |
|
Sequence number of the residue |
| insertioncode |
character |
|
An indicator for inserted residues |
| parent |
Chain |
|
The chain that this residue belongs to |
| isatom |
integer |
|
1 = standard residue, 0 = non-standard residue |
The attributes of the Residue class are:
| Attribute |
Type |
Restrictions |
Description |
| sequencenumber |
integer |
>-1,000 & <10,000 |
Sequence number of the residue |
| label |
string |
up to three characters |
Name of the residue |
| insertioncode |
character |
one character |
Code to indicate this residue was an insertion |
| chain |
Chain |
none |
The chain that contains this residue |
| isatom |
integer |
none |
Whether this residue is standard or not |
| AtomList |
List of Atom objects |
none |
List of Atom objects contained within this Residue object, in the order in which they had been inserted |
| AtomDict |
Dictionary of Atom objects |
none |
Dictionary of Atom objects keyed by a tuple of their label and altlocind attributes |
The GetAtom() method of the Residue class returns the Atom
object that has the specified atom name and alternate location
indicator. If the serial number is also provided then it must match the
number recorded for the Atom object. The search is confined to the subject Residue object of course. If the atom cannot be found, the return value is None. The arguments are:
| Argument |
Type |
Preset Value |
Description |
| atomname |
string |
|
Name of the atom |
| altlocind |
character |
" " (space) |
Alternate location indicator |
| serialnumber |
integer |
None |
Serial number of the atom |
The NewAtom() method of the Residue class creates an Atom object with the specified atom properties.
The atom must not already exist in the subject residue, i.e., the same
atom cannot be added to a residue more than once. The newly created Atom object is recorded in the AtomList list and the AtomDict dictionary and returned to the caller.
| Argument |
Type |
Preset Value |
Description |
| serialnumber |
integer |
|
Serial number of the new atom |
| atomname |
string |
|
Name of the new atom |
| x |
float |
|
X coordinate value |
| y |
float |
|
Y coordinate value |
| z |
float |
|
Z coordinate value |
| altlocind |
character |
" " (space) |
Alternate location indicator |
| occupancy |
float or None |
None |
Occupancy |
| tempfactor |
float or None |
None |
Temperature factor |
| segID |
up to four characters |
None |
Segment identifier |
| element |
up to two characters |
None |
Element |
| charge |
up to two characters |
None |
Charge |
The AtomIdentifiers() method of the Residue class (no argument) returns a list containing identifiers for the atoms that are contained in this residue. The identifiers are listed in the order in which the atoms had been inserted. The identifiers are tuples of the following Atom attributes: ( atomname, label, altlocind ). [ Index ]
The Chain Class
The Chain
class is used to represent a chain. A Chain
object contains the
properties of a chain and a table and dictionary of the Residue objects
representing the residues that are contained within this chain.
The constructor function Chain() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| chainidentifier |
character |
|
Chain identifier |
| parent |
PDBModel |
|
The model that this chain belongs to |
The attributes of the Chain class are:
| Attribute |
Type |
Restrictions |
Description |
| label |
character |
one character |
Name of or identifier for the chain |
| model |
PDBModel |
none |
The model that contains this chain |
| ResidueList |
List of Residue objects |
none |
List of Residue objects contained within this Chain object, in the order in which they had been inserted |
| ResidueDict |
Dictionary of Residue objects |
none |
Dictionary of Residue objects keyed by a tuple of their sequencenumber and insertioncode attributes |
The GetResidue() method of the Chain class returns the Residue object
that has the specified sequence number and insertion code. If the
residue name is also provided then it must match the name recorded for
the Residue object. The search is confined to the subject Chain object of course. If the residue cannot be found, the return value is None. The arguments are:
| Argument |
Type |
Preset Value |
Description |
| sequencenumber |
integer |
|
Sequence number of the residue |
| residuename |
string or None |
None |
Name of the residue |
| insertioncode |
character or None |
" " (blank) |
Indicates whether the residue has been inserted |
The AddResidue() method of the Chain class first looks for a Residue object with the specified residue properties. If the residue does not yet exist in the subject chain, a new Residue object is created and recorded in the ResidueList list and the ResidueDict dictionary. The existing or new Residue object is returned to the caller.
| Argument |
Type |
Preset Value |
Description |
| residuename |
string |
|
Name of the residue |
| sequencenumber |
integer |
|
Sequence number of the residue |
| isatom |
integer |
|
1 = standard, 0 = non-standard, residue |
| insertioncode |
character |
" " (space) |
Indicates whether this residue is an insertion |
The ResidueIdentifiers() method of the Chain class (no argument) returns a list containing identifiers for the residues that are contained in this chain
The identifiers are listed in the order in which the residues had been
inserted. The identifiers are tuples of the following Residue attributes: ( label, sequencenumber, insertioncode ). [ Index ]
The PDBModel Class
The PDBModel
class is used to represent a model. A PDBModel object contains the
properties of a model and a table and dictionary of the Chain objects
representing the chains that are contained within this model.
The constructor function PDBModel() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| serialnumber |
integer |
|
Serial number for this model |
The attributes of the PDBModel class are:
| Attribute |
Type |
Restrictions |
Description |
| serialnumber |
integer |
>-1,000 & <10,000 |
Serial number of the model |
| ChainList |
List of Chain objects |
none |
List of Chain objects contained within this PDBModel object, in the order in which they had been inserted |
| ChainDict |
Dictionary of Chain objects |
none |
Dictionary of Chain objects keyed by a tuple of their sequencenumber and insertioncode attributes |
The GetChain() method of the PDBModel class returns the Chain
object that has the specified chain identifier. The search is confined to the subject PDBModel object of course. If the chain cannot be found, the return value is None. The argument is:
| Argument |
Type |
Preset Value |
Description |
| chainidentifier |
integer |
|
Sequence number of the residue |
The AddChain() method of the PDBModel class first looks for a Chain object with the specified chain identifier. If the chain does not yet exist in the subject model, a new Chain object is created and recorded in the ChainList list and the ChainDict dictionary. The existing or new Chain object is returned to the caller.
| Argument |
Type |
Preset Value |
Description |
| chainidentifier |
character |
|
Chain identifier |
The ChainIdentifiers() method of the PDBModel class (no argument) returns a list containing identifiers for the chains that are contained in this model. The identifiers are listed in the order in which the chains had been
inserted. The identifier is label attribute of the Chain objects. [ Index ]
The Atomic Hierarchy
The Atom, Residue, Chain and PDBModule classes are used to construct a hierarchy summarized below:
Class
|
PDBModel |
Chain |
Residue |
Atom |
| Ancestor |
Type |
- |
PDBModel |
Chain |
Residue |
| attribute |
- |
model |
chain |
residue |
| Descendants |
Type |
Chain |
Residue |
Atom |
- |
| List attribute |
ChainList |
ResidueList |
AtomList |
- |
| Dictionary attribute |
ChainDict |
ResidueDict |
AtomDict |
- |
| Dictionary key |
label |
( sequencenumber, insertioncode ) |
( label, altlocind ) |
- |
| Add method |
AddChain() |
AddResidue() |
NewAtom() |
- |
| Find method |
GetChain() |
GetResidue() |
GetAtom() |
- |
The Header Class
The Header
class is used to represent the PDB HEADER record type.
The constructor function Header() takes the following arguments (all optional):
| Argument |
Type |
Preset Value |
Description |
| classification |
string or None |
None |
Classification of the molecule, up to 40 characters |
| depositiondate |
string or None |
None |
Deposition date, exactly nine characters |
| idcode |
string or None |
None |
PDB ID code, exactly four characters |
The argument names are also the names of the attributes.
The __str__() method of the Header class
is defined to return a string formatted as the PDB HEADER record. Some
of the unspecified fields will be filled with default text. [ Index ]
The Helix Class
The Helix
class is used to represent the PDB HELIX record type.
The constructor function Helix() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| serial |
integer |
|
Serial number of this helix |
| helixname |
string |
|
name of the helix |
| residue1 |
Residue |
|
The initial residue in the helix |
| residue2 |
Residue |
|
The terminal residue in the helix |
| helixclass |
integer |
|
Type of helix, 1 to 10 |
| comment |
string |
|
Comment |
| length |
integer |
|
length of the helix, i.e., number of residues |
The attributes of the Helix class are:
| Attribute |
Type |
Restrictions |
Description |
| serialnumber |
integer |
>-100 and <1,000 |
Serial number of this helix |
| helixname |
string |
up to three characters |
The name of the helix |
| residue1 |
Residue |
|
The initial residue of the helix |
| residue2 |
Residue |
|
The terminal residue of the helix |
| helixclass |
integer |
none imposed |
Class of helix, 1 to 10 |
| comment |
string |
up to 30 characters |
Comment |
| length |
integer |
less than 100,000 |
Length of the helix |
The __str__() method of the Helix class
is defined to return a string formatted as the PDB HELIX record. [ Index ]
The Sheet Class
The Sheet
class is used to represent the PDB SHEET record type.
The constructor function Sheet() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| strand |
integer |
|
Strand number |
| sheetname |
string |
|
name of the sheet |
| numstrands |
integer |
|
number of strands in this sheet |
| residue1 |
Residue |
|
The initial residue in the sheet |
| residue2 |
Residue |
|
The terminal residue in the sheet |
| sense |
integer |
|
Sense of strand with respect to previous strand, -1, 0, +1 |
| curratom |
Atom |
|
Registration atom in current strand |
| prevatom |
Atom |
|
Registration atom in previous strand |
The attributes of the Sheet class are:
| Attribute |
Type |
Restrictions |
Description |
| strandnumber |
integer |
>-100 and <1,000 |
Strand number of the current sheet |
| sheetname |
string |
up to three characters |
The name of the sheet |
| numstrands |
integer |
1 to 999 |
Number of strands in this sheet |
| residue1 |
Residue |
|
The initial residue of the sheet |
| residue2 |
Residue |
|
The terminal residue of the sheet |
| sense |
integer |
none imposed |
Sense of strand with respect to previous strand |
| currentatom |
Atom or None |
|
Registration atom in current strand |
| previousatom |
Atom or None |
|
Registration atom in previous strand |
The __str__() method of the Sheet class
is defined to return a string formatted as the PDB SHEET record. [ Index ]
The Turn Class
The Turn
class is used to represent the PDB TURN record type.
The constructor function Turn() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| turnnumber |
integer |
|
Turn number |
| turnname |
string |
|
Turn identifier |
| residue1 |
Residue |
|
The initial residue in the turn |
| residue2 |
Residue |
|
The terminal residue in the turn |
| comment |
string |
|
Comment |
The attributes of the Helix class are:
| Attribute |
Type |
Restrictions |
Description |
| turnnumber |
integer |
>-100 and <1,000 |
Turn number |
| turnname |
string |
up to three characters |
Turn identifier |
| residue1 |
Residue |
|
The initial residue of the turn |
| residue2 |
Residue |
|
The terminal residue of the turn |
| comment |
string |
up to 30 characters |
Comment |
The __str__() method of the Turn class
is defined to return a string formatted as the PDB TURN record. [ Index ]
The SSBond Class
The SSBond
class is used to represent the PDB SSBOND record type.
The constructor function SSBond() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| serial |
integer |
|
Serial number of this disulfide bond |
| atom1 |
Atom |
|
The first sulfur atom |
| atom2 |
Atom |
|
The other sulfur atom |
| symop1 |
string |
|
Symmetry operator for the first atom |
| symop2 |
string |
|
Symmetry operator for the second atom |
The attributes of the SSBond class are:
| Attribute |
Type |
Restrictions |
Description |
| serialnumber |
integer |
>-100 & <1,000 |
Serial number of this disulfide bond |
| atom1 |
Atom |
must be labeled "SG", and parent residue is labeled "CYS" |
The first sulfur atom |
| atom2 |
Atom |
must be labeled "SG", and parent residue is labeled "CYS" |
The other sulfur atom |
| symop1 |
string |
up to six characters |
Symmetry operator for the first atom |
| symop2 |
string |
up to six characters |
Symmetry operator for the second atom |
The __str__() method of the SSBond class
is defined to return a string formatted as the PDB SSBOND record. [ Index ]
The LinkBridge Class
The LinkBridge
class is used to represent the PDB LINK and SLTBRG record types.
The constructor function LinkBridge() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| atom1 |
Atom |
|
The first atom in the link or salt bridge |
| atom2 |
Atom |
|
The second atom in the link or salt bridge |
| symop1 |
string |
|
Symmetry operator for the first atom, up to six characters |
| symop2 |
string |
|
Symmetry operator for the second atom, up to six characters |
| islink |
integer |
1 |
1 = LINK, 0 = SLTBRG |
The attributes of the LinkBridge class are:
| Attribute |
Type |
Restrictions |
Description |
| islink |
integer |
|
1 to indicate a LINK, 0 SLTBRG |
| atom1 |
Atom |
|
The first atom |
| atom2 |
Atom |
|
The other atom |
| symop1 |
string |
up to six characters |
Symmetry operator for the first atom |
| symop2 |
string |
up to six characters |
Symmetry operator for the second atom |
The __str__() method of the LinkBridge class
is defined to return a string formatted either as the PDB LINK or SLTBRG records. [ Index ]
The Hydbnd Class
The Hydbnd
class is used to represent the PDB HYDBND record type.
The constructor function Hydbnd() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| atom1 |
Atom |
|
The first atom in the hydrogen bond (donor or acceptor not defined) |
| hydrogen |
Atom or None |
|
The hydrogen atom if the coordinates have been determined |
| atom2 |
Atom |
|
The second atom in the hydrogen bond |
| symop1 |
string |
|
Symmetry operator for the first atom |
| symop2 |
string |
|
Symmetry operator for the second atom |
The attributes of the Hydbnd class are:
| Attribute |
Type |
Restrictions |
Description |
| hydrogen |
Atom or None |
|
None if the hydrogen is not placed in the structure |
| atom1 |
Atom |
|
The first atom |
| atom2 |
Atom |
|
The other atom |
| symop1 |
string |
up to six characters |
Symmetry operator for the first atom |
| symop2 |
string |
up to six characters |
Symmetry operator for the second atom |
The __str__() method of the Hydbnd class
is defined to return a string formatted as the PDB HYDBND record. [ Index ]
The Cispep Class
The Cispep
class is used to represent the PDB CISPEP record type.
The constructor function Cispep() takes the following arguments:
| Argument |
Type |
Preset Value |
Description |
| serial |
integer |
|
Serial number |
| residue1 |
Residue |
|
The residue before Omega |
| residue2 |
Residue |
|
The residue after Omega |
| model |
integer |
|
Serial number of the model, 0 if only one model |
| angle |
float |
|
The angle Omega, in degrees |
The attributes of the Hydbnd class are:
| Attribute |
Type |
Restrictions |
Description |
| serialnumber |
integer |
>-100 and <1,000 |
Serial number |
| residue1 |
Residue |
|
The residue before the angle Omega |
| residue2 |
Residue |
|
The residue after the angle Omega |
| model |
integer |
none |
Serial number of the model |
| angle |
float |
none |
The angle Omega, degrees |
The __str__() method of the Hydbnd class
is defined to return a string formatted as the PDB HYDBND record. [ Index ]
The PDB Class
The PDB class is the parent of the FromPDB and IntoPDB classes.
The constructor function, PDB() takes no argument.
The data attributes of this class are:
| Attribute |
Type |
Initial Contents |
| MODELS |
List of PDBModel objects |
One PDBModel serial number 0 |
| ATOMS |
Dictionary of Atom objects keyed by the atom serial number |
none |
The MODELS attribute will be filled with one or more structures, each represented by a PDBModel object. The ATOMS attribute will eventually contain all the atoms of the YUP model or PDB file, each represented by an Atom object; the atom serial number will be used as key to the dictionary. [ Index ]
The CenterOfMass()
method takes no argument, calculates and returns the center of mass of
all the atoms contained in the PDB class and returns it as a tuple of
three numbers.
The Recenter()
method takes no argument, calculates the center of mass, and resets the
coordinates of all the atoms in the PDB class, so that they are
centered at the origin.
The FromPDB Class
The FromPDB class is derived from the PDB class (and therefore it inherits the attributes and methods of the parent class).
The constructor function FromPDB() takes the following argument:
| Argument |
Type |
Preset Value |
Description |
| pdbkeys |
List of strings |
PDB_STANDARD |
List of keywords, of the PDB record types that are to be parsed. Record types that are not named will be ignored. |
The list PDB_REQUIRED is defined in the Brookhaven module;
it contains the minimal set of PDB keywords of records that contain
structural data. PDB_STANDARD defines a slightly longer list of PDB
keywords; this list is used as default. A corresponding list
PDB_COMPLETE contains all the
keywords for which methods have been defined to parse the record
types.
The data attributes of this class may include the following:
| Attribute |
Type |
Restrictions |
Description |
| ReadRecord |
Dictionary of methods |
the methods must exist |
Dictionary of methods, keyed by the PDB keyword, the method parses the line |
| modelcount |
integer |
|
number of times the MODEL keyword has been read |
| endmdcount |
integer |
|
number of times the ENDMDL keyword has been read |
| onexit |
List of callable objects |
|
methods to be called once the END keyword is encountered |
| HEADER |
Header |
|
The HEADER record. Only one is allowed. |
| LINK |
List of LinkBridge objects |
|
Each LINK record results in a entry |
| SLTBRG |
List of LinkBridge objects |
|
Representation of the SLTBRG record |
| SSBOND |
List of SSBond objects |
|
Representation of the SSBOND record |
| HELIX |
List of Helix objects |
|
Representation of the HELIX record |
| SHEET |
List of Sheet objects |
|
Representation of the SHEET record |
| TURN |
List of Turn objects |
|
Representation of the TURN record |
| HYDBND |
List of Hydbnd objects |
|
Representation of the HYDBND record |
| CISPEP |
List of Cispep objects |
|
Representation of the CISPEP record |
Only
16 PDB record types are parsed; most record types are ignored. The name
of the method that wil be called to parse the record type X has to be named PDB_X. These methods take one argument, the entire line containing the keyword X. The supported record types at this time are:
| HEADER |
HELIX |
SHEET |
TURN |
SSBOND |
LINK |
HYDBND |
SLTBRG |
CISPEP |
MODEL |
ATOM |
HETATM |
TER |
ENDMDL |
CONECT |
END |
The
parsing methods can be replaced. New parsing methods can be added to
process the PDB record types that are presently ignored. Be sure to
specify the new keywords (pdbkeys) when you initialize this class.
The ReadFile() method scans the lines of a PDB file. The first six columns of each line are used as key in the ReadRecord dictionary to determine which method, if any, is to be used to parse the line. There is only one argument:
| Argument |
Type |
Preset Value |
Description |
| pdbfname |
string |
|
Name of the PDB file that is to be read |
This
method registers LINK, SLTBRG, HYDBND and SSBOND interactions with the
appropriate table. In addition, the interactions are registered with
each atom of the interacting pair. When the CONECT records are read,
the interactions are registered with the atoms of each pair, but not to
the specific interaction tables.
The Convert()
method is only a placeholder. It must be replaced with a custom method.
The purpose of this method is to convert the data that was read by the
previous method, into a YUP model.
The IntoYUP() method is a default implementation of the Convert()
method. It creates a YUP model using the Null force field. The model does not
contain a force field (the Energy attribute), thus it is not suitable
for simulations. However, the Coordinates can be manipulated using the AtomVector operators, methods and functions. There is only one argument:
| Argument |
Type |
Preset Value |
Description |
| model |
integer |
-1 |
The model index, 0 for the first model, -1 for the last model |
Use the FromPDB class to convert the data in a PDB file to a YUP model. First, derive a class from FromPDB. If you prefer, you can override the methods that parse the various PDB keywords (PDB_X in the above list). If you want to parse a record type that is currently ignored, define a new method PDB_X, where X is the new keyword. Make sure that you initialize FromPDB with a list of keywords that include the new method. The most important thing to do is to replace the Convert()
method. You do not even have to use the same name and it is up to you
which arguments the method needs. Note that your method is called after
ReadFile(). The model or models are contained in the MODELS attribute. You can traverse this table noting that it contains a list and a dictionary of Chains as well as a method to find a chain by its identifier. You can drill down the hierarchy all the way to Atom objects. At each level, you can also pop back up the hierarchy through the appropriate attribute (residue in the case of Atom, chain in the case of Residue and so on). You can also access the atoms directly through the ATOMS dictionary, using the serial number of the atom as key. The all uppercase attributes (HEADER, LINK,
etc) provide additional information for your model, and the atom and
residue references have been conveniently translated to the
corresponding Atom and Residue classes. [ Index ]
The IntoPDB Class
The IntoPDB class is derived from the PDB class (and therefore it inherits the attributes and methods of the parent class).
The constructor function IntoPDB() takes no argument.
The data attributes of this class may contain none to all of the following:
| Attribute |
Type |
Restrictions |
Description |
| HEADER |
Header |
|
The HEADER record. Only the last record is saved. |
| LINK |
List of LinkBridge objects |
|
Each LINK record results in a entry |
| SLTBRG |
List of LinkBridge objects |
|
Representation of the SLTBRG record |
| SSBOND |
List of SSBond objects |
|
Representation of the SSBOND record |
| HELIX |
List of Helix objects |
|
Representation of the HELIX record |
| SHEET |
List of Sheet objects |
|
Representation of the SHEET record |
| TURN |
List of Turn objects |
|
Representation of the TURN record |
| HYDBND |
List of Hydbnd objects |
|
Representation of the HYDBND record |
| CISPEP |
List of Cispep objects |
|
Representation of the CISPEP record |
The Convert()
method is only a placeholder. It must be replaced with a custom method.
The purpose of this method is to convert your YUP model into a hierarchy of PDBModel, Chain, Residue and Atom objects. This means populating the MODELS table.
The FromYUP() method converts a YUP Model object into a hierarchy of PDB objects. This is a default implementation of Convert().
Since, YUP hierarchies can be very complicated, and it takes too much
time to map it to the rather simpler PDB hierarchy, the atoms are all
placed in one chain and equally divided into residues containing up to
10 atoms each. There is only one argument:
| Argument |
Type |
Preset Value |
Description |
| M |
Model |
|
The YUP Model object |
The WriteFile() method writes out a PDB file. There is only one argument:
| Argument |
Type |
Preset Value |
Description |
| pdbfname |
string |
|
Name of the PDB file that is to be written |
This method will print the HEADER record only if the HEADER
attribute is defined. The LINK, SLTBRG and SSBOND records are printed
only if the corresponding attributes are defined and the tables are not
empty. Then, if the MODELS
attribute contains more than one model, each model will be placed
between MODEL and ENDMDL keywords. The atoms are printed in the order
that they were inserted, and not by the serial number. Finally, CONECT
records are generated for those atoms that have interactions registered.
Use the IntoPDB class to convert a YUP model into a PDB file.
This is done by mapping the YUP hierarchy to the PDBModel hierarchy.
The former is general while the latter is regular. It is up to you to
resolve any conflict. [ Index ]
Quick and Dirty Conversions
The YUP2PDB function uses the FromYUP and WriteFile methods from the IntoPDB
class to convert a YUP model into a PDB file. The first argument is the
YUP Model object, the second is the name of the PDB file.
The PDB2YUP function uses the ReadFile and IntoYUP methods from the FromPDBclass
to convert a PDB file into a YUP model. The first argument is the name
of the PDB file, the second is the index of the desired model. The
function returns the YUP Model object constructed from the data read from the PDB file. The model is incomplete, it lacks a force field.
Functions
The Recenter()
function recenters the coordinates of the atoms in the PDB file
identified in the first argument and writes out the new coordinates in
the PDB file named in the second argument:
| Argument |
Type |
Preset Value |
Description |
| inpdb |
string |
|
Name of the input PDB file |
| outpdb |
string |
|
Name of the output PDB file |
The ShiftPDB()
function, translates all the atoms of the file named in the first
argument, by an amount specified in the third argument and writes the
resulting PDB file named in the second argument:
| Argument |
Type |
Preset Value |
Description |
| inpdb |
string |
|
Name of the input PDB file |
| outpdb |
string |
|
Name of the output PDB file |
| shift |
tuple or list of three numbers |
|
Displacement in each dimension |
|