示例#1
0

def _cv_kwargs_remapper(dct):
    kwargs = dct.pop('kwargs', {})
    dct.update(kwargs)
    return dct


# MDTraj-specific
MDTRAJ_CV_PLUGIN = CVCompilerPlugin(
    builder=Builder(
        'openpathsampling.experimental.storage.'
        'collective_variables.MDTrajFunctionCV',
        remapper=_cv_kwargs_remapper),
    parameters=[
        Parameter('topology', build_topology),
        Parameter('func',
                  AllowedPackageHandler('mdtraj'),
                  json_type='string',
                  description="MDTraj function, e.g., "
                  "``compute_distances``"),
        Parameter('kwargs',
                  lambda kwargs:
                  {key: custom_eval(arg)
                   for key, arg in kwargs.items()},
                  json_type='object',
                  default=None,
                  description="keyword arguments for ``func``"),
        Parameter('period_min',
                  custom_eval_float,
                  default=None,
from paths_cli.compiling.core import (
    InstanceCompilerPlugin, Builder, Parameter
)
from paths_cli.compiling.tools import custom_eval
from paths_cli.compiling.plugins import (
    NetworkCompilerPlugin, CategoryPlugin, InterfaceSetPlugin
)
from paths_cli.compiling.root_compiler import compiler_for
from paths_cli.compiling.json_type import (
    json_type_ref, json_type_list, json_type_eval
)


INITIAL_STATES_PARAM = Parameter(
    'initial_states', compiler_for('volume'),
    json_type=json_type_list(json_type_ref('volume')),
    description="initial states for this transition",
)


INITIAL_STATE_PARAM = Parameter(
    'initial_state', compiler_for('volume'),
    json_type=json_type_list(json_type_ref('volume')),
    description="initial state for this transition",
)


FINAL_STATES_PARAM = Parameter(
    'final_states', compiler_for('volume'),
    json_type=json_type_list(json_type_ref('volume')),
    description="final states for this transition",
示例#3
0
def _openmm_options(dct):
    n_steps_per_frame = dct.pop('n_steps_per_frame')
    n_frames_max = dct.pop('n_frames_max')
    options = {
        'n_steps_per_frame': n_steps_per_frame,
        'n_frames_max': n_frames_max
    }
    dct['options'] = options
    return dct


OPENMM_PARAMETERS = [
    Parameter('topology',
              build_topology,
              json_type='string',
              description=("File describing the topoplogy of this system; "
                           "PDB recommended")),
    Parameter('system',
              load_openmm_xml,
              json_type='string',
              description="XML file with the OpenMM system"),
    Parameter('integrator',
              load_openmm_xml,
              json_type='string',
              description="XML file with the OpenMM integrator"),
    Parameter('n_steps_per_frame',
              custom_eval_int_strict_pos,
              json_type=json_type_eval('IntStrictPos'),
              description="number of MD steps per saved frame"),
    Parameter("n_frames_max",
    builder = paths.CVDefinedVolume
    if cv.period_min is not None or cv.period_max is not None:
        builder = paths.PeriodicCVDefinedVolume
        dct['period_min'] = cv.period_min
        dct['period_max'] = cv.period_max

    dct['collectivevariable'] = dct.pop('cv')
    # TODO: wrap this with some logging
    return builder(**dct)


CV_VOLUME_PLUGIN = VolumeCompilerPlugin(
    builder=cv_volume_build_func,
    parameters=[
        Parameter('cv',
                  compiler_for('cv'),
                  json_type=json_type_ref('cv'),
                  description="CV that defines this volume"),
        Parameter('lambda_min',
                  custom_eval_float,
                  json_type=json_type_eval("Float"),
                  description="Lower bound for this volume"),
        Parameter('lambda_max',
                  custom_eval_float,
                  json_type=json_type_eval("Float"),
                  description="Upper bound for this volume")
    ],
    description=("A volume defined by an allowed range of values for the "
                 "given CV."),
    name='cv-volume',
)
示例#5
0
def _group_parameter(group_name):
    return Parameter('group',
                     str,
                     json_type="string",
                     default=group_name,
                     description="the group name for these movers")
示例#6
0
def _strategy_name(class_name):
    return f"openpathsampling.strategies.{class_name}"


def _group_parameter(group_name):
    return Parameter('group',
                     str,
                     json_type="string",
                     default=group_name,
                     description="the group name for these movers")


# TODO: maybe this moves into shooting once we have the metadata?

ENGINE_PARAMETER = Parameter('engine',
                             compiler_for('engine'),
                             json_type=json_type_ref('engine'),
                             description="the engine for moves of this type")

SHOOTING_GROUP_PARAMETER = _group_parameter('shooting')
REPEX_GROUP_PARAMETER = _group_parameter('repex')
MINUS_GROUP_PARAMETER = _group_parameter('minus')

REPLACE_TRUE_PARAMETER = Parameter(
    'replace',
    bool,
    json_type="bool",
    default=True,
    description=("whether this should replace existing objects (default "
                 "True)"))
REPLACE_FALSE_PARAMETER = Parameter(
    'replace',
示例#7
0
from paths_cli.compiling.core import (InstanceCompilerPlugin, CategoryCompiler,
                                      Builder, Parameter)
from paths_cli.compiling.root_compiler import compiler_for
from paths_cli.compiling.tools import custom_eval_float
from paths_cli.compiling.plugins import ShootingPointSelectorPlugin
from paths_cli.compiling.json_type import json_type_ref, json_type_eval

shooting_selector_compiler = compiler_for('shooting-point-selector')
SP_SELECTOR_PARAMETER = Parameter(
    'selector',
    compiler_for('shooting-point-selector'),
    default=None,
    json_type=json_type_ref('shooting-point-selector'),
    description="shooting point selection algorithm to use.",
)

build_uniform_selector = ShootingPointSelectorPlugin(
    builder=Builder('openpathsampling.UniformSelector'),
    parameters=[],
    name='uniform',
    description=("Uniform shooting point selection probability: all frames "
                 "have equal probability (endpoints excluded)."),
)


def _remapping_gaussian_stddev(dct):
    dct['alpha'] = 0.5 / dct.pop('stddev')**2
    dct['collectivevariable'] = dct.pop('cv')
    dct['l_0'] = dct.pop('mean')
    return dct