Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ makedocs(
"Dihedral angle analysis" => "Dihedrals.md",
"Secondary structure" => "secondary_structures.md",
"Structural alignment" => "structural_alignment.md",
"Contacts" => "contacts.md",
],
"Simulation statistics" => Any[
" Block averages" => "block_averages.md",
Expand Down
33 changes: 33 additions & 0 deletions docs/src/contacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
```@meta
CollapsedDocStrings = true
```
# Contact analysis

Contact analysis routines allow the computation and tracking of contacts along a simulation.

## Distance between two residues

This function computes the minimum distance between the atoms of two residues. It can be
used standalone, but it is also the basis for the computation of contact maps.

```@docs
residue_residue_distance
```

## Contact map

The `contact_map` function is used to evaluate contacts within a structure, or among
two structures.

```@docs
contact_map
```

The output of `contact_map` is a `ContactMap` data structure:

```@docs
ContactMap
```



70 changes: 70 additions & 0 deletions ext/Contacts.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using MolSimToolkit: ContactMap
import PDBTools
import Plots: heatmap, cgrad

# the size of the plot should be proportional to the number
# of residues in each dimension, with a 100 residues for
# a 500px axis, by default
function _plot_size(map::ContactMap)
nres1 = size(map.matrix, 1)
nres2 = size(map.matrix, 2)
xpixels = min(600, max(300, round(Int,500 * nres1 / 100)))
ypixels = min(600, max(300, round(Int,500 * nres2 / 100)))
return (xpixels, ypixels)
end

function heatmap(
map::ContactMap{<:Real};
xstep=max(1, div(size(map.matrix, 1), 20)),
ystep=max(1, div(size(map.matrix, 2), 20)),
xticks=PDBTools.residue_ticks(map.residues1; stride=xstep, serial=true),
yticks=PDBTools.residue_ticks(map.residues2; stride=ystep, serial=true),
xrotation=60,
xlabel="residue",
ylabel="residue",
colorbar_title="distance (Å)",
aspect_ratio=1,
xlims=(1,size(map.matrix, 1)),
ylims=(1,size(map.matrix, 2)),
color=:grayC,
size=_plot_size(map),
framestyle=:box,
grid=false,
clims=(1,2) .* extrema(skipmissing(map.matrix)),
kargs...
)
return heatmap(map.matrix;
xlabel, ylabel, xticks, yticks, xrotation,
colorbar_title, color, aspect_ratio, xlims, ylims,
size, framestyle, grid, clims,
kargs...
)
end

function heatmap(
map::ContactMap{<:Bool};
xstep=max(1, div(size(map.matrix, 1), 20)),
ystep=max(1, div(size(map.matrix, 2), 20)),
xticks=PDBTools.residue_ticks(map.residues1; stride=xstep, serial=true),
yticks=PDBTools.residue_ticks(map.residues2; stride=ystep, serial=true),
xrotation=60,
xlabel="residue",
ylabel="residue",
aspect_ratio=1,
xlims=(1,size(map.matrix, 1)),
ylims=(1,size(map.matrix, 2)),
color=:Greys_9,
size=_plot_size(map),
framestyle=:box,
grid=false,
clims=(0,1),
colorbar=:none,
kargs...
)
return heatmap(map.matrix;
xlabel, ylabel, xticks, yticks, xrotation,
color, colorbar, aspect_ratio, xlims, ylims,
size, framestyle, grid, clims,
kargs...
)
end
4 changes: 2 additions & 2 deletions ext/MolSimStyle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const MolSimStyle_parameters = Dict{Symbol,Any}(
:fontfamily => "Computer Modern",
:margin => 0.5Plots.Measures.cm,
:grid => false,
:xlabel => "x",
:ylabel => "y",
# :xlabel => "x",
# :ylabel => "y",
:adjust_latex_font => true,
)

Expand Down
1 change: 1 addition & 0 deletions ext/Plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ module Plotting
include("./BlockAverages.jl")
include("./REMD.jl")
include("./SecondaryStructure.jl")
include("./Contacts.jl")
end
1 change: 1 addition & 0 deletions src/MolSimToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ include("./miscelaneous_functions/distances.jl")
include("./miscelaneous_functions/dihedrals.jl")
include("./miscelaneous_functions/center_of_mass.jl")
include("./miscelaneous_functions/most_representative_structure.jl")
include("./miscelaneous_functions/contacts.jl")
include("./secondary_structure/secondary_structure.jl")

# Time-dependent properties
Expand Down
Loading
Loading