Skip to content
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

Fix to environment SMIRKS parsing and update README and detailed examples with environment #7

Merged
merged 17 commits into from
Apr 24, 2017

Conversation

bannanc
Copy link
Collaborator

@bannanc bannanc commented Apr 3, 2017

My goal with this pull request is to get the examples to run correctly, specifically I will:

  • add parsing capability for Ring SMIRKS to ChemicalEnvironments
  • add check for '.' and '>>' in SMIRKS patterns and raise error
  • address smarty issue #16 on SMIRKS parsing in environment.py
  • update SMIRNOFF_comparison examples to import forcefield_utils correctly
  • update example in README to be a code snippet that works (unless the problem there is an issue with the code somewhere)
  • update README to include more information about ChemicalEnvironments.
  • examples for chemical environments are fairly outdated, I'm going to merge them into one ipython notebook and write a README for it.

@bannanc bannanc mentioned this pull request Apr 3, 2017
4 tasks
@bannanc bannanc changed the title [WIP] update examples and readmes [WIP] Fix to environment SMIRKS parsing and update README and detailed examples with environment Apr 14, 2017
@bannanc
Copy link
Collaborator Author

bannanc commented Apr 15, 2017

I'm getting closer to solving the parsing issues, I'm working on writing some "extra weird" SMIRKS strings to test it.

@bannanc
Copy link
Collaborator Author

bannanc commented Apr 20, 2017

@davidlmobley I think this is ready for a code review whenever you have time.

@bannanc bannanc changed the title [WIP] Fix to environment SMIRKS parsing and update README and detailed examples with environment Fix to environment SMIRKS parsing and update README and detailed examples with environment Apr 20, 2017
Copy link
Contributor

@davidlmobley davidlmobley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bannanc - looks good to me except minor typos/clarifications noted, and a question about whether you're testing some of the functionality which has been corrected/adjusted (if not then you probably want to modify tests slightly to do so).

Should be good to merge once these minor issues are corrected. Nice work!

We should be sure to do a new point release once this is merged.

README.md Outdated
Documentation forthcoming.
See `examples/chemicalEnvironments/` for now.
ChemicalEnvironments are a python class used to parse and manipulate SMIRKS strings.
They were created with the goal of being able to automatically and randomly generate parameters for SMIRKS Native-Open Force Fields.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were created with the goal of being able to automatically and randomly generate parameters for SMIRKS Native-Open Force Fields.

Is this the right way of explaining this? Currently we don't do anything with parameters. I think maybe it would be more accurate to say that they were created with the goal of being able to automatically and randomly explore chemical perception, so that someday we can sample over chemical perception at the same time as developing parameters... ?

### Initiating ChemicalEnvironments

All Chemical Environments can be initated using SMIRKS strings.
The general ChemicalEnvironment, with no input string is completely empty, however there
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"General ChemicalEnvironment objects with no input string are completely empty. However, there are five..." (The current wording "...with no input string is completely empty..." is confusing).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, singlequote names of data structures if possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For example, AtomChemicalEnvironment not AtomChemicalEnvironment -- it makes it more clear you're talking about code.)


* `moves_using_environments.ipynb` - uses the `moveTrees.uniq.*.txt` files to illustrate how to make moves in chemical perception space.

For a more thorough and automated tool for using ChemicalEnvironments to make changes to chemical perception see [smirky](https://github.com/open-forcefield-group/smarty), a tool we developed to rediscover SMIRNOFF parameters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there features of SMARTS/SMIRKS which are NOT (yet) supported which should be noted for the record? For example, a "Not yet supported" section?


### ANDtypes and ORtypes

ChemicalEnvironments store information about the SMIRKS string in the same way a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this backwards? It's not that they store information about a SMIRKS string -- they store information about a chemical graph and provide a mechanism to translate to and from SMIRKS patterns, right?

print("New Atom 1: %s " % atom1.asSMIRKS())
# New Atom 1: [#6X3,#7X2;+0:1]

# Change atom2's AND and OR types with the add*type methods
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you want a comment here to remind people what WAS in this? For example, "#Remember, angle contains the environment corresponding to SMIRKS smirks = "[#6X3,#7;+0:1]~;@[#8;r:2]~;@[#6X3,#7;+0:3]""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It took me a minute to figure out I had to scroll up to find out what this was talking about).

beta_list = angle.getBetaAtoms
# Note - Atoms can be replaced with Bonds in each of the above examples
```
3. Report the minimum order of a bond with Bond.getOrder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"minimum order"? Not "order"? Confuses me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add more commentary, but this is because there could be more than one bond type. For example, [*]-,:,=[*] could be single, aromatic, or double. getOrder() on that bond would return 1.

atomB = angle.selectAtom(B)
bondAB = angle.getBond(atomA, atomB) # returns None if no bond found
```
6. Get atoms bound to a specified atom with getNieghbors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getNeighbors misspelled


### `using_environments.ipynb`

This notebook should be your first stop for interactively understanding and using ChemicalEnvironemnts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChemicalEnvironments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note that some of these typos -- though not this one -- also show up in your using_environments.ipynb file and should be corrected there too.)


# Store the smirks pattern before and after the relevant atom
pre_smirks = smirks[:a_in]
post_smirks = smirks[a_out+1:]

# Check for ring index, i.e. the 1s in "[#6:1]1-CCCCC1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were we not handling ring subsearches like this before? If not we probably want to note this prominently in listing the changes this PR brings in. (Basically just we want to make it easy to tell where/when we made any especially important/big changes.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also, have you modified tests to test this?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we weren't covering them before, I wasn't aware that you could use the ring indexing until fairly recently.

I haven't added them to the tests yet, I have the complicated list in the ipython notebook. I could add that to the list in the tests.

of pattern is not parseable into ChemicalEnvironments" % smirks)
if smirks.find('>') != -1:
raise SMIRKSParsingError("Error: Provided SMIRKS ('%s') \
contains a '>' indicating a reaction. This type of pattern is not parseable \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Probably want to get this into a README somewhere too. :)

@bannanc
Copy link
Collaborator Author

bannanc commented Apr 24, 2017

@davidlmobley I made the changes you pointed out, I also updated the environment tests to make sure it could parse ring SMIRKS.

@davidlmobley
Copy link
Contributor

Thanks, @bannanc . So you should be good to merge once tests pass (currently broken).

@bannanc
Copy link
Collaborator Author

bannanc commented Apr 24, 2017

@davidlmobley
I miss typed an example SMIRKS in the test script.
Tests passing now.

@davidlmobley
Copy link
Contributor

Thanks, @bannanc !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants