當前位置: 首頁>>代碼示例>>Python>>正文


Python SETTINGS.get方法代碼示例

本文整理匯總了Python中prody.SETTINGS.get方法的典型用法代碼示例。如果您正苦於以下問題:Python SETTINGS.get方法的具體用法?Python SETTINGS.get怎麽用?Python SETTINGS.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在prody.SETTINGS的用法示例。


在下文中一共展示了SETTINGS.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: pathPDBMirror

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def pathPDBMirror(path=None, format=None):
    """Returns or specify PDB mirror path to be used by :func:`.fetchPDB`.
    To release the current mirror, pass an invalid path, e.g. ``path=''``.
    If you are keeping a partial mirror, such as PDB files in
    :file:`/data/structures/divided/pdb/` folder, specify *format*, which is
    ``'pdb'`` in this case."""

    if path is None:
        path = SETTINGS.get('pdb_mirror_path')
        format = SETTINGS.get('pdb_mirror_format', None)
        if path:
            if isdir(path):
                if format is None:
                    return path
                else:
                    return path, format
            else:
                LOGGER.warning('PDB mirror path {0} is not a accessible.'
                               .format(repr(path)))
    else:
        if isdir(path):
            path = abspath(path)
            LOGGER.info('Local PDB mirror path is set: {0}'
                        .format(repr(path)))
            SETTINGS['pdb_mirror_path'] = path
            SETTINGS['pdb_mirror_format'] = format
            SETTINGS.save()
        else:
            current = SETTINGS.pop('pdb_mirror_path')
            if current:
                LOGGER.info('PDB mirror {0} is released.'
                            .format(repr(current)))
                SETTINGS.save()
            else:
                raise IOError('{0} is not a valid path.'.format(repr(path)))
開發者ID:sixpi,項目名稱:ProDy,代碼行數:37,代碼來源:localpdb.py

示例2: backupFile

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def backupFile(filename, backup=None, backup_ext='.BAK', **kwargs):
    """Rename *filename* with *backup_ext* appended to its name for backup
    purposes, if *backup* is **True** or if automatic backups is turned on
    using :func:`.confProDy`.  Default extension :file:`.BAK` is used when
    one is not set using :func:`.confProDy`.  If *filename* does not exist,
    no action will be taken and *filename* will be returned.  If file is
    successfully renamed, new filename will be returned."""

    try:
        exists = isfile(filename)
    except Exception as err:
        raise TypeError('filename must be a string ({0})'.format(str(err)))

    from prody import SETTINGS
    if exists and (backup or SETTINGS.get('backup', False)):
        if backup_ext == '.BAK':
            backup_ext = SETTINGS.get('backup_ext', '.BAK')
        bak = filename + backup_ext
        if isfile(bak):
            try:
                os.remove(bak)
            except Exception as err:
                pass
        try:
            os.rename(filename, bak)
        except Exception as err:
            pass
        return bak
    else:
        return filename
開發者ID:fongchun,項目名稱:ProDy,代碼行數:32,代碼來源:pathtools.py

