creating.py (pymol-v1.8.6.0.tar.bz2) | : | creating.py (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 506 | skipping to change at line 506 | |||
EXAMPLES | EXAMPLES | |||
ramp_new e_pot_color, e_pot_map, [-10,0,10], [red,white,blue] | ramp_new e_pot_color, e_pot_map, [-10,0,10], [red,white,blue] | |||
ramp_update e_pot_color, range=[-15,0,15] | ramp_update e_pot_color, range=[-15,0,15] | |||
ramp_update e_pot_color, color=[green,white,orange] | ramp_update e_pot_color, color=[green,white,orange] | |||
SEE ALSO | SEE ALSO | |||
ramp_new | ramp_new | |||
''' | ''' | |||
return ramp_new(name, '', range, color, quiet=quiet, _self=cmd) | return _self.ramp_new(name, '', range, color, quiet=quiet) | |||
def isomesh(name, map, level=1.0, selection='', buffer=0.0, | def isomesh(name, map, level=1.0, selection='', buffer=0.0, | |||
state=1, carve=None, source_state=0, quiet=1, _self=cmd): | state=1, carve=None, source_state=0, quiet=1, _self=cmd): | |||
''' | ''' | |||
DESCRIPTION | DESCRIPTION | |||
"isomesh" creates a mesh isosurface object from a map object. | "isomesh" creates a mesh isosurface object from a map object. | |||
USAGE | USAGE | |||
skipping to change at line 968 | skipping to change at line 968 | |||
fragment name | fragment name | |||
''' | ''' | |||
r = DEFAULT_ERROR | r = DEFAULT_ERROR | |||
try: | try: | |||
if object==None: | if object==None: | |||
object=name | object=name | |||
model = fragments.get(str(name)) | model = fragments.get(str(name)) | |||
la = len(model.atom) | la = len(model.atom) | |||
if la: | if la and int(origin): | |||
position = _self.get_position() | position = _self.get_position() | |||
for c in range(0,3): | for c in range(0,3): | |||
mean_c = sum([a.coord[c] for a in model.atom]) / la | mean_c = sum([a.coord[c] for a in model.atom]) / la | |||
mean_c = position[c] - mean_c | mean_c = position[c] - mean_c | |||
for a in model.atom: | for a in model.atom: | |||
_self._adjust_coord(a, c, mean_c) | a.coord[c] += mean_c | |||
r = _self.load_model(model,str(object),quiet=quiet,zoom=zoom, _self= _self) | r = _self.load_model(model,str(object),quiet=quiet,zoom=zoom, _self= _self) | |||
except IOError: | except IOError: | |||
print("Error: unable to load fragment '%s'." % name) | raise pymol.CmdException("unable to load fragment '%s'." % name) | |||
except: | ||||
traceback.print_exc() | ||||
print("Error: unable to load fragment '%s'." % name) | ||||
if _self._raising(r,_self): raise pymol.CmdException | if _self._raising(r,_self): raise pymol.CmdException | |||
return r | return r | |||
def create(name, selection, source_state=0, | def create(name, selection, source_state=0, | |||
target_state=0, discrete=0, zoom=-1, quiet=1, | target_state=0, discrete=0, zoom=-1, quiet=1, | |||
singletons=0, extract=None, copy_properties=False, _self=cmd): | singletons=0, extract=None, copy_properties=False, _self=cmd): | |||
''' | ''' | |||
DESCRIPTION | DESCRIPTION | |||
"create" creates a new molecule object from a selection. It can | "create" creates a new molecule object from a selection. It can | |||
skipping to change at line 1030 | skipping to change at line 1027 | |||
load, copy, extract | load, copy, extract | |||
''' | ''' | |||
r = DEFAULT_ERROR | r = DEFAULT_ERROR | |||
target_state = int(target_state) | target_state = int(target_state) | |||
if target_state == -1: | if target_state == -1: | |||
target_state = _self.count_states('?' + name) + 1 | target_state = _self.count_states('?' + name) + 1 | |||
if copy_properties: | if copy_properties: | |||
print(' Warning: properties are not supported in Open-Source PyMOL') | print(' Warning: properties are not supported in Open-Source PyMOL') | |||
# preprocess selection | # preprocess selection | |||
selection = selector.process(selection) | selection = selector.process(selection) | |||
# | ||||
# TODO is this too much convenience? 'extract' should be a simple boolea | ||||
n | ||||
if extract in (None, 0, '0', ''): | ||||
extract = '' | ||||
elif extract in (1, '1'): | ||||
extract = selection | ||||
else: | ||||
print(' Warning: non-boolean extract values are deprecated!') | ||||
extract = selector.process(extract) | ||||
if extract: | ||||
extract_sele = _self.get_unused_name('_extract') | ||||
_self.select(extract_sele, extract, 0) | ||||
try: | try: | |||
_self.lock(_self) | _self.lock(_self) | |||
if name==None: | if not name: | |||
name = _self.get_unused_name("obj") | name = _self.get_unused_name("obj") | |||
r = _cmd.create(_self._COb,str(name),"("+str(selection)+")", | r = _cmd.create(_self._COb,str(name),"("+str(selection)+")", | |||
int(source_state)-1,int(target_state)-1, | int(source_state)-1,int(target_state)-1, | |||
int(discrete),int(zoom),int(quiet),int(singletons)) | int(discrete),int(zoom),int(quiet),int(singletons)) | |||
finally: | finally: | |||
_self.unlock(r,_self) | _self.unlock(r,_self) | |||
if not is_error(r): # temporary inefficient implementation | ||||
if extract not in (None, 0, '0'): | if extract: | |||
if extract not in (1, '1'): | if not is_error(r): | |||
extract = selector.process(extract) | _self.remove(extract_sele) | |||
else: | _self.delete(extract_sele) | |||
extract = selection | ||||
_self.remove("(("+extract+") in (%s)) and not (%s)"%(name,name)) | ||||
if _self._raising(r,_self): raise pymol.CmdException | if _self._raising(r,_self): raise pymol.CmdException | |||
return r | return r | |||
def extract(*arg,**kw): | def extract(*arg,**kw): | |||
''' | ''' | |||
DESCRIPTION | DESCRIPTION | |||
"extract" is simply a shorthand way calling the "create" command | "extract" is simply a shorthand way calling the "create" command | |||
with the extract argument activated, so that atoms in the new | with the extract argument activated, so that atoms in the new | |||
object are removed from the source object. | object are removed from the source object. | |||
skipping to change at line 1083 | skipping to change at line 1092 | |||
"extent" : 1, | "extent" : 1, | |||
"rms" : 2, | "rms" : 2, | |||
# "ellipse" : 2, for anisotropic b-factors? | # "ellipse" : 2, for anisotropic b-factors? | |||
} | } | |||
pseudoatom_mode_sc = Shortcut(pseudoatom_mode_dict.keys()) | pseudoatom_mode_sc = Shortcut(pseudoatom_mode_dict.keys()) | |||
unquote_re = re.compile(r"r?('.*'|\".*\")$") | unquote_re = re.compile(r"r?('.*'|\".*\")$") | |||
def unquote(s): | def unquote(s): | |||
if sys.version_info[0] > 2 and isinstance(s, bytes): | ||||
s = s.decode('utf-8', 'replace') | ||||
s = str(s) | s = str(s) | |||
if unquote_re.match(s): | if unquote_re.match(s): | |||
try: | try: | |||
return cmd.safe_eval(s) | return cmd.safe_eval(s) | |||
except SyntaxError: | except SyntaxError: | |||
print(" Warning: unquote failed for", repr(s)) | print(" Warning: unquote failed for", repr(s)) | |||
return s | return s | |||
def pseudoatom(object='', selection='', name='PS1', resn='PSD', resi='1', ch ain='P', | def pseudoatom(object='', selection='', name='PS1', resn='PSD', resi='1', ch ain='P', | |||
segi='PSDO', elem='PS', vdw=-1.0, hetatm=1, b=0.0, q=0.0, col or='', | segi='PSDO', elem='PS', vdw=-1.0, hetatm=1, b=0.0, q=0.0, col or='', | |||
End of changes. 8 change blocks. | ||||
16 lines changed or deleted | 29 lines changed or added |