From d5281271b150cf573bce9eec31ae597e1dbae30b Mon Sep 17 00:00:00 2001 From: Sami Chaaban <36083637+sami-chaaban@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:36:25 +0000 Subject: [PATCH] Update v1.51 --- starparser/__init__.py | 2 +- starparser/decisiontree.py | 2 +- starparser/particleplay.py | 22 +++++++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/starparser/__init__.py b/starparser/__init__.py index 42849d6..0317fe2 100644 --- a/starparser/__init__.py +++ b/starparser/__init__.py @@ -1,4 +1,4 @@ import os -__version__ = '1.50' +__version__ = '1.51' _ROOT = os.path.abspath(os.path.dirname(__file__)) \ No newline at end of file diff --git a/starparser/decisiontree.py b/starparser/decisiontree.py index 168c547..f580fc0 100644 --- a/starparser/decisiontree.py +++ b/starparser/decisiontree.py @@ -1050,7 +1050,7 @@ def decide(): """ --extract """ - + #Particles were already subsetted above, just write them here if params["parser_extractparticles"]: if params["parser_column"] == "" or params["parser_query"] == "": print("\n>> Error: enter a column (--c) and query (--q) to extract.\n") diff --git a/starparser/particleplay.py b/starparser/particleplay.py index c006c85..3d9fb0f 100644 --- a/starparser/particleplay.py +++ b/starparser/particleplay.py @@ -150,6 +150,8 @@ def checksubset(particles, queryexact): query[i] = str.replace(q,",", "/") columns = params["parser_column"].split("/") + for i,c in enumerate(columns): + columns[i] = makefullname(c) subsetparticles, extractednumber = extractparticles(particles, columns, query, queryexact) @@ -527,10 +529,10 @@ def extractoptics(particles, metadata, queryexact): column = params["parser_column"].split("/") if len(column)>1: - print("\n>> Error: you have specified two column. Only specify one if you're extracting from a subset of the data using a query.\n") + print("\n>> Error: you have specified two columns. Only specify one if you're extracting from a subset of the data using a query.\n") sys.exit() else: - column = column[0] + column = makefullname(column[0]) opticsheaders = metadata[1] opticsdata = metadata[2] @@ -575,4 +577,18 @@ def extractoptics(particles, metadata, queryexact): newopticsdata = opticsdata[opticsdata['_rlnOpticsGroup'].isin(non_repeating_values_set)] - return(newparticles, [metadata[0], metadata[1], newopticsdata, metadata[3], metadata[4]], extractednumber) \ No newline at end of file + return(newparticles, [metadata[0], metadata[1], newopticsdata, metadata[3], metadata[4]], extractednumber) + +def makefullname(col): + if col.startswith("_rln"): + return(col) + elif col.startswith("rln"): + return("_"+col) + elif col.startswith("_rn") or col.startswith("rn"): + print(f"\n>> Error: check the column name {col}.\n") + sys.exit() + elif col.startswith("rn") and not col.startswith("rln"): + print(f"\n>> Error: check the column name {col}.\n") + sys.exit() + else: + return("_rln"+col) \ No newline at end of file