Skip to content

Commit

Permalink
added chopping modification off of resiude in polymer sequence functi…
Browse files Browse the repository at this point in the history
…onality
  • Loading branch information
Ezra Peisach committed May 5, 2024
1 parent e24bfd6 commit 029361d
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 18 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.18"
__version__ = "0.19"
13 changes: 8 additions & 5 deletions wwpdb/apps/entity_transform/depict/PrdSummaryDepict.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,25 @@ def DoRenderSummaryPage(self, imageFlag=True):
#
if self.__splitPolymerResidueFlag:
text += '<li><a class="fltlft" href="/service/entity/result_view?' + input_data + '&type=split" target="_blank"> ' \
+ '<span style="color:red;">Split modified residue to standard residue + modification in polymer</span> </a></li>\n'
+ '<span style="color:red;">Split modified residue to standard residue + modification in polymer</span> </a></li>\n'
#
if self.__combResidueFlag:
text += '<li><a class="fltlft" href="/service/entity/result_view?' + input_data + '&type=merge" target="_blank"> ' \
+ '<span style="color:red;">Merge standard amino acid residue + modification to modified amino acid residue in polymer</span> </a></li>\n'
+ '<span style="color:red;">Merge standard amino acid residue + modification to modified amino acid residue in polymer</span> </a></li>\n'
#
if self.__matchResultFlag:
text += '<li><a class="fltlft" href="/service/entity/result_view?' + input_data \
+ '" target="_blank"> <span style="color:red;">View All Search Result(s)</span> </a></li>\n'
+ '" target="_blank"> <span style="color:red;">View All Search Result(s)</span> </a></li>\n'
#
if self.__graphmatchResultFlag:
text += '<li><a class="fltlft" href="/service/entity/result_view?' + input_data \
+ '&type=match" target="_blank"> Update Coordinate File with Match Result(s) </a></li>\n'
+ '&type=match" target="_blank"> Update Coordinate File with Match Result(s) </a></li>\n'
#
text += '<li><a class="fltlft" href="/service/entity/result_view?' + input_data \
+ '&type=input" target="_blank"> Update Coordinate File with Input IDs </a></li>\n'
+ '&type=input" target="_blank"> Update Coordinate File with Input IDs </a></li>\n'
#
text += '<li><a class="fltlft" href="/service/entity/result_view?' + input_data + '&type=split_with_input" target="_blank"> ' \
+ 'Split non standard residue in polymer </a></li>\n'
#
text += '<li><a class="fltlft" href="/service/entity/download_file?' + input_data + '" target="_blank"> Download Files </a></li>\n'
#
Expand Down
10 changes: 7 additions & 3 deletions wwpdb/apps/entity_transform/depict/StrFormDepict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion wwpdb/apps/entity_transform/depict/StrSummaryDepict.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def __depictionChain(self):
def __depictionLigand(self):
text = '<table>\n'
text += '<tr>\n'
text += '<th>Selection/<br/>User Defined Group ID</th>\n'
text += '<th>Selection/<br/>User Defined Group ID<br/><input id="ligand_select_all" value="Select All" type="button" onClick="select_ligand(' \
+ "'ligand_select_all'" + ');" /></th>\n'
text += '<th>3 Letter Code</th>\n'
text += '<th>Chain ID</th>\n'
text += '<th>ResNum</th>\n'
Expand Down
25 changes: 25 additions & 0 deletions wwpdb/apps/entity_transform/update/ChopperHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
25 changes: 23 additions & 2 deletions wwpdb/apps/entity_transform/update/CombineCoord.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions wwpdb/apps/entity_transform/webapp/EntityWebApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'] = '<tr><td colspan="6">Can not find summary result file.</td></tr>'
#
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:
Expand Down
10 changes: 9 additions & 1 deletion wwpdb/apps/entity_transform/webapp/FormPreProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
#
Expand All @@ -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
Expand Down

0 comments on commit 029361d

Please sign in to comment.