示例3: updateDefinitions

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def updateDefinitions():
    """Update definitions and set some global variables.  This function must be
    called at the end of the module."""

    global DEFINITIONS, AMINOACIDS, BACKBONE, TIMESTAMP
    DEFINITIONS = {}
    user = SETTINGS.get('flag_definitions', {})
    
    # nucleics
    nucleic = set()
    for key in ['nucleobase', 'nucleoside', 'nucleotide']:
        aset = set(user.get(key, DEFAULTS[key]))
        nucleic.update(aset)
        DEFINITIONS[key] = aset
    DEFINITIONS['nucleic'] = nucleic
    
    # heteros
    for key in ['water', 'lipid', 'ion', 'sugar', 'heme', 
                 'at', 'cg', 'purine', 'pyrimidine',]:
        DEFINITIONS[key] = set(user.get(key, DEFAULTS[key]))
        
    DEFINITIONS['backbone'] = DEFINITIONS['bb'] = set(user.get(key, 
                                                           DEFAULTS['bb']))
    DEFINITIONS['backbonefull'] = DEFINITIONS['bbfull'] = set(user.get(key, 
                                                           DEFAULTS['bbfull']))

    # element regex
    for key in ['hydrogen', 'carbon', 'nitrogen', 'oxygen', 'sulfur']:
        DEFINITIONS[key] = recompile(user.get(key, DEFAULTS[key]))

    try:
        nonstd = SETTINGS[NONSTANDARD_KEY]
        
    except KeyError:
        nonstd = NONSTANDARD
        DEFINITIONS.update(CATEGORIZED)
    else:

        for cat in CATEGORIES:
            for key in CATEGORIES[cat]:
                DEFINITIONS[key] = set(DEFAULTS[key])

        DEFINITIONS['charged'] = set(DEFINITIONS['acidic'])
        DEFINITIONS['charged'].update(DEFINITIONS['basic'])

        for resi, props in nonstd.iteritems():
            for prop in props: 
                DEFINITIONS[prop].add(resi)

    DEFINITIONS['stdaa'] = DEFAULTS['stdaa']
    DEFINITIONS['nonstdaa'] = set(nonstd)
    AMINOACIDS = set(DEFINITIONS['stdaa'])
    AMINOACIDS.update(DEFINITIONS['nonstdaa'])
    DEFINITIONS['protein'] = DEFINITIONS['aminoacid'] = AMINOACIDS
    
    BACKBONE = DEFINITIONS['bb']

    global TIMESTAMP
    TIMESTAMP = SETTINGS.get('flag_timestamp', 0)
開發者ID:anindita85,項目名稱:ProDy,代碼行數:61,代碼來源:flags.py

示例4: getPDBLocalFolder

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def getPDBLocalFolder():
    """Return the path to a local PDB folder and folder structure specifier. 
    If a local folder is not set, **None** will be returned."""

    folder = SETTINGS.get('pdb_local_folder')
    if folder:
        if isdir(folder):
            return folder, SETTINGS.get('pdb_local_divided', True)
        else:
            LOGGER.warning('PDB local folder {0:s} is not a accessible.'
                           .format(repr(folder)))
開發者ID:anindita85,項目名稱:ProDy,代碼行數:13,代碼來源:localpdb.py

示例5: wwPDBServer

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def wwPDBServer(*key):
    """Set/get `wwPDB`_ FTP/HTTP server location used for downloading PDB
    structures.  Use one of the following keywords for setting a server:

    +---------------------------+-----------------------------+
    | wwPDB FTP server          | *Key* (case insensitive)    |
    +===========================+=============================+
    | RCSB PDB (USA) (default)  | RCSB, USA, US               |
    +---------------------------+-----------------------------+
    | PDBe (Europe)             | PDBe, Europe, Euro, EU      |
    +---------------------------+-----------------------------+
    | PDBj (Japan)              | PDBj, Japan, Jp             |
    +---------------------------+-----------------------------+

    .. _wwPDB: http://www.wwpdb.org/"""

    if not key:
        return SETTINGS.get('wwpdb', None)
    elif len(key) == 1:
        try:
            key = key[0].lower()
        except AttributeError:
            raise TypeError('key must be a string')
        if key in WWPDB_FTP_SERVERS:
            SETTINGS['wwpdb'] = key
            SETTINGS.save()
            LOGGER.info('wwPDB server is set to {}.'
                        .format(WWPDB_FTP_SERVERS[key][0]))
        else:
            raise ValueError('{0} is not a valid wwPDB server identifier'
                             .format(repr(key)))
    else:
        raise TypeError('one wwPDB server identifier is expected, {0} given'
                        .format(len(key)))
開發者ID:fongchun,項目名稱:ProDy,代碼行數:36,代碼來源:wwpdb.py

