computing.py (pymol-v1.8.6.0.tar.bz2) | : | computing.py (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 17 | skipping to change at line 17 | |||
#G* Please see the accompanying LICENSE file for further information. | #G* Please see the accompanying LICENSE file for further information. | |||
#H* ------------------------------------------------------------------- | #H* ------------------------------------------------------------------- | |||
#I* Additional authors of this source file include: | #I* Additional authors of this source file include: | |||
#-* | #-* | |||
#-* | #-* | |||
#-* | #-* | |||
#Z* ------------------------------------------------------------------- | #Z* ------------------------------------------------------------------- | |||
from __future__ import print_function, absolute_import | from __future__ import print_function, absolute_import | |||
import sys | ||||
cmd_module = __import__("sys").modules["pymol.cmd"] | cmd_module = __import__("sys").modules["pymol.cmd"] | |||
from .cmd import _cmd, lock, unlock, Shortcut, \ | from .cmd import _cmd, lock, unlock, Shortcut, \ | |||
_feedback, fb_module, fb_mask, \ | _feedback, fb_module, fb_mask, \ | |||
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error, \ | DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error, \ | |||
is_list, safe_list_eval, is_string | is_list, safe_list_eval, is_string | |||
import traceback | import traceback | |||
import threading | import threading | |||
import os | import os | |||
import pymol | ||||
def model_to_sdf_list(self_cmd,model): | def model_to_sdf_list(self_cmd,model): | |||
from chempy import io | from chempy import io | |||
sdf_list = io.mol.toList(model) | sdf_list = io.mol.toList(model) | |||
fixed = [] | fixed = [] | |||
restrained = [] | restrained = [] | |||
at_id = 1 | at_id = 1 | |||
for atom in model.atom: | for atom in model.atom: | |||
if atom.flags & 4: | if atom.flags & 4: | |||
skipping to change at line 135 | skipping to change at line 137 | |||
# eliminate all sculpting information for object | # eliminate all sculpting information for object | |||
self.cmd.sculpt_purge() | self.cmd.sculpt_purge() | |||
self.cmd.set("sculpting",0) | self.cmd.set("sculpting",0) | |||
state = self_cmd.get_state() | state = self_cmd.get_state() | |||
if self_cmd.count_atoms(obj_name+" and flag 2"): # any atoms res trained? | if self_cmd.count_atoms(obj_name+" and flag 2"): # any atoms res trained? | |||
self_cmd.reference("validate",obj_name,state) # then we have reference coordinates | self_cmd.reference("validate",obj_name,state) # then we have reference coordinates | |||
input_model = self_cmd.get_model(obj_name,state=state) | input_model = self_cmd.get_model(obj_name,state=state) | |||
(fit_flag, sdf_list) = model_to_sdf_list(self_cmd,input_model) | (fit_flag, sdf_list) = model_to_sdf_list(self_cmd,input_model) | |||
input_sdf = ''.join(sdf_list) | input_sdf = ''.join(sdf_list) | |||
# print input_sdf | # print input_sdf | |||
if sys.version_info[0] > 2: | ||||
input_sdf = input_sdf.encode() | ||||
result = mengine.run(input_sdf) | result = mengine.run(input_sdf) | |||
if result != None: | if result != None: | |||
if len(result): | if len(result): | |||
clean_sdf = result[0] | clean_sdf = result[0] | |||
if sys.version_info[0] > 2: | ||||
clean_sdf = clean_sdf.decode() | ||||
clean_rec = clean_sdf.split("$$$$")[0] | clean_rec = clean_sdf.split("$$$$")[0] | |||
clean_name = "" | clean_name = "" | |||
self.energy = get_energy_from_rec(clean_rec) | self.energy = get_energy_from_rec(clean_rec) | |||
try: | try: | |||
if len(clean_rec) and int(self.energy) != 9999: | if len(clean_rec) and int(self.energy) != 9999: | |||
clean_name = "builder_clean_tmp" | clean_name = "builder_clean_tmp" | |||
self_cmd.set("suspend_updates") | self_cmd.set("suspend_updates") | |||
self.ok = 1 | self.ok = 1 | |||
else: | else: | |||
self.ok = 0 | self.ok = 0 | |||
skipping to change at line 200 | skipping to change at line 210 | |||
print("Clean-Error: If you believe PyMOL should be able to h andle this structure") | print("Clean-Error: If you believe PyMOL should be able to h andle this structure") | |||
print("Clean-Error: then please email that SD file to help@s chrodinger.com. Thank you!") | print("Clean-Error: then please email that SD file to help@s chrodinger.com. Thank you!") | |||
except IOError: | except IOError: | |||
print("Unabled to write '%s"%failed_file) | print("Unabled to write '%s"%failed_file) | |||
if aromatic: | if aromatic: | |||
print("Clean-Warning: Please eliminate aromatic bonds and th en try again.") | print("Clean-Warning: Please eliminate aromatic bonds and th en try again.") | |||
if message!=None: | if message!=None: | |||
self_cmd.do("_ wizard") | self_cmd.do("_ wizard") | |||
def _clean(selection, present='', state=-1, fix='', restrain='', | def _clean(selection, present='', state=-1, fix='', restrain='', | |||
method='mmff', async=0, save_undo=1, message=None, | method='mmff', save_undo=1, message=None, | |||
_self=cmd_module): | _self=cmd_module): | |||
self_cmd = _self | self_cmd = _self | |||
clean1_sele = "_clean1_tmp" | clean1_sele = "_clean1_tmp" | |||
clean2_sele = "_clean2_tmp" | clean2_sele = "_clean2_tmp" | |||
clean_obj = "_clean_obj" | clean_obj = "_clean_obj" | |||
r = DEFAULT_SUCCESS | r = DEFAULT_SUCCESS | |||
c = None | c = None | |||
if self_cmd.select(clean1_sele,selection,enable=0)>0: | if self_cmd.select(clean1_sele,selection,enable=0)>0: | |||
skipping to change at line 254 | skipping to change at line 264 | |||
self_cmd.delete(clean2_sele) | self_cmd.delete(clean2_sele) | |||
self_cmd.set("suspend_undo", suspend_undo, updates=0) | self_cmd.set("suspend_undo", suspend_undo, updates=0) | |||
except: | except: | |||
traceback.print_exc() | traceback.print_exc() | |||
if hasattr(c,"energy"): | if hasattr(c,"energy"): | |||
return c.energy | return c.energy | |||
else: | else: | |||
return None | return None | |||
def clean(selection, present='', state=-1, fix='', restrain='', | def clean(selection, present='', state=-1, fix='', restrain='', | |||
method='mmff', async=0, save_undo=1, message=None, | method='mmff', async_=0, save_undo=1, message=None, | |||
_self=cmd_module): | _self=cmd_module, **kwargs): | |||
if not int(async): | if int(state) == 0: | |||
return _clean(selection,present,state,fix,restrain,method,async,save_und | raise pymol.CmdException('cleaning all states not supported') | |||
o,message,_self) | ||||
async_ = int(kwargs.pop('async', async_)) | ||||
if kwargs: | ||||
raise pymol.CmdException('unknown argument: ' + ', '.join(kwargs)) | ||||
args = (selection, present, state, fix, restrain, method, save_undo, message | ||||
, _self) | ||||
if not async_: | ||||
return _clean(*args) | ||||
else: | else: | |||
try: | try: | |||
t = threading.Thread(target=_clean, | t = threading.Thread(target=_clean, | |||
args=(selection,present,state,fix,restrain, | args=args) | |||
method,async,save_undo,message,_self)) | ||||
t.setDaemon(1) | t.setDaemon(1) | |||
t.start() | t.start() | |||
except: | except: | |||
traceback.print_exc() | traceback.print_exc() | |||
return 0 | return 0 | |||
End of changes. 7 change blocks. | ||||
8 lines changed or deleted | 27 lines changed or added |