natverse / neuprintr

R client utilities for interacting with the neuPrint connectome analysis service
http://natverse.org/neuprintr
3 stars 3 forks source link

Add an option to make fixed searches #80

Closed romainFr closed 4 years ago

romainFr commented 4 years ago

neuprint_search used to only take in regular expressions, which can be a bit cumbersome when querying names with brackets and other special characters. This PR adds a fixed option to neuprint_search, which when TRUE, makes a literal search (like it's now in neuprint explorer), so that:

neuprint_search("PEN_a(PEN1)",field="type",fixed=TRUE)

returns what you would expect, when

neuprint_search("PEN_a(PEN1)",field="type",fixed=FALSE)

returns NULL as it's expecting the brackets to be escaped.

This uses (like neuprint explorer), CONTAINS instead of =~ in the query

romainFr commented 4 years ago

The default is such as existing code isn't altered (meaning it's using a regex)

romainFr commented 4 years ago

I'll merge as it works and doesn't affect the default behavior.

jefferis commented 4 years ago

Thanks @romainFr! Two quick comments.

  1. could you just clarify whether this requires a match to the whole name/type or if a partial match is sufficient? regexes must currently match the whole name/type
  2. would be great to include a test exercising this.
romainFr commented 4 years ago

Thanks!

  1. Yes, partial matches work. I added a sentence in the docstring
  2. Just pushed that
jefferis commented 4 years ago

Cool. Can one do fixed exact (whole teen) matches then? G.

Sent from my iPhone

On 13 Feb 2020, at 18:59, Romain Franconville notifications@github.com wrote:

Thanks!

Yes, partial matches work. I added a sentence in the docstring Just pushed that — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

jefferis commented 4 years ago

(just a note that the travis error was just a failure to roxygenise)

jefferis commented 4 years ago

(just a note that fixed=T does not handle exact matches where the whole field matches (only partial matches). I am addressing this.