Пример #1
0
def computeHittingTimes(settings, reverse=False):

    myMultistrand = MergeSim()
    myMultistrand.setNumOfThreads(NUM_PROCESS)

    if settings.type == enum_yurke2:
        myMultistrand.setOptionsFactory1(simulationYurke2, settings.nTrials)

    if settings.type == enum_bonnet:
        myMultistrand.setOptionsFactory2(simulationHairpin, settings.nTrials,
                                         reverse)

    if settings.type == enum_flamm:
        myMultistrand.setOptionsFactory1(simulationFlamm2000, settings.nTrials)

    if settings.type == enum_yurke:
        myMultistrand.setOptionsFactory1(simulationYurke, settings.nTrials)

    if settings.type == enum_rickettsia:
        myMultistrand.setOptionsFactory1(simulationRickettsia,
                                         12 * settings.nTrials)
        myMultistrand.setTerminationCriteria(terminationCount=settings.nTrials)

    if settings.type == enum_bonnet or settings.type == enum_yurke2:
        myMultistrand.setPassageMode()  # using the pre-set success / fail

    if settings.type == enum_flamm or settings.type == enum_yurke or settings.type == enum_rickettsia:
        # non-first stepping mode, no need to store trajectory information
        myMultistrand.setPassageMode()

    myMultistrand.run()

    return myMultistrand.results
def computeRate(selector):
    
    myMultistrand = MergeSim()
    
    myMultistrand.setOptionsFactory2(genOptions, NUMOFPATHS, selector) 
    myMultistrand.setNumOfThreads(NUMOFTHREADS)
    myMultistrand.setTerminationCriteria(TERMINATIONCRIT)
    myMultistrand.setLeakMode()  # the new leak object -- faster bootstrapping.
    
    myMultistrand.printTrajectory()
     
    return 0.0, 0.0, 0.0
    
    myMultistrand.run()
     
    myFSR = myMultistrand.results  
    low, high = myFSR.doBootstrap()
     
    return myFSR.k1(), low, high 
def estimateSuccessProbability(popularStructure, settings):

    # Do a quick first step simulation and see how many end up succeeding.
    # Use a new multistrand object so we don't lose the old results

    newMultistrand = MergeSim()
    newMultistrand.setNumOfThreads(myMultistrand.numOfThreads)

    oldTrials = settings.trials

    settings.trials = int(settings.trials / 50.0)
    settings.initialStructure = popularStructure

    first_step_simulation(newMultistrand, settings)
    settings.trials = oldTrials

    output = np.float(newMultistrand.nForward.value) / np.float(
        newMultistrand.trialsPerThread * newMultistrand.numOfThreads)

    return output
Пример #4
0
def first_passage_association(strand_seq, trials, concentration, T=20.0):

    thisMS = MergeSim()
    thisMS.setNumOfThreads(8)
    print "Running first passage time simulations for association of %s at %s..." % (
        strand_seq, concentration_string(concentration))

    def getOptions(trials):

        o = standardOptions(Literals.first_passage_time, TEMPERATURE, trials,
                            ATIME_OUT)

        hybridization(o, strand_seq, trials, True)
        setSaltGao2006(o)
        o.join_concentration = concentration
        o.DNA23Metropolis()

        return o

    thisMS.setOptionsFactory1(getOptions, trials)
    thisMS.setPassageMode()
    thisMS.run()

    return thisMS
Пример #5
0
def first_step_simulation(strand_seq, trials, T=20.0):

    myMS = MergeSim()
    myMS.setNumOfThreads(8)
    print(
        "Running first step mode simulations for %s (with Boltzmann sampling)..."
        % (strand_seq))

    def getOptions(trials):

        o = standardOptions(Literals.first_step, TEMPERATURE, trials,
                            ATIME_OUT)
        hybridization(o, strand_seq, trials)
        setSaltGao2006(o)
        o.DNA23Metropolis()

        return o

    myMS.setOptionsFactory1(getOptions, trials)
    myMS.setFirstStepMode()  # ensure the right results object is set.
    #     myMultistrand.setLeakMode()
    myMS.setTerminationCriteria(terminationCount=trials)
    myMS.run()
    return myMS
# FD: This script is now set to use 4 threads and just 50,000 trajectories.
# FD: This is different from the results in case1.pdf
# FD: The results of this study heavily depend on the parameterization of the Metropolis model: JS or DNA23 (see below).

from multistrand.objects import StopCondition, Domain, Complex, Strand
from multistrand.options import Options, Literals
from multistrand.concurrent import MergeSim
from multistrand._options.interface import FirstStepResult

import numpy as np

ATIME_OUT = 10.0

myMultistrand = MergeSim()
myMultistrand.setNumOfThreads(8)
myMultistrand.setLeakMode()


def first_step_simulation(strand_seq, trials, T=25, material="DNA"):

    print(
        "Running first step mode simulations for %s (with Boltzmann sampling)..."
        % (strand_seq))

    # Using domain representation makes it easier to write secondary structures.
    onedomain = Domain(name="onedomain", sequence=strand_seq)
    gdomain = Domain(name="gdomain", sequence="TTTT")

    top = Strand(name="top", domains=[onedomain])
    bot = top.C
#     myMultistrand.clear()

if __name__ == '__main__':

    if len(sys.argv) < 1:
        print """Usage:
              python hybridization_F3 <numOfThreads> <numOfPaths>  P0/P3/P4      \n
              Example: python hybridization_F3 2 100 P3
              """
        sys.exit()

    print sys.argv

    numOfThreads = np.int(sys.argv[1])
    numOfPaths = np.int(sys.argv[2])
    toggle = str(sys.argv[3])

    myMultistrand.setNumOfThreads(numOfThreads)

    if toggle == "test":
        doInference('TACCGT', "P0-test", 10, numOfPaths)  # P0
    if toggle == "test2":
        doInference(goa2006_P0, "P0-test", 10, numOfPaths)  # P0

    if toggle == "P0":
        doInference(goa2006_P0, toggle, 14, numOfPaths)  # P0
    if toggle == "P3":
        doInference(goa2006_P3, toggle, 14, numOfPaths)  # P3
    if toggle == "P4":
        doInference(goa2006_P4, toggle, 14, numOfPaths)  # P4