Visualize Topologies

Capped Alanine with a radical

from kimmdy.parsing import read_top
from kimmdy.topology.topology import Topology
from pathlib import Path
from kimmdy.tools import write_top_as_dot
import copy

This is the same reaction that would occur in the naive alanine HAT example (and integration test) if if where used with the dummy_first kmc method instead of standard rfkmc.

path_a = read_top(Path('../../tests/test_files/test_integration/alanine_hat_naive/Ala_out.top'), use_gmx_dir=False)
top = Topology(path_a)
top_a = copy.deepcopy(top)
top_b = top

top_b.break_bond(('7', '8'))
top_b.bind_bond(('8', '9'))

write_top_as_dot(top_a, "ala-top-a.dot")
write_top_as_dot(top_b, "ala-top-b.dot")
G 1 CT 1 CT 2 HC 2 HC 1 CT--2 HC 3 HC 3 HC 1 CT--3 HC 4 HC 4 HC 1 CT--4 HC 5 C 5 C 1 CT--5 C 6 O 6 O 5 C--6 O 7 N 7 N 5 C--7 N 8 H 8 H 7 N--8 H 9 CT 9 CT 7 N--9 CT 10 CT 10 CT 9 CT--10 CT 14 C 14 C 9 CT--14 C 11 HC 11 HC 10 CT--11 HC 12 HC 12 HC 10 CT--12 HC 13 HC 13 HC 10 CT--13 HC 15 O 15 O 14 C--15 O 16 N 16 N 14 C--16 N 17 H 17 H 16 N--17 H 18 CT 18 CT 16 N--18 CT 19 H1 19 H1 18 CT--19 H1 20 H1 20 H1 18 CT--20 H1 21 H1 21 H1 18 CT--21 H1
Figure 1: A diagram of the Ala topology
G 1 CT 1 CT 2 HC 2 HC 1 CT--2 HC 3 HC 3 HC 1 CT--3 HC 4 HC 4 HC 1 CT--4 HC 5 C 5 C 1 CT--5 C 6 O 6 O 5 C--6 O 7 N 7 N 5 C--7 N 9 CT 9 CT 7 N--9 CT 10 CT 10 CT 9 CT--10 CT 14 C 14 C 9 CT--14 C 11 HC 11 HC 10 CT--11 HC 12 HC 12 HC 10 CT--12 HC 13 HC 13 HC 10 CT--13 HC 15 O 15 O 14 C--15 O 16 N 16 N 14 C--16 N 17 H 17 H 16 N--17 H 18 CT 18 CT 16 N--18 CT 19 H1 19 H1 18 CT--19 H1 20 H1 20 H1 18 CT--20 H1 21 H1 21 H1 18 CT--21 H1 8 H 8 H 8 H--9 CT
Figure 2: A diagram of the Ala topology after HAT

Or we can look at a different HAT used in the unit tests:

path_a = read_top(Path('../../tests/test_files/test_integration/alanine_hat_naive/Ala_out.top'), use_gmx_dir=False)
top = Topology(path_a)

# move the radical to N16 before we start the reaction
top.break_bond(("16", "17"))
top.bind_bond(("9", "17"))
top_a = copy.deepcopy(top)
top_b = top

top_b.break_bond(("18", "21"))
top_b.bind_bond(("16", "21"))

write_top_as_dot(top_a, "ala-top-2-a.dot")
write_top_as_dot(top_b, "ala-top-2-b.dot")
G 1 CT 1 CT 2 HC 2 HC 1 CT--2 HC 3 HC 3 HC 1 CT--3 HC 4 HC 4 HC 1 CT--4 HC 5 C 5 C 1 CT--5 C 6 O 6 O 5 C--6 O 7 N 7 N 5 C--7 N 8 H 8 H 7 N--8 H 9 CT 9 CT 7 N--9 CT 10 CT 10 CT 9 CT--10 CT 14 C 14 C 9 CT--14 C 17 H 17 H 9 CT--17 H 11 HC 11 HC 10 CT--11 HC 12 HC 12 HC 10 CT--12 HC 13 HC 13 HC 10 CT--13 HC 15 O 15 O 14 C--15 O 16 N 16 N 14 C--16 N 18 CT 18 CT 16 N--18 CT 19 H1 19 H1 18 CT--19 H1 20 H1 20 H1 18 CT--20 H1 21 H1 21 H1 18 CT--21 H1
Figure 3: A diagram of the Ala topology
G 1 CT 1 CT 2 HC 2 HC 1 CT--2 HC 3 HC 3 HC 1 CT--3 HC 4 HC 4 HC 1 CT--4 HC 5 C 5 C 1 CT--5 C 6 O 6 O 5 C--6 O 7 N 7 N 5 C--7 N 8 H 8 H 7 N--8 H 9 CT 9 CT 7 N--9 CT 10 CT 10 CT 9 CT--10 CT 14 C 14 C 9 CT--14 C 17 H 17 H 9 CT--17 H 11 HC 11 HC 10 CT--11 HC 12 HC 12 HC 10 CT--12 HC 13 HC 13 HC 10 CT--13 HC 15 O 15 O 14 C--15 O 16 N 16 N 14 C--16 N 18 CT 18 CT 16 N--18 CT 21 H1 21 H1 16 N--21 H1 19 H1 19 H1 18 CT--19 H1 20 H1 20 H1 18 CT--20 H1
Figure 4: A diagram of the Ala topology after HAT

Multiple molecules

urea_dict = read_top(Path('../../tests/test_files/test_topology/urea.top'), use_gmx_dir=False)
urea = Topology(urea_dict)
write_top_as_dot(urea, "urea-top.dot")
G 1 C 1 C 2 O 2 O 1 C--2 O 3 N 3 N 1 C--3 N 6 N 6 N 1 C--6 N 4 H 4 H 3 N--4 H 5 H 5 H 3 N--5 H 7 H 7 H 6 N--7 H 8 H 8 H 6 N--8 H
Figure 5: Topology of one molecule of urea

When we want to run reactions within molecules that are either separate moleculetypes or multiples of the same moleculetype, KIMMDY can combine those into a single moleculetype and make multiples explicit.

i.e. if we have a topology with two molecules of urea defined as:

[ system ]
Urea in Water

[ molecules ]
;molecule name   nr.
Urea             2
SOL              1000
urea_dict = read_top(Path('../../tests/test_files/test_topology/urea-times-2.top'), use_gmx_dir=False)
urea = Topology(urea_dict)
write_top_as_dot(urea, "urea-2-top.dot")

We end up with

G 1 C 1 C 2 O 2 O 1 C--2 O 3 N 3 N 1 C--3 N 6 N 6 N 1 C--6 N 4 H 4 H 3 N--4 H 5 H 5 H 3 N--5 H 7 H 7 H 6 N--7 H 8 H 8 H 6 N--8 H 9 C 9 C 10 O 10 O 9 C--10 O 11 N 11 N 9 C--11 N 14 N 14 N 9 C--14 N 12 H 12 H 11 N--12 H 13 H 13 H 11 N--13 H 15 H 15 H 14 N--15 H 16 H 16 H 14 N--16 H
Figure 6: A diagram of the two urea molecules topology

This way, explicit atom numbers match up with the atom numbers in the coordinate file (or rather, line numbers - 2, since the numbers in the actual atomnr column can overflow due to the fixed-width file format).

Back to top