Skip to content

Commit

Permalink
Merge pull request #48 from scipion-em/rm_fix_plot
Browse files Browse the repository at this point in the history
fix search fit viewer, since it was showing the first 5 points insteadd of the first higher 5 points
  • Loading branch information
rmarabini committed Jun 1, 2021
2 parents 95387f2 + 1511ccc commit 6600cc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion phenix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

_logo = "phenix.png"
_references = ['Adams_2010']
__version__ = "3.1.3"
__version__ = "3.1.5"


class Plugin(pwem.Plugin):
Expand Down
28 changes: 17 additions & 11 deletions phenix/viewers/viewer_search_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,31 +159,37 @@ def _showPlot(self, e=None):
yList = []
conn = sqlite3.connect(os.path.abspath(self.protocol._getExtraPath(DATAFILE)))
c = conn.cursor()
sqlCommand = """SELECT model_to_map_fit
FROM %s
WHERE model_to_map_fit != -1
ORDER BY id
LIMIT %d""" % (TABLE, self.numAtomStruct)
sqlCommand = """
SELECT id, model_to_map_fit
FROM (
SELECT id, model_to_map_fit
FROM %s
WHERE model_to_map_fit != -1
ORDER BY model_to_map_fit desc
LIMIT %d) AS a
ORDER BY id
""" % (TABLE, self.numAtomStruct)

c.execute(sqlCommand)
rows = c.fetchall()

for counter, row in enumerate(rows, 1):
xList.append(counter)
yList.append(float(row[0]))
for row in rows:
xList.append(float(row[0]))
yList.append(float(row[1]))
# compute avg
sqlCommand = """SELECT AVG(model_to_map_fit)
FROM (SELECT model_to_map_fit
FROM %s
WHERE model_to_map_fit != -1
ORDER BY id
ORDER BY model_to_map_fit desc
LIMIT %d)""" % (TABLE, self.numAtomStruct)
c.execute(sqlCommand)
rows = c.fetchone(); avg = rows[0]
print("avg", avg)
fromRelation = """(SELECT model_to_map_fit
FROM %s
WHERE model_to_map_fit != -1
ORDER BY id
ORDER BY model_to_map_fit desc
LIMIT %d) AS mainTable""" % (TABLE, self.numAtomStruct)

sqlCommand = """SELECT AVG((mainTable.model_to_map_fit - sub.a) * (mainTable.model_to_map_fit - sub.a)) as var
Expand All @@ -205,7 +211,7 @@ def _showPlot(self, e=None):
return

title = 'Map Model Fit - avg = %f, std = %f'%(avg, std)
plt.plot(xList, yList)
plt.plot(xList, yList, 'x')
plt.axis([0, max(xList) + 1.0, 0.0, max(yList)+0.1])
plt.title(title)
plt.xlabel('#Atom Structs')
Expand Down

0 comments on commit 6600cc2

Please sign in to comment.