Skip to content

Commit

Permalink
Update v1.47
Browse files Browse the repository at this point in the history
  • Loading branch information
sami-chaaban committed Aug 26, 2023
1 parent 91b6409 commit 327638c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
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.45'
__version__ = '1.47'
_ROOT = os.path.abspath(os.path.dirname(__file__))
8 changes: 4 additions & 4 deletions starparser/columnplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def delcolumn(particles, columns, metadata):
The "1" tells .drop that it is the column axis that we want to drop
inplace means we want the dataframe to be modified instead of creating an assignment
"""
nocolparticles.drop(c, 1, inplace=True)
nocolparticles.drop(c, axis=1, inplace=True)

#We nead to remove that column header too. The heads are the third
#metadata (i.e. metadata[3])
Expand Down Expand Up @@ -77,7 +77,7 @@ def swapcolumns(original_particles, swapfrom_particles, columns):
The "1" means the column axis and inplace means the dataframe
should be modified instead of creating an assignment
"""
swappedparticles.drop(c,1,inplace=True)
swappedparticles.drop(c,axis=1,inplace=True)

"""
Insert the new column in the right index using .insert()
Expand Down Expand Up @@ -140,7 +140,7 @@ def importmicvalues(importedparticles, importfrom_particles, column):
The "1" tells .drop that it is the column axis that we want to drop
inplace means we want the dataframe to be modified instead of creating an assignment
"""
importedparticles.drop("_rlnMicrographNameSimple", 1, inplace=True)
importedparticles.drop("_rlnMicrographNameSimple", axis=1, inplace=True)

return(importedparticles)

Expand Down Expand Up @@ -293,7 +293,7 @@ def replacecolumn(particles,replacecol,newcol):
The "1" means the column axis and inplace means the dataframe
should be modified instead of creating an assignment
"""
particles.drop(replacecol, 1, inplace=True)
particles.drop(replacecol, axis=1, inplace=True)

#Insert the new column in the right index using .insert()
#Since newcol comes in as a list, we don't have to modify it
Expand Down
18 changes: 9 additions & 9 deletions starparser/particleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def limitparticles(particles, column, limit, operator):
elif operator == "le":
limitedparticles = limitedparticles[limitedparticles[tempcolumnname]<=limit]

particles.drop(tempcolumnname,1, inplace=True)
limitedparticles.drop(tempcolumnname,1, inplace=True)
particles.drop(tempcolumnname, axis=1, inplace=True)
limitedparticles.drop(tempcolumnname, axis=1, inplace=True)

if len(limitedparticles.index) == 0:
print("\n>> Error: there are no particles that match the criterion.\n")
Expand Down Expand Up @@ -74,10 +74,10 @@ def delparticles(particles, columns, query, queryexact):

if not queryexact:
q = "|".join(query)
purgedparticles.drop(purgedparticles[purgedparticles[columns[0]].str.contains(q)].index , 0,inplace=True)
purgedparticles.drop(purgedparticles[purgedparticles[columns[0]].str.contains(q)].index , axis=0,inplace=True)
else:
for q in query:
purgedparticles.drop(purgedparticles[purgedparticles[columns[0]]==q].index , 0,inplace=True)
purgedparticles.drop(purgedparticles[purgedparticles[columns[0]]==q].index , axis=0,inplace=True)

return(purgedparticles)

Expand All @@ -94,7 +94,7 @@ def delduplicates(particles, column):
def delmics(particles, micstodelete):
purgedparticles = particles.copy()
m = "|".join(micstodelete)
purgedparticles.drop(purgedparticles[purgedparticles["_rlnMicrographName"].str.contains(m)].index , 0,inplace=True)
purgedparticles.drop(purgedparticles[purgedparticles["_rlnMicrographName"].str.contains(m)].index , axis=0,inplace=True)
return(purgedparticles)

"""
Expand Down Expand Up @@ -122,7 +122,7 @@ def extractparticles(particles, columns, query, queryexact):
if not queryexact:
extractedparticles = particles.copy()
q = "|".join(query)
extractedparticles.drop(extractedparticles[~extractedparticles[columns[0]].str.contains(q)].index, 0,inplace=True)
extractedparticles.drop(extractedparticles[~extractedparticles[columns[0]].str.contains(q)].index, axis=0,inplace=True)
else:
toconcat = [particles[particles[columns[0]] == q] for q in query]
extractedparticles = pd.concat(toconcat)
Expand Down Expand Up @@ -212,11 +212,11 @@ def regroup(particles, numpergroup):
regroupedparticles.sort_values("_rlnDefocusU", inplace=True)

if "_rlnGroupNumber" in regroupedparticles.columns:
regroupedparticles.drop("_rlnGroupNumber", 1, inplace=True)
regroupedparticles.drop("_rlnGroupNumber", axis=1, inplace=True)
regroupedparticles["_rlnGroupNumber"] = newgroups

if "_rlnGroupName" in regroupedparticles.columns:
regroupedparticles.drop("_rlnGroupName", 1, inplace=True)
regroupedparticles.drop("_rlnGroupName", axis=1, inplace=True)
newgroups = [("group_"+str(i).zfill(4)) for i in newgroups]
regroupedparticles["_rlnGroupName"] = newgroups

Expand Down Expand Up @@ -331,7 +331,7 @@ def expandoptics(original_particles, original_metadata, newdata, newdata_metadat
newoptics=newoptics.loc[newoptics.index.repeat(newoptics.times)].reset_index(drop=True)

newoptics["_rlnOpticsGroup"] = range(1,totalimportoptics+len(opticsgrouplist))
newoptics.drop("times",1, inplace=True)
newoptics.drop("times",axis=1, inplace=True)

newopticsnames = newoptics["_rlnOpticsGroupName"].tolist()

Expand Down
8 changes: 4 additions & 4 deletions starparser/specialparticles.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def findnearby(coreparticles,nearparticles,threshdist):
print("\n>> Out of " + str(len(coreparticles.index)) + ", the subsets have:\n-FAR: " + str(len(farparticles.index)) + " particles\n-CLOSE: " + str(len(closeparticles.index)) + " particles\n-NO-MATCH: " + str(len(noparts)) + " particles\n")

#We can remove the new column we made above before returning the dataframes
closeparticles.drop("_rlnMicrographNameSimple", 1, inplace=True)
farparticles.drop("_rlnMicrographNameSimple", 1, inplace=True)
closeparticles.drop("_rlnMicrographNameSimple", axis=1, inplace=True)
farparticles.drop("_rlnMicrographNameSimple", axis=1, inplace=True)

return(farparticles, closeparticles, alldistances)

Expand Down Expand Up @@ -253,10 +253,10 @@ def getcluster(particles,threshold,minimum):
keep.append(names[i])

if len(keep) == 0:
print("\n>> Error: no particles were retained based on the criteria.\n")
print(">> Error: no particles were retained based on the criteria.\n")
sys.exit()
elif len(keep) == len(particles.index):
print("\n>> Error: all particles were retained. No star file will be output.\n")
print(">> Error: all particles were retained. No star file will be output.\n")
sys.exit()

"""
Expand Down

0 comments on commit 327638c

Please sign in to comment.