示例6: addNonstdAminoacid

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def addNonstdAminoacid(resname, *properties):
    """Add non-standard amino acid *resname* with *properties* selected from:
     
      * {props}
    
    >>> addNonstdAminoacid('PTR', 'acidic', 'aromatic', 'cyclic', 'large', 
    ... 'polar', 'surface')
    
    Default set of non-standard amino acids can be restored as follows:
    
    >>> flagDefinition(reset='nonstdaa')"""
    
    resname = str(resname)
    if len(resname) > 4:
        LOGGER.warn('Residue name {0:s} is unusually long.'
                    .format(repr(resname)))
    propset = set(properties)
    for cat, val in CATEGORIES.items():
        intersection = val.intersection(propset)
        if intersection:
            if len(intersection) > 1:
                raise ValueError('amino acid properties {0:s} cannot be '
                                   'present together'
                      .format(', '.join([repr(prp) for prp in intersection])))
            for prop in intersection:
                propset.remove(prop)
    if propset:
        raise ValueError('amino acid property {0:s} is not valid'
                           .format(repr(propset.pop())))
        
    nonstd = SETTINGS.get(NONSTANDARD_KEY, NONSTANDARD)
    nonstd[resname] = set(properties)
    updateNonstandard(nonstd)    
開發者ID:anindita85,項目名稱:ProDy,代碼行數:35,代碼來源:flags.py

示例7: changeDefinitions

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def changeDefinitions(**kwargs):
    
    defs = SETTINGS.get(DEFINITIONS_KEY, {})
    defs.update(kwargs)
    SETTINGS[DEFINITIONS_KEY] = defs
    SETTINGS[TIMESTAMP_KEY] = int(time())
    SETTINGS.save()
    updateDefinitions()
開發者ID:anindita85,項目名稱:ProDy,代碼行數:10,代碼來源:flags.py

示例8: pathPDBFolder

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def pathPDBFolder(folder=None, divided=False):
    """Returns or specify local PDB folder for storing PDB files downloaded from
    `wwPDB <http://www.wwpdb.org/>`_ servers.  Files stored in this folder can
    be accessed via :func:`.fetchPDB` from any working directory.  To release
    the current folder, pass an invalid path, e.g. ``folder=''``.

    If *divided* is **True**, the divided folder structure of wwPDB servers
    will be assumed when reading from and writing to the local folder.  For
    example, a structure with identifier **1XYZ** will be present as
    :file:`pdblocalfolder/yz/pdb1xyz.pdb.gz`.

    If *divided* is **False**, a plain folder structure will be expected and
    adopted when saving files.  For example, the same structure will be
    present as :file:`pdblocalfolder/1xyz.pdb.gz`.

    Finally, in either case, lower case letters will be used and compressed
    files will be stored."""

    if folder is None:
        folder = SETTINGS.get('pdb_local_folder')
        if folder:
            if isdir(folder):
                return folder, SETTINGS.get('pdb_local_divided', True)
            else:
                LOGGER.warn('PDB local folder {0} is not a accessible.'
                            .format(repr(folder)))
    else:
        if isdir(folder):
            folder = abspath(folder)
            LOGGER.info('Local PDB folder is set: {0}'.format(repr(folder)))
            if divided:
                LOGGER.info('wwPDB divided folder structure will be assumed.')
            else:
                LOGGER.info('A plain folder structure will be assumed.')
            SETTINGS['pdb_local_folder'] = folder
            SETTINGS['pdb_local_divided'] = bool(divided)
            SETTINGS.save()
        else:
            current = SETTINGS.pop('pdb_local_folder')
            if current:
                LOGGER.info('PDB folder {0} is released.'
                            .format(repr(current)))
                SETTINGS.pop('pdb_local_divided')
                SETTINGS.save()
            else:
                raise IOError('{0} is not a valid path.'.format(repr(folder)))
