Skip to content

Commit

Permalink
DAOTHER-8197: Add em_map display to review page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezra Peisach committed May 22, 2024
1 parent a8a7912 commit bcb2f74
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 2 deletions.
11 changes: 10 additions & 1 deletion wwpdb/apps/ann_tasks_v2/report/PdbxReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import sys
import traceback

from wwpdb.apps.ann_tasks_v2.report.styles.PdbxIo import PdbxReportIo, PdbxGeometryReportIo, PdbxXrayExpReportIo, PdbxLinksReportIo
from wwpdb.apps.ann_tasks_v2.report.styles.PdbxIo import PdbxReportIo, PdbxGeometryReportIo, PdbxXrayExpReportIo, PdbxLinksReportIo, EmInfoReportIo
from mmcif_utils.style.PdbxGeometryReportCategoryStyle import PdbxGeometryReportCategoryStyle

from wwpdb.apps.ann_tasks_v2.report.PdbxReportDepictBootstrap import PdbxReportDepictBootstrap
from wwpdb.apps.ann_tasks_v2.report.styles.DCCReport import PdbxXrayExpReportCategoryStyle
from wwpdb.apps.ann_tasks_v2.report.styles.ModelReport import PdbxReportCategoryStyle
from wwpdb.apps.ann_tasks_v2.report.styles.LinksReport import PdbxLinksReportCategoryStyle
from wwpdb.apps.ann_tasks_v2.report.styles.PdbxEmExtensionCategoryStyle import PdbxEmExtensionCategoryStyle


