Пример #1
0
def LUTE_GMECFinder(confSpace,
                    model,
                    pmat,
                    confLog=useJavaDefault,
                    printIntermediateConfs=useJavaDefault):
    '''
	:java:classdoc:`.lute.LUTEGMECFinder`

	:param confSpace: The conformation space
	:type confSpace: :java:ref:`.confspace.SimpleConfSpace`
	:param model: The LUTE model
	:type model: :java:ref:`.lute.LUTEState`
	:param pmat: The pruning matrix from the LUTE training calculation.
	:type pmat: :java:ref:`.pruning.PruningMatrix`
	:param str confLog: Path to file where conformations found during conformation space search should be logged.
	:builder_option printIntermediateConfs .gmec.SimpleGMECFinder$Builder#printIntermediateConfsToConsole:

	:rtype: :java:ref:`.lute.LUTEGMECFinder`
	'''

    builder = _get_builder(c.lute.LUTEGMECFinder)(pmat,
                                                  LUTE_ConfEnergyCalculator(
                                                      confSpace, model))

    if confLog is not useJavaDefault:
        logFile = jvm.toFile(confLog)
        builder.setLogPrinter(c.gmec.LoggingConfPrinter(logFile))

    if printIntermediateConfs is not useJavaDefault:
        builder.setPrintIntermediateConfsToConsole(printIntermediateConfs)

    return builder.build()
Пример #2
0
def DEE(confSpace,
        emat,
        singlesThreshold=useJavaDefault,
        pairsThreshold=useJavaDefault,
        singlesGoldsteinDiffThreshold=useJavaDefault,
        pairsGoldsteinDiffThreshold=useJavaDefault,
        triplesGoldsteinDiffThreshold=useJavaDefault,
        typeDependent=useJavaDefault,
        numIterations=useJavaDefault,
        showProgress=useJavaDefault,
        parallelism=useJavaDefault,
        cacheFile=useJavaDefault):
    '''
	:java:classdoc:`.pruning.SimpleDEE$Runner`

	:param confSpace: The design conformation space
	:type confSpace: :java:ref:`.confspace.SimpleConfSpace`
	:param emat: An energy matrix computed for the conformation space
	:type emat: :java:ref:`.ematrix.EnergyMatrix`

	:builder_option singlesThreshold .pruning.SimpleDEE$Runner#singlesThreshold:
	:builder_option pairsThreshold .pruning.SimpleDEE$Runner#pairsThreshold:
	:builder_option singlesGoldsteinDiffThreshold .pruning.SimpleDEE$Runner#singlesGoldsteinDiffThreshold:
	:builder_option pairsGoldsteinDiffThreshold .pruning.SimpleDEE$Runner#pairsGoldsteinDiffThreshold:
	:builder_option triplesGoldsteinDiffThreshold .pruning.SimpleDEE$Runner#triplesGoldsteinDiffThreshold:
	:builder_option typeDependent .pruning.SimpleDEE$Runner#typeDependent:
	:builder_option numIterations .pruning.SimpleDEE$Runner#numIterations:
	:builder_option showProgress .pruning.SimpleDEE$Runner#showProgress:
	'''

    runner = _get_builder(c.pruning.SimpleDEE, 'Runner')()

    if singlesThreshold is not useJavaDefault:
        runner.setSinglesThreshold(jvm.boxDouble(singlesThreshold))
    if pairsThreshold is not useJavaDefault:
        runner.setPairsThreshold(jvm.boxDouble(pairsThreshold))
    if singlesGoldsteinDiffThreshold is not useJavaDefault:
        runner.setSinglesGoldsteinDiffThreshold(
            jvm.boxDouble(singlesGoldsteinDiffThreshold))
    if pairsGoldsteinDiffThreshold is not useJavaDefault:
        runner.setPairsGoldsteinDiffThreshold(
            jvm.boxDouble(pairsGoldsteinDiffThreshold))
    if triplesGoldsteinDiffThreshold is not useJavaDefault:
        runner.setTriplesGoldsteinDiffThreshold(
            jvm.boxDouble(triplesGoldsteinDiffThreshold))
    if typeDependent is not useJavaDefault:
        runner.setTypeDependent(typeDependent)
    if numIterations is not useJavaDefault:
        runner.setNumIterations(numIterations)
    if showProgress is not useJavaDefault:
        runner.setShowProgress(showProgress)
    if parallelism is not useJavaDefault:
        runner.setParallelism(parallelism)
    if cacheFile is not useJavaDefault:
        runner.setCacheFile(jvm.toFile(cacheFile))

    return runner.run(confSpace, emat)
