editor.py (pymol-v1.8.6.0.tar.bz2) | : | editor.py (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
tmp_editor = _prefix + "0" | tmp_editor = _prefix + "0" | |||
tmp_connect = _prefix + "_con" | tmp_connect = _prefix + "_con" | |||
tmp_domain = _prefix + "_dom" | tmp_domain = _prefix + "_dom" | |||
tmp1 = _prefix + "1" | tmp1 = _prefix + "1" | |||
tmp2 = _prefix + "2" | tmp2 = _prefix + "2" | |||
tmp3 = _prefix + "3" | tmp3 = _prefix + "3" | |||
tmp4 = _prefix + "4" | tmp4 = _prefix + "4" | |||
# routines to assist in molecular editing | # routines to assist in molecular editing | |||
class undocontext: | ||||
def __init__(self, cmd, sele): | ||||
# not implemented in open-source | ||||
pass | ||||
def __enter__(self): | ||||
# not implemented in open-source | ||||
pass | ||||
def __exit__(self, exc_type, exc_value, traceback): | ||||
# not implemented in open-source | ||||
pass | ||||
def attach_fragment(selection,fragment,hydrogen,anchor,_self=cmd): | def attach_fragment(selection,fragment,hydrogen,anchor,_self=cmd): | |||
''' | ''' | |||
ARGUMENTS | ARGUMENTS | |||
selection = str: must be "pk1" | selection = str: must be "pk1" | |||
fragment = str: fragment name to load from fragment library | fragment = str: fragment name to load from fragment library | |||
hydrogen = int: hydrogen atom ID in fragment to fuse | hydrogen = int: hydrogen atom ID in fragment to fuse | |||
skipping to change at line 48 | skipping to change at line 61 | |||
''' | ''' | |||
if not selection in _self.get_names("selections"): | if not selection in _self.get_names("selections"): | |||
if fragment in _self.get_names("objects"): | if fragment in _self.get_names("objects"): | |||
print(" Error: an object with than name already exists") | print(" Error: an object with than name already exists") | |||
raise QuietException | raise QuietException | |||
else: | else: | |||
_self.fragment(fragment) | _self.fragment(fragment) | |||
if _self.get_setting_boolean("auto_remove_hydrogens"): | if _self.get_setting_boolean("auto_remove_hydrogens"): | |||
_self.remove("(hydro and %s)"%fragment) | _self.remove("(hydro and %s)"%fragment) | |||
else: | else: | |||
_self.fragment(fragment,tmp_editor) | _self.fragment(fragment,tmp_editor, origin=0) | |||
if _self.count_atoms("((%s) and elem H)"%selection,quiet=1): | if _self.count_atoms("((%s) and elem H)"%selection,quiet=1): | |||
_self.fuse("(%s and id %d)"%(tmp_editor,hydrogen),"(pk1)",1) | _self.fuse("(%s and id %d)"%(tmp_editor,hydrogen),"(pk1)",1) | |||
if _self.get_setting_boolean("auto_remove_hydrogens"): | if _self.get_setting_boolean("auto_remove_hydrogens"): | |||
_self.remove("(hydro and pkmol)") | _self.remove("(hydro and pkmol)") | |||
else: | else: | |||
_self.remove("(%s and id %d)"%(tmp_editor,hydrogen)) | _self.remove("(%s and id %d)"%(tmp_editor,hydrogen)) | |||
_self.fuse("(%s and id %d)"%(tmp_editor,anchor),"(pk1)",1) | _self.fuse("(%s and id %d)"%(tmp_editor,anchor),"(pk1)",1) | |||
if _self.get_setting_boolean("auto_remove_hydrogens"): | if _self.get_setting_boolean("auto_remove_hydrogens"): | |||
_self.remove("(hydro and pkmol)") | _self.remove("(hydro and pkmol)") | |||
elif _self.count_atoms('hydro and (neighbor pk2)'): | ||||
_self.h_fill() | ||||
_self.delete(tmp_editor) | _self.delete(tmp_editor) | |||
def combine_fragment(selection,fragment,hydrogen,anchor,_self=cmd): | def combine_fragment(selection,fragment,hydrogen,anchor,_self=cmd): | |||
if selection in _self.get_names("selections"): | with undocontext(_self, selection): | |||
_self.fragment(fragment,tmp_editor) | _self.fragment(fragment,tmp_editor) | |||
if _self.count_atoms("((%s) and elem H)"%selection,quiet=1): | try: | |||
_self.fuse("(%s and id %d)"%(tmp_editor,hydrogen),"(pk1)",3) | ||||
if _self.get_setting_boolean("auto_remove_hydrogens"): | ||||
_self.remove("(hydro and pkmol)") | ||||
else: | ||||
_self.fuse("(%s and id %d)"%(tmp_editor,anchor),"(pk1)",3) | ||||
if _self.get_setting_boolean("auto_remove_hydrogens"): | if _self.get_setting_boolean("auto_remove_hydrogens"): | |||
_self.remove("(hydro and pkmol)") | _self.remove("(hydro and ?%s)" % tmp_editor) | |||
_self.delete(tmp_editor) | _self.fuse("?%s" % tmp_editor, "(%s)" % selection, 3) | |||
finally: | ||||
_self.delete(tmp_editor) | ||||
#from time import time as ___time | #from time import time as ___time | |||
#___total = 0.0 | #___total = 0.0 | |||
#___seg1 = 0.0 | #___seg1 = 0.0 | |||
#___seg2 = 0.0 | #___seg2 = 0.0 | |||
#___seg3 = 0.0 | #___seg3 = 0.0 | |||
#___pass = 0 | #___pass = 0 | |||
#___last = ___time() | #___last = ___time() | |||
def attach_amino_acid(selection,amino_acid,center=0,animate=-1,object="",hydro=- 1,ss=-1,_self=cmd): | def attach_amino_acid(selection,amino_acid,center=0,animate=-1,object="",hydro=- 1,ss=-1,_self=cmd): | |||
skipping to change at line 154 | skipping to change at line 166 | |||
psi=-47.0 | psi=-47.0 | |||
elif ss==2: # antipara-beta | elif ss==2: # antipara-beta | |||
phi=-139.0 | phi=-139.0 | |||
psi=135.0 | psi=135.0 | |||
elif ss==3: # para-beta | elif ss==3: # para-beta | |||
phi=-119.0 | phi=-119.0 | |||
psi=113.0 | psi=113.0 | |||
else: | else: | |||
phi=180.0 | phi=180.0 | |||
psi=180.0 | psi=180.0 | |||
_self.fragment(amino_acid,tmp_editor) | _self.fragment(amino_acid,tmp_editor, origin=0) | |||
if _self.count_atoms("elem N",domain=tmp_connect): | if _self.count_atoms("elem N",domain=tmp_connect): | |||
tmp = [ None ] | tmp = [ None ] | |||
_self.iterate(tmp_connect,"tmp[0]=resv", space={ 'tmp' : tmp }) | _self.iterate(tmp_connect,"tmp[0]=resv", space={ 'tmp' : tmp }) | |||
tmp[0] = str(tmp[0]-1) # counting down | tmp[0] = str(tmp[0]-1) # counting down | |||
_self.alter(tmp_editor,"resi=tmp[0]",space={ 'tmp' : tmp}) | _self.alter(tmp_editor,"resi=tmp[0]",space={ 'tmp' : tmp}) | |||
_self.set_geometry(tmp_connect, 3, 3) # make nitrogen planar | _self.set_geometry(tmp_connect, 3, 3) # make nitrogen planar | |||
_self.fuse("(%s and name C)"%(tmp_editor),tmp_connect,2) | _self.fuse("(%s and name C)"%(tmp_editor),tmp_connect,2) | |||
_self.select(tmp_domain, "byresi (pk1 | pk2)") | _self.select(tmp_domain, "byresi (pk1 | pk2)") | |||
if not hydro: | if not hydro: | |||
skipping to change at line 406 | skipping to change at line 418 | |||
resi = resi - 1 | resi = resi - 1 | |||
if not len(sequence): | if not len(sequence): | |||
r = DEFAULT_SUCCESS | r = DEFAULT_SUCCESS | |||
if _self.get_setting_int('auto_zoom'): | if _self.get_setting_int('auto_zoom'): | |||
_self.zoom(name) | _self.zoom(name) | |||
return r | return r | |||
def fab(input,name=None,mode='peptide',resi=1,chain='',segi='',state=-1, | def fab(input,name=None,mode='peptide',resi=1,chain='',segi='',state=-1, | |||
dir=1,hydro=-1,ss=0,async=-1,quiet=1,_self=cmd): | dir=1,hydro=-1,ss=0,async_=-1,quiet=1,_self=cmd, **kwargs): | |||
''' | ''' | |||
DESCRIPTION | DESCRIPTION | |||
Build a peptide | Build a peptide | |||
ARGUMENTS | ARGUMENTS | |||
input = str: sequence in one-letter code | input = str: sequence in one-letter code | |||
name = str: name of object to create {default: } | name = str: name of object to create {default: } | |||
ss = int: Secondary structure 1=alpha helix, 2=antiparallel beta, 3=parallel beta, 4=flat | ss = int: Secondary structure 1=alpha helix, 2=antiparallel beta, 3=parallel beta, 4=flat | |||
EXAMPLE | EXAMPLE | |||
fab ACDEFGH | fab ACDEFGH | |||
fab ACDEFGH, helix, ss=1 | fab ACDEFGH, helix, ss=1 | |||
''' | ''' | |||
if async<1: | async_ = int(kwargs.pop('async', async_)) | |||
if kwargs: | ||||
raise pymol.CmdException('unknown argument: ' + ', '.join(kwargs)) | ||||
if async_ < 1: | ||||
r = _fab(input,name,mode,resi,chain,segi, | r = _fab(input,name,mode,resi,chain,segi, | |||
state,dir,hydro,ss,quiet,_self) | state,dir,hydro,ss,quiet,_self) | |||
else: | else: | |||
fab_thread = threading.Thread(target=_fab, args=(input,name,mode, | fab_thread = threading.Thread(target=_fab, args=(input,name,mode, | |||
resi,chain, | resi,chain, | |||
segi,state,dir, | segi,state,dir, | |||
hydro,ss,quiet,_self)) | hydro,ss,quiet,_self)) | |||
fab_thread.setDaemon(1) | fab_thread.setDaemon(1) | |||
fab_thread.start() | fab_thread.start() | |||
r = DEFAULT_SUCCESS | r = DEFAULT_SUCCESS | |||
End of changes. 9 change blocks. | ||||
13 lines changed or deleted | 30 lines changed or added |