開發者ID:sixpi,項目名稱:ProDy,代碼行數:48,代碼來源:localpdb.py

示例9: pathVMD

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def pathVMD(*path):
    """Return VMD path, or set it to be a user specified *path*."""

    if not path:
        path = SETTINGS.get('vmd', None)
        if isExecutable(path):
            return path
        else:
            LOGGER.warning('VMD path is not set by user, looking for it.')

            vmdbin = None
            vmddir = None
            if PLATFORM == 'Windows':
                if PY3K:
                    import winreg
                else:
                    import _winreg as winreg  # PY3K: OK
                for vmdversion in ('1.8.7', '1.9', '1.9.1'):
                    try:
                        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                                'Software\\University of Illinois\\VMD\\' +
                                vmdversion)
                        vmddir = winreg.QueryValueEx(key, 'VMDDIR')[0]
                        vmdbin = join(vmddir, 'vmd.exe')
                    except:
                        pass
                    try:
                        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                    'Software\\WOW6432node\\University of Illinois\\VMD\\' +
                    vmdversion)
                        vmddir = winreg.QueryValueEx(key, 'VMDDIR')[0]
                        vmdbin = join(vmddir, 'vmd.exe')
                    except:
                        pass
            else:
                vmdbin = which('vmd')
                if False:
                    pipe = os.popen('which vmd')
                    vmdbin = pipe.next().strip()
                    vmdfile = open(vmdbin)
                    for line in vmdfile:
                        if line.startswith('defaultvmddir='):
                            vmddir = line.split('=')[1].replace('"', '')
                            break
                    vmdfile.close()
            if isExecutable(vmdbin):
                setVMDpath(vmdbin)
                return vmdbin
    elif len(path) == 1:
        path = path[0]
        if isExecutable(path):
            SETTINGS['vmd'] = path
            SETTINGS.save()
            LOGGER.info("VMD path is set to '{0}'.".format(path))
        else:
            raise OSError('{0} is not executable.'.format(str(path)))
    else:
        raise ValueError('specify a single path string')
開發者ID:barettog1,項目名稱:ProDy,代碼行數:60,代碼來源:nmdfile.py

示例10: getVMDpath

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def getVMDpath():
    """Return VMD path set by user or one identified automatically."""

    path = SETTINGS.get("vmd", None)
    if isExecutable(path):
        return path
    else:
        LOGGER.warning("VMD path is not set by user, looking for it.")

        from types import StringType, UnicodeType

        vmdbin = None
        vmddir = None
        if PLATFORM == "Windows":
            import _winreg

            for vmdversion in ("1.8.7", "1.9", "1.9.1"):
                try:
                    key = _winreg.OpenKey(
                        _winreg.HKEY_LOCAL_MACHINE, "Software\\University of Illinois\\VMD\\" + vmdversion
                    )
                    vmddir = _winreg.QueryValueEx(key, "VMDDIR")[0]
                    vmdbin = os.path.join(vmddir, "vmd.exe")
                except:
                    pass
                try:
                    key = _winreg.OpenKey(
                        _winreg.HKEY_LOCAL_MACHINE, "Software\\WOW6432node\\University of Illinois\\VMD\\" + vmdversion
                    )
                    vmddir = _winreg.QueryValueEx(key, "VMDDIR")[0]
                    vmdbin = os.path.join(vmddir, "vmd.exe")
                except:
                    pass
        else:
            vmdbin = which("vmd")
            if False:
                pipe = os.popen("which vmd")
                vmdbin = pipe.next().strip()
                vmdfile = open(vmdbin)
                for line in vmdfile:
                    if line.startswith("defaultvmddir="):
                        vmddir = line.split("=")[1].replace('"', "")
                        break
                vmdfile.close()
        if (
            False
            and isinstance(vmdbin, (StringType, UnicodeType))
            and isinstance(vmddir, (StringType, UnicodeType))
            and os.path.isfile(vmdbin)
            and os.path.isdir(vmddir)
        ):
            pass  # return vmdbin, vmddir
        if isExecutable(vmdbin):
            setVMDpath(vmdbin)
            return vmdbin