Пример #3
0
def LUTE_train(confEcalc,
               emat,
               pmat,
               maxRMSE=0.1,
               maxOverfittingScore=1.5,
               randomSeed=12345,
               confDBPath=None):
    '''
	Trains a LUTE model

	For examples using LUTE, see examples/python.GMEC/LUTE.*.py and examples/python.KStar/LUTE.*.py in your Osprey distribution.

	:param confEcalc: The conformation energy calculator
	:type confEcalc: :java:ref:`.energy.ConfEnergyCalculator`
	:param emat: An energy matrix
	:type emat: :java:ref:`.ematrix.EnergyMatrix`
	:param pmat: A pruning matrix, resulting from DEE
	:type pmat: :java:ref:`.pruning.PruningMatrix`

	:param float maxRMSE: The maximum tolerable fit RMS error
	:param float maxOverfittingScore: The maximum tolerable amount of overfitting (score = training set RMSE / test set RMSE)
	:param int randomSeed: Random seed to use for conformation sampling
	:param str confDBPath: Path to write/read confDB file, or None to omit saving the confDB to disk

	:returns: The LUTE model
	:rtype: :java:ref:`.lute.LUTEState`
	'''

    confSpace = confEcalc.confSpace

    # make a conf DB, saved to a file if needed
    if confDBPath is None:
        confDB = c.confspace.ConfDB(confSpace)
    else:
        confDB = c.confspace.ConfDB(confSpace, jvm.toFile(confDBPath))

    try:

        # make a conf table for LUTE
        confTable = jvm.getInnerClass(c.confspace.ConfDB, 'ConfTable')(confDB,
                                                                       'LUTE')

        # use the OLSCG fitter for LUTE (it's a little faster than LASSO in practice)
        fitter = jvm.getInnerClass(c.lute.LUTE, 'Fitter').OLSCG

        # train LUTE
        lute = c.lute.LUTE(confSpace)
        sampler = c.lute.UniformConfSampler(confSpace, pmat, randomSeed)
        lute.sampleTuplesAndFit(confEcalc, emat, pmat, confTable, sampler,
                                fitter, maxOverfittingScore, maxRMSE)
        lute.reportConfSpaceSize(pmat)

        # return the LUTE fit
        return c.lute.LUTEState(lute.getTrainingSystem())

    finally:
        confDB.close()
