Skip to content

Commit

Permalink
initialize options with default value, add tests for methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Dec 8, 2024
1 parent 0a1abf2 commit 0384786
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions src/mddf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function mddf(
trajectory_file::String,
solute::AtomSelection,
solvent::AtomSelection,
options::Options;
options::Options=Options();
trajectory_format::String="",
chemfiles::Bool=false,
kargs...)
Expand All @@ -194,7 +194,7 @@ end
function mddf(
trajectory_file::String,
solute_and_solvent::AtomSelection,
options::Options;
options::Options=Options();
trajectory_format::String="",
chemfiles::Bool=false,
kargs...
Expand Down Expand Up @@ -528,7 +528,7 @@ function coordination_number(
trajectory_file::String,
solute::AtomSelection,
solvent::AtomSelection,
options::Options;
options::Options=Options();
trajectory_format::String="",
chemfiles::Bool=false,
kargs...)
Expand All @@ -540,7 +540,7 @@ end
function coordination_number(
trajectory_file::String,
solute_and_solvent::AtomSelection,
options::Options;
options::Options=Options();
trajectory_format::String="",
chemfiles::Bool=false,
kargs...
Expand Down Expand Up @@ -608,9 +608,6 @@ end
# Test wrong frame_weights input
@test_throws ArgumentError mddf(trajectory_file, protein, water, Options(); frame_weights=[1.0], trajectory_format)

# The coordination_number(::String, args...; kargs...) is a placeholder for the docs only
@test_throws ArgumentError coordination_number("string.txt", 1.0)

# Self correlation
atoms = readPDB("$data_dir/toy/self_monoatomic.pdb")
atom = AtomSelection(select(atoms, "resname WAT and model 1"), natomspermol=1)
Expand Down Expand Up @@ -709,6 +706,38 @@ end
@test R.density.solvent 2 / R.volume.total
@test R.density.solvent_bulk 0.5 / R.volume.bulk
end
end

@testitem "mddf - available methods" begin
using ComplexMixtures
using PDBTools: readPDB, select
using ComplexMixtures.Testing: data_dir
atoms = readPDB("$data_dir/toy/cross.pdb")
protein = AtomSelection(select(atoms, "protein and model 1"), nmols=1)
water = AtomSelection(select(atoms, "resname WAT and model 1"), natomspermol=3)
trajectory_file = "$data_dir/toy/cross.pdb"

atom = AtomSelection(select(atoms, "resname WAT and model 1"), natomspermol=1)
t = Trajectory(trajectory_file, atom; format="PDBTraj")

options = Options()
trajectory_file = "$data_dir/toy/self_monoatomic.pdb"
atom = AtomSelection(select(atoms, "resname WAT and model 1"), natomspermol=1)
r1 = mddf(trajectory_file, atom, atom)
r2 = mddf(trajectory_file, atom, atom, Options())
@test coordination_number(r1) coordination_number(r2)
r1 = mddf(trajectory_file, atom)
r2 = mddf(trajectory_file, atom, Options())
@test coordination_number(r1) coordination_number(r2)
r1 = coordination_number(trajectory_file, atom, atom)
r2 = coordination_number(trajectory_file, atom, atom, Options())
@test coordination_number(r1) coordination_number(r2)
r1 = coordination_number(trajectory_file, atom)
r2 = coordination_number(trajectory_file, atom, Options())
@test coordination_number(r1) coordination_number(r2)

# The coordination_number(::String, args...; kargs...) is a placeholder for the docs only
@test_throws ArgumentError coordination_number("string.txt", 1.0)

end

Expand Down

0 comments on commit 0384786

Please sign in to comment.