Source code for schrodinger.application.desmond.stage.deprecate

"""
Various multisim concrete stage classes.

Copyright Schrodinger, LLC. All rights reserved.

"""
import warnings

from schrodinger.application.desmond import cmj

from . import fep_mapper

__all__ = [
    'ForcefieldBuilder',
    'SolvatePocket',
    'AlignCore',
    'FepMapping',
]

# These classes have been renamed
FepMapping = fep_mapper.FepMapper
FepProteinMapper = fep_mapper.ProteinFepMapper
LeadOptMap = fep_mapper.FepMapper


[docs]class RemovedStageError(Exception): pass
[docs]class MustSkip(cmj.StageBase): """ This stage functionality is no longer supported and cannot be executed (ie must be skipped or be before the restore point in a checkpoint) """ # abstract class should not have a name so it cannot be instantiated # directly and should not inherit parent name or it will overwrite parent # class in `stage_cls` dict NAME = None
[docs] def migrate_param(self, param): """ Because the original class is removed, any non-base class params will result in errors on parsing, even though they will not be used as the class is never executed. To fix this we remove any param attributes not defined in `cmj.StageBase`, excepting protected fields. `param.should_skip must be false if the stage is executed, which is verified in `self.crunch`. :param param: a param corresponding to this stage class to migrate """ # this doesn't recursively delete. For the existing stages this seems # fine, but it may need to be updated if new stages change existing # base class parameters to maps. for key in param: if (key not in ("__CLS__", "__NAME__") and key not in self.PARAM.VALIDATE): del param[key] # always warn for deprecated stage warnings.warn( DeprecationWarning( f"The '{self.NAME}' stage is deprecated and will be removed " f"entirely in a future release"))
[docs] def crunch(self): if not self.param.should_skip: # only raise error if executed raise RemovedStageError( f"The '{self.NAME}' stage functionality is no longer supported." f"For backwards compatibility it is allowed only if " f"`param.should_skip`=True")
[docs]class ForcefieldBuilder(MustSkip): NAME = "ffbuilder"
[docs]class AlignCore(MustSkip): NAME = "align_core"
[docs]class SolvatePocket(MustSkip): NAME = "solvate_pocket"