Dihedral angle analysis

MolSimToolkit.average_dihedralsFunction
average_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
source
MolSimToolkitShared.dihedralFunction
dihedral(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.

source
MolSimToolkitShared.dihedralsFunction
dihedrals(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 MolSimToolkitShared: dihedrals

julia> v1 = [[-8.483, -14.912, -6.726], [-5.113, -13.737, -5.466], [-3.903, -11.262, -8.062], [-1.162, -9.64, -6.015]];

julia> v2 = [[-9.229, -14.861, -5.481], [-8.483, -14.912, -6.726], [-7.227, -14.047, -6.599], [-7.083, -13.048, -7.303]];

julia> dihedrals([v1,v2])
2-element Vector{Float64}:
  164.43481280739516
 -115.82544005374316
source