Пример #4
0
def GMECFinder(astar,
               confEcalc,
               confLog=None,
               printIntermediateConfs=None,
               useExternalMemory=None,
               resumeLog=None,
               confDBFile=None):
    '''
	:java:classdoc:`.gmec.SimpleGMECFinder`

	:builder_option astar .gmec.SimpleGMECFinder$Builder#search:

		Use one of :py:func:`AStarTraditional` or :py:func:`AStarMPLP` to get an A* implementation.

	:builder_option confEcalc .gmec.SimpleGMECFinder$Builder#confEcalc:

		Use :py:func:`ConfEnergyCalculator` to get a conformation energy calculator.

	:param str confLog: Path to file where conformations found during conformation space search should be logged.
	:builder_option printIntermediateConfs .gmec.SimpleGMECFinder$Builder#printIntermediateConfsToConsole:
	:builder_option useExternalMemory .gmec.SimpleGMECFinder$Builder#useExternalMemory:
	:param str resumeLog: Path to log file where resume info will be written or read, so designs can be resumed.
	:builder_return .gmec.SimpleGMECFinder$Builder:
	'''

    builder = _get_builder(c.gmec.SimpleGMECFinder)(astar, confEcalc)

    if confLog is not None:
        logFile = jvm.toFile(confLog)
        builder.setLogPrinter(c.gmec.LoggingConfPrinter(logFile))

    if printIntermediateConfs is not None:
        builder.setPrintIntermediateConfsToConsole(printIntermediateConfs)

    if useExternalMemory == True:
        builder.useExternalMemory()

    if resumeLog is not None:
        builder.setResumeLog(jvm.toFile(resumeLog))

    if confDBFile is not None:
        builder.setConfDB(jvm.toFile(confDBFile))

    return builder.build()
Пример #5
0
def DEE_read(confSpace, path):
    '''
	Reads a pruning matrix from a file

	:param confSpace: The design conformation space
	:type confSpace: :java:ref:`.confspace.SimpleConfSpace`
	:param str path: Path to the file
	'''

    return c.pruning.SimpleDEE.read(confSpace, jvm.toFile(path))
Пример #6
0
def KStar(proteinConfSpace,
          ligandConfSpace,
          complexConfSpace,
          epsilon=useJavaDefault,
          stabilityThreshold=useJavaDefault,
          maxSimultaneousMutations=useJavaDefault,
          writeSequencesToConsole=False,
          writeSequencesToFile=None,
          useExternalMemory=useJavaDefault,
          showPfuncProgress=useJavaDefault):
    '''
	:java:classdoc:`.kstar.KStar`

	For examples using K*, see the examples/python.KStar directory in your Osprey distribution.

	:param proteinConfSpace: :java:fielddoc:`.kstar.KStar#protein`
	:type proteinConfSpace: :java:ref:`.confspace.SimpleConfSpace`
	:param ligandConfSpace: :java:fielddoc:`.kstar.KStar#ligand`
	:type ligandConfSpace: :java:ref:`.confspace.SimpleConfSpace`
	:param complexConfSpace: :java:fielddoc:`.kstar.KStar#complex`
	:type complexConfSpace: :java:ref:`.confspace.SimpleConfSpace`
	:builder_option epsilon .kstar.KStar$Settings$Builder#epsilon:
	:builder_option stabilityThreshold .kstar.KStar$Settings$Builder#stabilityThreshold:
	:builder_option maxSimultaneousMutations .kstar.KStar$Settings$Builder#maxSimultaneousMutations:
	:builder_option useExternalMemory .kstar.KStar$Settings$Builder#useExternalMemory:
	:builder_option showPfuncProgress .kstar.KStar$Settings$Builder#showPfuncProgress:
	:param bool writeSequencesToConsole: True to write sequences and scores to the console
	:param str writeSequencesToFile: Path to the log file to write sequences scores (in TSV format), or None to skip logging

	:rtype: :java:ref:`.kstar.KStar`
	'''

    # build settings
    settingsBuilder = _get_builder(jvm.getInnerClass(c.kstar.KStar,
                                                     'Settings'))()
    if epsilon is not useJavaDefault:
        settingsBuilder.setEpsilon(epsilon)
    if stabilityThreshold is not useJavaDefault:
        settingsBuilder.setStabilityThreshold(
            jvm.boxDouble(stabilityThreshold))
    if maxSimultaneousMutations is not useJavaDefault:
        settingsBuilder.setMaxSimultaneousMutations(maxSimultaneousMutations)
    if writeSequencesToConsole:
        settingsBuilder.addScoreConsoleWriter()
    if writeSequencesToFile is not None:
        settingsBuilder.addScoreFileWriter(jvm.toFile(writeSequencesToFile))
    if useExternalMemory is not useJavaDefault:
        settingsBuilder.setExternalMemory(useExternalMemory)
    if showPfuncProgress is not useJavaDefault:
        settingsBuilder.setShowPfuncProgress(showPfuncProgress)
    settings = settingsBuilder.build()

    return c.kstar.KStar(proteinConfSpace, ligandConfSpace, complexConfSpace,
                         settings)
