topology_superimposer
The main module responsible for the superimposition.
Classes:
-
Atom
– -
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.
-
get_atoms_bonds_from_mol2
–Use Parmed to load the files.
-
assign_coords_from_pdb
–Match the atoms from the ParmEd object based on a .pdb file
Atom
Atom(name, atom_type, charge=0, use_general_type=False)
Methods:
-
eq
–Check if the atoms are of the same type and have a charge within the given absolute tolerance.
-
united_eq
–Like .eq, but treat the atoms as united atoms.
Attributes:
-
united_charge
–United atom charge: summed charges of this atom and the bonded hydrogens.
Source code in ties/topology_superimposer.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
united_charge
property
united_charge
United atom charge: summed charges of this atom and the bonded hydrogens.
eq
eq(atom, atol=0)
Check if the atoms are of the same type and have a charge within the given absolute tolerance.
Source code in ties/topology_superimposer.py
187 188 189 190 191 192 193 194 |
|
united_eq
united_eq(atom, atol=0)
Like .eq, but treat the atoms as united atoms. Check if the atoms have the same atom type, and if if their charges are within the absolute tolerance. If the atoms have hydrogens, add up the attached hydrogens and use a united atom representation.
Source code in ties/topology_superimposer.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
AtomPair
AtomPair(left_node, right_node)
An atom pair for networkx.
Source code in ties/topology_superimposer.py
229 230 231 232 233 |
|
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.
-
enforce_no_partial_rings
–http://www.alchemistry.org/wiki/Constructing_a_Pathway_of_Intermediate_States
-
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
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
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
322 323 324 325 326 327 328 |
|
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
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
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
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
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
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
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
670 671 672 673 674 675 676 677 678 679 680 681 682 |
|
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
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
|
ringring
ringring()
Rings can only be matched to rings.
Source code in ties/topology_superimposer.py
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
|
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
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
|
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
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
|
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
781 782 783 784 785 786 787 |
|
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
789 790 791 792 793 794 795 796 797 798 799 800 801 802 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 835 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 |
|
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
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 |
|
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
905 906 907 908 909 910 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 |
|
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
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 |
|
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
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 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 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 |
|
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
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 |
|
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
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 |
|
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
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 |
|
remove_lonely_hydrogens
remove_lonely_hydrogens()
You could also remove the hydrogens when you correct charges.
Source code in ties/topology_superimposer.py
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 |
|
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
1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 |
|
get_net_charge
get_net_charge()
Calculate the net charge difference across the matched pairs.
Source code in ties/topology_superimposer.py
1352 1353 1354 1355 1356 1357 1358 |
|
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
1360 1361 1362 1363 1364 1365 1366 |
|
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
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 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 |
|
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
1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 |
|
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
1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
|
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
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 |
|
rmsd
rmsd()
For each pair take the distance, and then get rmsd, so root(mean(square(deviation)))
Source code in ties/topology_superimposer.py
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 |
|
link_pairs
link_pairs(from_pair, pairs)
This helps take care of the bonds.
Source code in ties/topology_superimposer.py
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 |
|
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
1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 |
|
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
1761 1762 1763 1764 1765 1766 |
|
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
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 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 |
|
enforce_no_partial_rings
enforce_no_partial_rings()
http://www.alchemistry.org/wiki/Constructing_a_Pathway_of_Intermediate_States It is the opening or closing of the rings that is an issue. This means that if any atom on a ring disappears, it breaks the ring, and therefore the entire ring should be removed and appeared again.
If any atom is removed, it should check if it affects other rings, therefore cascading removing further rings.
Source code in ties/topology_superimposer.py
1873 1874 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 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 |
|
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
1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 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 |
|
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
2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 |
|
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
2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 |
|
get_circles
get_circles()
Return circles found in the matched pairs.
Source code in ties/topology_superimposer.py
2236 2237 2238 2239 2240 2241 2242 2243 |
|
get_original_circles
get_original_circles()
Return the original circles present in the input topologies.
Source code in ties/topology_superimposer.py
2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 |
|
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
2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 |
|
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
2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 |
|
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
2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 |
|
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
2388 2389 2390 2391 2392 2393 2394 2395 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 2424 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 |
|
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
2555 2556 2557 2558 2559 2560 2561 2562 |
|
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
2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 |
|
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
2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 |
|
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
2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 |
|
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
2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 |
|
toJSON
toJSON()
" Extract all the important information and return a json string.
Source code in ties/topology_superimposer.py
2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 |
|
get_largest
get_largest(lists)
return a list of largest solutions
Source code in ties/topology_superimposer.py
2758 2759 2760 2761 2762 2763 2764 |
|
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
2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 |
|
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
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 2858 2859 2860 |
|
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
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 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 |
|
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=True, 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
3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 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 |
|
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
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 |
|
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
3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 |
|
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
3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 |
|
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
3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 |
|
get_atoms_bonds_from_mol2
get_atoms_bonds_from_mol2(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
4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 |
|
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
4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 |
|