-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of the GEN_FF workflow #383
base: master
Are you sure you want to change the base?
Conversation
da3a010
to
d4712e0
Compare
molecule.nodes[atom]['resname'] = resname | ||
molecule.nodes[atom]['resid'] = node + 1 | ||
#print(meta_graph.nodes[node]['graph'].nodes[atom]) | ||
atomname = meta_graph.nodes[node]['graph'].nodes[atom]['atomname'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working on the effort in gh-390 to build SEBS, using this command (via subprocess
):
subprocess.CalledProcessError: Command '['polyply', 'gen_ff', '-i', 'smiles_molecule.acpype/smiles_molecule_GMX_OPLS.top', '-s', '{[#styrene]|2[#ethylene]|2[#butylene]|2[#styrene]|2}.{#styrene=[<]CC[>]c1ccccc1,#ethylene=[<]CCCC[>],#butylene=[<]CC[>](CC)}']' returned non-zero exit status 1.
I ended up with the traceback below the fold, affecting this line.
traceback
Traceback (most recent call last):
File "/home/treddy/python_venvs/py_311_hemd/bin/polyply", line 292, in <module>
main()
File "/home/treddy/python_venvs/py_311_hemd/bin/polyply", line 288, in main
subprogram(**args_dict)
File "/home/treddy/python_venvs/py_311_hemd/lib/python3.11/site-packages/polyply/src/gen_ff.py", line 90, in gen_ff
meta_mol = MetaMolecule.from_cgsmiles_str(force_field=force_field,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/treddy/python_venvs/py_311_hemd/lib/python3.11/site-packages/polyply/src/meta_molecule.py", line 424, in from_cgsmiles_str
atomname = meta_graph.nodes[node]['graph'].nodes[atom]['atomname']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'atomname'
The error was triggered by this CGSmiles string originally: '{[#styrene]|2[#ethylene]|2[#butylene]|2[#styrene]|2}.{#styrene=[<]CC[>]c1ccccc1,#ethylene=[<]CCCC[>],#butylene=[<]CC[>](CC)}'
I can reproduce the error with a much simpler CGSmiles string, "{[#styrene]|2}.{#styrene=[<]CC[>]c1ccccc1}"
,
and even with: '{[#styrene]}.{#styrene=[<]CC[>]c1ccccc1}'
.
Some debug printing shows the problematic atom in the context of the full CGSmiles input to be this one:
***** atom: 49
***** nodes: [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56]
***** type(nodes): <class 'networkx.classes.reportviews.NodeView'>
***** atom index: {'charge': 0, 'aromatic': False, 'element': 'H', 'fragid': [3], 'fragname': 'ethylene', 'resname': 'ethylene'}
I'll see if I can dig a bit deeper..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that molecule.nodes[atom]['atomname']
is already populated in some cases, so the shim below seems to get past that particular issue:
--- a/polyply/src/meta_molecule.py
+++ b/polyply/src/meta_molecule.py
@@ -421,8 +421,12 @@ class MetaMolecule(nx.Graph):
molecule.nodes[atom]['resname'] = resname
molecule.nodes[atom]['resid'] = node + 1
#print(meta_graph.nodes[node]['graph'].nodes[atom])
- atomname = meta_graph.nodes[node]['graph'].nodes[atom]['atomname']
- molecule.nodes[atom]['atomname'] = atomname
+ try:
+ atomname = meta_graph.nodes[node]['graph'].nodes[atom]['atomname']
+ molecule.nodes[atom]['atomname'] = atomname
+ except KeyError:
+ # the atomname tends to already be populated in some cases
+ pass
But then there's yet another error:
Traceback (most recent call last):
File "/home/treddy/python_venvs/py_311_hemd/lib/python3.11/site-packages/polyply/src/graph_utils.py", line 225, in find_one_ismags_match
mapping = next(raw_matches)
^^^^^^^^^^^^^^^^^
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/treddy/python_venvs/py_311_hemd/bin/polyply", line 292, in <module>
main()
File "/home/treddy/python_venvs/py_311_hemd/bin/polyply", line 288, in main
subprogram(**args_dict)
File "/home/treddy/python_venvs/py_311_hemd/lib/python3.11/site-packages/polyply/src/gen_ff.py", line 97, in gen_ff
unique_fragments, res_graph = FragmentFinder(target_mol).extract_unique_fragments(meta_mol.molecule)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/treddy/python_venvs/py_311_hemd/lib/python3.11/site-packages/polyply/src/fragment_finder.py", line 141, in extract_unique_fragments
mapping = find_one_ismags_match(self.molecule,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/treddy/python_venvs/py_311_hemd/lib/python3.11/site-packages/polyply/src/graph_utils.py", line 228, in find_one_ismags_match
raise IOError("no match_found")
OSError: no match_found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylerjereddy I think this might be a dependency error, where the atomnames are different from what polyply expects. We've been changing quite a bit in the CGSmiles package over the past few weeks.I'll try taking a look to see if I can manage to figure it out.
@fgrunewald @pckroon I can see different errors at different Some
|
I also thought about checking the CI logs on this branch to see what got pulled in on the last push, but it has been a few months since the last commit and the logs are gone I think. |
Pysmiles has seen quite some changes in the past weeks. I think the issues you're running into appeared after pckroon/pysmiles#47 got merged. |
@pckroon I just tried that
|
That's probably an issue in cgsmiles. AFAIK that version of pysmiles is what cgsmiles currently understands, but it's all in motion. |
@tylerjereddy et al. This has been an issue in cgsmiles and is resolved upon merging CGSmiles PR33 |
This is the preliminary implementation of the gen_ff workflow. To generate ff-parameters from an itp file use:
You can then generate an arbitrary polymer with:
LICENSE NOTICE
This code is currently licensed under PolyForm Noncommercial License 1.0.0, meaning it can be adopted shared and used as long as not for commercial purposes.