Ticket #1972: pdb__init__.py.diff

File pdb__init__.py.diff, 2.4 KB (added by tic20@…, 6 years ago)

Added by email2trac

  • src/bundles/pdb/src/__init__.py

    diff --git a/src/bundles/pdb/src/__init__.py b/src/bundles/pdb/src/__init__.py
    index af759f8..7a83083 100644
    a b from .pdb import process_chem_name, format_nonstd_res_info  
    1717
    1818from chimerax.core.toolshed import BundleAPI
    1919
     20def _fetch_wrapper_dummy(fetch_func):
     21    def fetch(session, pdb_id, fetch_source='rcsb', ignore_cache=False,
     22            structure_factors=False, over_sampling=1.5, **kw):
     23        if structure_factors:
     24            from chimerax.core.errors import UserError
     25            raise UserError('Loading structure factors requires the ChimeraX-Clipper plugin '
     26                'available from the Tool Shed.')
     27        return fetch_func(session, pdb_id, ignore_cache=ignore_cache, **kw)
     28    return fetch
     29
    2030class _PDBioAPI(BundleAPI):
    2131
    2232    from chimerax.core.commands import EnumOf
    class _PDBioAPI(BundleAPI):  
    2939        # returns (list of models, status message)
    3040        from . import pdb
    3141        fetcher = pdb.fetch_pdb_pdbe if database_name == "pdbe" else pdb.fetch_pdb
    32         return fetcher(session, identifier, ignore_cache=ignore_cache, **kw)
     42        try:
     43            from chimerax.clipper.io import fetch_cif
     44            return fetch_cif.fetch_wrapper(fetcher)(session, identifier, ignore_cache=ignore_cache, **kw)
     45        except ImportError:
     46            return _fetch_wrapper_dummy(fetcher)(session, identifier, ignore_cache=ignore_cache, **kw)
     47
     48        # return fetcher(session, identifier, ignore_cache=ignore_cache, **kw)
    3349
    3450    @staticmethod
    3551    def open_file(session, stream, file_name, *, auto_style=True, coordsets=False, atomic=True,
    36              max_models=None, log_info=True, combine_sym_atoms=True):
     52             max_models=None, log_info=True, combine_sym_atoms=True,
     53             structure_factors=False, over_sampling=None):
    3754        # 'open_file' is called by session code to open a file
    3855        # returns (list of models, status message)
     56        if structure_factors or over_sampling:
     57            from chimerax.core.errors import UserError
     58            raise UserError('structureFactors and overSampling arguments are only '
     59                'valid when fetching models from an online database.')
    3960        from . import pdb
    4061        return pdb.open_pdb(session, stream, file_name, auto_style=auto_style,
    4162            coordsets=coordsets, atomic=atomic, max_models=max_models, log_info=log_info,