Skip to content

Commit

Permalink
added CIF Dictionary checking for PRD entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezra Peisach committed Jan 28, 2024
1 parent 3e43b36 commit a131bb1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion wwpdb/apps/entity_transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
__author__ = "Ezra Peisach"
__email__ = "[email protected]"
__license__ = "Apache 2.0"
__version__ = "0.17.6"
__version__ = "0.17.7"
50 changes: 41 additions & 9 deletions wwpdb/apps/entity_transform/utils/DownloadFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
__license__ = "Creative Commons Attribution 3.0 Unported"
__version__ = "V0.07"

import os
import sys
import os,sys,traceback

from wwpdb.utils.config.ConfigInfo import ConfigInfo

from wwpdb.utils.dp.RcsbDpUtility import RcsbDpUtility

class DownloadFile(object):
""" Class responsible for download files.
Expand Down Expand Up @@ -99,6 +98,7 @@ def __findPRDFiles(self):
def __updatePrdCcChemName(self):
setting = " RCSBROOT=" + self.__cI.get("SITE_ANNOT_TOOLS_PATH") + "; export RCSBROOT; "
#
dictCheckMsg = ""
for prdid in self.__PrdIds:
prdfile = os.path.join(self.__sessionPath, prdid + ".cif")
if not os.access(prdfile, os.F_OK):
Expand All @@ -107,12 +107,44 @@ def __updatePrdCcChemName(self):
prdccid = prdid.replace("PRD", "PRDCC")
prdccfile = os.path.join(self.__sessionPath, prdccid + ".cif")
if not os.access(prdccfile, os.F_OK):
continue
cmd = setting + "${RCSBROOT}/bin/UpdatePrdCcName -prd " + prdfile + " -log " \
+ os.path.join(self.__sessionPath, prdid + "-name-update.log") + " > " \
+ os.path.join(self.__sessionPath, prdid + "-name-update.clog") + " 2>&1; "
else:
cmd = setting + "${RCSBROOT}/bin/UpdatePrdCcName -prd " + prdfile + " -prdcc " + prdccfile + " -log " \
+ os.path.join(self.__sessionPath, prdid + "-name-update.log") + " > " \
+ os.path.join(self.__sessionPath, prdid + "-name-update.clog") + " 2>&1; "
#
cmd = setting + "${RCSBROOT}/bin/UpdatePrdCcName -prd " + prdfile + " -prdcc " + prdccfile + " -log " \
+ os.path.join(self.__sessionPath, prdccid + "-name-update.log") + " > " \
+ os.path.join(self.__sessionPath, prdccid + "-name-update.clog") + " 2>&1; "
os.system(cmd)
#
logfile = os.path.join(self.__sessionPath, "checking-" + prdid + ".log")
if os.access(logfile, os.F_OK):
os.remove(logfile)
#
try:
dp = RcsbDpUtility(tmpPath=self.__sessionPath, siteId=self.__siteId, verbose=self.__verbose, log=self.__lfh)
dp.imp(prdfile)
dp.op("check-cif")
dp.exp(logfile)
if os.access(logfile, os.F_OK):
ifh = open(logfile, "r")
sIn = ifh.read()
ifh.close()
if not sIn:
dictCheckMsg += "\n" + prdid + ": OK\n"
else:
dictCheckMsg += "\n" + prdid + ":\n" + sIn + "\n"
#
#
dp.cleanup()
except:
traceback.print_exc(file=self.__lfh)
#
#
if not dictCheckMsg:
return dictCheckMsg
else:
return "<pre>\nCIF Dictionary Check:\n" + dictCheckMsg + "</pre>\n"
#

def ListFiles(self):
Expand All @@ -136,7 +168,7 @@ def ListPrds(self):
if not self.__PrdIds:
return ""
#
self.__updatePrdCcChemName()
dictCheckMsg = self.__updatePrdCcChemName()
#
content = ""
for prd_id in self.__PrdIds:
Expand All @@ -147,4 +179,4 @@ def ListPrds(self):
myD = {}
myD["sessionid"] = self.__sessionId
myD["form_data"] = content
return self.__processTemplate("download/prd_cvs_tmplt.html", myD)
return dictCheckMsg + self.__processTemplate("download/prd_cvs_tmplt.html", myD)

0 comments on commit a131bb1

Please sign in to comment.