-
Notifications
You must be signed in to change notification settings - Fork 8
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
Initial Chemical Environment Sampler with basic moves for Bonds, Angles, Torsions, and Impropers #112
Conversation
Also, I haven't written any tests for the sampler_smirky.py yet. My plan is to mimic the ones we have for the current sampler, but if anyone thinks there is something different it should check, please let me know. |
This is great! Looking ahead, we'll want to divorce the sampler from the set of
|
For now this will give @cbayly13 and me somewhere to figure out how to make moves in this space in a way that will reach the level of complexity we need. I guess we could have written the separate tools and used them here, but it was a bit easier working in the framework we already had for atomtypes. @cbayly13 I imagine you will work primarily in the |
You don't need separate tools, but you will need to refactor the class into several different classes so we can keep things isolated in a way that allows us to experiment with different strategies for atom type proposals without breaking everything or duplicating a ton of code. |
I agree with both of you here, @bannanc and @jchodera . We're heading in the direction @jchodera mentions, but this allows us to proceed with testing out the move proposals Christopher is working on with the chemical environment objects while John finalizes the @bannanc has been working on this for a while, since long before we started discussing the parameter sampling API over here (#110 (comment)); as we've discussed in prior calls, we headed this direction since (a) we need a descendant of smarty which allows us to test sampling of more than just vdW types, and (b) it wasn't time to figure out the general parameter sampling API until we had the ability to calculate properties. In other words, this allows us to continue to make forward progress on figuring out how to do reasonable SMIRKS sampling for other parameter types (and test the results) so that we will know what to put into the API once we sort out what it looks like. Otherwise, Christopher and Caitlin would just end up sitting on their hands waiting... |
Oh, it's fine for now. I'm just saying you're going to need to refactor it soon (probably over the next ~2 weeks). |
@jchodera 👍 . We're totally expecting to have to refactor, yes. We're on the same page. :) |
…nds, Angles, Impropers, and Torsions).
@bannanc - I'm going over this a bit. It's actually looking really great! I have a few notes/questions. These sort of started off as questions, but as my understanding developed they became more of notes. They're probably still useful for the record, however -- just realize that most of the questions actually get answered:
For the record, in this set there are currently six angle patterns, and above we got four when looking at 119 elements. The other two are Tests-wise, you'll definitely want tests which correspond to your |
Next, @bannanc , comments/answers/partial answers on some of your questions:
It looks like currently you raise an exception if a SMIRKS isn't parseable. I think this is the right thing to do (as if we're doing this correctly, our smirks should all be parseable) and I would put it inside the chemical environment objects so that the user of the environment object doesn't have to remember to check. In other words, have your code check itself for bugs rather than having the user check... :)
This sounds reasonable to me. I'd like to hear a little more on your rationale for not adding empty atoms, though:
At first I agreed completely, as I thought adding another atom doesn't provide any more information if it is empty. But then I thought through an example. If we're looking at an angle, for example, which has three labeled atoms, and we add a fourth atom, it initially didn't seem like it would add value to add a fourth atom if that atom is empty (since the only case where this could matter would be if it ended up clarifying the number of bonds an atom involved can make - for example if we have Now, I realize that a more "traditional" way of saying that the first atom can't be a halogen or an oxygen that already has two bonds or (etc.) would be to decorate it with all those things, and maybe that will typically make more sense. So I don't necessarily have a problem with initiating atoms with one ORtype and allowing deletion of atoms with one ORtype, if you and Christopher are convinced that the information we gain by adding/deleting empty atoms isn't useful. I also note that there are disadvantages to adding/deleting only empty atoms, one of which is then that it takes more work (and more moves) to get to the type of decoration we often expect to be most useful, which is where we SPECIFY an alpha or beta substituent. Maybe this is enough reason to use the approach you mention.
Can you clarify this point? I don't actually understand what you're saying. Why would Hopefully I hit all the major points. I haven't done that much code review, but functionally it looks good. Let me know when you're ready for more detailed code review. |
…gle, Impropers, and Torsions).
…nb for use in smirksEnvMoves to actually attempt to perform them. These files can be used to test smirksEnvMoves.
…Impropers, and Torsions).
@bannanc - tests are failing because of an issue with importing OpenEye toolkits. I don't think your modifications have caused this, but it's possible there is already a fix in master that you haven't pulled into this? Otherwise I may need to investigate as maybe Travis is failing at installing them. |
…s in BAIT space (Bonds, Angle, Impropers, and Torsions). Now all functions have a doc string.
@davidlmobley I haven't pulled from master in a while, so it's possible I missed a change there, I'll do that now. edit: I just tried to pull origin master and it said I was up to date... |
Bring Bayly's latest envMoves examples from his branch into environment branch, updating existing PR #112
I was testing some things this morning, the plan was just to import environments and create some with smirks and make sure the getTypes() method was working correctly. When I imported smarty.environments I got the following warning:
I'm guessing that whatever is causing this warning could also be causing the checks to fail. Any ideas? |
@bannanc - I'm not seeing |
However, it looks like the "Cannot import..." message is coming from |
Thanks for the direction @davidlmobley , I couldn't find vendor anywhere either, I will poke around and post anything I find. |
Now it looks like python 2 tests are passing, but not 3? I probably accidentally added something that isn't python3 compatible accidentally, I'll investigate. |
@davidlmobley I found it, there was an issue with how the smarty tools were being imported and a few issues with print statements. It looks like everything is passing now. |
Nice work, @bannanc . But this is still [WIP], yes? Or is at the point where you can finalize a reasonable addition/modularization of this and get it merged and bring in other things later? |
@davidlmobley I think there are going to be a lot of changes in the format of chemical environments and the sampler as I import @cbayly13 's moves so I don't think we should merge into master until I get those combined. |
@bannanc - would it make sense to bring this one in as a functional unit before you do that, since it will involve a ton of other modifications/extensions/changes? Just asking. |
@davidlmobley |
OK, let's do that. Merging. |
I have made an updated version of sampler.py called sampler_smirky.py.
Instead of using string manipulations to sample atomtypes it uses chemical environment to sample Atoms, Bonds, Angles, Torsions, or Impropers.
This is still very much as a WIP stage, but it does run and now @cbayly13 can work on how to make moves.
I imagine some things will change in this set up, but here is an example of how to used the sampler, there are a few examples also in examples/smirky_sampler/
This primarily addresses issue #97 , but I've made a few other changes while working on this that will address other issues.
#93 Chemical Environments now have a function getType() which, per @cbayly13 's request returns
'VdW', 'Bond', 'Angle', 'Torsion', 'Improper' or None (if there are 0 or more than 4 labeled atoms)
#96 I think needs to be discussed a little, I have included in the sampler checks that smirks are parseable when making moves, I'm not sure if this is a check we should include inside the chemical environments also or instead.
#98 I fixed smirksEnvDepict.ipynb in examples/chemicalEnvironments/ to copy the molecule so the original isn't flattened
#99 I updated the addAtom function in chemicalEnvironments to optionally check if the atom is "empty." We are currently thinking of empty atoms as those with only 1
ORtype
decorator and 0ANDtype
decorators. @cbayly13 and I have discussed this a little offline and we don't think it makes sense to add empty atoms. @jchodera our understanding is that as long as our moves are reversible they should be allowed? So when we add atoms we will initiate them with 1ORtype
and removing can't happen unless there is only that oneORtype
.That being said the removeAtom also removes the associated bond, currently
removeAtom
doesn't look at the associated bond.#110 This is not a creation of the
ChemicalEnvironmentProposalEngine
, but I think a lot of the frame work will end up in this sampler.