Load parameters from an Impact file
martimunicoy opened this issue · comments
Description
A nice add-on to the package would be a method to get a BaseParameterWrapper
from an Impact file.
Solution
Implement a static method in the BaseParameterWrapper
class to load the parameters from an Impact file.
Error
When obtaining the Topology
of a molecule parameterized in two different ways (parameterizing with the Force Field and obtaining the parameters from an Impact Template) in some cases, the following error occurs:
- First case: Impact template from molecule parameterized with the Force Field
Before _sort()
in Impact:
[Atom(index=0, PDB_name=_C1_, OPLS_type=OFFT),
Atom(index=1, PDB_name=_C2_, OPLS_type=OFFT),
Atom(index=3, PDB_name=_C3_, OPLS_type=OFFT),
Atom(index=5, PDB_name=_N1_, OPLS_type=OFFT),
Atom(index=8, PDB_name=_N2_, OPLS_type=OFFT),
Atom(index=9, PDB_name=_S1_, OPLS_type=OFFT),
Atom(index=10, PDB_name=_O1_, OPLS_type=OFFT),
Atom(index=11, PDB_name=_O2_, OPLS_type=OFFT),
Atom(index=12, PDB_name=_C4_, OPLS_type=OFFT),
Atom(index=4, PDB_name=_O3_, OPLS_type=OFFT),
Atom(index=2, PDB_name=_H1_, OPLS_type=OFFT),
Atom(index=6, PDB_name=_H2_, OPLS_type=OFFT),
Atom(index=13, PDB_name=_H3_, OPLS_type=OFFT),
Atom(index=14, PDB_name=_H4_, OPLS_type=OFFT),
Atom(index=15, PDB_name=_H5_, OPLS_type=OFFT),
Atom(index=7, PDB_name=_H6_, OPLS_type=OFFT)]
After _sort()
in Impact:
[Atom(index=0, PDB_name=_C1_, OPLS_type=OFFT),
Atom(index=1, PDB_name=_C2_, OPLS_type=OFFT),
Atom(index=2, PDB_name=_H1_, OPLS_type=OFFT),
Atom(index=3, PDB_name=_C3_, OPLS_type=OFFT),
Atom(index=4, PDB_name=_O3_, OPLS_type=OFFT),
Atom(index=5, PDB_name=_N1_, OPLS_type=OFFT),
Atom(index=6, PDB_name=_H2_, OPLS_type=OFFT),
Atom(index=7, PDB_name=_H6_, OPLS_type=OFFT),
Atom(index=8, PDB_name=_N2_, OPLS_type=OFFT),
Atom(index=9, PDB_name=_S1_, OPLS_type=OFFT),
Atom(index=10, PDB_name=_O1_, OPLS_type=OFFT),
Atom(index=11, PDB_name=_O2_, OPLS_type=OFFT),
Atom(index=12, PDB_name=_C4_, OPLS_type=OFFT),
Atom(index=13, PDB_name=_H3_, OPLS_type=OFFT),
Atom(index=14, PDB_name=_H4_, OPLS_type=OFFT),
Atom(index=15, PDB_name=_H5_, OPLS_type=OFFT)]
And this new sorted list of atoms is the order that appears in the Impact template.
- Second case: Impact template from molecule parameterized using the from_impact_file method
Before_sort()
inImpact:
[Atom(index=0, PDB_name=_C1_, OPLS_type=OFFT),
Atom(index=1, PDB_name=_C2_, OPLS_type=OFFT),
Atom(index=2, PDB_name=_H1_, OPLS_type=OFFT),
Atom(index=3, PDB_name=_C3_, OPLS_type=OFFT),
Atom(index=4, PDB_name=_O3_, OPLS_type=OFFT),
Atom(index=5, PDB_name=_N1_, OPLS_type=OFFT),
Atom(index=6, PDB_name=_H2_, OPLS_type=OFFT),
Atom(index=7, PDB_name=_H6_, OPLS_type=OFFT),
Atom(index=8, PDB_name=_N2_, OPLS_type=OFFT),
Atom(index=9, PDB_name=_S1_, OPLS_type=OFFT),
Atom(index=10, PDB_name=_O1_, OPLS_type=OFFT),
Atom(index=11, PDB_name=_O2_, OPLS_type=OFFT),
Atom(index=12, PDB_name=_C4_, OPLS_type=OFFT),
Atom(index=13, PDB_name=_H3_, OPLS_type=OFFT),
Atom(index=14, PDB_name=_H4_, OPLS_type=OFFT),
Atom(index=15, PDB_name=_H5_, OPLS_type=OFFT)]
The order before the _sort()
corresponds to the sorted order in the first case, which makes sense since this Topology
has been generated using the parameters obtained from the Impact template.
After _sort()
in Impact:
[Atom(index=0, PDB_name=_C1_, OPLS_type=OFFT),
Atom(index=1, PDB_name=_C2_, OPLS_type=OFFT),
Atom(index=2, PDB_name=_O1_, OPLS_type=OFFT),
Atom(index=3, PDB_name=_H1_, OPLS_type=OFFT),
Atom(index=4, PDB_name=_S1_, OPLS_type=OFFT),
Atom(index=5, PDB_name=_C3_, OPLS_type=OFFT),
Atom(index=6, PDB_name=_O2_, OPLS_type=OFFT),
Atom(index=7, PDB_name=_H5_, OPLS_type=OFFT),
Atom(index=8, PDB_name=_O3_, OPLS_type=OFFT),
Atom(index=9, PDB_name=_N1_, OPLS_type=OFFT),
Atom(index=10, PDB_name=_H2_, OPLS_type=OFFT),
Atom(index=11, PDB_name=_H6_, OPLS_type=OFFT),
Atom(index=12, PDB_name=_N2_, OPLS_type=OFFT),
Atom(index=13, PDB_name=_C4_, OPLS_type=OFFT),
Atom(index=14, PDB_name=_H3_, OPLS_type=OFFT),
Atom(index=15, PDB_name=_H4_, OPLS_type=OFFT)]
The atom's indexes are reindex again in a different way.
Questions
- Is it correct to reindex again the atoms in a Molecule in a different way even if the molecule is the same than before?
- If this is correct, I think in the Impact Template the coordinates from the ZMatrix
are not reindexed since we obtain the same order of coordinates even if the order of atom names has been changed. For example:
UNK 16 16 26 40 0
1 0 M OFFT _C1_ 0 1.429601 139.941294 -135.794610
2 1 M OFFT _C2_ 0 1.376865 113.017813 -136.312563
3 1 M OFFT _H1_ 0 1.096068 176.171882 -70.829593
4 2 M OFFT _C3_ 0 1.373603 142.762085 -7.642123
5 2 M OFFT _O3_ 0 1.383431 154.372794 172.357505
6 4 M OFFT _N1_ 0 1.355463 144.724477 -0.000000
7 4 M OFFT _H2_ 0 1.088259 150.231118 179.997708
8 5 M OFFT _H6_ 0 0.995051 146.109885 0.000936
9 6 M OFFT _N2_ 0 1.318995 142.370875 0.000000
10 6 S OFFT _S1_ 0 1.739079 156.646106 -179.998468
11 10 S OFFT _O1_ 0 1.501974 141.270592 -0.770592
12 10 S OFFT _O2_ 0 1.501654 141.162735 120.569191
13 10 S OFFT _C4_ 0 1.772998 144.137104 -118.464413
14 13 S OFFT _H3_ 0 1.113773 137.082153 154.420850
15 13 S OFFT _H4_ 0 1.126930 134.606657 32.813352
16 13 S OFFT _H5_ 0 1.102237 133.833751 -86.828034
UNK 16 16 26 40 0
1 0 M OFFT _C1_ 0 1.429601 139.941294 -135.794610
2 1 M OFFT _C2_ 0 1.376865 113.017813 -136.312563
3 1 M OFFT _O1_ 0 1.096068 176.171882 -70.829593
4 2 M OFFT _H1_ 0 1.373603 142.762085 -7.642123
5 2 M OFFT _S1_ 0 1.383431 154.372794 172.357505
6 4 M OFFT _C3_ 0 1.355463 144.724477 -0.000000
7 4 M OFFT _O2_ 0 1.088259 150.231118 179.997708
8 5 M OFFT _H5_ 0 0.995051 146.109885 0.000936
9 6 M OFFT _O3_ 0 1.318995 142.370875 0.000000
10 6 S OFFT _N1_ 0 1.739079 156.646106 -179.998468
11 10 S OFFT _H2_ 0 1.501974 141.270592 -0.770592
12 10 S OFFT _H6_ 0 1.501654 141.162735 120.569191
13 10 S OFFT _N2_ 0 1.772998 144.137104 -118.464413
14 13 S OFFT _C4_ 0 1.113773 137.082153 154.420850
15 13 S OFFT _H3_ 0 1.126930 134.606657 32.813352
16 13 S OFFT _H4_ 0 1.102237 133.833751 -86.828034
Thanks for the excellent description, @laumalo.
Firstly, it seems strange to me that both atom reorderings do not match. A bad atom ordering might cause some trouble when running PELE, as a consequence the reordering algorithm was strongly validated when loading a molecule with the force field. Thus, any mismatch between both approaches should come from the new from_impact_file()
method. The core selection might be the reason of the mismatch. Note that this new method should not suggest a new core selection but employ the information saved in the Impact file (atoms are listed with an M
or S
depending on their location, respectively, if they are in the core or in the side chain).
Regarding the second point, it seems like the reordering of atoms does not affect to the zmatrix. This issue probably happens because the zmatrix is computed using an independent class and the reordering only affects to a private list of atoms owned by the Impact
class. So the ZMatrix
class cannot access to the reordered list of atoms. We will have to work on a fix for it, nice catch!
Regarding the second point commented, the error was introduced by a missmatch in the atom names between the Molecule
object and the BaseParameterWrapper
object due to the from_impact_template()
method since in cases where the parametrization is done with the parameterize()
method of Force Field this error did not occur:
UNL 10 9 13 25 0
1 2 S OFFT _O1_ 0 1.248148 147.066621 -42.333451
2 4 S OFFT _C1_ 0 1.471015 154.513939 -8.710222
3 2 S OFFT _O2_ 0 1.378430 148.634167 137.606235
4 0 M OFFT _C2_ 0 1.351681 122.976486 -1.401441
5 4 S OFFT _C3_ 0 1.471246 113.290420 32.282884
6 5 S OFFT _O3_ 0 1.400505 150.092585 34.077933
7 5 S OFFT _O4_ 0 1.239650 147.366131 -145.846157
8 4 M OFFT _H1_ 0 1.115174 129.960154 -125.800180
9 4 M OFFT _H2_ 0 1.104475 141.443968 127.264070
10 6 S OFFT _H3_ 0 1.010543 142.604914 -86.560488
UNL 10 9 13 25 0
1 0 M OFFT _C2_ 0 1.351681 122.976486 -1.401441
2 1 M OFFT _H1_ 0 1.115174 129.960154 -125.800180
3 1 M OFFT _H2_ 0 1.104475 141.443968 127.264070
4 1 S OFFT _C1_ 0 1.471015 154.513939 -8.710222
5 1 S OFFT _C3_ 0 1.471246 113.290420 32.282884
6 4 S OFFT _O1_ 0 1.248148 147.066621 -42.333451
7 4 S OFFT _O2_ 0 1.378430 148.634167 137.606235
8 5 S OFFT _O3_ 0 1.400505 150.092585 34.077933
9 5 S OFFT _O4_ 0 1.239650 147.366131 -145.846157
10 8 S OFFT _H3_ 0 1.010543 142.604914 -86.560488
Where the ZMatrix
is correctly sorted according to the atoms. Thus, this is not a general error.
The error regarding the from_impact_template() method was fixed in this commit.