Dihedral angle analysis
This is an experimental feature. Breaking changes may occur without a breaking package release.
MolSimToolkit.average_dihedrals
— Methodaverage_dihedrals(sim::Simulation, v::AbstractVector{<:AbstractVector{<:Integer}}; degrees=true)
average_dihedrals(sim::Simulation, v::AbstractVector{<:AbstractVector{<:PDBTools.Atom}}; degrees=true)
Computes the average dihedral angles for many sets of 4 vectors from a trajectory. The input is a vector of vectors, containing the indices of the atoms forming the dihedral angles, or the PDBTools.Atom
objects.
The function returns a vector with the average dihedral angles in radians or degrees.
Example
julia> using MolSimToolkit, MolSimToolkit.Testing, PDBTools
julia> atoms = read_pdb(Testing.namd2_pdb);
julia> cAs = select(atoms, "name CA and residue < 5"); # 4 atoms
julia> r1b = select(atoms, "residue 1 and backbone"); # 4 atoms
julia> inds = [ index.(cAs), index.(r1b) ]; # List of vector of indices
julia> sim = Simulation(Testing.namd2_pdb, Testing.namd2_traj);
julia> ds = average_dihedrals(sim, inds)
2-element Vector{Float64}:
-60.12860673875001
-0.3398274578758668
julia> ats = [ cAs, r1b ]; # List of vectors of PDBTools.Atom
julia> ds = average_dihedrals(sim, ats)
2-element Vector{Float64}:
-60.12860673875001
-0.3398274578758668
MolSimToolkit.dihedral
— Methoddihedral(v1, v2, v3, v4; degrees=true)
dihedral(v::AbstractVector; degrees=true)
Computes the dihedral angle between the planes formed by the vectors v1-v2
and v2-v3
, and v2-v3
and v3-v4
. The input vectors must have 3 elements. The function returns the dihedral angle in radians or degrees. If the input is a vector with 4 vectors, the function computes the dihedral angle between the planes formed by the vectors v[1]-v[2]
and v[2]-v[3]
, and v[2]-v[3]
and v[3]-v[4]
.
The optional argument degrees
specifies whether the output is in degrees (default) or radians.
MolSimToolkit.dihedrals
— Methoddihedrals(v::AbstractVector{<:AbstractVector}; degrees=true)
Computes the dihedral angles for many sets of 4 vectors. The input is a vector of vectors, where each element is a vector with 4 vectors. The function returns a vector with the dihedral angles in radians or degrees.
Example
julia> using MolSimToolkit, MolSimToolkit.Testing, PDBTools
julia> atoms = read_pdb(Testing.namd2_pdb);
julia> cAs = select(atoms, "name CA and residue < 5");
julia> r1b = select(atoms, "residue 1 and backbone");
julia> ds = dihedrals([ coor(cAs), coor(r1b) ])
2-element Vector{Float32}:
164.4348
-115.82544