Пример #1
0
def run_molecules(ENGINE,
                  rang=5,
                  recur=100,
                  refine=False,
                  explore=True,
                  exportPdb=False,
                  xyzFrequency=500):
    ENGINE.set_groups_as_molecules()
    [
        g.set_move_generator(
            MoveGeneratorCollector(collection=[
                TranslationGenerator(amplitude=0.2),
                RotationGenerator(amplitude=2)
            ],
                                   randomize=True)) for g in ENGINE.groups
    ]
    # number of steps
    nsteps = 20 * len(ENGINE.groups)
    # set selector
    gs = RecursiveGroupSelector(RandomSelector(ENGINE),
                                recur=recur,
                                refine=refine,
                                explore=explore)
    ENGINE.set_group_selector(gs)
    for stepIdx in range(rang):
        LOGGER.info("Running 'molecules' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps,
                   saveFrequency=nsteps,
                   xyzFrequency=xyzFrequency,
                   xyzPath="moleculeTraj.xyz",
                   restartPdb=None)
Пример #2
0
def normal_run():
    LOGGER.force_log("info",
                     "normal selection %i started... DON'T INTERRUPT" %
                     numberOfSteps,
                     stdout=True,
                     file=False)
    # load fresh engine
    engine = create_engine()
    # delete existing log files
    normalLogs = [
        fn for fn in next(os.walk("."))[2]
        if ".log" in fn and normalSelLog in fn
    ]
    [os.remove(l) for l in normalLogs]
    # set log file name
    LOGGER.set_log_file_basename(normalSelLog)
    # set random group selector
    engine.set_group_selector(RandomSelector(engine))
    # run engine
    engine.run(numberOfSteps=numberOfSteps,
               saveFrequency=2 * numberOfSteps,
               restartPdb=None)
    LOGGER.force_log("info",
                     "normal selection finished",
                     stdout=True,
                     file=False)
