From f8c8434c9d606a53fea1cc157a21fe0ea2e90af3 Mon Sep 17 00:00:00 2001 From: andrewtarzia Date: Mon, 28 Oct 2024 12:40:06 +0100 Subject: [PATCH] Add example and output. --- examples/optwrite_example.py | 49 ++++++++++ examples/optwrite_output/etkdg_out.mol | 127 +++++++++++++++++++++++++ examples/optwrite_output/mmff_out.mol | 127 +++++++++++++++++++++++++ examples/optwrite_output/uff_out.mol | 127 +++++++++++++++++++++++++ 4 files changed, 430 insertions(+) create mode 100644 examples/optwrite_example.py create mode 100644 examples/optwrite_output/etkdg_out.mol create mode 100644 examples/optwrite_output/mmff_out.mol create mode 100644 examples/optwrite_output/uff_out.mol diff --git a/examples/optwrite_example.py b/examples/optwrite_example.py new file mode 100644 index 0000000..87fcae3 --- /dev/null +++ b/examples/optwrite_example.py @@ -0,0 +1,49 @@ +# ruff: noqa: T201 + +import logging +from pathlib import Path + +import stk + +import stko + + +def main() -> None: + """Run the example.""" + bb1 = stk.BuildingBlock("NCCN", [stk.PrimaryAminoFactory()]) + bb2 = stk.BuildingBlock("O=CCCC=O", [stk.AldehydeFactory()]) + polymer = stk.ConstructedMolecule( + topology_graph=stk.polymer.Linear( + building_blocks=(bb1, bb2), + repeating_unit="AB", + num_repeating_units=3, + optimizer=stk.Collapser(scale_steps=False), + ), + ) + + output_directory = Path("optwrite_output") + output_directory.mkdir(exist_ok=True, parents=True) + + optimiser = stko.OptWriterSequence( + optimizers={ + "etkdg": stko.ETKDG(), + "uff": stko.UFF(), + "mmff": stko.MMFF(), + }, + writer=stk.MolWriter(), + output_directory=output_directory, + ) + + polymer = optimiser.optimize(polymer) + + # Delete some, rerun. + (output_directory / "mmff_out.mol").unlink() + polymer = optimiser.optimize(polymer) + + +if __name__ == "__main__": + logging.basicConfig( + level=logging.INFO, + format="%(asctime)s | %(levelname)s | %(message)s", + ) + main() diff --git a/examples/optwrite_output/etkdg_out.mol b/examples/optwrite_output/etkdg_out.mol new file mode 100644 index 0000000..bb269a0 --- /dev/null +++ b/examples/optwrite_output/etkdg_out.mol @@ -0,0 +1,127 @@ + + RDKit 3D + + 0 0 0 0 0 0 0 0 0 0999 V3000 +M V30 BEGIN CTAB +M V30 COUNTS 57 56 0 0 0 +M V30 BEGIN ATOM +M V30 1 N -8.7253 2.0615 -1.1552 0 +M V30 2 C -7.3109 2.1250 -1.4520 0 +M V30 3 C -6.4890 2.0630 -0.1761 0 +M V30 4 N -6.7505 0.8547 0.5146 0 +M V30 5 H -8.8856 1.6166 -0.2047 0 +M V30 6 H -9.1721 1.5378 -1.9270 0 +M V30 7 H -6.9454 1.3341 -2.1163 0 +M V30 8 H -7.1406 3.1523 -1.8761 0 +M V30 9 H -6.7234 2.9706 0.4474 0 +M V30 10 H -5.4135 2.1215 -0.4442 0 +M V30 11 N -4.1891 -1.4429 -0.4840 0 +M V30 12 C -2.8634 -1.4576 -1.0534 0 +M V30 13 C -1.9940 -0.6620 -0.0939 0 +M V30 14 N -0.6344 -0.6123 -0.5652 0 +M V30 15 H -2.8559 -0.9676 -2.0488 0 +M V30 16 H -2.5085 -2.4823 -1.1273 0 +M V30 17 H -2.0338 -1.0379 0.9262 0 +M V30 18 H -2.3473 0.3978 -0.0461 0 +M V30 19 N 2.8751 0.4023 1.0896 0 +M V30 20 C 4.0931 -0.2949 1.0053 0 +M V30 21 C 5.3108 0.6331 0.8635 0 +M V30 22 N 6.4431 -0.2388 0.8051 0 +M V30 23 H 4.1839 -1.0164 0.1690 0 +M V30 24 H 4.2562 -0.8095 1.9930 0 +M V30 25 H 5.1869 1.1513 -0.1260 0 +M V30 26 H 5.3628 1.3645 1.7087 0 +M V30 27 C -5.8126 0.1568 0.9917 0 +M V30 28 C -6.1036 -1.1125 1.7152 0 +M V30 29 C -6.0146 -2.2991 0.7885 0 +M V30 30 C -4.6416 -2.3748 0.2325 0 +M V30 31 H -4.7956 0.4669 0.8841 0 +M V30 32 H -5.3463 -1.2774 2.5309 0 +M V30 33 H -7.0902 -1.0273 2.2082 0 +M V30 34 H -6.2520 -3.2104 1.3909 0 +M V30 35 H -6.7774 -2.1877 -0.0358 0 +M V30 36 H -4.0269 -3.2435 0.4518 0 +M V30 37 C 0.1180 -1.6242 -0.4494 0 +M V30 38 C 1.5110 -1.5759 -0.9313 0 +M V30 39 C 2.0246 -0.1554 -1.0826 0 +M V30 40 C 1.9516 0.5019 0.2374 0 +M V30 41 H -0.2548 -2.5226 0.0036 0 +M V30 42 H 1.5693 -2.0119 -1.9690 0 +M V30 43 H 2.1174 -2.1678 -0.2193 0 +M V30 44 H 1.4216 0.3940 -1.8365 0 +M V30 45 H 3.0600 -0.1360 -1.4362 0 +M V30 46 H 1.0757 1.0864 0.4798 0 +M V30 47 C 7.5684 0.0618 0.3453 0 +M V30 48 C 7.8257 1.4202 -0.2037 0 +M V30 49 C 9.2174 1.3525 -0.8541 0 +M V30 50 C 10.1465 0.9933 0.2359 0 +M V30 51 O 10.2021 1.6741 1.2624 0 +M V30 52 H 8.3459 -0.7025 0.3612 0 +M V30 53 H 7.8212 2.1150 0.6525 0 +M V30 54 H 7.0648 1.6889 -0.9762 0 +M V30 55 H 9.3967 2.3261 -1.3221 0 +M V30 56 H 9.1464 0.4991 -1.5694 0 +M V30 57 H 10.8017 0.1278 0.1682 0 +M V30 END ATOM +M V30 BEGIN BOND +M V30 1 1 1 2 +M V30 2 1 2 3 +M V30 3 1 3 4 +M V30 4 1 1 5 +M V30 5 1 1 6 +M V30 6 1 2 7 +M V30 7 1 2 8 +M V30 8 1 3 9 +M V30 9 1 3 10 +M V30 10 1 11 12 +M V30 11 1 12 13 +M V30 12 1 13 14 +M V30 13 1 12 15 +M V30 14 1 12 16 +M V30 15 1 13 17 +M V30 16 1 13 18 +M V30 17 1 19 20 +M V30 18 1 20 21 +M V30 19 1 21 22 +M V30 20 1 20 23 +M V30 21 1 20 24 +M V30 22 1 21 25 +M V30 23 1 21 26 +M V30 24 1 27 28 +M V30 25 1 28 29 +M V30 26 1 29 30 +M V30 27 1 27 31 +M V30 28 1 28 32 +M V30 29 1 28 33 +M V30 30 1 29 34 +M V30 31 1 29 35 +M V30 32 1 30 36 +M V30 33 1 37 38 +M V30 34 1 38 39 +M V30 35 1 39 40 +M V30 36 1 37 41 +M V30 37 1 38 42 +M V30 38 1 38 43 +M V30 39 1 39 44 +M V30 40 1 39 45 +M V30 41 1 40 46 +M V30 42 1 47 48 +M V30 43 1 48 49 +M V30 44 1 49 50 +M V30 45 2 50 51 +M V30 46 1 47 52 +M V30 47 1 48 53 +M V30 48 1 48 54 +M V30 49 1 49 55 +M V30 50 1 49 56 +M V30 51 1 50 57 +M V30 52 2 4 27 +M V30 53 2 11 30 +M V30 54 2 14 37 +M V30 55 2 19 40 +M V30 56 2 22 47 +M V30 END BOND +M V30 END CTAB +M END + +$$$$ diff --git a/examples/optwrite_output/mmff_out.mol b/examples/optwrite_output/mmff_out.mol new file mode 100644 index 0000000..f829d18 --- /dev/null +++ b/examples/optwrite_output/mmff_out.mol @@ -0,0 +1,127 @@ + + RDKit 3D + + 0 0 0 0 0 0 0 0 0 0999 V3000 +M V30 BEGIN CTAB +M V30 COUNTS 57 56 0 0 0 +M V30 BEGIN ATOM +M V30 1 N -9.7205 2.4412 0.1748 0 +M V30 2 C -8.7253 2.4626 -0.9019 0 +M V30 3 C -7.3480 2.0064 -0.3925 0 +M V30 4 N -7.4721 0.6414 0.1529 0 +M V30 5 H -9.5476 1.5811 0.7050 0 +M V30 6 H -10.6481 2.3394 -0.2334 0 +M V30 7 H -9.0544 1.7874 -1.7020 0 +M V30 8 H -8.6598 3.4738 -1.3157 0 +M V30 9 H -6.9984 2.6846 0.3963 0 +M V30 10 H -6.6338 2.0454 -1.2248 0 +M V30 11 N -4.0588 -1.7774 -1.5924 0 +M V30 12 C -2.6349 -2.1017 -1.7749 0 +M V30 13 C -1.7761 -1.1799 -0.9066 0 +M V30 14 N -0.3638 -1.5630 -1.0477 0 +M V30 15 H -2.3809 -1.9596 -2.8321 0 +M V30 16 H -2.4140 -3.1534 -1.5498 0 +M V30 17 H -2.1004 -1.2636 0.1386 0 +M V30 18 H -1.9166 -0.1384 -1.2228 0 +M V30 19 N 3.4392 1.2184 1.2207 0 +M V30 20 C 4.4653 0.2500 1.6078 0 +M V30 21 C 5.8574 0.8571 1.4063 0 +M V30 22 N 6.8602 -0.1458 1.7652 0 +M V30 23 H 4.3981 -0.7054 1.0795 0 +M V30 24 H 4.3247 0.0100 2.6690 0 +M V30 25 H 5.9681 1.1602 0.3587 0 +M V30 26 H 5.9553 1.7465 2.0397 0 +M V30 27 C -6.3566 -0.0024 0.1728 0 +M V30 28 C -6.3116 -1.4242 0.6676 0 +M V30 29 C -6.1455 -2.3668 -0.5146 0 +M V30 30 C -4.6835 -2.5767 -0.8000 0 +M V30 31 H -5.4061 0.4323 -0.1865 0 +M V30 32 H -5.4914 -1.5116 1.3871 0 +M V30 33 H -7.2532 -1.6426 1.1833 0 +M V30 34 H -6.5682 -3.3481 -0.2750 0 +M V30 35 H -6.6418 -1.9875 -1.4135 0 +M V30 36 H -4.1867 -3.4033 -0.2611 0 +M V30 37 C 0.3940 -1.0382 -0.1495 0 +M V30 38 C 1.8708 -1.3283 -0.1335 0 +M V30 39 C 2.6570 -0.1667 -0.7246 0 +M V30 40 C 2.6713 1.0148 0.2098 0 +M V30 41 H 0.0132 -0.3478 0.6267 0 +M V30 42 H 2.0560 -2.2309 -0.7262 0 +M V30 43 H 2.1592 -1.5306 0.9038 0 +M V30 44 H 2.2135 0.1642 -1.6709 0 +M V30 45 H 3.6851 -0.4728 -0.9383 0 +M V30 46 H 1.8979 1.7782 0.0148 0 +M V30 47 C 8.1102 0.1239 1.6053 0 +M V30 48 C 8.7065 1.3870 1.0329 0 +M V30 49 C 8.9214 1.2341 -0.4679 0 +M V30 50 C 10.0908 0.3423 -0.8074 0 +M V30 51 O 10.7997 -0.2131 0.0260 0 +M V30 52 H 8.8332 -0.6678 1.8728 0 +M V30 53 H 9.6511 1.5798 1.5538 0 +M V30 54 H 8.0486 2.2374 1.2276 0 +M V30 55 H 9.1343 2.2139 -0.9091 0 +M V30 56 H 8.0328 0.8222 -0.9576 0 +M V30 57 H 10.2830 0.2121 -1.8853 0 +M V30 END ATOM +M V30 BEGIN BOND +M V30 1 1 1 2 +M V30 2 1 2 3 +M V30 3 1 3 4 +M V30 4 1 1 5 +M V30 5 1 1 6 +M V30 6 1 2 7 +M V30 7 1 2 8 +M V30 8 1 3 9 +M V30 9 1 3 10 +M V30 10 1 11 12 +M V30 11 1 12 13 +M V30 12 1 13 14 +M V30 13 1 12 15 +M V30 14 1 12 16 +M V30 15 1 13 17 +M V30 16 1 13 18 +M V30 17 1 19 20 +M V30 18 1 20 21 +M V30 19 1 21 22 +M V30 20 1 20 23 +M V30 21 1 20 24 +M V30 22 1 21 25 +M V30 23 1 21 26 +M V30 24 1 27 28 +M V30 25 1 28 29 +M V30 26 1 29 30 +M V30 27 1 27 31 +M V30 28 1 28 32 +M V30 29 1 28 33 +M V30 30 1 29 34 +M V30 31 1 29 35 +M V30 32 1 30 36 +M V30 33 1 37 38 +M V30 34 1 38 39 +M V30 35 1 39 40 +M V30 36 1 37 41 +M V30 37 1 38 42 +M V30 38 1 38 43 +M V30 39 1 39 44 +M V30 40 1 39 45 +M V30 41 1 40 46 +M V30 42 1 47 48 +M V30 43 1 48 49 +M V30 44 1 49 50 +M V30 45 2 50 51 +M V30 46 1 47 52 +M V30 47 1 48 53 +M V30 48 1 48 54 +M V30 49 1 49 55 +M V30 50 1 49 56 +M V30 51 1 50 57 +M V30 52 2 4 27 +M V30 53 2 11 30 +M V30 54 2 14 37 +M V30 55 2 19 40 +M V30 56 2 22 47 +M V30 END BOND +M V30 END CTAB +M END + +$$$$ diff --git a/examples/optwrite_output/uff_out.mol b/examples/optwrite_output/uff_out.mol new file mode 100644 index 0000000..31f16ae --- /dev/null +++ b/examples/optwrite_output/uff_out.mol @@ -0,0 +1,127 @@ + + RDKit 3D + + 0 0 0 0 0 0 0 0 0 0999 V3000 +M V30 BEGIN CTAB +M V30 COUNTS 57 56 0 0 0 +M V30 BEGIN ATOM +M V30 1 N -8.5501 2.3560 -1.4818 0 +M V30 2 C -7.1477 2.1372 -1.8257 0 +M V30 3 C -6.3014 1.9791 -0.5638 0 +M V30 4 N -6.6677 0.7680 0.1334 0 +M V30 5 H -8.9509 1.4513 -1.1427 0 +M V30 6 H -9.0604 2.5902 -2.3641 0 +M V30 7 H -7.0454 1.2348 -2.4697 0 +M V30 8 H -6.7716 3.0144 -2.3965 0 +M V30 9 H -6.4514 2.8594 0.0997 0 +M V30 10 H -5.2286 1.9294 -0.8543 0 +M V30 11 N -4.3836 -1.9471 -0.5279 0 +M V30 12 C -2.9886 -1.9752 -0.9071 0 +M V30 13 C -2.2545 -0.7552 -0.3395 0 +M V30 14 N -0.8836 -0.7218 -0.7995 0 +M V30 15 H -2.9251 -1.9509 -2.0158 0 +M V30 16 H -2.5155 -2.9186 -0.5551 0 +M V30 17 H -2.2830 -0.7629 0.7728 0 +M V30 18 H -2.7653 0.1677 -0.6883 0 +M V30 19 N 3.2702 -0.3907 1.6619 0 +M V30 20 C 4.4526 -1.0261 1.1140 0 +M V30 21 C 5.4836 0.0249 0.7051 0 +M V30 22 N 6.6533 -0.6314 0.1604 0 +M V30 23 H 4.1993 -1.6892 0.2602 0 +M V30 24 H 4.8992 -1.6660 1.9047 0 +M V30 25 H 5.0481 0.7066 -0.0557 0 +M V30 26 H 5.7696 0.6188 1.6008 0 +M V30 27 C -6.0779 0.4024 1.2169 0 +M V30 28 C -6.4755 -0.8732 1.9039 0 +M V30 29 C -6.2347 -2.1027 1.0197 0 +M V30 30 C -4.7839 -2.2382 0.6610 0 +M V30 31 H -5.2810 1.0070 1.6443 0 +M V30 32 H -5.8967 -0.9762 2.8474 0 +M V30 33 H -7.5528 -0.8196 2.1707 0 +M V30 34 H -6.5486 -3.0131 1.5732 0 +M V30 35 H -6.8581 -2.0365 0.1004 0 +M V30 36 H -4.0708 -2.5083 1.4365 0 +M V30 37 C 0.0192 -1.5198 -0.3441 0 +M V30 38 C 1.4259 -1.4475 -0.8646 0 +M V30 39 C 2.1010 -0.1156 -0.5116 0 +M V30 40 C 2.2604 0.0486 0.9829 0 +M V30 41 H -0.2272 -2.2625 0.4111 0 +M V30 42 H 1.4067 -1.5661 -1.9694 0 +M V30 43 H 2.0119 -2.2930 -0.4461 0 +M V30 44 H 1.4825 0.7237 -0.8969 0 +M V30 45 H 3.0776 -0.0456 -1.0312 0 +M V30 46 H 1.4438 0.5152 1.5243 0 +M V30 47 C 7.6984 -0.0130 -0.2791 0 +M V30 48 C 7.8201 1.4947 -0.2785 0 +M V30 49 C 9.1650 1.9649 -0.8467 0 +M V30 50 C 10.3150 1.5665 0.0323 0 +M V30 51 O 10.4190 2.0212 1.1605 0 +M V30 52 H 8.5187 -0.6099 -0.6661 0 +M V30 53 H 7.6981 1.8827 0.7560 0 +M V30 54 H 7.0084 1.9202 -0.9067 0 +M V30 55 H 9.1544 3.0720 -0.9417 0 +M V30 56 H 9.3115 1.5396 -1.8635 0 +M V30 57 H 11.0678 0.8794 -0.3397 0 +M V30 END ATOM +M V30 BEGIN BOND +M V30 1 1 1 2 +M V30 2 1 2 3 +M V30 3 1 3 4 +M V30 4 1 1 5 +M V30 5 1 1 6 +M V30 6 1 2 7 +M V30 7 1 2 8 +M V30 8 1 3 9 +M V30 9 1 3 10 +M V30 10 1 11 12 +M V30 11 1 12 13 +M V30 12 1 13 14 +M V30 13 1 12 15 +M V30 14 1 12 16 +M V30 15 1 13 17 +M V30 16 1 13 18 +M V30 17 1 19 20 +M V30 18 1 20 21 +M V30 19 1 21 22 +M V30 20 1 20 23 +M V30 21 1 20 24 +M V30 22 1 21 25 +M V30 23 1 21 26 +M V30 24 1 27 28 +M V30 25 1 28 29 +M V30 26 1 29 30 +M V30 27 1 27 31 +M V30 28 1 28 32 +M V30 29 1 28 33 +M V30 30 1 29 34 +M V30 31 1 29 35 +M V30 32 1 30 36 +M V30 33 1 37 38 +M V30 34 1 38 39 +M V30 35 1 39 40 +M V30 36 1 37 41 +M V30 37 1 38 42 +M V30 38 1 38 43 +M V30 39 1 39 44 +M V30 40 1 39 45 +M V30 41 1 40 46 +M V30 42 1 47 48 +M V30 43 1 48 49 +M V30 44 1 49 50 +M V30 45 2 50 51 +M V30 46 1 47 52 +M V30 47 1 48 53 +M V30 48 1 48 54 +M V30 49 1 49 55 +M V30 50 1 49 56 +M V30 51 1 50 57 +M V30 52 2 4 27 +M V30 53 2 11 30 +M V30 54 2 14 37 +M V30 55 2 19 40 +M V30 56 2 22 47 +M V30 END BOND +M V30 END CTAB +M END + +$$$$