Skip to content

Commit

Permalink
Merge pull request #23 from wwPDB/DAOTHER-8398
Browse files Browse the repository at this point in the history
Created link review section and table. Integration with mol*
  • Loading branch information
wmorellato authored May 2, 2024
2 parents e607e27 + de8a89d commit bef3539
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 41 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,12 +20,13 @@
import sys
import traceback

from wwpdb.apps.ann_tasks_v2.report.styles.PdbxIo import PdbxReportIo, PdbxGeometryReportIo, PdbxXrayExpReportIo
from wwpdb.apps.ann_tasks_v2.report.styles.PdbxIo import PdbxReportIo, PdbxGeometryReportIo, PdbxXrayExpReportIo, PdbxLinksReportIo
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


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

if contentType in ["links-report"]:
self.setFilePath(filePath, fileFormat=fileFormat, idCode=idCode)
dd = self.doReport(contentType)
rdd = PdbxReportDepictBootstrap(styleObject=PdbxLinksReportCategoryStyle(), 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 @@ -173,6 +180,8 @@ def doReport(self, contentType="model"):
pdbxR = PdbxGeometryReportIo(verbose=self.__verbose, log=self.__lfh)
elif contentType == "dcc-report":
pdbxR = PdbxXrayExpReportIo(verbose=self.__verbose, log=self.__lfh)
elif contentType == "links-report":
pdbxR = PdbxLinksReportIo(verbose=self.__verbose, log=self.__lfh)

pdbxR.setFilePath(localPath, idCode=None)
pdbxR.get()
Expand Down
21 changes: 19 additions & 2 deletions wwpdb/apps/ann_tasks_v2/report/PdbxReportDepictBootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PdbxReportDepictBootstrap(PdbxDepictBootstrapBase):
This version uses Bootstrap CSS framework constructs.
"""
MAX_LINES = 12

def __init__(self, styleObject=None, includePath=None, verbose=False, log=sys.stderr):
"""
Expand Down Expand Up @@ -96,7 +97,6 @@ def __setup(self):
# ('citation','Primary citation','column-wise'),
("pdbx_validate_close_contact", "Close contacts", "row-wise"),
("pdbx_validate_symm_contact", "Close symmetry contacts", "row-wise"),
("struct_conn", "Links", "row-wise"),
# ('symmetry', 'Symmetry', 'row-wise'),
# ('cell', 'Cell constants', 'row-wise'),
# ('exptl_crystal_grow', 'Crystallization details', 'row-wise'),
Expand Down Expand Up @@ -132,6 +132,10 @@ def __setup(self):
("pdbx_validate_polymer_linkage", "Polymer linkages", "row-wise"),
("pdbx_validate_chiral", "Chirality exceptions", "row-wise"),
]
elif self.__st.getStyleId() in ["PDBX_LINKS_REPORT_V1"]:
self.__reportCategories = [
("struct_conn", "", "row-wise"),
]

def render(self, eD, style="tabs", leadingHtmlL=None, trailingHtmlL=None):
""" """
Expand Down Expand Up @@ -326,7 +330,11 @@ def __doRenderAccordion(self, eD):
oL.append('<a class="accordion-toggle" data-toggle="collapse" data-parent="#%s" href="#%s"><h4>%s</h4></a>' % (idTop, idSection, abbrev))
oL.append("</div>")
oL.append('<div id="%s" class="accordion-body collapse %s">' % (idSection, active))
oL.append('<div class="accordion-inner">')

if len(cD[catName]) > PdbxReportDepictBootstrap.MAX_LINES:
oL.append('<div class="accordion-inner" style="max-height: 50vh; overflow-y: scroll;">')
else:
oL.append('<div class="accordion-inner">')
#
oL.append('<table class="table table-striped table-bordered table-condensed">')
if catStyle == "column-wise":
Expand Down Expand Up @@ -530,6 +538,15 @@ def __markupRow(self, catName, rD):
itemValue,
itemValue,
)

if catName == "struct_conn":
itemName = "_struct_conn.id"
if itemName in rD:
itemValue = rD[itemName]
rD[itemName] = '<a href="#" onclick="inspect(\'%s\'); return false;">%s</button>' % (
itemValue.strip(),
itemValue,
)

