exporting.py (pymol-open-source-2.2.0) | : | exporting.py (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
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 | |||
if __name__=='pymol.exporting': | if True: | |||
import os | import os | |||
import sys | import sys | |||
if sys.version_info[0] == 2: | if sys.version_info[0] == 2: | |||
import thread | import thread | |||
else: | else: | |||
import _thread as thread | import _thread as thread | |||
from . import selector | from . import selector | |||
import re | import re | |||
import copy | import copy | |||
skipping to change at line 650 | skipping to change at line 650 | |||
r = _cmd.assign_atom_types(_self._COb, selection, int(1), int(state- 1), quiet) | r = _cmd.assign_atom_types(_self._COb, selection, int(1), int(state- 1), quiet) | |||
finally: | finally: | |||
_self.unlock(r,_self) | _self.unlock(r,_self) | |||
return r | return r | |||
def get_str(format, selection='(all)', state=-1, ref='', | def get_str(format, selection='(all)', state=-1, ref='', | |||
ref_state=-1, multi=-1, quiet=1, _self=cmd): | ref_state=-1, multi=-1, quiet=1, _self=cmd): | |||
''' | ''' | |||
DESCRIPTION | DESCRIPTION | |||
Like "get_bytes" but return a unicode string. | ||||
''' | ||||
assert format not in ('mmtf',), 'binary format, use get_bytes' | ||||
b = get_bytes(format, selection, state, ref, ref_state, multi, quiet, _s | ||||
elf) | ||||
return b.decode('utf-8') | ||||
def get_bytes(format, selection='(all)', state=-1, ref='', | ||||
ref_state=-1, multi=-1, quiet=1, _self=cmd): | ||||
''' | ||||
DESCRIPTION | ||||
API-only function which exports the selection to a molecular file | API-only function which exports the selection to a molecular file | |||
format and returns it as a string. | format and returns it as a binary ("bytes") string. | |||
ARGUMENTS | ARGUMENTS | |||
format = str: pdb|cif|sdf|mol|mol2|mae|pqr|xyz | format = str: pdb|cif|sdf|mol|mol2|mae|pqr|xyz | |||
selection = str: atom selection {default: all} | selection = str: atom selection {default: all} | |||
state = int: object state (-1=current, 0=all) {default: -1} | state = int: object state (-1=current, 0=all) {default: -1} | |||
ref = str: object name which defines reference frame {default: } | ref = str: object name which defines reference frame {default: } | |||
skipping to change at line 673 | skipping to change at line 684 | |||
ref_state = int: state of ref object {default: -1} | ref_state = int: state of ref object {default: -1} | |||
multi = int: for multi-entry file formats, 0 = single entry, | multi = int: for multi-entry file formats, 0 = single entry, | |||
1 = by object, 2 = by object-state, -1 = format default {default: -1} | 1 = by object, 2 = by object-state, -1 = format default {default: -1} | |||
''' | ''' | |||
with _self.lockcm: | with _self.lockcm: | |||
return _cmd.get_str(_self._COb, str(format), str(selection), | return _cmd.get_str(_self._COb, str(format), str(selection), | |||
int(state) - 1, str(ref), int(ref_state), | int(state) - 1, str(ref), int(ref_state), | |||
int(multi), int(quiet)) | int(multi), int(quiet)) | |||
if sys.version_info[0] == 2: | ||||
get_str = get_bytes | ||||
def multifilesave(filename, selection='*', state=-1, format='', ref='', | def multifilesave(filename, selection='*', state=-1, format='', ref='', | |||
ref_state=-1, quiet=1, _self=cmd): | ref_state=-1, quiet=1, _self=cmd): | |||
''' | ''' | |||
DESCRIPTION | DESCRIPTION | |||
For a selection that spans multiple molecular objects and/or states, | For a selection that spans multiple molecular objects and/or states, | |||
save each object and/or state to a separate file. Takes a filename | save each object and/or state to a separate file. Takes a filename | |||
argument with placeholders: | argument with placeholders: | |||
{name} : object name | {name} : object name | |||
skipping to change at line 952 | skipping to change at line 966 | |||
savefunctions = { | savefunctions = { | |||
'cif': get_str, # mmCIF | 'cif': get_str, # mmCIF | |||
'xyz': get_str, | 'xyz': get_str, | |||
'pdb': get_str, | 'pdb': get_str, | |||
'pqr': get_str, | 'pqr': get_str, | |||
'sdf': get_str, | 'sdf': get_str, | |||
'mol2': get_str, | 'mol2': get_str, | |||
'mae': get_str, | 'mae': get_str, | |||
'mol': get_str, | 'mol': get_str, | |||
'mmtf': 'pymol.lazyio:get_mmtfstr', | 'mmtf': get_bytes, | |||
'pse': get_psestr, | 'pse': get_psestr, | |||
'psw': get_psestr, | 'psw': get_psestr, | |||
'fasta': get_fastastr, | 'fasta': get_fastastr, | |||
'aln': get_alnstr, | 'aln': get_alnstr, | |||
'ccp4': get_ccp4str, | 'ccp4': get_ccp4str, | |||
'png': png, | 'png': png, | |||
End of changes. 5 change blocks. | ||||
3 lines changed or deleted | 18 lines changed or added |