2.0.6 • Published 7 years ago

pdb-lib v2.0.6

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

##Another library to parse and manipulate "Protein Data Bank" files Last revision : GL -- 06042016 Version tag : 0.2

###1. Installation and test To install package and dependencies npm install pdb-lib

Launch test within the test folder node ./test.js -f ./1Z00.pdb

###2. API

Loading library

var pdbLib = require("pdb-lib")

Invoking parser

pdbLib.parse({"ValidKey" : input).on('end', callback) Where callback is passed the created pdbObject as single parameter. The inputs must be passed along with key used for source identification. Following {key, input} pairs are supported:

  • file : path to a file following the PDB standard
  • rStream : a reference to a node readable stream
Parsing example

pdbLib.parse({file : "./test/1Z00.pdb"})       .on("end", function(pdbObjInp){             pdbObject = pdbObjInp;       });

Manipulating coordinates

The pdbObject interface tries to combine object chaining with "pymol-like" selecting expressions. A pdbObject implements the following methods.

Note: Internally, the pdbObject performs most operations on a record of atoms named current selection. On any fresh pdbObject, current selection must be initialized by calling the model method!

pdbObject.resName(coordinateSelectorExpression)

Extract from the current selection all atom records with resName field matching the provided coordinateSelectorExpression. returns: the pdbObject

pdbObject.resSeq(coordinateSelectorExpression)

Extract from the current selection all atom records with resSeq field matching the provided coordinateSelectorExpression. returns: the pdbObject

pdbObject.name(coordinateSelectorExpression)

Extract from the current selection all atom records with name field matching the provided coordinateSelectorExpression. returns: the pdbObject

pdbObject.chain(coordinateSelectorExpression)

Extract from the current selection all atom records with segID field matching the provided coordinateSelectorExpression. returns: the pdbObject

coordinateSelectorExpression specifications

The coordinateSelectorExpressions are strings used to generate regular expressions. Theses are used by the pdbObject to scan its current selection of atom records. The subset of matching records are consequently deleted from the current section or used to replace the current selection.

Variable type

coordinateSelectorExpression are passed to a pdbObject method as single or multiple arguments. In the latter case, the OR-logic is employed.

  • Select all Lys, Leu, Asp, Asn, Arg : pdbObj.resName('L*','A*')
Regular Expression behavior

The character "" specifies a unix-like wildcard (`/./` re-like) Chaining selector methods allows to apply the AND-logic.

  • Select atoms of Lys AND chain A : pdbObj.resName('LYS').chain('A')
Interval boundaries

Interval of values can be specified for serial and resSeq fields. Omit one boundary to specify a half-opened interval.

  • Select residues between positions 16 and 54 : pdbObj.resSeq("16:54")
  • Select all residues up to number 54 : pdbObj.resSeq(":54")

Deleting specific atoms

The same logic is employed to delete atom selections. Selecting atoms based on atom attributes is achieved through similar methods suffixed with the Del string.

pdbObject.resNameDel(coordinateSelectorExpression)

Delete from the current selection all atom records with resName field matching the provided coordinateSelectorExpression. returns: the pdbObject

pdbObject.resSeqDel(coordinateSelectorExpression)

Delete from the current selection all atom records with resSeq field matching the provided coordinateSelectorExpression. returns: the pdbObject

pdbObject.nameDel(coordinateSelectorExpression)

Delete from the current selection all atom records with name field matching the provided coordinateSelectorExpression. returns: the pdbObject

pdbObject.chainDel(coordinateSelectorExpression)

Delete from the current selection all atom records with segID field matching the provided coordinateSelectorExpression. returns: the pdbObject

Coordinates manipulation exemples

  • Delete atoms from the chain B, then remove two fragments pdbObj.model(1).chainDel('B').resSeqDel("290:301","270:277")

Additional methods

pdbObject.naturalAminoAcidOnly()

A short-cut method to select only the atoms part of the 20 natural amino-acids. returns: the pdbObject

pdbObject.bFactor(value, Optional type="increment")

Update the bFactor fields of the current selection of atoms to specified value. By default, any previous value is erased. If the optional parameter is set to "increment", the current bFactor values are incremented of value. returns: null

pdbObject.selecSize()

Compute the size of the current selection of atoms returns: current selection array length

pdbObject.listChainID()

Extract from current selection a list of non-redundant chain identifiers. returns : Array of single characters