Skip to content

Commit 0d46769

Browse files
committed
Add unit tests for ring break and size change detection.
1 parent 7ca8c75 commit 0d46769

2 files changed

Lines changed: 269 additions & 1 deletion

File tree

tests/Align/test_align.py

Lines changed: 135 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from sire.legacy.Mol import AtomIdx, Element, PartialMolecule
66

77
import BioSimSpace as BSS
8-
from tests.conftest import has_amber
8+
from tests.conftest import has_amber, has_openff
99

1010
# Store the tutorial URL.
1111
url = BSS.tutorialUrl()
@@ -695,3 +695,137 @@ def test_ion_merge(system):
695695
water_coords = water._sire_object.property("coordinates").to_vector()[0]
696696
assert coords0 == coords1
697697
assert coords0 == water_coords
698+
699+
700+
@pytest.mark.skipif(has_openff is False, reason="Requires OpenFF to be installed.")
701+
@pytest.mark.parametrize(
702+
"ligands, mapping",
703+
[
704+
(
705+
("Schindler_SYK_CHEMBL3265035", "Schindler_SYK_CHEMBL3265033"),
706+
{
707+
5: 8,
708+
6: 32,
709+
7: 31,
710+
8: 11,
711+
9: 12,
712+
10: 13,
713+
11: 14,
714+
12: 15,
715+
13: 16,
716+
14: 17,
717+
15: 18,
718+
16: 19,
719+
17: 20,
720+
18: 21,
721+
19: 22,
722+
20: 23,
723+
21: 24,
724+
22: 25,
725+
23: 26,
726+
24: 27,
727+
25: 28,
728+
26: 29,
729+
27: 30,
730+
28: 10,
731+
29: 9,
732+
38: 53,
733+
39: 52,
734+
40: 43,
735+
41: 44,
736+
42: 45,
737+
43: 46,
738+
44: 47,
739+
45: 48,
740+
46: 49,
741+
47: 50,
742+
48: 51,
743+
49: 42,
744+
50: 41,
745+
1: 1,
746+
2: 4,
747+
34: 36,
748+
33: 35,
749+
3: 3,
750+
4: 34,
751+
35: 1,
752+
0: 6,
753+
32: 37,
754+
31: 7,
755+
36: 33,
756+
},
757+
),
758+
(
759+
("Schindler_SYK_CHEMBL3265035", "Schindler_SYK_CHEMBL3265036"),
760+
{
761+
5: 7,
762+
6: 31,
763+
7: 30,
764+
8: 10,
765+
9: 11,
766+
10: 12,
767+
11: 13,
768+
12: 14,
769+
13: 15,
770+
14: 16,
771+
15: 17,
772+
16: 18,
773+
17: 19,
774+
18: 20,
775+
19: 21,
776+
20: 22,
777+
21: 23,
778+
22: 24,
779+
23: 25,
780+
24: 26,
781+
25: 27,
782+
26: 28,
783+
27: 29,
784+
28: 9,
785+
29: 8,
786+
38: 54,
787+
39: 53,
788+
40: 44,
789+
41: 45,
790+
42: 46,
791+
43: 47,
792+
44: 48,
793+
45: 49,
794+
46: 50,
795+
47: 51,
796+
48: 52,
797+
49: 43,
798+
50: 42,
799+
0: 4,
800+
1: 5,
801+
2: 6,
802+
3: 0,
803+
4: 1,
804+
30: 3,
805+
31: 39,
806+
32: 38,
807+
33: 40,
808+
34: 41,
809+
35: 32,
810+
36: 33,
811+
37: 34,
812+
},
813+
),
814+
],
815+
)
816+
def test_ring_opening_and_size_change(ligands, mapping):
817+
# These perturbations involve ring formation (acyclic atoms in mol0 become
818+
# ring members in mol1) combined with ring size changes in the existing
819+
# fused bicyclic core. Check that the merge succeeds when both flags are
820+
# allowed.
821+
m0 = BSS.IO.readMolecules(f"{url}/{ligands[0]}.sdf.bz2")[0]
822+
m1 = BSS.IO.readMolecules(f"{url}/{ligands[1]}.sdf.bz2")[0]
823+
824+
m0 = BSS.Parameters.openff_unconstrained_2_1_1(m0).getMolecule()
825+
m1 = BSS.Parameters.openff_unconstrained_2_1_1(m1).getMolecule()
826+
827+
m0 = BSS.Align.rmsdAlign(m0, m1, mapping)
828+
829+
BSS.Align.merge(
830+
m0, m1, mapping, allow_ring_breaking=True, allow_ring_size_change=True
831+
)