Пример #3
0
def angles_HCH(ENGINE, rang=5, recur=10, refine=False, explore=True):
    groups = []
    for idx in range(0, ENGINE.pdb.numberOfAtoms, 13):
        groups.append(np.array([idx + 1, idx + 2, idx + 3],
                               dtype=np.int32))  # H11-C1-H12
        groups.append(np.array([idx + 4, idx + 5, idx + 6],
                               dtype=np.int32))  # H21-C2-H22
        groups.append(np.array([idx + 7, idx + 8, idx + 9],
                               dtype=np.int32))  # H31-C3-H32
        groups.append(np.array([idx + 10, idx + 11, idx + 12],
                               dtype=np.int32))  # H41-C4-H42
    ENGINE.set_groups(groups)
    [
        g.set_move_generator(AngleAgitationGenerator(amplitude=5))
        for g in ENGINE.groups
    ]
    # set selector
    if refine or explore:
        gs = RecursiveGroupSelector(RandomSelector(ENGINE),
                                    recur=recur,
                                    refine=refine,
                                    explore=explore)
        ENGINE.set_group_selector(gs)
    # number of steps
    nsteps = recur * len(ENGINE.groups)
    for stepIdx in range(rang):
        LOGGER.info("Running 'angles_HCH' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
Пример #4
0
def refine(ENGINE, nsteps=1000, rang=5):
    # create group of single molecule
    ENGINE.set_groups_as_molecules()
    ENGINE.set_groups(ENGINE.groups[0])
    # set move generator
    [g.set_move_generator( MoveGeneratorCollector(collection=[TranslationGenerator(amplitude=2),RotationGenerator(amplitude=45)],randomize=True) ) for g in ENGINE.groups]
    # set selector
    recur = nsteps
    gs = RecursiveGroupSelector(RandomSelector(ENGINE), recur=recur, refine=True, explore=False)
    # run
    for step in range(rang):
        ENGINE.run(numberOfSteps=nsteps, saveFrequency=2*nsteps)  
Пример #5
0
def atoms(ENGINE, rang=30, recur=20, refine=False, explore=True):
    ENGINE.set_groups_as_atoms()
    # set selector
    if refine or explore:
        gs = RecursiveGroupSelector(RandomSelector(ENGINE),
                                    recur=recur,
                                    refine=refine,
                                    explore=explore)
        ENGINE.set_group_selector(gs)
    # number of steps
    nsteps = recur * len(ENGINE.groups)
    for stepIdx in range(rang):
        LOGGER.info("Running 'atoms' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
Пример #6
0
def run_atoms(ENGINE, rang=None, recur=None, xyzFrequency=500):
    ENGINE.set_groups(None)
    # set selector
    if recur is None: recur = 10
    ENGINE.set_group_selector(RandomSelector(ENGINE))
    # number of steps
    nsteps = recur * len(ENGINE.groups)
    if rang is None: rang = 20
    for stepIdx in range(rang):
        LOGGER.info("Running 'atoms' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps,
                   saveFrequency=nsteps,
                   xyzFrequency=xyzFrequency,
                   xyzPath="atomsTraj.xyz",
                   restartPdb=None)
Пример #7
0
def run_recurring_atoms(ENGINE,
                        rang=None,
                        recur=None,
                        explore=True,
                        refine=False,
                        xyzFrequency=500):
    ENGINE.set_groups(None)
    # set selector
    if recur is None: recur = 10
    gs = RecursiveGroupSelector(RandomSelector(ENGINE),
                                recur=recur,
                                refine=refine,
                                explore=explore)
    ENGINE.set_group_selector(gs)
    # number of steps
    nsteps = recur * len(ENGINE.groups)
    if rang is None: rang = 20
    for stepIdx in range(rang):
        LOGGER.info("Running 'explore' mode step %i" % (stepIdx))
        if explore:
            ENGINE.run(numberOfSteps=nsteps,
                       saveFrequency=nsteps,
                       xyzFrequency=xyzFrequency,
                       xyzPath="exploreTraj.xyz",
                       restartPdb=None)
        elif refine:
            ENGINE.run(numberOfSteps=nsteps,
                       saveFrequency=nsteps,
                       xyzFrequency=xyzFrequency,
                       xyzPath="refineTraj.xyz",
                       restartPdb=None)
        else:
            ENGINE.run(numberOfSteps=nsteps,
                       saveFrequency=nsteps,
                       xyzFrequency=xyzFrequency,
                       xyzPath="recurTraj.xyz",
                       restartPdb=None)
Пример #8
0
def atoms_type(ENGINE,
               type='C',
               rang=30,
               recur=20,
               refine=False,
               explore=True):
    allElements = ENGINE.allElements
    groups = []
    for idx, el in enumerate(allElements):
        if el == type:
            groups.append([idx])
    ENGINE.set_groups(groups)
    # set selector
    if refine or explore:
        gs = RecursiveGroupSelector(RandomSelector(ENGINE),
                                    recur=recur,
                                    refine=refine,
                                    explore=explore)
        ENGINE.set_group_selector(gs)
    # number of steps
    nsteps = recur * len(ENGINE.groups)
    for stepIdx in range(rang):
        LOGGER.info("Running 'atoms' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
Пример #9
0
    # set groups as all atoms
    ENGINE.set_groups_as_atoms()
    LOGGER.info("@%s Setting groups as atoms (%i)"%(fname, len(ENGINE.groups)))

# run all frames as a mixture system of all subframes
WM.run_dependant(nCycle=10000, firstNAccepted=1, numberOfSteps=100, subframesWeight=None, normalize=1, driftTolerance=1)
WM.run_dependant(nCycle=10000, firstNAccepted=1, numberOfSteps=100, subframesWeight=10,   normalize=1, driftTolerance=1)


################################################################################
################## MOVE ALL ATOMS IN ALL FRAMES SYNCHRONOUSLY ##################
RECUR = 200
for sf in ENGINE.frames[multiframe]['frames_name']:
    fname = os.path.join(multiframe, sf)
    ENGINE.set_used_frame(fname)
    # set groups as all atoms
    ENGINE.set_groups_as_atoms()
    # create recurring random selector to explore
    gs = RecursiveGroupSelector(RandomSelector(ENGINE), recur=RECUR, refine=False, explore=True)
    ENGINE.set_group_selector(gs)
    LOGGER.info("@%s Setting groups as atoms (%i)"%(fname, len(ENGINE.groups)))

# run all frames as a mixture system of all subframes
WM.run_dependant(nCycle=10000, firstNAccepted=1, numberOfSteps=RECUR, saveFrequency=10, cycleTimeout=900)



################################################################################
################################  CALL plot.py  ################################
os.system("%s %s"%(sys.executable, os.path.join(DIR_PATH, 'plot.py')))
Пример #10
0
def run_explore(recur=50, saveFreq=10000, ncores=1):
    gs = RecursiveGroupSelector(RandomSelector(ENGINE), recur=recur, refine=False, explore=True)
    ENGINE.set_group_selector(gs)
     # number of steps
    nsteps = recur*len(ENGINE.groups)
    ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps, ncores=ncores, restartPdb=None)