fit.xyz {bio3d} | R Documentation |
Coordinate Superposition
Description
Coordinate superposition with the Kabsch algorithm.
Usage
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)
Arguments
fixed |
numeric vector of xyz coordinates. |
mobile |
numeric vector, numeric matrix, or an object with an
|
fixed.inds |
a vector of indices that selects the elements of
|
mobile.inds |
a vector of indices that selects the elements
of |
full.pdbs |
logical, if TRUE “full” coordinate files
(i.e. all atoms) are written to the location specified by
|
prefix |
prefix to mobile$id to locate “full” input PDB files. Only
required if |
pdbext |
the file name extension of the input PDB files. |
outpath |
character string specifing the output directory when
|
xx |
numeric vector corresponding to the moving ‘subject’ coordinate set. |
yy |
numeric vector corresponding to the fixed ‘target’ coordinate set. |
xfit |
logical vector with the same length as |
yfit |
logical vector with the same length as |
verbose |
logical, if TRUE more details are printed. |
... |
other parameters for |
ncore |
number of CPU cores used to do the calculation.
|
nseg.scale |
split input data into specified number of segments prior to running multiple core calculation. |
Details
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.
Value
Returns moved coordinates.
Author(s)
Barry Grant with rot.lsq
contributions from Leo Caves
References
Grant, B.J. et al. (2006) Bioinformatics 22, 2695–2696.
Kabsch Acta Cryst (1978) A34, 827–828.
See Also
rmsd
, read.pdb
,
read.fasta.pdb
, read.dcd
Examples
# 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)
gaps <- 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] )
## Not run:
##-- 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)
## End(Not run)
##--- Fit two PDBs
A <- read.pdb("1bg2")
A.ind <- atom.select(A, resno=c(256:269), elety='CA')
B <- read.pdb("2kin")
B.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)
## Not run:
# Write out moved PDB
C <- B; C$xyz = xyz
write.pdb(pdb=C, file = "moved.pdb")
## End(Not run)