Пример #7
0
def LUTE_write(model, path):
    '''
	Writes a LUTE model to a file

	:param model: The LUTE model
	:type model: :java:ref:`.lute.LUTEState`
	:param str path: Path to the file
	'''

    file = jvm.toFile(path)
    c.lute.LUTEIO.write(model, file)
    print('LUTE model saved to %s' % file.getAbsolutePath())
Пример #8
0
def DEEGMECFinder(emat,
                  confSpace,
                  ecalc,
                  confEcalc,
                  name,
                  use_epic,
                  use_lute,
                  confLog=None,
                  printIntermediateConfs=None,
                  useExternalMemory=None):
    '''
	:java:classdoc:`.gmec.SimpleGMECFinder`

	:builder_option astar .gmec.SimpleGMECFinder$Builder#search:

			Use one of :py:func:`AStarTraditional` or :py:func:`AStarMPLP` to get an A* implementation.

	:builder_option confEcalc .gmec.SimpleGMECFinder$Builder#confEcalc:

			Use :py:func:`ConfEnergyCalculator` to get a conformation energy calculator.

	:param str confLog: Path to file where conformations found during conformation space search should be logged.
	:builder_option printIntermediateConfs .gmec.SimpleGMECFinder$Builder#printIntermediateConfsToConsole:
	:builder_option useExternalMemory .gmec.SimpleGMECFinder$Builder#useExternalMemory:
	:builder_return .gmec.SimpleGMECFinder$Builder:
	'''

    builder = _get_builder(c.gmec.DEEGMECFinder)(emat, confSpace, ecalc,
                                                 confEcalc, name)

    if confLog is not None:
        logFile = jvm.toFile(confLog)
        builder.setLogPrinter(c.gmec.LoggingConfPrinter(logFile))

    if printIntermediateConfs is not None:
        builder.setPrintIntermediateConfsToConsole(printIntermediateConfs)

    if useExternalMemory == True:
        builder.useExternalMemory()

    gf = builder.build()

    if use_epic:
        gf.epicSettings = c.ematrix.epic.EPICSettings.defaultEPIC()
        gf.pruningSettings.algOption = 3
    if use_lute:
        gf.luteSettings = c.tupexp.LUTESettings.defaultLUTE()
        gf.pruningSettings.algOption = 3
        gf.pruningSettings.useTriples = True

    return gf
Пример #9
0
def EnergyMatrix(confEcalc, cacheFile=None):
    '''
	:java:methoddoc:`.ematrix.SimplerEnergyMatrixCalculator#calcEnergyMatrix`

	:builder_option confEcalc .ematrix.SimplerEnergyMatrixCalculator$Builder#confEcalc:
	:builder_option cacheFile .ematrix.SimplerEnergyMatrixCalculator$Builder#cacheFile:
	'''

    builder = _get_builder(c.ematrix.SimplerEnergyMatrixCalculator)(confEcalc)

    if cacheFile is not None:
        builder.setCacheFile(jvm.toFile(cacheFile))

    return builder.build().calcEnergyMatrix()
Пример #10
0
def LUTE_read(path):
    '''
	Reads a LUTE model from a file

	:param str path: Path to the file

	:returns: The LUTE model
	:rtype: :java:ref:`.lute.LUTEState`
	'''

    file = jvm.toFile(path)
    model = c.lute.LUTEIO.read(file)
    print('LUTE model read from %s' % file.getAbsolutePath())
    return model
