Skip to content

Commit

Permalink
Update v1.38
Browse files Browse the repository at this point in the history
  • Loading branch information
sami-chaaban committed Nov 20, 2021
1 parent 5c25cb3 commit 822cd94
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Column query term(s). E.g. *\_rlnMicrographName*. This is used to look for a spe

**```--q```** *```query(ies)```*

Particle query term(s) to look for in the values within the specified column. To enter multiple queries, separate them with a slash (e.g. 20200101/20200203 to request matching either of the two queries). Use ```--e``` if the query(ies) should exactly match the values in the column.
Particle query term(s) to look for in the values within the specified column. To enter multiple queries, separate them with a slash (e.g. 20200101/20200203 to request matching either of the two queries). To escape a slash, precede it with "," (i.e. ,/). Use ```--e``` if the query(ies) should exactly match the values in the column (see below).

**```--e```**

Expand Down
2 changes: 1 addition & 1 deletion starparser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os

__version__ = '1.37'
__version__ = '1.38'
_ROOT = os.path.abspath(os.path.dirname(__file__))
2 changes: 1 addition & 1 deletion starparser/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def argparse():

query_opts.add_option("--q",
action="store", dest="parser_query", type="string", default="", metavar='query(ies)',
help="Particle query term(s) to look for in the values within the specified column. To enter multiple queries, separate them with a slash: 20200101/20200203. Use --e if the query should exactly match the value.")
help="Particle query term(s) to look for in the values within the specified column. To enter multiple queries, separate them with a slash: 20200101/20200203. To escape a slash, use a \",\". Use --e if the query should exactly match the value.")

query_opts.add_option("--e",
action="store_true", dest="parser_exact", default=False, metavar="match-exactly",
Expand Down
11 changes: 9 additions & 2 deletions starparser/decisiontree.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,15 @@ def decide():
totalparticles = len(allparticles.index)

#If a query was passed, then turn it into a list. Since queries are split by a slash, .split("/") creates the list for us
#Escape a / with a , preceding it (i.e. ,/).
#!!This needs to be updated in particleplay if change here!!
if params["parser_query"] != "":
query = params["parser_query"].split("/")
query = params["parser_query"]
escape = ",/"
query = str.replace(params["parser_query"],escape, ",")
query = query.split("/")
for i,q in enumerate(query):
query[i] = str.replace(q,",", "/")

#If no column was passed, the query can't be checked.
if params["parser_column"] == "":
Expand Down Expand Up @@ -933,7 +940,7 @@ def decide():
particles2use = particleplay.checksubset(allparticles, queryexact)

"""
--extract_particles
--extract
"""

if params["parser_extractparticles"]:
Expand Down
10 changes: 9 additions & 1 deletion starparser/particleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,16 @@ def checksubset(particles, queryexact):

params = argparser.argparse()
if params["parser_column"] != "" and params["parser_query"] != "":
query = params["parser_query"].split("/")

query = params["parser_query"]
escape = ",/"
query = str.replace(params["parser_query"],escape, ",")
query = query.split("/")
for i,q in enumerate(query):
query[i] = str.replace(q,",", "/")

columns = params["parser_column"].split("/")

subsetparticles, extractednumber = extractparticles(particles, columns, query, queryexact)

print("\n>> Created a subset of " + str(extractednumber) + " particles (out of " + str(len(particles.index)) + ", " + str(round(extractednumber*100/len(particles.index),1)) + "%) that match " + str(query) + " in the columns " + str(columns) + ".")
Expand Down

0 comments on commit 822cd94

Please sign in to comment.