From 029361da4d16eb25cb3f05c38c67aaa9d4bb6985 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Sun, 5 May 2024 16:01:03 -0400 Subject: [PATCH] added chopping modification off of resiude in polymer sequence functionality --- wwpdb/apps/entity_transform/__init__.py | 2 +- .../depict/PrdSummaryDepict.py | 13 ++++++---- .../entity_transform/depict/StrFormDepict.py | 10 +++++--- .../depict/StrSummaryDepict.py | 3 ++- .../entity_transform/update/ChopperHandler.py | 25 +++++++++++++++++++ .../entity_transform/update/CombineCoord.py | 25 +++++++++++++++++-- .../entity_transform/webapp/EntityWebApp.py | 12 +++++---- .../entity_transform/webapp/FormPreProcess.py | 10 +++++++- 8 files changed, 82 insertions(+), 18 deletions(-) diff --git a/wwpdb/apps/entity_transform/__init__.py b/wwpdb/apps/entity_transform/__init__.py index afebe05..72aafe0 100644 --- a/wwpdb/apps/entity_transform/__init__.py +++ b/wwpdb/apps/entity_transform/__init__.py @@ -2,4 +2,4 @@ __author__ = "Ezra Peisach" __email__ = "ezra.peisach@rcsb.org" __license__ = "Apache 2.0" -__version__ = "0.18" +__version__ = "0.19" diff --git a/wwpdb/apps/entity_transform/depict/PrdSummaryDepict.py b/wwpdb/apps/entity_transform/depict/PrdSummaryDepict.py index 3bc2aae..6facf3f 100644 --- a/wwpdb/apps/entity_transform/depict/PrdSummaryDepict.py +++ b/wwpdb/apps/entity_transform/depict/PrdSummaryDepict.py @@ -61,22 +61,25 @@ def DoRenderSummaryPage(self, imageFlag=True): # if self.__splitPolymerResidueFlag: text += '
  • ' \ - + 'Split modified residue to standard residue + modification in polymer
  • \n' + + 'Split modified residue to standard residue + modification in polymer \n' # if self.__combResidueFlag: text += '
  • ' \ - + 'Merge standard amino acid residue + modification to modified amino acid residue in polymer
  • \n' + + 'Merge standard amino acid residue + modification to modified amino acid residue in polymer \n' # if self.__matchResultFlag: text += '
  • View All Search Result(s)
  • \n' + + '" target="_blank"> View All Search Result(s) \n' # if self.__graphmatchResultFlag: text += '
  • Update Coordinate File with Match Result(s)
  • \n' + + '&type=match" target="_blank"> Update Coordinate File with Match Result(s) \n' # text += '
  • Update Coordinate File with Input IDs
  • \n' + + '&type=input" target="_blank"> Update Coordinate File with Input IDs \n' + # + text += '
  • ' \ + + 'Split non standard residue in polymer
  • \n' # text += '
  • Download Files
  • \n' # diff --git a/wwpdb/apps/entity_transform/depict/StrFormDepict.py b/wwpdb/apps/entity_transform/depict/StrFormDepict.py index e2ff19d..88ecefd 100644 --- a/wwpdb/apps/entity_transform/depict/StrFormDepict.py +++ b/wwpdb/apps/entity_transform/depict/StrFormDepict.py @@ -106,9 +106,13 @@ def LaunchEditor(self): def __processSplitWithChopper(self, myD): ciffile = self._identifier + '_model_P1.cif' - combObj = CombineCoord(reqObj=self._reqObj, instList=[str(self._reqObj.getValue('split_polymer_residue'))], cifFile=ciffile, - verbose=self._verbose, log=self._lfh) - combObj.processWithCopy() + residueId = str(self._reqObj.getValue('split_polymer_residue')) + if not residueId: + residueId = '_'.join([str(self._reqObj.getValue('chain_id')), str(self._reqObj.getValue('res_name')), \ + str(self._reqObj.getValue('res_num')), str(self._reqObj.getValue('ins_code'))]) + # + combObj = CombineCoord(reqObj=self._reqObj, instList=[residueId], cifFile=ciffile, verbose=self._verbose, log=self._lfh) + combObj.processWithCopy(submitValue=self.__submitValue) message = combObj.getMessage() # if message: diff --git a/wwpdb/apps/entity_transform/depict/StrSummaryDepict.py b/wwpdb/apps/entity_transform/depict/StrSummaryDepict.py index 52b08f1..4d18db1 100644 --- a/wwpdb/apps/entity_transform/depict/StrSummaryDepict.py +++ b/wwpdb/apps/entity_transform/depict/StrSummaryDepict.py @@ -227,7 +227,8 @@ def __depictionChain(self): def __depictionLigand(self): text = '\n' text += '\n' - text += '\n' + text += '\n' text += '\n' text += '\n' text += '\n' diff --git a/wwpdb/apps/entity_transform/update/ChopperHandler.py b/wwpdb/apps/entity_transform/update/ChopperHandler.py index 26cd533..f771172 100644 --- a/wwpdb/apps/entity_transform/update/ChopperHandler.py +++ b/wwpdb/apps/entity_transform/update/ChopperHandler.py @@ -21,6 +21,12 @@ __license__ = "Creative Commons Attribution 3.0 Unported" __version__ = "V0.07" +try: + import cPickle as pickle +except ImportError: + import pickle as pickle +# + import os import sys @@ -104,10 +110,29 @@ def __runMappingScript(self): def __searchOtherInstances(self): """ Get other instances list """ + residue_id = '' + if self.__option == 'split_residue': + pickleFilePath = os.path.join(self.__instancePath, self.__instId + ".pkl") + if os.access(pickleFilePath, os.F_OK): + fb = open(pickleFilePath, "rb") + pickleD = pickle.load(fb) + fb.close() + # + if ('residue' in pickleD) and pickleD['residue']: + residue_id = pickleD['residue'] + # + # + # + self.__lfh.write("residue_id=%s\n" % residue_id) searchPath = os.path.join(self.__sessionPath, 'search') extraOptions = ' -summaryfile ' + self.__summaryFile + ' -searchpath ' + searchPath + ' -merge_cif ' + self.__instId \ + '.merge.cif -chopper_cif ' + os.path.join(self.__instancePath, 'chopper_output.cif') + ' ' # + if residue_id != '': + identifier = str(self.__reqObj.getValue("identifier")) + ciffile = os.path.join(self.__sessionPath, identifier + '_model_P1.cif') + extraOptions += ' -residue_id ' + residue_id + ' -model_cif ' + ciffile + # self.__cmdUtil.setSessionPath(self.__instancePath) self.__cmdUtil.runAnnotCmd('SearchAllInstances', '', self.__instId + '.all_instance_search.list', 'search-instances.log', 'search-instances.clog', extraOptions) diff --git a/wwpdb/apps/entity_transform/update/CombineCoord.py b/wwpdb/apps/entity_transform/update/CombineCoord.py index 0bcd880..77a05ff 100644 --- a/wwpdb/apps/entity_transform/update/CombineCoord.py +++ b/wwpdb/apps/entity_transform/update/CombineCoord.py @@ -21,6 +21,12 @@ __license__ = "Creative Commons Attribution 3.0 Unported" __version__ = "V0.07" +try: + import cPickle as pickle +except ImportError: + import pickle as pickle +# + import os import shutil import sys @@ -45,6 +51,7 @@ def __init__(self, reqObj=None, instList=None, cifFile=None, verbose=False, log= self.__sessionPath = None self.__instId = '' self.__message = '' + self.__submitValue = '' # self.__getSession() self.__getInstId() @@ -62,7 +69,22 @@ def processWithCombine(self): # self.__runUpdateScript() - def processWithCopy(self): + def processWithCopy(self, submitValue=''): + # + self.__submitValue = submitValue + # + if self.__submitValue and (len(self.__instList) == 1) and self.__instList[0]: + pickleFilePath = os.path.join(self.__instancePath, self.__instId + ".pkl") + if os.access(pickleFilePath, os.F_OK): + os.remove(pickleFilePath) + # + pickleD = {} + pickleD['residue'] = self.__instList[0] + pickleD['submit'] = self.__submitValue + # + fb = open(pickleFilePath, "wb") + pickle.dump(pickleD, fb) + fb.close() # if not self.__runCopyScript(): self.__runCombineScript() @@ -122,7 +144,6 @@ def __runCopyScript(self): if not os.access(source, os.F_OK): return False # - # shutil.copyfile(source, os.path.join(self.__instancePath, self.__instId + ext)) # return True diff --git a/wwpdb/apps/entity_transform/webapp/EntityWebApp.py b/wwpdb/apps/entity_transform/webapp/EntityWebApp.py index ff66b01..a6bed30 100644 --- a/wwpdb/apps/entity_transform/webapp/EntityWebApp.py +++ b/wwpdb/apps/entity_transform/webapp/EntityWebApp.py @@ -793,7 +793,7 @@ def _resultView(self): rC = ResponseContent(reqObj=self.__reqObj, verbose=self.__verbose, log=self.__lfh) # instId = str(self.__reqObj.getValue("instanceid")) - type = str(self.__reqObj.getValue("type")) # pylint: disable=redefined-builtin + viewType = str(self.__reqObj.getValue("type")) # pylint: disable=redefined-builtin resultObj = None if self.__summaryCifObj: resultObj = ResultDepict(reqObj=self.__reqObj, summaryCifObj=self.__summaryCifObj, verbose=self.__verbose, log=self.__lfh) @@ -804,28 +804,30 @@ def _resultView(self): myD['title'] = self.__title myD['pdbid'] = self.__reqObj.getValue('pdbid') myD['label'] = self.__reqObj.getValue('label') - if type == 'match': + if viewType == 'match': if resultObj: myD['form_data'] = resultObj.DoRenderUpdatePage() else: myD['form_data'] = 'Can not find summary result file.' # rC.setHtmlText(self.__processTemplate('update_form/update_match_tmplt.html', myD)) - elif type == 'input': + elif viewType == 'input': if resultObj: myD['form_data'] = resultObj.DoRenderInputPage() else: myD['form_data'] = 'Can not find summary result file.' # rC.setHtmlText(self.__processTemplate('update_form/update_user_input_tmplt.html', myD)) - elif type == 'split': + elif viewType == 'split': if resultObj: myD['form_data'] = resultObj.DoRenderSplitPage() else: myD['form_data'] = '' # rC.setHtmlText(self.__processTemplate('summary_view/split_polymer_residue_tmplt.html', myD)) - elif type == 'merge': + elif viewType == 'split_with_input': + rC.setHtmlText(self.__processTemplate('summary_view/split_polymer_residue_input_tmplt.html', myD)) + elif viewType == 'merge': if resultObj: myD['form_data'] = resultObj.DoRenderMergePage() else: diff --git a/wwpdb/apps/entity_transform/webapp/FormPreProcess.py b/wwpdb/apps/entity_transform/webapp/FormPreProcess.py index 6c48dde..253ce86 100644 --- a/wwpdb/apps/entity_transform/webapp/FormPreProcess.py +++ b/wwpdb/apps/entity_transform/webapp/FormPreProcess.py @@ -38,6 +38,9 @@ def __init__(self, reqObj=None, verbose=False, log=sys.stderr): # pylint: disab self.__ligandList = self.__reqObj.getValueList('ligand') self.__groupList = self.__reqObj.getValueList('group') self.__splitPolymerResidue = str(self.__reqObj.getValue('split_polymer_residue')) + self.__chainID = str(self.__reqObj.getValue('chain_id')) + self.__resName = str(self.__reqObj.getValue('res_name')) + self.__resNum = str(self.__reqObj.getValue('res_num')) # self.__errorMessage = '' # @@ -51,8 +54,13 @@ def __preProcessForm(self): # Check for non standard residue # if self.__submitValue == 'Split with chopper': - if not self.__splitPolymerResidue: + hasResidueSelected = False + if self.__splitPolymerResidue or (self.__chainID and self.__resName and self.__resNum): + hasResidueSelected = True + # + if not hasResidueSelected: self.__errorMessage = 'No residue selected' + # return # # Check no values
    Selection/
    User Defined Group ID
    Selection/
    User Defined Group ID
    3 Letter CodeChain IDResNum
    Can not find summary result file.