exporting.py (pymol-v2.1.0.tar.bz2) | : | exporting.py (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
skipping to change at line 124 | skipping to change at line 124 | |||
scenes = str(scenes) | scenes = str(scenes) | |||
scene_list = scenes.split() | scene_list = scenes.split() | |||
cache_mode = int(_self.get('cache_mode')) | cache_mode = int(_self.get('cache_mode')) | |||
_self.set('cache_mode',2) | _self.set('cache_mode',2) | |||
if not len(scene_list): | if not len(scene_list): | |||
scene_list = _self.get_scene_list() | scene_list = _self.get_scene_list() | |||
for scene in scene_list: | for scene in scene_list: | |||
scene = scene.strip() | scene = scene.strip() | |||
if not quiet: | if not quiet: | |||
print(" cache: optimizing scene '%s'."%scene) | print(" cache: optimizing scene '%s'."%scene) | |||
cmd.scene(scene,animate=0) | _self.scene(scene,animate=0) | |||
cmd.rebuild() | _self.rebuild() | |||
cmd.refresh() | _self.refresh() | |||
if len(cur_scene): | if len(cur_scene): | |||
cmd.scene(cur_scene,animate=0) | _self.scene(cur_scene,animate=0) | |||
else: | else: | |||
scene_list = _self.get_scene_list() | scene_list = _self.get_scene_list() | |||
if len(scene_list): | if len(scene_list): | |||
cmd.scene(scene_list[0],animate=0) | _self.scene(scene_list[0],animate=0) | |||
else: | else: | |||
if not quiet: | if not quiet: | |||
print(" cache: no scenes defined -- optimizing current d isplay.") | print(" cache: no scenes defined -- optimizing current d isplay.") | |||
cmd.rebuild() | _self.rebuild() | |||
cmd.refresh() | _self.refresh() | |||
usage = _self._cache_purge(-1,_self=_self) | usage = _self._cache_purge(-1,_self=_self) | |||
if cache_mode: | if cache_mode: | |||
_self.set('cache_mode',cache_mode) | _self.set('cache_mode',cache_mode) | |||
else: | else: | |||
_self.set('cache_mode',2) # hmm... could use 1 here instead. | _self.set('cache_mode',2) # hmm... could use 1 here instead. | |||
_self.set('cache_max',cache_max) # restore previous limits | _self.set('cache_max',cache_max) # restore previous limits | |||
if not quiet: | if not quiet: | |||
print(" cache: optimization complete (~%0.1f MB)."%(usage*4/1000 000.0)) | print(" cache: optimization complete (~%0.1f MB)."%(usage*4/1000 000.0)) | |||
try: | try: | |||
_self.lock(_self) | _self.lock(_self) | |||
skipping to change at line 174 | skipping to change at line 174 | |||
'MET' : 'M', | 'MET' : 'M', | |||
'ASN' : 'N', | 'ASN' : 'N', | |||
'PRO' : 'P', | 'PRO' : 'P', | |||
'GLN' : 'Q', | 'GLN' : 'Q', | |||
'ARG' : 'R', | 'ARG' : 'R', | |||
'SER' : 'S', | 'SER' : 'S', | |||
'THR' : 'T', | 'THR' : 'T', | |||
'VAL' : 'V', | 'VAL' : 'V', | |||
'TRP' : 'W', | 'TRP' : 'W', | |||
'TYR' : 'Y', | 'TYR' : 'Y', | |||
# RNA | ||||
'A' : 'A', | ||||
'U' : 'U', | ||||
'G' : 'G', | ||||
'C' : 'C', | ||||
# DNA | ||||
'DA' : 'A', | ||||
'DT' : 'T', | ||||
'DG' : 'G', | ||||
'DC' : 'C', | ||||
} | } | |||
def get_fastastr(selection="all", state=-1, quiet=1, _self=cmd): | def get_fastastr(selection="all", state=-1, quiet=1, key='', _self=cmd): | |||
dict = { 'seq' : {} } | ''' | |||
# we use (alt '' or alt 'A') because 'guide' picks up | DESCRIPTION | |||
# non-canonical structures: eg, 1ejg has residue 22 as a SER and | ||||
# PRO, which guide will report twice | API only. Get protein and nucleic acid sequences in fasta format. | |||
_self.iterate("("+selection+") and polymer and name CA and alt +A", | ||||
"seq[model]=seq.get(model,[]);seq[model].append(resn)",space | Used for saving: | |||
=dict) | PyMOL> save foo.fasta | |||
seq = dict['seq'] | ||||
result = [] | New in PyMOL 2.2: | |||
for obj in _self.get_names("objects",selection='('+selection+')'): | - chain specific keys (key argument) | |||
if obj in seq: | - nucleic acid support | |||
cur_seq = [_resn_to_aa.get(x,'?') for x in seq[obj]] | ||||
result.append(">%s"%obj) | ARGUMENTS | |||
cur_seq = ''.join(cur_seq) | ||||
while len(cur_seq): | selection = str: atom selection (reduced to "guide & alt +A") {default: all} | |||
if len(cur_seq)>=70: | ||||
result.append(cur_seq[0:70]) | state = int: (only used if state > 0) | |||
cur_seq=cur_seq[70:] | ||||
else: | quiet = 0/1: UNUSED | |||
result.append(cur_seq) | ||||
break | key = str: python expression {default: model + "_" + chain} | |||
result = '\n'.join(result) | Use key=model to get the old (non-chain specific) behavior | |||
if len(result): | ''' | |||
result = result + '\n' | import textwrap | |||
return result | import collections | |||
seq = collections.OrderedDict() | ||||
lines = [] | ||||
selection = "(" + selection + ") & guide & alt +A" | ||||
if int(state) > 0: | ||||
selection += ' & state {}'.format(state) | ||||
if not key: | ||||
key = 'model + "_" + chain' | ||||
# for discrete objects: state specific keys | ||||
key += ' + (":{}".format(state) if state else "")' | ||||
_self.iterate(selection, | ||||
"seq.setdefault((" + key + "),[]).append(resn)", | ||||
space={'seq': seq, 'str': str}) | ||||
for key, resn_list in seq.items(): | ||||
cur_seq = ''.join(_resn_to_aa.get(x, '?') for x in resn_list) | ||||
lines.append(">{}".format(key)) | ||||
lines.extend(textwrap.wrap(cur_seq, 70)) | ||||
if lines: | ||||
lines.append('') # final newline | ||||
return '\n'.join(lines) | ||||
def get_pdbstr(selection="all", state=-1, ref='', ref_state=-1, quiet=1, _se lf=cmd): | def get_pdbstr(selection="all", state=-1, ref='', ref_state=-1, quiet=1, _se lf=cmd): | |||
''' | ''' | |||
DESCRIPTION | DESCRIPTION | |||
"get_pdbstr" in an API-only function which returns a pdb | "get_pdbstr" in an API-only function which returns a pdb | |||
corresponding to the atoms in the selection provided and that are | corresponding to the atoms in the selection provided and that are | |||
present in the indicated state | present in the indicated state | |||
PYMOL API | PYMOL API | |||
skipping to change at line 519 | skipping to change at line 555 | |||
if prior: | if prior: | |||
# fetch the prior image, without doing any work (fast-path / non-GLU T thread-safe) | # fetch the prior image, without doing any work (fast-path / non-GLU T thread-safe) | |||
r = _self._png(str(filename),0,0,float(dpi),0,int(quiet),1, | r = _self._png(str(filename),0,0,float(dpi),0,int(quiet),1, | |||
int(format),_self) | int(format),_self) | |||
if r != 1: # no prior image available -- revert to default behavior | if r != 1: # no prior image available -- revert to default behavior | |||
if prior < 0: # default is to fall back to actual rendering | if prior < 0: # default is to fall back to actual rendering | |||
prior = 0 | prior = 0 | |||
if not prior: | if not prior: | |||
dpi = float(dpi) | dpi = float(dpi) | |||
if dpi < 0: | if dpi < 0: | |||
dpi = cmd.get_setting_float('image_dots_per_inch') | dpi = _self.get_setting_float('image_dots_per_inch') | |||
width = _unit2px(width, dpi) | width = _unit2px(width, dpi) | |||
height = _unit2px(height, dpi) | height = _unit2px(height, dpi) | |||
if thread.get_ident() == pymol.glutThread: | if thread.get_ident() == pymol.glutThread: | |||
r = _self._png(str(filename),int(width),int(height),float(dpi), | r = _self._png(str(filename),int(width),int(height),float(dpi), | |||
int(ray),int(quiet),0,int(format),_self) | int(ray),int(quiet),0,int(format),_self) | |||
else: | else: | |||
r = _self._do("cmd._png('''%s''',%d,%d,%1.6f,%d,%d,%d,%d)"% | r = _self._do("cmd._png('''%s''',%d,%d,%1.6f,%d,%d,%d,%d)"% | |||
(filename,width,height,dpi, | (filename,width,height,dpi, | |||
ray,int(quiet),0,int(format)),_self=_self) | ray,int(quiet),0,int(format)),_self=_self) | |||
End of changes. 7 change blocks. | ||||
34 lines changed or deleted | 69 lines changed or added |