Skip to content

Commit

Permalink
add stereo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mojaie committed Nov 17, 2024
1 parent af7e0a7 commit 2dad3b6
Showing 1 changed file with 92 additions and 12 deletions.
104 changes: 92 additions & 12 deletions test/stereo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ end
edges = Edge.([(1,2), (1,3), (1,4), (1,5)])
default_config = Dict{Symbol,Any}(
:on_init => MolecularGraph.sdf_on_init!, :updater => MolecularGraph.sdf_on_update!)
uns1 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(uns1, :stereocenter))
uns = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(uns, :stereocenter))

bonds = [
SDFBond(1, 0),
Expand Down Expand Up @@ -151,6 +151,24 @@ end
mol8 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test get_prop(mol8, :stereocenter)[1] == (2, 3, 5, true)

bonds = [
SDFBond(1, 1),
SDFBond(1, 0),
SDFBond(1, 6),
SDFBond(1, 1)
]
mol9 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test get_prop(mol9, :stereocenter)[1] == (2, 3, 5, true)

bonds = [
SDFBond(1, 6),
SDFBond(1, 1),
SDFBond(1, 1),
SDFBond(1, 6)
]
mol10 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test get_prop(mol10, :stereocenter)[1] == (2, 3, 5, false)

bonds = [
SDFBond(1, 1),
SDFBond(1, 0),
Expand All @@ -171,7 +189,7 @@ end
]
wrong2 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(wrong2, :stereocenter))
@test haskey(wrong4.gprops, :stereocenter_ignored)
@test haskey(wrong2.gprops, :stereocenter_ignored)

bonds = [
SDFBond(1, 1),
Expand All @@ -181,7 +199,27 @@ end
]
wrong3 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(wrong3, :stereocenter))
@test haskey(wrong_all.gprops, :stereocenter_ignored)
@test haskey(wrong3.gprops, :stereocenter_ignored)

bonds = [
SDFBond(1, 6),
SDFBond(1, 6),
SDFBond(1, 6),
SDFBond(1, 6)
]
wrong4 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(wrong4, :stereocenter))
@test haskey(wrong4.gprops, :stereocenter_ignored)

bonds = [
SDFBond(1, 1),
SDFBond(1, 6),
SDFBond(1, 1),
SDFBond(1, 6)
]
wrong5 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(wrong5, :stereocenter))
@test haskey(wrong5.gprops, :stereocenter_ignored)

# degree=3
atoms = [
Expand All @@ -196,27 +234,69 @@ end
SDFBond(1, 0)
]
edges = Edge.([(1,2), (1,3), (1,4)])
uns2 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(uns2, :stereocenter))
implh_uns = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(implh_uns, :stereocenter))
@test !haskey(implh_uns.gprops, :stereocenter_ignored)

bonds = [
SDFBond(1, 1), SDFBond(1, 0), SDFBond(1, 0)
SDFBond(1, 1),
SDFBond(1, 0),
SDFBond(1, 0)
]
implh1 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test get_prop(implh1, :stereocenter)[1] == (2, 3, 4, true)

bonds = [
SDFBond(1, 0), SDFBond(1, 6), SDFBond(1, 0)
SDFBond(1, 0),
SDFBond(1, 6),
SDFBond(1, 0)
]
implh2 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test get_prop(implh2, :stereocenter)[1] == (2, 3, 4, false)

bonds = [
SDFBond(1, 0), SDFBond(1, 6), SDFBond(1, 1)
SDFBond(1, 6),
SDFBond(1, 6),
SDFBond(1, 0)
]
wrong5 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(wrong5, :stereocenter))
@test haskey(wrong5.gprops, :stereocenter_ignored)
implh3 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test get_prop(implh3, :stereocenter)[1] == (2, 3, 4, true)

bonds = [
SDFBond(1, 0),
SDFBond(1, 6),
SDFBond(1, 1)
]
implh_wrong = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(implh_wrong, :stereocenter))
@test haskey(implh_wrong.gprops, :stereocenter_ignored)

bonds = [
SDFBond(1, 1),
SDFBond(1, 1),
SDFBond(1, 1)
]
implh_wrong2 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(implh_wrong2, :stereocenter))
@test haskey(implh_wrong2.gprops, :stereocenter_ignored)

bonds = [
SDFBond(1, 6),
SDFBond(1, 6),
SDFBond(1, 6)
]
implh_wrong3 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(implh_wrong3, :stereocenter))
@test haskey(implh_wrong3.gprops, :stereocenter_ignored)

bonds = [
SDFBond(1, 6),
SDFBond(1, 1),
SDFBond(1, 6)
]
implh_wrong4 = MolGraph(edges, atoms, bonds, config_map=default_config)
@test isempty(get_prop(implh_wrong4, :stereocenter))
@test haskey(implh_wrong4.gprops, :stereocenter_ignored)

# transformed
atoms = [
Expand Down

0 comments on commit 2dad3b6

Please sign in to comment.