cl-pdb is a Common Lisp library for reading, rebuilding, slicing, and writing .pdb files.
The project is built around a simple canonical model:
- a
pdbcontainsresidue - a
residuecontainsatom
The goal is not only to parse PDB lines one by one, but to reconstruct a usable in-memory representation that can then be queried, transformed, sliced, and written back.
cl-pdb currently provides:
- parsing of core structural records such as
ATOM,HETATM,HET,TITLE, andSEQRES - reconstruction of residues from atom-level records
- normalization of residue kinds (for example amino acids, waters, ions, lipids, unknown residues)
- simple residue and atom views
- a first writer for exporting a full
pdbor a list of residues
The library is currently centered on manipulation and extraction. Audit/reporting tools are intended to be built on top of this core later.
The code is organized into a few explicit layers.
Stable domain objects.
atom.class.lispresidue.class.lisptitle.class.lispseqres.class.lisppdb.class.lisp
The main model exposed to users is:
pdbresidueatom
title and seqres are currently raw helper objects used during parsing/building.
Low-level parsing of PDB records.
This layer turns one textual record into one small raw object.
Examples:
ATOM->atomHETATM->atomHET->residueTITLE->titleSEQRES->seqres
Files:
common.lispatom.lisphet.lisphetatm.lisptitle.lispseqres.lisp
Reconstruction of the canonical pdb object.
This layer is responsible for:
- dispatching records through
ingest - grouping atoms into residues
- accumulating
TITLE - accumulating
SEQRESby chain - producing the final
pdb
Files:
ingest.lispbuild.lispfinalize.lispread-pdb.lisp
Simple residue normalization.
This currently assigns domain-level residue kinds such as:
:amino-acid:water:ion:lipid:unknown
File:
residue-kind.lisp
Simple views and slices over already-built structures.
This layer is intended to make cl-pdb convenient to use for extraction and manipulation.
Examples of current views:
residues-in-chainresidues-of-kindresidues-namedhetero-residuesunknown-residuesatoms-of-residueatoms-in-chainatoms-of-kind
The pipe, pipe-residues, and pipe-atoms macros are meant to make view composition more convenient.
First writer implementation.
This layer currently supports writing:
- a full
pdb - a list of residues
Files:
write-pdb.lisp
(defparameter *pdb* (pdb:read-pdb #P"example.pdb"))