"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/pymol/importing.py" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

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.

importing.py  (pymol-open-source-2.2.0):importing.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.importing': if True:
import re import re
import os import os
import sys import sys
import copy import copy
import traceback import traceback
import pymol import pymol
cmd = sys.modules["pymol.cmd"] cmd = sys.modules["pymol.cmd"]
from . import setting
from . import selector from . import selector
from . import colorprinting from . import colorprinting
from .cmd import _cmd,lock,unlock,Shortcut, \ from .cmd import _cmd, \
_feedback,fb_module,fb_mask, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error, \ DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error, \
_load, is_list, space_sc, safe_list_eval, is_string, loadable _load, is_list, space_sc, safe_list_eval, is_string, loadable
from .constants import _loadable from .constants import _loadable
from pymol.creating import unquote from pymol.creating import unquote
def incentive_format_not_available_func(format=''): def incentive_format_not_available_func(format=''):
raise pymol.IncentiveOnlyException( raise pymol.IncentiveOnlyException(
"'%s' format not supported by this PyMOL build" % format) "'%s' format not supported by this PyMOL build" % format)
from chempy import io,PseudoFile from chempy import io
# TODO remove (keep for now for eventual legacy uses in scripts)
loadable_sc = Shortcut(loadable.__dict__.keys())
def filename_to_objectname(fname, _self=cmd): def filename_to_objectname(fname, _self=cmd):
oname, _, _, _ = filename_to_format(fname) oname, _, _, _ = filename_to_format(fname)
return _self.get_legal_name(oname) return _self.get_legal_name(oname)
def filename_to_format(filename): def filename_to_format(filename):
filename = os.path.basename(filename) filename = os.path.basename(filename)
pre, delim, ext = filename.rpartition('.') pre, delim, ext = filename.rpartition('.')
if ext in ('gz', 'bz2',): if ext in ('gz', 'bz2',):
skipping to change at line 487 skipping to change at line 482
seq_order.append(legal_key) seq_order.append(legal_key)
legal_dict[key] = legal_key legal_dict[key] = legal_key
key = legal_key key = legal_key
seq = line[16:].strip() seq = line[16:].strip()
if seq != '': if seq != '':
seq_dict[key] = seq_dict.get(key,'') + seq seq_dict[key] = seq_dict.get(key,'') + seq
for key in seq_order: for key in seq_order:
raw_seq = seq_dict[key].replace('-','') raw_seq = seq_dict[key].replace('-','')
_self.fab(raw_seq, key, quiet=quiet) _self.fab(raw_seq, key, quiet=quiet)
def _processFASTA(fname,quiet=1,_self=cmd): def _processFASTA(fname, oname, quiet=1, _self=cmd):
legal_dict = {} legal_dict = {}
seq_dict = {} seq_dict = {}
seq_order = [] seq_order = []
for line in open(fname).readlines(): for line in open(fname).readlines():
line = line.strip() line = line.strip()
if len(line): if len(line):
if line[0:1] == '>': if line[0:1] == '>':
key = line[1:].strip() key = line[1:].strip()
legal_key = _self.get_legal_name(key) legal_key = _self.get_legal_name(key)
if key not in legal_dict: if key not in legal_dict:
seq_order.append(legal_key) seq_order.append(legal_key)
legal_dict[key] = legal_key legal_dict[key] = legal_key
key = legal_key key = legal_key
elif key: elif key:
seq = line seq = line
if '-' in seq:
# sequence alignment
from pymol.seqalign import load_aln_multi
return load_aln_multi(fname, oname, quiet=quiet,
_self=_self)
seq_dict[key] = seq_dict.get(key,'') + seq seq_dict[key] = seq_dict.get(key,'') + seq
for key in seq_order: for key in seq_order:
raw_seq = seq_dict[key].replace('-','') raw_seq = seq_dict[key].replace('-','')
_self.fab(raw_seq, key, quiet=quiet) _self.fab(raw_seq, key, quiet=quiet)
def _processPWG(fname,_self=cmd): def _processPWG(fname,_self=cmd):
r = DEFAULT_ERROR r = DEFAULT_ERROR
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
import urllib import urllib
skipping to change at line 1324 skipping to change at line 1326
if chain and isinstance(r, str): if chain and isinstance(r, str):
if _self.count_atoms(r'?%s & c. \%s' % (r, chain)) == 0: if _self.count_atoms(r'?%s & c. \%s' % (r, chain)) == 0:
_self.delete(r) _self.delete(r)
raise pymol.CmdException('no such chain: ' + chain) raise pymol.CmdException('no such chain: ' + chain)
_self.remove(r'?%s & ! c. \%s' % (r, chain)) _self.remove(r'?%s & ! c. \%s' % (r, chain))
return r return r
def fetch(code, name='', state=0, finish=1, discrete=-1, def fetch(code, name='', state=0, finish=1, discrete=-1,
multiplex=-2, zoom=-1, type='', async_=-1, path='', multiplex=-2, zoom=-1, type='', async_=0, path='',
file=None, quiet=1, _self=cmd, **kwargs): file=None, quiet=1, _self=cmd, **kwargs):
''' '''
DESCRIPTION DESCRIPTION
"fetch" downloads a file from the internet (if possible) "fetch" downloads a file from the internet (if possible)
USAGE USAGE
fetch code [, name [, state [, finish [, discrete [, multiplex fetch code [, name [, state [, finish [, discrete [, multiplex
skipping to change at line 1349 skipping to change at line 1351
code = a single PDB identifier or a list of identifiers. Supports code = a single PDB identifier or a list of identifiers. Supports
5-letter codes for fetching single chains (like 1a00A). 5-letter codes for fetching single chains (like 1a00A).
name = the object name into which the file should be loaded. name = the object name into which the file should be loaded.
state = the state number into which the file should loaded. state = the state number into which the file should loaded.
type = str: cif, pdb, pdb1, 2fofc, fofc, emd, cid, sid {default: cif type = str: cif, pdb, pdb1, 2fofc, fofc, emd, cid, sid {default: cif
(default was "pdb" up to 1.7.6)} (default was "pdb" up to 1.7.6)}
async_ = 0/1: download in the background and do not block the PyMOL
command line {default: 0 -- changed in PyMOL 2.3}
PYMOL API PYMOL API
cmd.fetch(string code, string name, int state, init finish, cmd.fetch(string code, string name, int state, init finish,
int discrete, int multiplex, int zoom, string type, int discrete, int multiplex, int zoom, string type,
int async, string path, string file, int quiet) int async, string path, string file, int quiet)
NOTES NOTES
When running in interactive mode, the fetch command loads When running in interactive mode, the fetch command loads
structures asyncronously by default, meaning that the next command structures asyncronously by default, meaning that the next command
skipping to change at line 1617 skipping to change at line 1622
return _self.load_model(obj, object, state) return _self.load_model(obj, object, state)
loadfunctions = { loadfunctions = {
'mae': incentive_format_not_available_func, 'mae': incentive_format_not_available_func,
'pdbml': 'pymol.lazyio:load_pdbml', 'pdbml': 'pymol.lazyio:load_pdbml',
'cml': 'pymol.lazyio:load_cml', 'cml': 'pymol.lazyio:load_cml',
'mtz': load_mtz, 'mtz': load_mtz,
'py': lambda filename, _self: _self.do("_ run %s" % filename), 'py': lambda filename, _self: _self.do("_ run %s" % filename),
'pml': lambda filename, _self: _self.do("_ @%s" % filename), 'pml': lambda filename, _self: _self.do("_ @%s" % filename),
'pwg': _processPWG, 'pwg': _processPWG,
'aln': _processALN, 'aln': 'pymol.seqalign:load_aln_multi',
'fasta': _processFASTA, 'fasta': _processFASTA,
'png': 'pymol.viewing:load_png', 'png': 'pymol.viewing:load_png',
'idx': load_idx, 'idx': load_idx,
'pse': load_pse, 'pse': load_pse,
'psw': load_pse, 'psw': load_pse,
'cex': 'pymol.m4x:readcex', 'cex': 'pymol.m4x:readcex',
'ply': load_ply, 'ply': load_ply,
'r3d': load_r3d, 'r3d': load_r3d,
'cc1': load_cc1, 'cc1': load_cc1,
'pdb': read_pdbstr, 'pdb': read_pdbstr,
 End of changes. 9 change blocks. 
11 lines changed or deleted 16 lines changed or added

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