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

Allow molecules to be searched with min/max values #131

Merged
merged 2 commits into from
Jun 22, 2019

Conversation

psavery
Copy link
Collaborator

@psavery psavery commented May 22, 2019

In the minValues parameter, one can pass in things like:

{ "properties.heavyAtomCount": 4 }

and the results will only contain molecules that have at
least 4 heavy atoms. The maxValues parameter can be used
in a similar way.

If both the minValues and maxValues parameters are used, then
the results will satisfy both.

Signed-off-by: Patrick Avery patrick.avery@kitware.com

In the minValues parameter, one can pass in things like:
```
{ "properties.heavyAtomCount": 4 }
```

and the results will only contain molecules that have at
least 4 heavy atoms. The maxValues parameter can be used
in a similar way.

If both the minValues and maxValues parameters are used, then
the results will satisfy both.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
@psavery
Copy link
Collaborator Author

psavery commented May 22, 2019

This works toward some of the content of this issue.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
@psavery
Copy link
Collaborator Author

psavery commented Jun 20, 2019

This is ready for review.

@psavery psavery merged commit 16ca4a9 into master Jun 22, 2019
@psavery psavery deleted the search-min-max-values branch June 22, 2019 18:23
@psavery
Copy link
Collaborator Author

psavery commented Jun 22, 2019

As a side note, this also provides an indirect way to search for exact values as well, because the user can specify something like { "properties.heavyAtomCount": 4 } as both a min value and a max value (in which case it must be equal).

@cryos
Copy link
Member

cryos commented Jun 24, 2019

Wouldn't it be more efficient to add an endpoint to search for an exact match? I don't know how clever MongoDB is about optimizing that, but it seems a little strange not to simply offer an equality query too.

@psavery
Copy link
Collaborator Author

psavery commented Jun 24, 2019

Yes, that makes sense. I can add it.

@psavery
Copy link
Collaborator Author

psavery commented Jun 24, 2019

Well, I actually just noticed that everything I added in this PR and more (equality comparisons included) are already available to use in the GET /molecules/search endpoint with the query parameter. It looks like Chris added these features several years ago (implementation here). I'm not sure why we haven't been using it - I can ask Chris about it when he gets back.

@cryos
Copy link
Member

cryos commented Jun 24, 2019

I thought you knew about that, I think it may need updating to our new document layout. We used it to great effect in a previous project, but it was kept around for reference. It would be nice to update it, and get it working again.

@psavery
Copy link
Collaborator Author

psavery commented Jun 25, 2019

Seems like, for the most part, it is working and in good condition. It worked for me for inchi, inchikey, name, formula, smiles, mass, atomCount, and heavyAtomCount. I also tried the gte, lte, gt, lt, eq, and ne operators, and various combinations of them with and and or.

The only thing that didn't work for me so far is more complex InChIs. For instance, the InChI that we get from Open Babel for butanol is InChI=1S/4CH4.H2O/h4*1H4;1H2. It raises an invalid query exception, which might be because of a parsing error.

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.

None yet

3 participants