Skip to content

Commit

Permalink
Merge pull request #29 from wwPDB/DAOTHER-9171
Browse files Browse the repository at this point in the history
Create the "PCM/PTM" tab in AnnMod
  • Loading branch information
wmorellato authored Sep 2, 2024
2 parents 4826285 + 181b8af commit 639d7a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 106 deletions.
39 changes: 24 additions & 15 deletions wwpdb/apps/ann_tasks_v2/pcm/PcmCCDEditorForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import traceback

from wwpdb.utils.dp.RcsbDpUtility import RcsbDpUtility

# Set the default logger handler level to INFO -- this should not be set here - but at hight level
# logging.getLogger().setLevel(logging.INFO)

from wwpdb.io.locator.PathInfo import PathInfo

class PcmCCDEditorForm(object):
"""
Expand All @@ -35,9 +32,12 @@ def __setup(self):
self.__sessionPath = self.__sObj.getPath()
self.__entryId = self.__reqObj.getValue("entryid")
self.__identifier = self.__reqObj.getValue("display_identifier")
self.__csvPath = os.path.join(self.__sessionPath, self.__entryId + "_ccd_no_pcm_ann.csv")
self.__entryFile = None
#
self.__pI = PathInfo(siteId=self.__siteId, sessionPath=self.__sessionPath, verbose=self.__verbose, log=self.__lfh)
self.__csvFile = self.__pI.getFileName(self.__entryId, contentType="pcm-missing-data", formatType="csv", versionId="none", partNumber="1")
self.__csvPath = os.path.join(self.__sessionPath, self.__csvFile)
#
self.__tableTemplate = '<table id="table_%s" class="table table-condensed table-bordered table-striped">\n'
self.__tdTagTemplate = '<td style="border-style:none">%s</td>\n'
self.__editableTemplate = '<b class="%s" id="%s" style="display:inline">%s</b>'
Expand Down Expand Up @@ -69,21 +69,22 @@ def run(self):
def __runPcmCcdCheck(self):
"""Run PCM script to check missing annotation"""
self.__entryFile = self.__reqObj.getValue("entryfilename")
entry_file_path = os.path.join(self.__sessionPath, self.__entryFile)
inpPdbxPath = os.path.join(self.__sessionPath, self.__entryFile)

if not os.access(entry_file_path, os.F_OK):
logging.error("Missing entry file %s", entry_file_path)
if not os.access(inpPdbxPath, os.F_OK):
logging.error("Missing entry file %s", inpPdbxPath)
return
#
logging.info("Processing entry file %s", self.__entryFile)

#
if os.access(self.__csvPath, os.F_OK):
os.remove(self.__csvPath)
#
try:
dp = RcsbDpUtility(tmpPath=self.__sessionPath, siteId=self.__siteId, verbose=self.__verbose, log=self.__lfh)
dp.imp(entry_file_path)
dp.addInput(name="id", value=self.__entryId)
dp.imp(inpPdbxPath)
dp.op("annot-pcm-check-ccd-ann")
dp.exp(dstPath=self.__csvPath)
dp.expLog(os.path.join(self.__sessionPath, self.__entryId + "_ccd_no_pcm_ann.log"))
dp.expList(dstPathList=[inpPdbxPath, self.__csvPath])
dp.cleanup()
except: # noqa: E722 pylint: disable=bare-except
traceback.print_exc(file=self.__lfh)
Expand All @@ -109,9 +110,17 @@ def __buildCCDFormHtml(self):
if not os.access(self.__csvPath, os.F_OK):
myD = {}
myD["statuscode"] = "failed"
myD["statustext"] = "Failed to build form for %s" % self.__entryId
myD["statustext"] = "Failed to build form for %s. Couldn't find output csv file" % self.__entryId
return myD

with open(self.__csvPath, 'r') as fp:
content = "PTM annotation is successfully updated. No missing pcm data found."
if content in fp.read():
myD = {}
myD["statuscode"] = "ok"
myD["htmlcontent"] = content
return myD

htmlcontent = self.__tableTemplate % self.__identifier
htmlcontent += (
"<tr>\n<th>Comp Id</th>\n<th>Modified Residue Id</th>\n<th>Type</th>\n<th>Category</th>\n<th>Position</th>\n<th>Polypeptide Position</th>\n<th>Comp Id Linking Atom</th>\n<th>Modified Residue Id Linking Atom</th>\n<th>First Instance Model Db Code</th>\n<th>ChemRefUI Link</th>\n</tr>\n" # noqa: E501
Expand Down Expand Up @@ -152,4 +161,4 @@ def __buildCCDFormHtml(self):
myD = {}
myD["statuscode"] = "ok"
myD["htmlcontent"] = htmlcontent
return myD
return myD
91 changes: 0 additions & 91 deletions wwpdb/apps/tests-ann/PcmPyTest.py

This file was deleted.

0 comments on commit 639d7a0

Please sign in to comment.