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

Unable to Search for Atom Names Containing ' #115

Closed
fjclark opened this issue Oct 19, 2023 · 3 comments
Closed

Unable to Search for Atom Names Containing ' #115

fjclark opened this issue Oct 19, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@fjclark
Copy link
Collaborator

fjclark commented Oct 19, 2023

Describe the bug

I am trying to modify BioSimSpace so that specifying restraint="backbone" also works for nucleic acids. However, several nucleic acid backbone atoms contain ' in their names, which results in an error:

sys.search("atomname O5'")

Gives:

ValueError: 'Invalid search query: "atomname O5'" : SireMol::parse_error: Failed to parse any of the selection 'atomname 
O5''. (call sire.error.get_last_error_details() for more info)

I am doing this correctly? Apologies if I have missed this in the tutorials. Thanks very much.

To Reproduce

Here is my RNA test system.

  • OS: Ubuntu 22.04
  • Version of Python: 3.11
  • Version of sire: 2023.4.0
  • I confirm that I have checked this bug still exists in the latest released version of sire: yes
@fjclark fjclark added the bug Something isn't working label Oct 19, 2023
@chryswoods
Copy link
Contributor

Thanks for reporting - the issue is that ' is used as the quote character for strings in the parser. So you could search for atomname 'C 1' etc.

To escape the quote, we need to switch to the regular expression mode in the grammar (https://sire.openbiosim.org/cheatsheet/search.html#strings).

You put regular expressions within / characters. So searching for atomname /O5'/ would work.

Note you could also use *, ? and other regular expression glob patterns as well.

@fjclark
Copy link
Collaborator Author

fjclark commented Oct 19, 2023

Thanks very much for the quick reply. Sorry I missed this in the docs.

@fjclark fjclark closed this as completed Oct 19, 2023
@chryswoods
Copy link
Contributor

No need to apologise - I didn't know the code could do that either ;-)

Initially I thought that I would have to write code to let us escape single quotes, e.g. atomname O5\'. Then, as I was writing a reply saying this wasn't supported, I thought maybe it would be ok in the regex code, so gave it a try. I was surprised and happy it worked.

I'm going to add some docs to the regex code and the tutorial to show how we can escape single quotes this way. I may also think about how to add proper escaping to the syntax, as it is surprising that it doesn't escape quotes.

fjclark added a commit to fjclark/biosimspace-openbiosim that referenced this issue Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants