"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/pymol/editing.py" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

editing.py  (pymol-v1.8.6.0.tar.bz2):editing.py  (pymol-v2.1.0.tar.bz2)
skipping to change at line 1132 skipping to change at line 1132
r = DEFAULT_ERROR r = DEFAULT_ERROR
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.h_fix(_self._COb,str(selection),int(quiet)) r = _cmd.h_fix(_self._COb,str(selection),int(quiet))
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise pymol.CmdException if _self._raising(r,_self): raise pymol.CmdException
return r return r
def h_add(selection="(all)",quiet=1,_self=cmd): def h_add(selection="(all)", quiet=1, state=0, legacy=0, _self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"h_add" uses a rudimentary algorithm to add hydrogens onto a "h_add" adds hydrogens onto a molecule based on current valences.
molecule based on current valences.
USAGE USAGE
h_add selection h_add [ selection [, state ]]
ARGUMENTS ARGUMENTS
selection = string {default: (all)} selection = string {default: (all)}
state = int {default: 0 (all states)}
NOTES NOTES
Because PDB files do not normally contain bond valences for Because PDB files do not normally contain bond valences for
ligands and other nonstandard components, it may be necessary to ligands and other nonstandard components, it may be necessary to
manually correct ligand conformations before adding hydrogens. manually correct ligand conformations before adding hydrogens.
PYMOL API
cmd.h_add( string selection="(all)" )
SEE ALSO SEE ALSO
h_fill h_fill
''' '''
# preprocess selection # preprocess selection
selection = selector.process(selection) selection = selector.process(selection)
# #
r = DEFAULT_ERROR r = DEFAULT_ERROR
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.h_add(_self._COb,selection,int(quiet)) r = _cmd.h_add(_self._COb,selection,int(quiet),
int(state) - 1, int(legacy))
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise pymol.CmdException if _self._raising(r,_self): raise pymol.CmdException
return r return r
def sort(object="",_self=cmd): def sort(object="",_self=cmd):
''' '''
DESCRIPTION DESCRIPTION
"sort" reorders atoms in the structure. It usually only necessary "sort" reorders atoms in the structure. It usually only necessary
skipping to change at line 2526 skipping to change at line 2524
This is primarily useful for passing selection information into This is primarily useful for passing selection information into
Chempy models, which have a 32 bit attribute "flag" which holds Chempy models, which have a 32 bit attribute "flag" which holds
this information. this information.
If the 'auto_indicate_flags' setting is true, then PyMOL will automatically If the 'auto_indicate_flags' setting is true, then PyMOL will automatically
create a selection called "indicate" which contains all atoms with that flag create a selection called "indicate" which contains all atoms with that flag
after applying the command. after applying the command.
SPECIAL FLAGS SPECIAL FLAGS
* Flags 0-7 are reserved for molecular modeling * Flags 0-5 are reserved for molecular modeling
focus 0 = Atoms of Interest (i.e. a ligand in an active site) \\ focus 0 = Atoms of Interest (i.e. a ligand in an active site) \\
free 1 = Free Atoms (free to move subject to a force-field) \\ free 1 = Free Atoms (free to move subject to a force-field) \\
restrain 2 = Restrained Atoms (typically harmonically contrained) \\ restrain 2 = Restrained Atoms (typically harmonically contrained) \\
fix 3 = Fixed Atoms (no movement allowed) \\ fix 3 = Fixed Atoms (no movement allowed) \\
exclude 4 = Atoms which should not be part of any simulation exclude 4 = Atoms which should not be part of any simulation
study 5
* Flags 6-7 are for protein and nucleic acid classification
* Flags 8-15 are free for end users to manipulate * Flags 8-15 are free for end users to manipulate
* Flags 16-23 are reserved for external GUIs and linked applications * Flags 16-21 are reserved for external GUIs and linked applications
* Flags 22-23 are for temporary use only (flag 23 used for coverage
tracking when assigning parameters in chempy.champ.assign)
* Flags 24-30 are reserved for PyMOL internal usage * Flags 24-31 are reserved for PyMOL internal usage
exfoliate 24 = Remove surface from atoms when surfacing \\ exfoliate 24 = Remove surface from atoms when surfacing \\
ignore 25 = Ignore atoms altogether when surfacing \\ ignore 25 = Ignore atoms altogether when surfacing \\
no_smooth 26 = Do not smooth atom position no_smooth 26 = Do not smooth atom position
* Flag 31 is reserved for coverage tracking when assigning parameters, etc.
PYMOL API PYMOL API
cmd.flag(int flag, string selection, string action="reset", cmd.flag(int flag, string selection, string action="reset",
int indicate=0) int indicate=0)
''' '''
r = DEFAULT_ERROR r = DEFAULT_ERROR
# preprocess selection # preprocess selection
new_flag = flag_sc.interpret(str(flag)) new_flag = flag_sc.interpret(str(flag))
if new_flag: if new_flag:
skipping to change at line 2658 skipping to change at line 2660
''' '''
DESCRIPTION DESCRIPTION
Mutate selenomethionine to methionine Mutate selenomethionine to methionine
''' '''
x = _self.alter('(%s) and MSE/SE' % selection, 'name="SD";elem="S"') x = _self.alter('(%s) and MSE/SE' % selection, 'name="SD";elem="S"')
_self.flag('ignore', '(%s) and resn MSE' % (selection), 'clear') _self.flag('ignore', '(%s) and resn MSE' % (selection), 'clear')
_self.alter('(%s) and resn MSE' % selection, 'resn="MET";type="ATOM"') _self.alter('(%s) and resn MSE' % selection, 'resn="MET";type="ATOM"')
if not int(quiet): if not int(quiet):
print(' Altered %d MSE residues to MET' % (x)) print(' Altered %d MSE residues to MET' % (x))
def _base(i, numerals, _emptyzero=False):
if i == 0:
return '' if _emptyzero else numerals[0]
b = len(numerals)
return _base(i // b, numerals, True) + numerals[i % b]
def uniquify(identifier, selection, reference='', quiet=1, _self=cmd):
'''
DESCRIPTION
Make `identifier` unique with respect to reference selection.
ARGUMENTS
identifier = str: atom identifier (chain, segi, etc.)
selection = str: atom selection to modify
reference = str: atom selection whose identifiers must not be
present in the first selection {default: !selection}
EXAMPLE
fetch 1a00 1hbb, async=0
uniquify chain, 1hbb
# 1hbb now has chains E,F,G,H
'''
import itertools
import string
if not reference:
reference = '!(' + selection + ')'
p = identifier
set_ref = set()
set_sel = set()
mapping = {}
space = {'set_ref': set_ref, 'set_sel': set_sel, 'mapping': mapping}
_self.iterate(reference, 'set_ref.add(' + p + ')', space=space)
_self.iterate(selection, 'set_sel.add(' + p + ')', space=space)
set_union = set_ref | set_sel
set_inter = set_ref & set_sel
if not set_inter:
return
baseargs = ()
i_iter = itertools.count(1)
if isinstance(next(iter(set_inter)), int):
basefunc = int
elif p in ('resi',):
basefunc = str
else:
basefunc = _base
baseargs = (string.ascii_uppercase + '123456789',)
i_iter = itertools.count(0)
for name in set_inter:
for i in i_iter:
newname = basefunc(i, *baseargs)
if newname not in set_union:
mapping[name] = newname
set_union.add(newname)
break
_self.alter(selection, '%s = mapping.get(%s, %s)' % (p, p, p),
space=space)
if not int(quiet):
print(' Uniquify: renamed %d %s identifier(s)' % (len(mapping), p))
def copy_to(name, selection, rename='chain segi ID', zoom=-1, quiet=1, _self
=cmd):
'''
DESCRIPTION
Copies selection to object `name` (all states) and by default
renames chain, segi and ID identifiers to avoid naming conflicts.
ARGUMENTS
name = str: object name to modify
selection = str: atom selection (will be copied to `name`)
rename = str: space separated list of identifiers to rename
{default: chain segi ID}
SEE ALSO
create, fuse
'''
temp = _self.get_unused_name('_tmp')
try:
_self.create(temp, selection, zoom=0)
_self.disable(' '.join(_self.get_object_list(selection)))
for prop in rename.split():
if prop.upper() == 'ID':
_self.alter(temp, 'ID = -1')
else:
uniquify(prop, temp, '?' + name, quiet=quiet)
_self.create(name, '?' + name + ' ' + temp, zoom=zoom)
_self.unpick()
if not int(quiet):
n = _self.count_atoms(temp)
print(' Copied %d atoms to object %s' % (n, name))
finally:
_self.delete(temp)
 End of changes. 12 change blocks. 
14 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)