Correlation functions
intermittent_correlation also applies to the identities of hydrogen bonds, as computed by hydrogen_bond_occupancy — see Persistence of hydrogen bonds.
MolSimToolkit.intermittent_correlation — Method
intermittent_correlation(
hbo::HydrogenBondOccupancy;
maxdelta::Integer = length(hbo.list) ÷ 10,
show_progress::Bool = true,
)Calculate the intermittent correlation function of the hydrogen bonds found by the hydrogen_bond_occupancy function. That is, computes the probability of finding a given hydrogen bond (the same donnor, polar hydrogen, and acceptor atoms) present at frame i + delta, given that it was present at frame i, for each hydrogen bond independently. The hydrogen bond does not need to remain present in every frame in between: it may break and reform within the interval (that is what makes this correlation function "intermittent", as opposed to "continuous").
Returns an OffsetArray with indices 0:maxdelta, where the value at position 0 is 1.0, corresponding to the normalized count of events.
Arguments
hbo::HydrogenBondOccupancy: The result of thehydrogen_bond_occupancyfunction.maxdelta::Integer: The maximum delta-step to be considered. Defaults tolength(hbo.list) ÷ 10.show_progress::Bool: Show progress bar. Defaults totrue.
Example
julia> using MolSimToolkit, MolSimToolkit.Testing
julia> sim = Simulation(Testing.namd_pdb, Testing.namd_traj);
julia> hbo = hydrogen_bond_occupancy(sim, "protein", show_progress=false)["protein => protein"];
julia> c = intermittent_correlation(hbo; maxdelta=4, show_progress=false);
julia> c[0]
1.0
MolSimToolkit.intermittent_correlation — Method
intermittent_correlation(
occupancy::Occupancy;
maxdelta::Integer = length(occupancy.list) ÷ 10,
show_progress::Bool = true,
)Calculate the intermittent correlation function of the occupancy of a binding site, as computed by the occupancy function. That is, computes the probability of finding a solvent molecule at the site at frame i + delta, given that it was found at the site at frame i, for each solvent molecule independently.
Returns an OffsetArray with indices 0:maxdelta, where the value at position 0 is 1.0, corresponding to the normalized count of events.
Arguments
occupancy::Occupancy: The result of theoccupancyfunction.maxdelta::Integer: The maximum delta-step to be considered. Defaults tolength(occupancy.list) ÷ 10.show_progress::Bool: Show progress bar. Defaults totrue.
Example
julia> using MolSimToolkit, PDBTools, MolSimToolkit.Testing
julia> sim = Simulation(Testing.namd2_pdb, Testing.namd2_traj);
julia> protein = select(get_atoms(sim), "protein");
julia> tmao = select(get_atoms(sim), "resname TMAO");
julia> occ = occupancy(sim, protein, tmao; solvent_natomspermol=14, cutoff=3.0, show_progress=false);
julia> c = intermittent_correlation(occ; maxdelta=4, show_progress=false);
julia> c
5-element OffsetArray(::Vector{Float64}, 0:4) with eltype Float64 with indices 0:4:
1.0
0.39
0.23469387755102042
0.12903225806451613
0.033707865168539325
MolSimToolkit.intermittent_correlation — Method
intermittent_correlation(
data::AbstractVector;
maxdelta = length(data) ÷ 10,
types::Function = x -> true,
show_progress::Bool = true,
)Calculate the intermittent correlation function of a time series. That is, computes the probability of finding a value of the same type at a step i + delta in the time series, given that it was present in step i.
Returns an OffsetArray with indices 0:maxdelta, where the value at position 0 is 1.0, corresponding to the normalized count of events.
Arguments
data::AbstractVector: The time series to be analyzed.maxdelta::Integer: The maximum delta-step to be considered. Defaults tolength(data) ÷ 10.types(optional): A function that returnstruefor the types of data that should be considered. Defaults to all data, i. e.x -> true. For example, to ignore0values, usetypes = x -> x != 0.show_progress::Bool: Show progress bar. Defaults totrue.
Examples
Here we produce a time-series of 10,000 elements, as a sequence of 1's and 0's ([1, 0, 1, 0, ...]), and calculate the intermittent correlation function. The probability of finding the same number (0 or 1) after odd steps is 0, and the probability of finding the same number after even steps is 1.
julia> using MolSimToolkit
julia> data = [ mod(i,2) for i in 1:10^4 ];
julia> intermittent_correlation(data; maxdelta=4, show_progress=false)
5-element OffsetArray(::Vector{Float64}, 0:4) with eltype Float64 with indices 0:4:
1.0
0.0
1.0
0.0
1.0
julia> intermittent_correlation(data; maxdelta=4, types = x -> x != 0, show_progress=false)
5-element OffsetArray(::Vector{Float64}, 0:4) with eltype Float64 with indices 0:4:
1.0
0.0
1.0
0.0
1.0In the second run, we have ignored the 0 values, and the result is the same, because here the correlations of the 1 values are the same as the correlations of the 0 values.