-
Notifications
You must be signed in to change notification settings - Fork 34
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
Integrate stk as a structure provider, and generate shapes for custom bonds #366
Conversation
Thanks a lot for sending this contribution!
Are you referring to 9615954? If yes, it is already merged in the main branch, so rebasing on top of that should be all you need to do!
You can check this on your machine by running
This is actually the intention behind this part of the code! There is a Then on top of this, we could add the function that generates bonds as shapes (like we have Overall, the code could look something like this from the user perspective: structures = stk.read_structures(...) # not sure about the name of the actual function from STK here ^_^
bonds = chemiscope.stk_bonds_to_shapes(structures)
chemiscope.show(frames=structures, properties=..., shapes=bonds) The good point about this approach is that this will then be an easy change when/if we integrate bonds directly in the dataset given to JavaScript. One would just remove the |
If we go with the full support for STK data in chemiscope (in addition to ASE), it might make sense to do a separate PR adding just basic support (i.e. atomic names + positions + cell), and keep the bonds => shape transformation functionality separate. |
Thank you for the response!
Works a charm, TY! Regarding the stk-specific methods, I am very happy with your suggestion. Does that mean you would then add it as a dependancy, or an optional dependancy for the user to add?
This sounds like a good idea - I might put it all into this draft PR to get it aligned with your code and then "close-reopen" as needed. |
Also, regarding the failed python 3.9 test, that seems to be an issue with ase? |
I would leave stk as an optional dependency: chemiscope is not really using stk, but instead providing adapters from stk data, which are only relevant if the user already has and is using stk. The CI failure is actually a linter error (at the end, you can see
The ASE things printed near the end are only warnings. |
Ah ok, I was seeing red after fixing the lint issue and panicked... aha its ok on my local machine. |
Updated this, one issue I foresee is that stk molecules do not contain properties, so we can add them through their own dictionary like in the example, or I can write an stk molecule-containing class that also has properties? Will chemiscope check the validity of a json file (i.e. matching of structures and properties) elsewhere? |
Also, currently, the tests may fail because of a bug in rdkit rdkit/rdkit#7841 and the latest version. I have pinned the rdkit version for that reason, but that should be fixed soon. |
In this case, the properties should be given separately yes!
Yes, we check this both in Python (before creating the JSON file) and in JavaScript (in case people are not using chemiscope to create the JSON files and they have errors inside). |
Perfect! I have marked this ready to review for feedback on the processing, to make sure I understood it all. And if so, I can split into separate PRs if you see fit. |
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.
couple of small comments in passing, I still have to do a more in depth review of the code
83ec081
to
4ca9fca
Compare
All looks quite nice, but the example does not build into the docs. It definitely misses dependences in requirements.txt, and I think the data folder should be hardcoded to be "data/" as in other examples, without trying to guess the path. If one wants to run these manually the should be ran from the |
Ok, I will try and fix the issues to get the docs buildings.
If I understand correctly, the use of |
Fixing the documentation requires removing this line anyway it seems, so I will go back to |
As far as I can tell locally, everything in tests and website.yml run now |
I am working on the versioning because the latest stk/stko requires Python 3.11 and the website is 3.10. Will update soon. |
We can update the website building to run on Python 3.11, that's fine with me |
Didn't work with tox, and given that the other examples don't do any of this, I'd stick to the local assumption (or change all examples for consistency). |
If it doesn't break other things, I think we can. |
Indeed because it did not work with tox, I went back to the existing assumption. |
I am happy to test this change before you review this PR. |
0ed9815
to
4f0ad7a
Compare
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.
This looks pretty good! I don't think splitting this into two separate PR is really necessary, but if you want to keep multiple commit in the history could you please squash them into logical units? Otherwise I'll squash the whole PR when merging.
__all__ = [ | ||
"convert_stk_bonds_as_shapes", | ||
] |
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.
I don't think this is correct. __all__
controls what gets imported when someone does from xxx import *
.
If this is a workaround the linter about unused import, feel free to use # noqa
for this import!
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.
Done.
Ok, all done through these comments. Thank you for the feedback! I think its ok for you to squash all commits here upon merging. |
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.
Thanks a lot for this work! I'll merge once CI is happy
Excellent! Thank you! What is the release schedule for chemiscope? (just asking to allow for lazy pip-install usage aha) |
Maybe we could do a point release after this is merged? |
Yes, we can do a point release! EDIT: I'll finish up #367 first and also include it in the release |
self.assertEqual( | ||
data["structures"][0]["x"], | ||
[ | ||
1.6991195138834223, | ||
0.7737143493209756, | ||
-0.41192204250544034, | ||
-0.7778845126633998, | ||
-1.1777543806588109, | ||
-0.10527292738297804, | ||
], |
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.
@andrewtarzia when running this test locally, I get an error:
AssertionError: Lists differ: [1.8856062905183792, 0.8568739943293787, -0.[74 chars]6763] != [1.6991195138834223, 0.7737143493209756, -0.[77 chars]7804]
First differing element 0:
1.8856062905183792
1.6991195138834223
- [1.8856062905183792,
- 0.8568739943293787,
- -0.4418130132537843,
- -1.224037530127693,
- -0.6838309641680245,
- -0.3927987773106763]
+ [1.6991195138834223,
+ 0.7737143493209756,
+ -0.41192204250544034,
+ -0.7778845126633998,
+ -1.1777543806588109,
+ -0.10527292738297804]
Do you think this is because the orientation of the molecule is not fixed? Or that rdkit gives different results here for some reason?
I'm running on an arm64 CPU / macOS if that's relevant
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.
Mm that is strange. Molecule construction in stk should be constant by setting rdkit seeds and such. That said, I don't think we've ever tested on a mac, I will check with another Mac user. Sorry!
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.
Yes, so Lukas confirmed that the STK tests fail on a Mac. I assume that the coordinates are self consistent, but the random numbers used differ across hardware. What's the best course of action? I could provide coordinates to the molecules instead of using rdkit conformer generation? Or can we mute a test on certain hardware?
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.
For the tests in chemiscope, I'll just remove the tests about the exact coordinate values, it does not matter too much to test the functionality here!
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.
I agree in this case!
In this pull request, I implement the "simple" solution from #361 through a Python function and example for others to use.
This builds off an unreleased branch from @Luthaf and so it may require rebasing before merging, but I was hoping to get feedback/discuss some questions anyway in this draft.
Discussion points:
pip install stk
) if they want to run the example? But I did this as an example for you, and I think a better option (that does not confuse the user) would be to just show the example with bonds collected by hand..mol
/rdkit/stk (for example), and can be used in place of thease.read
statement?Remaining todo: