Ticket #1972: mmcif__init__.py.diff

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

Added by email2trac

  • src/bundles/mmcif/src/__init__.py

    diff --git a/src/bundles/mmcif/src/__init__.py b/src/bundles/mmcif/src/__init__.py
    index e68440e..7142686 100644
    a b from .mmcif import (  
    2121
    2222from chimerax.core.toolshed import BundleAPI
    2323
     24def _fetch_wrapper_dummy(fetch_func):
     25    def fetch(session, pdb_id, fetch_source='rcsb', ignore_cache=False,
     26            structure_factors=False, over_sampling=1.5, **kw):
     27        if structure_factors:
     28            from chimerax.core.errors import UserError
     29            raise UserError('Loading structure factors requires the ChimeraX-Clipper plugin '
     30                'available from the Tool Shed.')
     31        return fetch_func(session, pdb_id, ignore_cache=ignore_cache, **kw)
     32    return fetch
     33
    2434
    2535class _PDBioAPI(BundleAPI):
    2636
    class _PDBioAPI(BundleAPI):  
    4252            from chimerax.core.errors import UserError
    4353            raise UserError("Unknown database for fetching mmCIF: '%s'.  Known databases are: %s"
    4454                            % (database_name, ", ".join(list(fetchers.keys()))))
    45         return fetcher(session, identifier, ignore_cache=ignore_cache, **kw)
     55        try:
     56            from chimerax.clipper.io import fetch_cif
     57            return fetch_cif.fetch_wrapper(fetcher)(session, identifier, ignore_cache=ignore_cache, **kw)
     58        except ImportError:
     59            return _fetch_wrapper_dummy(fetcher)(session, identifier, ignore_cache=ignore_cache, **kw)
    4660
    4761    @staticmethod
    4862    def open_file(session, path, file_name, *, auto_style=True, coordsets=False, atomic=True,
    49                   max_models=None, log_info=True, combine_sym_atoms=True):
     63                  max_models=None, log_info=True, combine_sym_atoms=True,
     64                  structure_factors=False, over_sampling=None):
    5065        # 'open_file' is called by session code to open a file
    5166        # returns (list of models, status message)
     67        if structure_factors or over_sampling:
     68            from chimerax.core.errors import UserError
     69            raise UserError('structureFactors and overSampling arguments are only '
     70                'valid when fetching models from an online database.')
     71
    5272        from . import mmcif
    5373        return mmcif.open_mmcif(session, path, file_name, auto_style=auto_style,
    5474                                coordsets=coordsets, atomic=atomic, max_models=max_models,