Skip to content

Commit

Permalink
some example script simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Feb 20, 2024
1 parent 359dfd1 commit b3974c8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions docs/src/assets/scripts/example2/script2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ plot!(

# Plot DMF group contributions to the MDDF. We use a dictionary where
# the keys are the group names, and the values are the atom names of the group
groups = Dict(
groups = (
"CO" => ["C","O"], # carbonyl
"N" => ["N"],
"Methyl groups" => ["CC","CT","HC1","HC2","HC3","HT1","HT2","HT3"],
)
for (group_label, group_atoms) in pairs(groups)
for (group_label, group_atoms) in groups
# Retrieve the contributions of the atoms of this group
group_contrib = contributions(results, SolventGroup(group_atoms))
# Plot the contributions of this groups, with the appropriate label
Expand All @@ -55,11 +55,11 @@ plot!(xlim=(1,5), ylabel="MDDF", subplot=1)
# Plot ACR group contributions to the MDDF. This is an interesting case,
# as the groups are repeated along the polymer chain
#
groups = Dict(
L"\textrm{CH_3}" => ["CF","HF1","HF2","HF3", "CL","HL1","HL2","HL3"], # terminal methyles
groups = (
"CH_3" => ["CF","HF1","HF2","HF3", "CL","HL1","HL2","HL3"], # terminal methyles
"CO" => ["OE1","CD"], # carbonyl
L"\textrm{NH_2}" => ["NE2","HE22","HE21"], # amine
L"\textrm{CHCH_2}" => ["C","H2","H1","CA","HA"], # backbone
"NH_2" => ["NE2","HE22","HE21"], # amine
"CHCH_2" => ["C","H2","H1","CA","HA"], # backbone
)
# Plot total mddf
plot!(
Expand All @@ -69,12 +69,12 @@ plot!(
subplot=2
)
# Plot group contributions
for (group_name, atom_names) in pairs(groups)
for (group_name, atom_names) in groups
group_contrib = contributions(results, SoluteGroup(atom_names))
plot!(
results.d,
movavg(group_contrib,n=10).x,
label=group_name,
label=latexstring("\\textrm{$group_name}"),
subplot=2
)
end
Expand Down
2 changes: 1 addition & 1 deletion docs/src/assets/scripts/example2/script3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ results = load("./mddf.json")
group_contribs = Vector{Float64}[]
labels = LaTeXString[]
for (imer, mer) in enumerate(eachresidue(acr))
for (group_label, group_atoms) in pairs(groups)
for (group_label, group_atoms) in groups
# only first residue has a terminal CH3
if imer != 1 && group_label == "CH_3"
continue
Expand Down
4 changes: 2 additions & 2 deletions docs/src/assets/scripts/example3/script2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ mddf_ethanol_POPC = load("mddf_ethanol_POPC.json")
#
# Define the groups using selections. Set a dict, in which the keys are the group names
# and the values are the selections
groups = Dict(
groups = (
"Hydroxyl" => select(ethanol, "name O1 or name HO1"),
"Aliphatic chain" => select(ethanol, "not name O1 and not name HO1"),
)
# plot the total mddf and the contributions of the groups
x = mddf_ethanol_POPC.d
plot(x, movavg(mddf_ethanol_POPC.mddf, n=10).x, label="Total MDDF")
for (group_name, group_atoms) in pairs(groups)
for (group_name, group_atoms) in groups
cont = contributions(mddf_ethanol_POPC, SolventGroup(group_atoms))
y = movavg(cont, n=10).x
plot!(x, y, label=group_name)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/assets/scripts/example3/script3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mddf_water_POPC = load("mddf_water_POPC.json")
# Here we define the POPC groups, from the atom names. Each group
# is a vector of atom names, and the keys are the group names.
#
groups = Dict(
groups = (
"Choline" => ["N", "C12", "H12A", "H12B", "C13", "H13A", "H13B", "H13C", "C14",
"H14A", "H14B", "H14C", "C15", "H15A", "H15B", "H15C", "C11", "H11A", "H11B"],
"Phosphate" => ["P", "O13", "O14", "O12"],
Expand All @@ -55,7 +55,7 @@ plot(
movavg(mddf_water_POPC.mddf, n=10).x,
label="Total water-POPC MDDF"
)
for (group_name, group_atoms) in pairs(groups)
for (group_name, group_atoms) in groups
cont = contributions(mddf_water_POPC, SoluteGroup(group_atoms))
y = movavg(cont, n=10).x
plot!(x, y, label=group_name)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/assets/scripts/example3/script4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mddf_ethanol_POPC = load("mddf_ethanol_POPC.json")
# Here we define the POPC groups, from the atom names. Each group
# is a vector of atom names, and the keys are the group names.
#
groups = Dict(
groups = (
"Choline" => ["N", "C12", "H12A", "H12B", "C13", "H13A", "H13B", "H13C", "C14",
"H14A", "H14B", "H14C", "C15", "H15A", "H15B", "H15C", "C11", "H11A", "H11B"],
"Phosphate" => ["P", "O13", "O14", "O12"],
Expand All @@ -55,7 +55,7 @@ plot(
movavg(mddf_ethanol_POPC.mddf, n=10).x,
label="Total ethanol-POPC MDDF"
)
for (group_name, group_atoms) in pairs(groups)
for (group_name, group_atoms) in groups
cont = contributions(mddf_ethanol_POPC, SoluteGroup(group_atoms))
y = movavg(cont, n=10).x
plot!(x, y, label=group_name)
Expand Down
8 changes: 4 additions & 4 deletions docs/src/assets/scripts/example3/script5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mddf_ethanol_POPC = load("mddf_ethanol_POPC.json")
# Splitting the oleoyl chain into groups along the the chain.
# The labels `CH_2` etc stand for `CH₂`, for example, in LaTeX notation,
# for a nicer plot axis ticks formatting.
oleoyl_groups = [
oleoyl_groups = (
"CO" => ["O22", "C21"],
"CH_2" => ["H2R", "H2S", "C22"],
"CH_2" => ["C23", "H3R", "H3S"],
Expand All @@ -47,7 +47,7 @@ oleoyl_groups = [
"CH_2" => ["C216", "H16R", "H16S"],
"CH_2" => ["C217", "H17R", "H17S"],
"CH_3" => ["C218", "H18R", "H18S", "H18T"]
]
)

# Format tick labels with LaTeX
labels_o = [latexstring("\\textrm{$key}") for (key, val) in oleoyl_groups]
Expand Down Expand Up @@ -87,7 +87,7 @@ annotate!( 14, 2.7, text("Oleoyl", :left, 12, plot_font), subplot=1)
#
# Repeat procedure for the palmitoyl groups
#
palmitoyl_groups = [
palmitoyl_groups = (
"CO" => ["C31", "O32"],
"CH_2" => ["C32", "H2X", "H2Y"],
"CH_2" => ["C33", "H3X", "H3Y"],
Expand All @@ -104,7 +104,7 @@ palmitoyl_groups = [
"CH_2" => ["C314", "H14X", "H14Y"],
"CH_2" => ["C315", "H15X", "H15Y"],
"CH_3" => ["C316", "H16X", "H16Y", "H16Z"],
]
)

# Format tick labels with LaTeX
labels_p = [latexstring("\\textrm{$key}") for (key, val) in palmitoyl_groups]
Expand Down
4 changes: 2 additions & 2 deletions docs/src/assets/scripts/example4/script3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ mddf_glyc_water = load("./mddf_glyc_water.json")
# 2D maps plot of group contributions

# Glycerol groups
groups = [
groups = (
"OH" => ["O1", "HO1"], # first hydroxyl
"CH_2" => ["C1", "H11", "H12"], # first CH2
"OH" => ["O2", "HO2"], # second hydroxyl
"CH" => ["C2", "H2"], # CH
"CH_2" => ["C3", "H31", "H32"], # second CH2
"OH" => ["O3", "HO3"] # third hydroxyl
]
)
labels = latexstring.("\\textrm{$name}" for (name, atoms) in groups)

#
Expand Down

0 comments on commit b3974c8

Please sign in to comment.