開發者ID:anindita85,項目名稱:ProDy,代碼行數:57,代碼來源:functions.py

示例11: getPDBMirrorPath

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def getPDBMirrorPath():
    """Return the path to a local PDB mirror, or **None** if a mirror path is 
    not set."""

    path = SETTINGS.get('pdb_mirror_path')
    if path:
        if isdir(path):
            return path
        else:
            LOGGER.warning('PDB mirror path {0:s} is not a accessible.'
                           .format(repr(path)))
開發者ID:anindita85,項目名稱:ProDy,代碼行數:13,代碼來源:localpdb.py

示例12: getNonstdProperties

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def getNonstdProperties(resname):
    """Return properties of non-standard amino acid *resname*.
    
    >>> getNonstdProperties('PTR')
    ['acidic', 'aromatic', 'cyclic', 'large', 'polar', 'surface']"""
    
    try:
        alist = list(SETTINGS.get(NONSTANDARD_KEY, NONSTANDARD)[resname])
    except KeyError:
        raise ValueError('{0:s} is not a non-standard residue name'
                           .format(repr(resname)))
    else:
        alist.sort()
        return alist
開發者ID:anindita85,項目名稱:ProDy,代碼行數:16,代碼來源:flags.py

示例13: listNonstdAAProps

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def listNonstdAAProps(resname):
    """Returns properties of non-standard amino acid *resname*.

    .. ipython:: python

       listNonstdAAProps('PTR')"""

    try:
        alist = list(SETTINGS.get(NONSTANDARD_KEY, NONSTANDARD)[resname])
    except KeyError:
        raise ValueError('{0} is not a non-standard residue name'
                         .format(repr(resname)))
    else:
        alist.sort()
        return alist
開發者ID:fongchun,項目名稱:ProDy,代碼行數:17,代碼來源:flags.py

示例14: getWWPDBFTPServer

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def getWWPDBFTPServer():
    """Return a tuple containing name, host, and path of the currently 
    set `wwPDB <http://www.wwpdb.org/>`_ FTP server."""
    
    server = SETTINGS.get('wwpdb_ftp', None)
    if server is None:
        LOGGER.warning('A wwPDB FTP server is not set, default FTP server '
                       'RCSB PDB is used. Use `setWWPDBFTPServer` function '
                       'to set a server close to your location.')
        return _WWPDB_RCSB
    else:
        if server[2].endswith('data/structures/divided/pdb/'):
            return (server[0], server[1], 
                    server[2][:-len('data/structures/divided/pdb/')])
        else:
            return server
開發者ID:anindita85,項目名稱:ProDy,代碼行數:18,代碼來源:wwpdbftp.py

示例15: delNonstdAminoacid

# 需要導入模塊: from prody import SETTINGS [as 別名]
# 或者: from prody.SETTINGS import get [as 別名]
def delNonstdAminoacid(resname):
    """Delete non-standard amino acid *resname*.
    
    >>> delNonstdAminoacid('PTR')
    >>> flagDefinition('nonstdaa') # doctest: +ELLIPSIS
    ['ASX', 'CSO', 'GLX', ..., 'TPO', 'XAA', 'XLE']
    
    Default set of non-standard amino acids can be restored as follows:
    
    >>> flagDefinition(reset='nonstdaa')"""
    
    
    nonstd = SETTINGS.get(NONSTANDARD_KEY, NONSTANDARD)
    try:
        nonstd.pop(resname)
    except KeyError:
        raise ValueError('{0:s} is not a non-standard residue name'
                           .format(repr(resname)))
    else:
        updateNonstandard(nonstd)
開發者ID:anindita85,項目名稱:ProDy,代碼行數:22,代碼來源:flags.py


注:本文中的prody.SETTINGS.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。