fit.xyz(fixed, mobile, fixed.inds = NULL, mobile.inds = NULL, verbose=FALSE, prefix= "", pdbext = "", outpath = "fitlsq", full.pdbs=FALSE, ncore = 1, nseg.scale = 1, ...)rot.lsq(xx, yy, xfit = rep(TRUE, length(xx)), yfit = xfit, verbose = FALSE)
xyz
component containing one or more coordinate sets. fixed
upon which fitting should be based.mobile
upon which fitting should be based.outpath
. full.pdbs
is TRUE. full.pdbs
is TRUE. xx
, with
TRUE elements corresponding to the subset of positions upon which
fitting is to be performed. yy
, with
TRUE elements corresponding to the subset of positions upon which
fitting is to be performed. read.pdb
. ncore>1
requires package parallel installed. Coordinate superposition with the Kabsch algorithm.
The function fit.xyz
is a wrapper for the function
rot.lsq
, which performs the actual coordinate superposition.
The function rot.lsq
is an implementation of the Kabsch
algorithm (Kabsch, 1978) and evaluates the optimal rotation matrix
to minimize the RMSD between two structures.
Since the Kabsch algorithm assumes that the number of points are the
same in the two input structures, care should be taken to ensure that
consistent atom sets are selected with fixed.inds
and
mobile.inds
.
Optionally, full PDB file superposition and output can be
accomplished by setting full.pdbs=TRUE
. In that case, the
input (mobile
) passed to fit.xyz
should be a list object
obtained with the function read.fasta.pdb
, since the
components id
, resno
and xyz
are required to
establish correspondences. See the examples below.
In dealing with large vector and matrix, running on multiple
cores, especially when ncore>>1
, may ask for a large portion
of system memory. To avoid the overuse of memory, input data is first
split into segments (for xyz matrix, the splitting is along the row).
The number of data segments is equal to nseg.scale*nseg.base
, where
nseg.base
is an integer determined by the dimension of the data.
Grant, B.J. et al. (2006) Bioinformatics 22, 2695--2696.
Kabsch Acta Cryst (1978) A34, 827--828.
# PDB server connection required - testing excluded ##--- Read an alignment & Fit aligned structures aln <- read.fasta(system.file("examples/kif1a.fa",package="bio3d")) pdbs <- read.fasta.pdb(aln)pdb/seq: 1 name: http://www.rcsb.org/pdb/files/1bg2.pdb pdb/seq: 2 name: http://www.rcsb.org/pdb/files/1i6i.pdb PDB has ALT records, taking A only, rm.alt=TRUE pdb/seq: 3 name: http://www.rcsb.org/pdb/files/1i5s.pdb PDB has ALT records, taking A only, rm.alt=TRUE pdb/seq: 4 name: http://www.rcsb.org/pdb/files/2ncd.pdbgaps <- gap.inspect(pdbs$xyz) xyz <- fit.xyz( fixed = pdbs$xyz[1,], mobile = pdbs$xyz, fixed.inds = gaps$f.inds, mobile.inds = gaps$f.inds ) #rmsd( xyz[, gaps$f.inds] ) #rmsd( pdbs$xyz[, gaps$f.inds] ) ##-- Superpose again this time outputing PDBs xyz <- fit.xyz( fixed = pdbs$xyz[1,], mobile = pdbs, fixed.inds = gaps$f.inds, mobile.inds = gaps$f.inds, outpath = "rough_fit", full.pdbs = TRUE)PDB has ALT records, taking A only, rm.alt=TRUE PDB has ALT records, taking A only, rm.alt=TRUE##--- Fit two PDBs A <- read.pdb("1bg2")Note: Accessing on-line PDB fileA.ind <- atom.select(A, resno=c(256:269), elety='CA') B <- read.pdb("2kin")Note: Accessing on-line PDB file PDB has ALT records, taking A only, rm.alt=TRUEB.ind <- atom.select(B, resno=c(257:270), elety='CA') xyz <- fit.xyz(fixed=A$xyz, mobile=B$xyz, fixed.inds=A.ind$xyz, mobile.inds=B.ind$xyz) # Write out moved PDB C <- B; C$xyz = xyz write.pdb(pdb=C, file = "moved.pdb")
rmsd
, read.pdb
,
read.fasta.pdb
, read.dcd
rot.lsq
contributions from Leo Caves