def __attributePart(self, name):
i = name.find(".")
Expand Down
39 changes: 39 additions & 0 deletions wwpdb/apps/ann_tasks_v2/report/styles/LinksReport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Report style details for PDBx struct_conn category.
"""


from mmcif_utils.style.PdbxCategoryStyleBase import PdbxCategoryStyleBase


class PdbxLinksReportCategoryStyle(PdbxCategoryStyleBase):
_styleId = "PDBX_LINKS_REPORT_V1"
_categoryInfo = [
("struct_conn", "table"),
]
_cDict = {
"struct_conn": [
('_struct_conn.id', '%s', 'str', ''),
("_struct_conn.pdbx_leaving_atom_flag", "%s", "str", ""),
("_struct_conn.ptnr1_auth_asym_id", "%s", "str", ""),
("_struct_conn.ptnr1_auth_comp_id", "%s", "str", ""),
("_struct_conn.ptnr1_auth_seq_id", "%s", "str", ""),
("_struct_conn.ptnr1_symmetry", "%s", "str", ""),
("_struct_conn.ptnr2_auth_asym_id", "%s", "str", ""),
("_struct_conn.ptnr2_auth_comp_id", "%s", "str", ""),
("_struct_conn.ptnr2_auth_seq_id", "%s", "str", ""),
("_struct_conn.ptnr2_symmetry", "%s", "str", ""),
("_struct_conn.pdbx_dist_value", "%s", "str", ""),
],
}
_excludeList = []
_suppressList = []
#

def __init__(self):
super(PdbxLinksReportCategoryStyle, self).__init__(styleId=PdbxLinksReportCategoryStyle._styleId,
catFormatL=PdbxLinksReportCategoryStyle._categoryInfo,
catItemD=PdbxLinksReportCategoryStyle._cDict,
excludeList=PdbxLinksReportCategoryStyle._excludeList,
suppressList=PdbxLinksReportCategoryStyle._suppressList)
38 changes: 0 additions & 38 deletions wwpdb/apps/ann_tasks_v2/report/styles/ModelReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class PdbxReportCategoryStyle(PdbxCategoryStyleBase):
("struct_conf", "table"),
("struct_conf_type", "table"),
("pdbx_struct_mod_residue", "table"),
("struct_conn", "table"),
("struct_conn_type", "table"),
("struct_ncs_oper", "table"),
("struct_sheet", "table"),
Expand Down Expand Up @@ -1027,43 +1026,6 @@ class PdbxReportCategoryStyle(PdbxCategoryStyleBase):
("_pdbx_struct_mod_residue.parent_comp_id", "%s", "str", ""),
("_pdbx_struct_mod_residue.details", "%s", "str", ""),
],
"struct_conn": [
# ('_struct_conn.id', '%s', 'str', ''),
("_struct_conn.conn_type_id", "%s", "str", ""),
("_struct_conn.pdbx_dist_value", "%s", "str", ""),
# ('_struct_conn.pdbx_PDB_id', '%s', 'str', ''),
# ('_struct_conn.pdbx_ptnr1_mod_name', '%s', 'str', ''),
# ('_struct_conn.pdbx_ptnr1_replaced_atom', '%s', 'str', ''),
("_struct_conn.ptnr1_label_asym_id", "%s", "str", ""),
("_struct_conn.ptnr1_label_comp_id", "%s", "str", ""),
# ('_struct_conn.ptnr1_label_seq_id', '%s', 'str', ''),
("_struct_conn.ptnr1_auth_seq_id", "%s", "str", ""),
("_struct_conn.ptnr1_label_atom_id", "%s", "str", ""),
# ('_struct_conn.pdbx_ptnr1_standard_comp_id', '%s', 'str', ''),
("_struct_conn.ptnr1_symmetry", "%s", "str", ""),
("_struct_conn.ptnr2_label_asym_id", "%s", "str", ""),
("_struct_conn.ptnr2_label_comp_id", "%s", "str", ""),
("_struct_conn.ptnr2_auth_seq_id", "%s", "str", ""),
# ('_struct_conn.ptnr2_label_seq_id', '%s', 'str', ''),
("_struct_conn.ptnr2_label_atom_id", "%s", "str", ""),
("_struct_conn.ptnr2_symmetry", "%s", "str", ""),
("_struct_conn.pdbx_ptnr1_label_alt_loc", "%s", "str", ""),
("_struct_conn.pdbx_ptnr1_label_ins_code", "%s", "str", ""),
("_struct_conn.pdbx_ptnr2_label_alt_loc", "%s", "str", ""),
("_struct_conn.pdbx_ptnr2_label_ins_code", "%s", "str", ""),
("_struct_conn.ptnr1_auth_asym_id", "%s", "str", ""),
("_struct_conn.ptnr1_auth_comp_id", "%s", "str", ""),
("_struct_conn.ptnr2_auth_asym_id", "%s", "str", ""),
("_struct_conn.ptnr2_auth_comp_id", "%s", "str", ""),
# ('_struct_conn.pdbx_ptnr3_label_atom_id', '%s', 'str', ''),
# ('_struct_conn.pdbx_ptnr3_label_seq_id', '%s', 'str', ''),
# ('_struct_conn.pdbx_ptnr3_label_comp_id', '%s', 'str', ''),
# ('_struct_conn.pdbx_ptnr3_label_asym_id', '%s', 'str', ''),
# ('_struct_conn.pdbx_ptnr3_label_alt_loc', '%s', 'str', ''),
# ('_struct_conn.pdbx_ptnr3_label_ins_code', '%s', 'str', ''),
("_struct_conn.details", "%s", "str", ""),
("_struct_conn.pdbx_value_order", "%s", "str", ""),
],
"struct_conn_type": [("_struct_conn_type.id", "%s", "str", ""), ("_struct_conn_type.criteria", "%s", "str", ""), ("_struct_conn_type.reference", "%s", "str", "")],
"struct_ncs_oper": [
("_struct_ncs_oper.id", "%s", "str", ""),
Expand Down
51 changes: 51 additions & 0 deletions wwpdb/apps/ann_tasks_v2/report/styles/PdbxIo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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

logger = logging.getLogger()

Expand Down Expand Up @@ -133,6 +134,56 @@ def getContourLevelMap(self, mapId="primary map"):
return ""


class PdbxLinksReportIo(PdbxStyleIoUtil):
"""Methods for reading PDBx data files for reporting including style details. Specific to link information."""

def __init__(self, verbose=True, log=sys.stderr):
super(PdbxLinksReportIo, self).__init__(styleObject=PdbxLinksReportCategoryStyle(), verbose=verbose, log=log)
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)


class PdbxGeometryReportIo(PdbxStyleIoUtil):
"""Methods for reading PDBx geometry data files for reporting applications including style details."""

Expand Down
19 changes: 19 additions & 0 deletions wwpdb/apps/ann_tasks_v2/webapp/CommonTasksWebAppWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@ def _renderCheckReports(self, entryId, fileSource="archive", instance=None, cont
"model",
"dcc-report",
"geometry-check-report",
"links-report",
"misc-check-report",
"format-check-report",
"dict-check-report",
Expand Down Expand Up @@ -2185,6 +2186,15 @@ def _renderCheckReports(self, entryId, fileSource="archive", instance=None, cont
else:
# myD[cT] = self.__getMessageTextWithMarkup('No geometry issues.')
myD[cT] = self.__getMessageTextWithMarkup("")
elif cT == "links-report":
# Links report
ok = du.fetchId(entryId, contentType="model", formatType="pdbx", fileSource=fileSource, instance=instance, versionId=versionId)
if ok:
downloadPath = du.getDownloadPath()
aTagList.append(du.getAnchorTag())
myD[cT] = "\n".join(pR.makeTabularReport(filePath=downloadPath, contentType="links-report", idCode=entryId, layout=layout))
else:
myD[cT] = self.__getMessageTextWithMarkup("")
elif cT == "misc-check-report":
# Misc check report
ok = du.fetchId(entryId, contentType="misc-check-report", formatType="txt", fileSource=fileSource, instance=instance)
Expand Down Expand Up @@ -2501,6 +2511,15 @@ def _makeCheckReports(self, entryIdList, fileSource="wf-archive", operationList=
rptPath = chk.getReportPath()
duL.copyToDownload(rptPath)
aTagList.append(duL.getAnchorTag())

if "read-links" in operationList:
reader = LinksReader(reqObj=self._reqObj, verbose=self._verbose, log=self._lfh)
reader.run(entryId=entryId, inpPath=modelFilePath)
hasDiags = chk.getReportSize() > 0
if hasDiags:
rptPath = chk.getReportPath()
duL.copyToDownload(rptPath)
aTagList.append(duL.getAnchorTag())

if "check-special-position" in operationList:
chk = SpecialPositionCalc(reqObj=self._reqObj, verbose=self._verbose, log=self._lfh)
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 @@ -332,6 +332,7 @@ def _generateFullCheckReportHtml(self, idCode, fileSource="wf-archive", instance
"dcc-report",
"special-position-report",
"geometry-check-report",
"links-report",
"misc-check-report",
"format-check-report",
"dict-check-report",
Expand Down

0 comments on commit bef3539

Please sign in to comment.