Calculate the RMSD between coordinate sets.

rmsd(a, b=NULL, a.inds=NULL, b.inds=NULL, fit=FALSE, ncore=1, nseg.scale=1)

Arguments

a

a numeric vector containing the reference coordinate set for comparison with the coordinates in b. Alternatively, if b=NULL then a can be a matrix or list object containing multiple coordinates for pairwise comparison.

b

a numeric vector, matrix or list object with an xyz component, containing one or more coordinate sets to be compared with a.

a.inds

a vector of indices that selects the elements of a upon which the calculation should be based.

b.inds

a vector of indices that selects the elements of b upon which the calculation should be based.

fit

logical, if TRUE coordinate superposition is performed prior to RMSD calculation.

ncore

number of CPU cores used to do the calculation. ncore>1 requires package ‘parallel’ installed.

nseg.scale

split input data into specified number of segments prior to running multiple core calculation. See fit.xyz.

Details

RMSD is a standard measure of structural distance between coordinate sets.

Structure a[a.inds] and b[b.inds] should have the same length.

A least-squares fit is performed prior to RMSD calculation by setting fit=TRUE. See the function fit.xyz for more details of the fitting process.

Value

Returns a numeric vector of RMSD value(s).

References

Grant, B.J. et al. (2006) Bioinformatics 22, 2695--2696.

Author

Barry Grant

See also

Examples

# \donttest{ # Redundant testing excluded # -- Calculate RMSD between two or more 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.pdb
# Gap positions inds <- gap.inspect(pdbs$xyz) # Superposition before pairwise RMSD rmsd(pdbs$xyz, fit=TRUE)
#> Warning: No indices provided, using the 293 non NA positions
#> 1bg2 1i6i 1i5s 2ncd #> 1bg2 0.000 2.654 2.412 2.775 #> 1i6i 2.654 0.000 2.202 3.063 #> 1i5s 2.412 2.202 0.000 2.904 #> 2ncd 2.775 3.063 2.904 0.000
# RMSD between structure 1 and structures 2 and 3 rmsd(a=pdbs$xyz[1,], b=pdbs$xyz[2:3,], a.inds=inds$f.inds, b.inds=inds$f.inds, fit=TRUE)
#> 1i6i 1i5s #> 2.654 2.412
# RMSD between structure 1 and all structures in alignment rmsd(a=pdbs$xyz[1,], b=pdbs, a.inds=inds$f.inds, b.inds=inds$f.inds, fit=TRUE)
#> 1bg2 1i6i 1i5s 2ncd #> 0.000 2.654 2.412 2.775
# RMSD without superposition rmsd(pdbs$xyz)
#> Warning: No indices provided, using the 293 non NA positions
#> 1bg2 1i6i 1i5s 2ncd #> 1bg2 0.000 48.901 48.533 63.343 #> 1i6i 48.901 0.000 58.171 53.186 #> 1i5s 48.533 58.171 0.000 88.198 #> 2ncd 63.343 53.186 88.198 0.000
# }