topology_superimposer
The main module responsible for the superimposition.
Classes:
-
AtomPair
–An atom pair for networkx.
-
SuperimposedTopology
–SuperimposedTopology contains in the minimal case two sets of nodes S1 and S2, which
Functions:
-
get_largest
–return a list of largest solutions
-
long_merge
–Carry out a merge and apply all checks.
-
merge_compatible_suptops
–Imagine mapping of two carbons C1 and C2 to another pair of carbons C1' and C2'.
-
merge_compatible_suptops_faster
–:param pairing_suptop:
-
superimpose_topologies
–The main function that manages the entire process.
-
extract_best_suptop
–Assumes that any merging possible already took place.
-
is_mirror_of_one
–"Mirror" in the sense that it is an alternative topological way to traverse the molecule.
-
generate_nxg_from_list
–Helper function. Generates a graph from a list of atoms
-
get_starting_configurations
–Minimise the number of starting configurations to optimise the process speed.
-
ties_pmd_from_rdmol
–Generate a parmed structure from an RDKit Mol.
-
get_atoms_bonds_from_file
–Use Parmed to load the files.
-
assign_coords_from_pdb
–Match the atoms from the ParmEd object based on a .pdb file
AtomPair
AtomPair(left_node, right_node)
An atom pair for networkx.
Source code in ties/topology_superimposer.py
50 51 52 53 54 |
|
SuperimposedTopology
SuperimposedTopology(topology1=None, topology2=None, parmed_ligA=None, parmed_ligZ=None)
SuperimposedTopology contains in the minimal case two sets of nodes S1 and S2, which are paired together and represent a strongly connected component.
However, it can also represent the symmetrical versions that were superimposed.
Methods:
-
mcs_score
–Raturn a ratio of the superimposed atoms to the number of all atoms.
-
write_metadata
–Writes a .json file with a summary of which atoms are classified as appearing, disappearing
-
write_pdb
–param filename: name or a filepath of the new file. If None, standard preconfigured pattern will be used.
-
write_mol2
–param filename: str location where the .mol2 file should be saved.
-
get_single_topology_region
–Return: matched atoms (even if they were unmatched for any reason)
-
get_single_topology_app
–fixme - called app but gives both app and dis
-
ringring
–Rings can only be matched to rings.
-
is_or_was_matched
–A helper function. For whatever reasons atoms get discarded.
-
get_unmatched_atoms
–Find the atoms in both topologies which were unmatched and return them.
-
get_unique_atom_count
–Requires that the .assign_atoms_ids() was called.
-
align_ligands_using_mcs
–Align the two ligands using the MCS (Maximum Common Substructure).
-
alchemical_overlap_check
–Calculate how well the alchemical regions overlap using distances between them.
-
rm_matched_pairs_with_different_bonds
–Scan the matched pairs. Assume you have three pairs
-
get_dual_topology_bonds
–Get the bonds between all the atoms.
-
largest_cc_survives
–CC - Connected Component.
-
assign_atoms_ids
–Assign an ID to each pair A1-B1. This means that if we request an atom ID
-
get_appearing_atoms
–fixme - should check first if atomName is unique
-
get_disappearing_atoms
–fixme - should check first if atomName is unique
-
remove_lonely_hydrogens
–You could also remove the hydrogens when you correct charges.
-
match_gaff2_nondirectional_bonds
–If needed, swap cc-cd with cd-cc.
-
get_net_charge
–Calculate the net charge difference across
-
get_matched_with_diff_q
–Returns a list of matched atom pairs that have a different q,
-
apply_net_charge_filter
–Averaging the charges across paired atoms introduced inequalities.
-
remove_attached_hydrogens
–The node_pair to which these hydrogens are attached was removed.
-
find_lowest_rmsd_mirror
–Walk through the different mirrors and out of all options select the one
-
is_subgraph_of_global_top
–Check if after superimposition, one graph is a subgraph of another
-
rmsd
–For each pair take the distance, and then get rmsd, so root(mean(square(deviation)))
-
link_pairs
–This helps take care of the bonds.
-
find_mirror_choices
–For each pair (A1, B1) find all the other options in the mirrors where (A1, B2)
-
add_alternative_mapping
–This means that there is another way to traverse and overlap the two molecules,
-
correct_for_coordinates
–Use the coordinates of the atoms, to figure out which symmetries are the correct ones.
-
is_area_overlapping_fully
–Each atom in one set has to be matched to an atom in the second set. And vice versa.
-
is_area_overlapping
–Even a small overlap will return True.
-
enforce_no_partial_rings
–Ensure that rings are either fully matched,
-
get_topology_similarity_score
–Having the superimposed A(Left) and B(Right), score the match.
-
unmatch_pairs_with_different_charges
–Removes the matched pairs where atom charges are more different
-
is_consistent_with
–Conditions:
-
get_circles
–Return circles found in the matched pairs.
-
get_original_circles
–Return the original circles present in the input topologies.
-
cycle_spans_multiple_cycles
–What is the circle is shared?
-
merge
–Absorb the other suptop by adding all the node pairs that are not present
-
validate_charges
–Check the original charges:
-
redistribute_charges
–After the match is made and the user commits to the superimposed topology,
-
contains_same_atoms_symmetric
–The atoms can be paired differently, but they are the same.
-
is_subgraph_of
–Checks if this superimposed topology is a subgraph of another superimposed topology.
-
subgraph_relationship
–Return
-
is_mirror_of
–this is a naive check
-
eq
–Check if the superimposed topology is "the same". This means that every pair has a corresponding pair in the
-
toJSON
–"
Source code in ties/topology_superimposer.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
mcs_score
mcs_score()
Raturn a ratio of the superimposed atoms to the number of all atoms. Specifically, (superimposed_atoms_number * 2) / (atoms_number_ligandA + atoms_number_ligandB) :return:
Source code in ties/topology_superimposer.py
145 146 147 148 149 150 151 |
|
write_metadata
write_metadata(filename=None)
Writes a .json file with a summary of which atoms are classified as appearing, disappearing as well as all other metadata relevant to this superimposition/hybrid. TODO add information: - config class in general -- relative paths to ligand 1, ligand 2 (the latest copies, ie renamed etc) -- general settings used - pair? bonds? these can be restractured, so not necessary?
param filename: a location where the metadata should be saved
Source code in ties/topology_superimposer.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
write_pdb
write_pdb(filename=None)
param filename: name or a filepath of the new file. If None, standard preconfigured pattern will be used.
Source code in ties/topology_superimposer.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
write_mol2
write_mol2(filename=None, use_left_charges=True, use_left_coords=True)
param filename: str location where the .mol2 file should be saved.
Source code in ties/topology_superimposer.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
|
get_single_topology_region
get_single_topology_region()
Return: matched atoms (even if they were unmatched for any reason)
Source code in ties/topology_superimposer.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
|
get_single_topology_app
get_single_topology_app()
fixme - called app but gives both app and dis get the appearing and disappearing region in the hybrid single topology use the single topology region and classify all other atoms not in it as either appearing or disappearing
Source code in ties/topology_superimposer.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
|
ringring
ringring()
Rings can only be matched to rings.
Source code in ties/topology_superimposer.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
|
is_or_was_matched
is_or_was_matched(atom_name1, atom_name2)
A helper function. For whatever reasons atoms get discarded. E.g. they had a different charge, or were part of the disjointed component, etc. This function simply checks if the most original match was made between the two atoms. It helps with verifying the original matching.
Source code in ties/topology_superimposer.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
|
get_unmatched_atoms
get_unmatched_atoms()
Find the atoms in both topologies which were unmatched and return them. These are both, appearing and disappearing.
Note that some atoms were removed due to charges.
Source code in ties/topology_superimposer.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
|
get_unique_atom_count
get_unique_atom_count()
Requires that the .assign_atoms_ids() was called. This should be rewritten. But basically, it needs to count each matched pair as one atom, and the appearing and disappearing atoms separately.
Source code in ties/topology_superimposer.py
665 666 667 668 669 670 671 |
|
align_ligands_using_mcs
align_ligands_using_mcs(overwrite_original=False, use_disjointed=False)
Align the two ligands using the MCS (Maximum Common Substructure). The ligA here is the reference (docked) to which the ligZ is aligned.
:param overwrite_original: After aligning by MCS, update the internal coordinates which will be saved to a file at the end. :type overwrite_original: bool
Source code in ties/topology_superimposer.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
|
alchemical_overlap_check
alchemical_overlap_check() -> tuple[float]
Calculate how well the alchemical regions overlap using distances between them.
For A (left) and B (right). For each atom in B, find the distance to closest alchemical atom in A to get B-A distances. Then apply RMS(B-A).
Do the same steps in reverse to get A-B.
For B-A
0, B and A are the same size.
0, B is growing
If both, B-A and A-B > 0, this means the alchemical regions are divergent.
This function takes the coordinates as they come.
:return: RMS(A-B), max(A-B), RMS(B-A), max(B-A)
Source code in ties/topology_superimposer.py
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
|
rm_matched_pairs_with_different_bonds
rm_matched_pairs_with_different_bonds()
Scan the matched pairs. Assume you have three pairs A-B=C with the double bond on the right side, and the alternative bonds A=B-C remove all A, B and C pairs because of the different bonds Remove them by finding that A-B is not A=B, and B=C is not B-C
return: the list of removed pairs
Source code in ties/topology_superimposer.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 |
|
get_dual_topology_bonds
get_dual_topology_bonds()
Get the bonds between all the atoms. Use the atom IDs for the bonds.
Source code in ties/topology_superimposer.py
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 |
|
largest_cc_survives
largest_cc_survives(verbose=True)
CC - Connected Component.
Removes any disjoint components. Only the largest CC will be left. In the case of of equal length CCs, an arbitrary is chosen.
How: Generates the graph where each pair is a single node, connecting the nodes if the bonds exist. Uses then networkx to find CCs.
Source code in ties/topology_superimposer.py
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 |
|
assign_atoms_ids
assign_atoms_ids(id_start=1)
Assign an ID to each pair A1-B1. This means that if we request an atom ID for A1 or B1 it will be the same.
Then assign different IDs for the other atoms
Source code in ties/topology_superimposer.py
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 |
|
get_appearing_atoms
get_appearing_atoms()
fixme - should check first if atomName is unique
Return a list of appearing atoms (atomName) which are the atoms that are
Source code in ties/topology_superimposer.py
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
|
get_disappearing_atoms
get_disappearing_atoms()
fixme - should check first if atomName is unique
fixme - update to using the node set
Return a list of appearing atoms (atomName) which are the atoms that are found in the topology, and that are not present in the matched_pairs
Source code in ties/topology_superimposer.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 |
|
remove_lonely_hydrogens
remove_lonely_hydrogens()
You could also remove the hydrogens when you correct charges.
Source code in ties/topology_superimposer.py
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 |
|
match_gaff2_nondirectional_bonds
match_gaff2_nondirectional_bonds()
If needed, swap cc-cd with cd-cc. If two pairs are linked: (CC/CD) - (CD/CC), replace them according to the left side: (CC/CC) - (CD/CD). Apply this rule to all other pairs in Table I (b) at http://ambermd.org/antechamber/gaff.html
These two define where the double bond is in a ring. GAFF decides on which one is cc or cd depending on the arbitrary atom order. This intervention we ensure that we do not remove atoms based on that arbitrary order.
This method is idempotent.
Source code in ties/topology_superimposer.py
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 |
|
get_net_charge
get_net_charge()
Calculate the net charge difference across the matched pairs.
Source code in ties/topology_superimposer.py
1291 1292 1293 1294 1295 1296 1297 |
|
get_matched_with_diff_q
get_matched_with_diff_q()
Returns a list of matched atom pairs that have a different q, sorted in the descending order (the first pair has the largest q diff).
Source code in ties/topology_superimposer.py
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 |
|
apply_net_charge_filter
apply_net_charge_filter(net_charge_threshold)
Averaging the charges across paired atoms introduced inequalities. Check if the sum of the inequalities in charges is below net_charge. If not, remove pairs until that net_charge is met. Which pairs are removed depends on the approach. Greedy removal of the pairs with the highest difference can create disjoint blocks which creates issues in themselves.
Specifically, create copies for each strategy here and try a couple of them.
Returns: a new suptop where the net_charge_threshold is enforced.
Source code in ties/topology_superimposer.py
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 |
|
remove_attached_hydrogens
remove_attached_hydrogens(node_pair)
The node_pair to which these hydrogens are attached was removed. Remove the dangling hydrogens.
Check if these hydrogen are matched/superimposed. If that is the case. Remove the pairs.
Note that if the hydrogens are paired and attached to node_pairA, they have to be attached to node_pairB, as a rule of being a match.
Source code in ties/topology_superimposer.py
1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 |
|
find_lowest_rmsd_mirror
find_lowest_rmsd_mirror()
Walk through the different mirrors and out of all options select the one that has the lowest RMSD. This way we increase the chance of getting a better match. However, long term it will be necessary to use the dihedrals to ensure that we match the atoms better.
Source code in ties/topology_superimposer.py
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 |
|
is_subgraph_of_global_top
is_subgraph_of_global_top()
Check if after superimposition, one graph is a subgraph of another :return:
Source code in ties/topology_superimposer.py
1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 |
|
rmsd
rmsd()
For each pair take the distance, and then get rmsd, so root(mean(square(deviation)))
Source code in ties/topology_superimposer.py
1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 |
|
link_pairs
link_pairs(from_pair, pairs)
This helps take care of the bonds.
Source code in ties/topology_superimposer.py
1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 |
|
find_mirror_choices
find_mirror_choices()
For each pair (A1, B1) find all the other options in the mirrors where (A1, B2)
ie Ignore (X, B1) search, if we repair from A to B, then B to A should be repaired too
fixme - is this still necessary if we are traversing all paths?
Source code in ties/topology_superimposer.py
1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 |
|
add_alternative_mapping
add_alternative_mapping(weird_symmetry)
This means that there is another way to traverse and overlap the two molecules, but that the self is better (e.g. lower rmsd) than the other one
Source code in ties/topology_superimposer.py
1737 1738 1739 1740 1741 1742 |
|
correct_for_coordinates
correct_for_coordinates()
Use the coordinates of the atoms, to figure out which symmetries are the correct ones. Rearrange so that the overall topology represents the one that has appropriate coordinates, whereas all the mirrors represent the other poor matches.
fixme - ensure that each node is used only once at the end
Source code in ties/topology_superimposer.py
1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 |
|
is_area_overlapping_fully
is_area_overlapping_fully(l_atoms, r_atoms)
Each atom in one set has to be matched to an atom in the second set. And vice versa.
:param l_atoms: :param r_atoms: :return:
Source code in ties/topology_superimposer.py
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 |
|
is_area_overlapping
is_area_overlapping(l_atoms, r_atoms)
Even a small overlap will return True.
:param l_atoms: :param r_atoms: :return:
Source code in ties/topology_superimposer.py
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 |
|
enforce_no_partial_rings
enforce_no_partial_rings()
Ensure that rings are either fully matched, or not matched with anything at all.
Source code in ties/topology_superimposer.py
1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 |
|
get_topology_similarity_score
get_topology_similarity_score()
Having the superimposed A(Left) and B(Right), score the match. This is a rather naive approach. It compares A-B match by checking if any of the node X and X' in A and B have a bond to another node Y that is not present in A-B, but that is directly reachable from X and X' in a similar way. We ignore the charge of Y and focus here only on the topology.
For every "external bond" from the component we try to see if topologically it scores well. So for any matched pair, we extend the topology and the score is equal to the size of such an component. Then we do this for all other matching nodes and sum the score.
fixme - maybe you should use the entire graphs in order to see if this is good or not?
so the simpler approach is to ignore charges for a second to only understand the relative place in the topology, in other words, the question is, how similar are two nodes A and B vs A and C? let's traverse A and B together, and then A and C together, and while doing that, ignore the charges. In this case, A and B could get together 20 parts, whereas A and C traverses together 22 parts, meaning that topologically, it is a more suitable one, because it closer corresponds to the actual atom. Note that this approach has problem: - you can imagine A and B traversing where B is in a completely wrong global place, but it happens to have a bigger part common to A, than C which globally is correct. Answer to this: at the same time, ideally B would be excluded, because it should have been already matched to another topology.
Alternative approach: take into consideration other components and the distance from this component to them. Specifically, allows mismatches
FIXME - allow flexible mismatches. Meaning if someone mutates one bonded atom, then it might be noticed that
Source code in ties/topology_superimposer.py
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 |
|
unmatch_pairs_with_different_charges
unmatch_pairs_with_different_charges(atol)
Removes the matched pairs where atom charges are more different than the provided absolute tolerance atol (units in Electrons).
remove_dangling_h: After removing any pair it also removes any bound hydrogen(s).
Source code in ties/topology_superimposer.py
2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 |
|
is_consistent_with
is_consistent_with(suptop)
Conditions
- There should be a minimal overlap of at least 1 node.
- There is no pair (Na=Nb) in this sup top such that (Na=Nc) or (Nb=Nc) for some Nc in the other suptop.
- The number of cycles in this suptop and the other suptop must be the same (?removing for now, fixme)
- merging cannot lead to new cycles?? (fixme). What is the reasoning behind this? I mean, I guess the assumption is that, if the cycles were compatible, they would be created during the search, rather than now while merging. ??
Source code in ties/topology_superimposer.py
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 |
|
get_circles
get_circles()
Return circles found in the matched pairs.
Source code in ties/topology_superimposer.py
2266 2267 2268 2269 2270 2271 2272 2273 |
|
get_original_circles
get_original_circles()
Return the original circles present in the input topologies.
Source code in ties/topology_superimposer.py
2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 |
|
cycle_spans_multiple_cycles
cycle_spans_multiple_cycles()
What is the circle is shared? We are using cycles which excluded atoms that join different rings. fixme - could this lead to a special case?
Source code in ties/topology_superimposer.py
2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 |
|
merge
merge(suptop)
Absorb the other suptop by adding all the node pairs that are not present in the current sup top.
WARNING: ensure that the other suptop is consistent with this sup top.
Source code in ties/topology_superimposer.py
2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 |
|
validate_charges
staticmethod
validate_charges(atom_list_l, atom_list_right)
Check the original charges: - ensure that the total charge of L and R are integers - ensure that they are equal to the same integer
Source code in ties/topology_superimposer.py
2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 |
|
redistribute_charges
redistribute_charges()
After the match is made and the user commits to the superimposed topology, the charges can be revised. We calculate the average charges between every match, and check how that affects the rest of the molecule (the unmatched atoms). Then, we distribute the charges to the unmatched atoms to get the net charge as a whole number/integer.
This function should be called after removing the matches for whatever reason. ie at the end of anything that could modify the atom pairing.
Source code in ties/topology_superimposer.py
2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 |
|
contains_same_atoms_symmetric
contains_same_atoms_symmetric(other_sup_top)
The atoms can be paired differently, but they are the same.
Source code in ties/topology_superimposer.py
2626 2627 2628 2629 2630 2631 2632 2633 |
|
is_subgraph_of
is_subgraph_of(other_sup_top)
Checks if this superimposed topology is a subgraph of another superimposed topology. Or if any mirror topology is a subgraph.
Source code in ties/topology_superimposer.py
2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 |
|
subgraph_relationship
subgraph_relationship(other_sup_top)
Return 1 if self is a supergraph of other, -1 if self is a subgraph of other 0 if they have the same number of elements (regardless of what the nodes are)
Source code in ties/topology_superimposer.py
2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 |
|
is_mirror_of
is_mirror_of(other_sup_top)
this is a naive check fixme - check if the found superimposed topology is the same (ie the same matches), what then?
some of the superimposed topologies represent symmetrical matches, for example, imagine T1A and T1B is a symmetrical version of T2A and T2B, this means that - the number of nodes in T1A, T1B, T2A, and T2B is the same - all the nodes in T1A are in T2A, - all the nodes in T1B are in T2B
Source code in ties/topology_superimposer.py
2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 |
|
eq
eq(sup_top)
Check if the superimposed topology is "the same". This means that every pair has a corresponding pair in the other topology (but possibly in a different order)
Source code in ties/topology_superimposer.py
2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 |
|
toJSON
toJSON()
" Extract all the important information and return a json string.
Source code in ties/topology_superimposer.py
2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 |
|
get_largest
get_largest(lists)
return a list of largest solutions
Source code in ties/topology_superimposer.py
2860 2861 2862 2863 2864 2865 2866 |
|
long_merge
long_merge(suptop1, suptop2)
Carry out a merge and apply all checks. Merge suptop2 into suptop1.
Source code in ties/topology_superimposer.py
2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 |
|
merge_compatible_suptops
merge_compatible_suptops(suptops)
Imagine mapping of two carbons C1 and C2 to another pair of carbons C1' and C2'. If C1 was mapped to C1', and C2 to C2', and each craeted a suptop, then we have to join the two suptops.
fixme - appears to be doing too many combinations Consider using a queue. Add the new combinations here rather than restarting again and again. You could keep a list of "combinations" in a queue, and each time you make a new element,
Source code in ties/topology_superimposer.py
2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 |
|
merge_compatible_suptops_faster
merge_compatible_suptops_faster(pairing_suptop: Dict, min_bonds: int)
:param pairing_suptop: :param min_bonds: if the End molecule at this point has only two bonds, they can be mapped to two other bonds in the start molecule. :return:
Source code in ties/topology_superimposer.py
2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 |
|
superimpose_topologies
superimpose_topologies(top1_nodes, top2_nodes, pair_charge_atol=0.1, use_charges=True, use_coords=True, starting_node_pairs=None, force_mismatch=None, disjoint_components=False, net_charge_filter=True, net_charge_threshold=0.1, redistribute_charges_over_unmatched=True, parmed_ligA=None, parmed_ligZ=None, align_molecules=True, partial_rings_allowed=False, ignore_charges_completely=False, ignore_bond_types=True, ignore_coords=False, use_general_type=True, use_only_element=False, check_atom_names_unique=True, starting_pairs_heuristics=0.2, starting_pair_seed=None, logging_key=None, config=None)
The main function that manages the entire process.
TODO: - check if each molecule topology is connected
Source code in ties/topology_superimposer.py
3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 |
|
extract_best_suptop
extract_best_suptop(suptops, ignore_coords, weights, get_list=False)
Assumes that any merging possible already took place. We now have a set of solutions and have to select the best ones.
:param suptops: :param ignore_coords: :return:
Source code in ties/topology_superimposer.py
3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 |
|
is_mirror_of_one
is_mirror_of_one(candidate_suptop, suptops, ignore_coords, extract_weight_ratio)
"Mirror" in the sense that it is an alternative topological way to traverse the molecule.
extract_weight_ratio: refers to the extract_best_suptop function parameter
Depending on the "better" fit between the two mirrors, we pick the one that is better.
Source code in ties/topology_superimposer.py
3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 |
|
generate_nxg_from_list
generate_nxg_from_list(atoms)
Helper function. Generates a graph from a list of atoms @parameter atoms: follow the internal format for atoms
Source code in ties/topology_superimposer.py
3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 |
|
get_starting_configurations
get_starting_configurations(left_atoms, right_atoms, fraction=0.2, filter_ring_c=True)
Minimise the number of starting configurations to optimise the process speed. Use: * the rarity of the specific atom types, * whether the atoms are bottlenecks (so they do not suffer from symmetry). The issue with symmetry is that it is impossible to find the proper symmetry match if you start from the wrong symmetry. @parameter fraction: ensure that the number of atoms used to start the traversal is not more than the fraction value of the overall number of possible matches, counted as a fraction of the maximum possible number of pairs (MIN(LEFTNODES, RIGHTNODES)) @parameter filter_ring_c: filter out the carbon elements in the rings to avoid any issues with the symmetry. This assumes that a ring usually has one N element, etc.
Source code in ties/topology_superimposer.py
3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 |
|
ties_pmd_from_rdmol
ties_pmd_from_rdmol(mol: Mol)
Generate a parmed structure from an RDKit Mol.
The atom types and charges are extracted from the properties.
:param mol: :return:
Source code in ties/topology_superimposer.py
4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 |
|
get_atoms_bonds_from_file
get_atoms_bonds_from_file(ref_filename, mob_filename, use_general_type=True)
Use Parmed to load the files.
returns
1) a dictionary with charges, e.g. Item: "C17" : -0.222903
2) a list of bonds
Source code in ties/topology_superimposer.py
4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 |
|
assign_coords_from_pdb
assign_coords_from_pdb(atoms, pdb_atoms)
Match the atoms from the ParmEd object based on a .pdb file and overwrite the coordinates from ParmEd. :param atoms: internal Atom representation (fixme: refer to it here in docu), will have their coordinates overwritten. :param pdb_atoms: atoms loaded with ParmEd with the coordinates to be used
Source code in ties/topology_superimposer.py
4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 |
|