tests/Sandpit/Exscientia/Align/test_align.py

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,137 @@ def test_ion_merge():
750750
water_coords = water._sire_object.property("coordinates").to_vector()[0]
751751
assert coords0 == coords1
752752
assert coords0 == water_coords
753+
754+
755+
@pytest.mark.skipif(has_openff is False, reason="Requires OpenFF to be installed.")
756+
@pytest.mark.parametrize(
757+
"ligands, mapping",
758+
[
759+
(
760+
("Schindler_SYK_CHEMBL3265035", "Schindler_SYK_CHEMBL3265033"),
761+
{
762+
5: 8,
763+
6: 32,
764+
7: 31,
765+
8: 11,
766+
9: 12,
767+
10: 13,
768+
11: 14,
769+
12: 15,
770+
13: 16,
771+
14: 17,
772+
15: 18,
773+
16: 19,
774+
17: 20,
775+
18: 21,
776+
19: 22,
777+
20: 23,
778+
21: 24,
779+
22: 25,
780+
23: 26,
781+
24: 27,
782+
25: 28,
783+
26: 29,
784+
27: 30,
785+
28: 10,
786+
29: 9,
787+
38: 53,
788+
39: 52,
789+
40: 43,
790+
41: 44,
791+
42: 45,
792+
43: 46,
793+
44: 47,
794+
45: 48,
795+
46: 49,
796+
47: 50,
797+
48: 51,
798+
49: 42,
799+
50: 41,
800+
1: 1,
801+
2: 4,
802+
34: 36,
803+
33: 35,
804+
3: 3,
805+
4: 34,
806+
35: 1,
807+
0: 6,
808+
32: 37,
809+
31: 7,
810+
36: 33,
811+
},
812+
),
813+
(
814+
("Schindler_SYK_CHEMBL3265035", "Schindler_SYK_CHEMBL3265036"),
815+
{
816+
5: 7,
817+
6: 31,
818+
7: 30,
819+
8: 10,
820+
9: 11,
821+
10: 12,
822+
11: 13,
823+
12: 14,
824+
13: 15,
825+
14: 16,
826+
15: 17,
827+
16: 18,
828+
17: 19,
829+
18: 20,
830+
19: 21,
831+
20: 22,
832+
21: 23,
833+
22: 24,
834+
23: 25,
835+
24: 26,
836+
25: 27,
837+
26: 28,
838+
27: 29,
839+
28: 9,
840+
29: 8,
841+
38: 54,
842+
39: 53,
843+
40: 44,
844+
41: 45,
845+
42: 46,
846+
43: 47,
847+
44: 48,
848+
45: 49,
849+
46: 50,
850+
47: 51,
851+
48: 52,
852+
49: 43,
853+
50: 42,
854+
0: 4,
855+
1: 5,
856+
2: 6,
857+
3: 0,
858+
4: 1,
859+
30: 3,
860+
31: 39,
861+
32: 38,
862+
33: 40,
863+
34: 41,
864+
35: 32,
865+
36: 33,
866+
37: 34,
867+
},
868+
),
869+
],
870+
)
871+
def test_ring_opening_and_size_change(ligands, mapping):
872+
# These perturbations involve ring formation (acyclic atoms in mol0 become
873+
# ring members in mol1) combined with ring size changes in the existing
874+
# fused bicyclic core. Check that the merge succeeds when both flags are
875+
# allowed.
876+
m0 = BSS.IO.readMolecules(f"{url}/{ligands[0]}.sdf.bz2")[0]
877+
m1 = BSS.IO.readMolecules(f"{url}/{ligands[1]}.sdf.bz2")[0]
878+
879+
m0 = BSS.Parameters.openff_unconstrained_2_1_1(m0).getMolecule()
880+
m1 = BSS.Parameters.openff_unconstrained_2_1_1(m1).getMolecule()
881+
882+
m0 = BSS.Align.rmsdAlign(m0, m1, mapping)
883+
884+
BSS.Align.merge(
885+
m0, m1, mapping, allow_ring_breaking=True, allow_ring_size_change=True
886+
)

0 commit comments

Comments
 (0)