fit.xyz {bio3d} | R Documentation |
Coordinate superposition with the Kabsch algorithm.
fit.xyz(fixed, mobile, fixed.inds = NULL, mobile.inds = NULL, verbose=FALSE, pdb.path = "./", pdbext = ".pdb", outpath = "fitlsq/", het=FALSE, full.pdbs=FALSE) rot.lsq(xx, yy, xfit = rep(TRUE, length(xx)), yfit = xfit, verbose = FALSE)
fixed |
numeric vector of xyz coordinates. |
mobile |
numeric vector, numeric matrix, or an object with an
xyz component containing one or more coordinate sets. |
fixed.inds |
a vector of indices that selects the elements of
fixed upon which fitting should be based. |
mobile.inds |
a vector of indices that selects the elements
of mobile upon which fitting should be based. |
full.pdbs |
logical, if TRUE “full” coordinate files
(i.e. all atoms) are written to the location specified by
outpath . |
het |
logical, if TRUE ‘HETATM’ records from full PDB
files are written to output superposed PDB files. Only required if
full.pdbs is TRUE. |
pdb.path |
path to the “full” input PDB files. Only
required if full.pdbs is TRUE. |
pdbext |
the file name extension of the input PDB files. |
outpath |
character string specifing the output directory when
full.pdbs is TRUE. |
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 xx , with
TRUE elements corresponding to the subset of positions upon which
fitting is to be performed. |
yfit |
logical vector with the same length as yy , with
TRUE elements corresponding to the subset of positions upon which
fitting is to be performed. |
verbose |
logical, if TRUE more details are printed. |
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.
Returns moved coordinates.
Barry Grant with rot.lsq
contributions from Leo Caves
Grant, B.J. et al. (2006) Bioinformatics 22, 2695–2696.
Kabsch Acta Cryst (1978) A34, 827–828.
rmsd
, read.pdb
,
read.fasta.pdb
, read.dcd
## Not run: ##--- Read an alignment & Fit aligned structures aln <- read.fasta(system.file("examples/kif1a.fa",package="bio3d")) pdb.path = system.file("examples",package="bio3d") pdbs <- read.fasta.pdb(aln, pdb.path = pdb.path, pdbext = ".ent") ## End(Not run) #-- OR Read previously saved kinesin data & Fit aligned structures data(kinesin) attach(kinesin) 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 ) # Use indices from 'core.find()' for improved fitting #core <- core.find(pdbs) # see ?core.find # Superpose again this time outputing PDBs ## Not run: xyz <- fit.xyz( fixed = pdbs$xyz[1,], mobile = pdbs, fixed.inds = gaps$f.inds, mobile.inds = gaps$f.inds, pdb.path = system.file("examples/",package="bio3d"), pdbext = ".ent", outpath = "rough_fit/", full.pdbs = TRUE) ##--- Fit two PDBs A <- read.pdb(system.file("examples/d1bg2__.ent",package="bio3d")) A.ind <- atom.select(A, "///256:269///CA/") B <- read.pdb(system.file("examples/d2kin.1.ent",package="bio3d")) B.ind <- atom.select(B, "///257:270///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") ## End(Not run)