Пример #11
0
def EwakstarDoer(state,
                 useWtBenchmark=useJavaDefault,
                 numEWAKStarSeqs=useJavaDefault,
                 logFile=None,
                 epsilon=useJavaDefault,
                 pfEw=useJavaDefault,
                 eW=useJavaDefault,
                 orderOfMag=useJavaDefault,
                 numPfConfs=useJavaDefault,
                 numTopSeqs=useJavaDefault,
                 mutableType=useJavaDefault,
                 numMutable=useJavaDefault,
                 seqFilterOnly=useJavaDefault,
                 numCPUs=useJavaDefault):

    builder = _get_builder(c.ewakstar.EwakstarDoer)()

    builder.addState(state)

    if useWtBenchmark is not useJavaDefault:
        builder.setUseWtBenchmark(useWtBenchmark)
    if epsilon is not useJavaDefault:
        builder.setEpsilon(epsilon)
    if pfEw is not useJavaDefault:
        builder.setPfEw(pfEw)
    if eW is not useJavaDefault:
        builder.setEw(eW)
    if orderOfMag is not useJavaDefault:
        builder.setOrderOfMag(orderOfMag)
    if numPfConfs is not useJavaDefault:
        builder.setNumPfConfs(numPfConfs)
    if numTopSeqs is not useJavaDefault:
        builder.setNumTopOverallSeqs(numTopSeqs)
    if mutableType is not useJavaDefault:
        builder.setMutableType(mutableType)
    if numMutable is not useJavaDefault:
        builder.setNumMutable(numMutable)
    if seqFilterOnly is not useJavaDefault:
        builder.setSeqFilterOnly(seqFilterOnly)
    if numCPUs is not useJavaDefault:
        builder.setNumCpus(numCPUs)
    if numEWAKStarSeqs is not useJavaDefault:
        builder.setNumEWAKStarSeqs(numEWAKStarSeqs)

    if logFile is not None:
        builder.setLogFile(jvm.toFile(logFile))

    return builder.build()
Пример #12
0
def MSKStar(objective,
            constraints=[],
            epsilon=useJavaDefault,
            objectiveWindowSize=useJavaDefault,
            objectiveWindowMax=useJavaDefault,
            maxSimultaneousMutations=useJavaDefault,
            minNumConfTrees=useJavaDefault,
            logFile=None):
    '''
	:java:classdoc:`.kstar.MSKStar`

	:builder_option objective .kstar.MSKStar$Builder#objective:

	:param constraints: List of LMFEs to use as constraints
	:type constraints: list of :java:ref:`.kstar.MSKStar$LMFE`

	:builder_option epsilon .kstar.MSKStar$Builder#epsilon:
	:builder_option objectiveWindowSize .kstar.MSKStar$Builder#objectiveWindowSize:
	:builder_option objectiveWindowMax .kstar.MSKStar$Builder#objectiveWindowMax:
	:builder_option maxSimultaneousMutations .kstar.MSKStar$Builder#maxSimultaneousMutations:
	:builder_option minNumConfTrees .kstar.MSKStar$Builder#minNumConfsTrees:

	:param str logFile: :java:fielddoc:`.kstar.MSKStar$Builder#logFile`

	:builder_return .kstar.MSKStar$Builder:
	'''

    builder = _get_builder(c.kstar.MSKStar)(objective)

    for constraint in constraints:
        builder.addConstraint(constraint)

    if objectiveWindowSize is not useJavaDefault:
        builder.setObjectiveWindowSize(objectiveWindowSize)
    if objectiveWindowMax is not useJavaDefault:
        builder.setObjectiveWindowMax(objectiveWindowMax)
    if maxSimultaneousMutations is not useJavaDefault:
        builder.setMaxSimultaneousMutations(maxSimultaneousMutations)
    if minNumConfTrees is not useJavaDefault:
        builder.setMinNumConfTrees(jvm.boxInt(minNumConfTrees))

    if logFile is not None:
        builder.setLogFile(jvm.toFile(logFile))

    return builder.build()