class PdbxReport(object):
Expand Down Expand Up @@ -117,6 +118,12 @@ def makeTabularReport(self, filePath=None, contentType=None, idCode=None, layout
rdd = PdbxReportDepictBootstrap(styleObject=PdbxLinksReportCategoryStyle(), includePath=includePath, verbose=self.__verbose, log=self.__lfh)
oL = rdd.render(dd, style=layout, leadingHtmlL=leadingHtmlL, trailingHtmlL=trailingHtmlL)

if contentType in ["em-map-info-report"]:
self.setFilePath(filePath, fileFormat=fileFormat, idCode=idCode)
dd = self.doReport(contentType)
rdd = PdbxReportDepictBootstrap(styleObject=PdbxEmExtensionCategoryStyle(), includePath=includePath, verbose=self.__verbose, log=self.__lfh)
oL = rdd.render(dd, style=layout, leadingHtmlL=leadingHtmlL, trailingHtmlL=trailingHtmlL)

if self.__debug:
self.__lfh.write("+PdbxReport.makeTabularReport - generated HTML \n%s\n" % "\n".join(oL))

Expand Down Expand Up @@ -182,6 +189,8 @@ def doReport(self, contentType="model"):
pdbxR = PdbxXrayExpReportIo(verbose=self.__verbose, log=self.__lfh)
elif contentType == "links-report":
pdbxR = PdbxLinksReportIo(verbose=self.__verbose, log=self.__lfh)
elif contentType == "em-map-info-report":
pdbxR = EmInfoReportIo(verbose=self.__verbose, log=self.__lfh)

pdbxR.setFilePath(localPath, idCode=None)
pdbxR.get()
Expand Down
6 changes: 6 additions & 0 deletions wwpdb/apps/ann_tasks_v2/report/PdbxReportDepictBootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def __setup(self):
self.__reportCategories = [
("struct_conn", "", "row-wise"),
]
elif self.__st.getStyleId() in ["PDBX_STYLE_EmExtension_V1"]:
self.__reportCategories = [
("em_map", "", "row-wise"),
]
else:
self.__lfh.write("Error: PdbxReportDepict.__setup unknown style %s\n" % self.__st.getStyleId())

def render(self, eD, style="tabs", leadingHtmlL=None, trailingHtmlL=None):
""" """
Expand Down
55 changes: 55 additions & 0 deletions wwpdb/apps/ann_tasks_v2/report/styles/PdbxIo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
# from mmcif_utils.style.PdbxReportCategoryStyle import PdbxReportCategoryStyle
from wwpdb.apps.ann_tasks_v2.report.styles.ModelReport import PdbxReportCategoryStyle
from wwpdb.apps.ann_tasks_v2.report.styles.LinksReport import PdbxLinksReportCategoryStyle
from wwpdb.apps.ann_tasks_v2.report.styles.PdbxEmExtensionCategoryStyle import PdbxEmExtensionCategoryStyle

logger = logging.getLogger()

Expand Down Expand Up @@ -872,3 +873,57 @@ def update(self, catName, attributeName, value, iRow=0):

def write(self, filePath):
return self.writeFile(filePath)

class EmInfoReportIo(PdbxStyleIoUtil):
"""Methods for reading EM information details."""

def __init__(self, verbose=True, log=sys.stderr):
super(EmInfoReportIo, self).__init__(styleObject=PdbxEmExtensionCategoryStyle(), verbose=verbose, log=log)

# self.__verbose = verbose
# self.__debug = False
self.__lfh = log
#
self.__filePath = None

self.__idCode = None

def getCategory(self, catName="entity"):
return self.getItemDictList(catName)

def setFilePath(self, filePath, idCode=None):
"""Specify the file path for the target and optionally provide an identifier
for the data section within the file.
"""
self.__filePath = filePath
self.__idCode = idCode
if self.readFile(self.__filePath):
if self.__idCode is not None:
return self.setContainer(containerName=self.__idCode)
else:
return self.setContainer(containerIndex=0)
else:
return False

def get(self):
"""
Check for a valid current data container.
Returns True for success or False otherwise.
"""
return self.getCurrentContainerId() is not None

def complyStyle(self):
return self.testStyleComplete(self.__lfh)

def setBlock(self, blockId):
return self.setContainer(containerName=blockId)

def newBlock(self, blockId):
return self.newContainer(containerName=blockId)

def update(self, catName, attributeName, value, iRow=0):
return self.updateAttribute(catName, attributeName, value, iRow=iRow)

def write(self, filePath):
return self.writeFile(filePath)
26 changes: 25 additions & 1 deletion wwpdb/apps/ann_tasks_v2/webapp/CommonTasksWebAppWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,7 @@ def _renderCheckReports(self, entryId, fileSource="archive", instance=None, cont
"special-position-report",
"emd-xml-header-report",
"em-map-check-report",
"em-map-info-report",
"downloads",
]:
myD[ky] = None
Expand Down Expand Up @@ -2297,6 +2298,29 @@ def _renderCheckReports(self, entryId, fileSource="archive", instance=None, cont
myD[cT] = self.__getFileTextWithMarkup(downloadPath)
else:
myD[cT] = self.__getMessageTextWithMarkup("")
elif cT == "em-map-info-report":
if useModelFileVersion:
versionId = "latest"
else:
versionId = "none"

# Try to avoid fetch if not needed
downloadPath = du.getFilePath(entryId, contentType="model", formatType="pdbx", fileSource=fileSource, instance=instance, versionId=versionId)
if downloadPath is None or not os.path.exists(downloadPath):
ok = du.fetchId(entryId, contentType="model", formatType="pdbx", fileSource=fileSource, instance=instance, versionId=versionId)
downloadPath = du.getDownloadPath()
else:
ok = True
if ok:
aTagList.append(du.getAnchorTag())
myD[cT] = "\n".join(pR.makeTabularReport(filePath=downloadPath, contentType="em-map-info-report", idCode=entryId, layout=layout))
else:
myD[cT] = self.__getMessageTextWithMarkup("None")
elif cT == "downloads":
# We call this a "report type" - might not be correct...
pass
else:
self._lfh.write("+CommonTasksWebAppWorker._renderCheckReports() unknown report %r\n" % cT)

# downloads

Expand Down Expand Up @@ -2700,7 +2724,7 @@ def _generateCheckReportsJson(self, entryId, operation, fileSource="wf-archive",
"check-em-map",
]
aTagList = self._makeCheckReports([entryId], operationList=opList, fileSource=fileSource, useFileVersions=useFileVersions)
cTList = ["model"]
cTList = ["model", "em-map-info-report"]
cTList.extend(sorted(opCtD.values()))
if self._verbose:
self._lfh.write("+ReviewDataWebAppWorker._reviewDataInlineIdOps() content type list %r\n" % cTList)
Expand Down
1 change: 1 addition & 0 deletions wwpdb/apps/ann_tasks_v2/webapp/ReviewDataWebAppWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def _generateFullCheckReportHtml(self, idCode, fileSource="wf-archive", instance
# 'model-pdb',
"emd-xml-header-report",
"em-map-check-report",
"em-map-info-report",
"downloads",
]
reportD = self._renderCheckReports(idCode, fileSource=fileSource, instance=instance, contentTypeList=cTL)
Expand Down

0 comments on commit bcb2f74

Please sign in to comment.