コード例 #1
0
def hybridization(options, mySeq, myTrials=0, doFirstPassage=False):

    # Using domain representation makes it easier to write secondary structures.
    onedomain = Domain(name="itall", sequence=mySeq)
    top = Strand(name="top", domains=[onedomain])
    bot = top.C

    # Note that the structure is specified to be single stranded, but this will be over-ridden when Boltzmann sampling is turned on.
    startTop = Complex(strands=[top], structure=".")
    startBot = Complex(strands=[bot], structure=".")

    # Turns Boltzmann sampling on for this complex and also does sampling more efficiently by sampling 'trials' states.
    if (myTrials > 0):
        setBoltzmann(startTop, myTrials)
        setBoltzmann(startBot, myTrials)

    # Stop when the exact full duplex is achieved.
    success_complex = Complex(strands=[top, bot], structure="(+)")
    stopSuccess = StopCondition(
        Options.STR_SUCCESS, [(success_complex, Options.exactMacrostate, 0)])

    # Declare the simulation unproductive if the strands become single-stranded again.
    failed_complex = Complex(strands=[top], structure=".")
    stopFailed = StopCondition(Options.STR_FAILURE,
                               [(failed_complex, Options.dissocMacrostate, 0)])

    options.start_state = [startTop, startBot]

    # Point the options to the right objects
    if not doFirstPassage:

        options.stop_conditions = [stopSuccess, stopFailed]

    else:

        options.stop_conditions = [stopSuccess]
コード例 #2
0
def changeComplex(options, expirement_type=NORMAL, trials=500):
    # Easiest to use full dot paren here
    # See SI Document for these sequences and lengths!
    toehold_length = 7
    h_length = 15

    helper = Strand(name="Helper_AAq",
                    sequence="TTTCCTAATCCCAATCAACACCTTTCCTA")
    produce_bot = Strand(
        name="Produce_BOT_CApAq",
        sequence="GTAAAGACCAGTGGTGTGAAGATAGGAAAGGTGTTGATTGGGATTAGGAAACC")
    ap = Strand(name="ap",
                sequence="CATCACTATCAATCATACATGGTTTCCTATCTTCACACCACTGG")
    aq = Strand(name="aq",
                sequence="CATCACTATCAATCATACATGGTTTCCTAATCCCAATCAACACC")

    # Offset of two to account for clamp domains
    produce_struct = "." * toehold_length + "(" * (
        len(produce_bot.sequence) -
        toehold_length) + "+" + '.' * (toehold_length + h_length - 2) + ')' * (
            len(ap.sequence) - toehold_length - h_length + 2) + "+" + '.' * (
                toehold_length + h_length) + ')' * (len(ap.sequence) -
                                                    toehold_length - h_length)

    if expirement_type == WITHOUT_GG:
        ap = Strand(name="ap",
                    sequence="CATCACTATCAATCATACATTTTCCTATCTTCACACCACTGG")

        # bot, aq, ap
        # Offsets due to a) clamp domains b) two b.p. removal
        produce_struct = "." * toehold_length + "(" * (
            len(produce_bot.sequence) - toehold_length) + "+" + '.' * (
                toehold_length + h_length - 2) + ')' * (
                    len(ap.sequence) - toehold_length - h_length +
                    4) + "+" + '.' * (toehold_length + h_length - 2) + ')' * (
                        len(ap.sequence) - toehold_length - h_length + 2)

    elif expirement_type == WITHOUT_G:
        ap = Strand(name="ap",
                    sequence="CATCACTATCAATCATACATGTTTCCTATCTTCACACCACTGG")

        # bot, aq, ap
        # Offsets due to a) clamp domains b) one b.p. removal
        produce_struct = "." * toehold_length + "(" * (
            len(produce_bot.sequence) - toehold_length) + "+" + '.' * (
                toehold_length + h_length - 2) + ')' * (
                    len(ap.sequence) - toehold_length - h_length +
                    3) + "+" + '.' * (toehold_length + h_length - 1) + ')' * (
                        len(ap.sequence) - toehold_length - h_length + 1)

    elif expirement_type == HELPER_WITHOUT_CC:
        # only modify helper sequence here - remove the two 3' most 'C'.
        helper = Strand(name="Helper_AAq",
                        sequence="TTTCCTAATCCCAATCAACACCTTTTA")

        # No change required elsewhere -  we check for the release of strands rather than the complicated
        # leak complex formed for simplicity. We should really check for ANY free strands here i.e. Ap OR Aq
        # but it is hard to imagine a mechanism which results in the release of Ap in this simulation

    produce_complex = Complex(name="produce",
                              strands=[produce_bot, aq, ap],
                              structure=produce_struct)
    helper_complex = Complex(name="helper",
                             strands=[helper],
                             structure='.' * len(helper.sequence))
    leak_complex = Complex(name="leak",
                           strands=[aq],
                           structure='.' * len(aq.sequence))

    if trials > 0:
        setBoltzmann(produce_complex, trials, 75)
        setBoltzmann(helper_complex, trials, 75)

    success_stop_cond = StopCondition(
        Literals.success, [(leak_complex, Options.dissoc_macrostate, 0)])
    # the leak has failed if we end up with our initial complexes again.
    # check if we end up with a free helper complex
    failure_stop_cond = StopCondition(
        Literals.failure, [(helper_complex, Options.dissoc_macrostate, 0)])

    options.start_state = [produce_complex, helper_complex]
    options.stop_conditions = [success_stop_cond, failure_stop_cond]
コード例 #3
0
def machinek2014(options, selector, trialsIn):
    # we only allow first step mode at this point.

    # these are the sequences we need to build the dot-parens
    incumbent = ""
    target = ""
    invader = ""

    toeholdSelect = selector / 12
    mismatchSelect = selector % 12

    positionSelector = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14]
    mismatchSelect = positionSelector[mismatchSelect]

    # decide on toehold sequence
    toeholdSeq = "ATGTGG"  # 6 nt toehold option

    if toeholdSelect == 1:
        toeholdSeq = "ATGTGGA"  # 7 nt toehold option
    if toeholdSelect == 2:
        toeholdSeq = "ATGTGGAGGG"  # 10 nt toehold option

    # determine the incumbent, target and invader sequences
    # FD: copy-pasting supplementary Table 6 directly

    if mismatchSelect == 0 or mismatchSelect == 2 or mismatchSelect == 12 or mismatchSelect == 14:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTTGAGGTTGA"
        target = "CCCTCCACATTCAACCTCAAACTCACC"

        if mismatchSelect == 0:  # perfect
            invader = "GGTGAGTTTGAGGTTGA"

        if mismatchSelect == 2:
            invader = "GGTGAGTTTGAGGTTCA"

        if mismatchSelect == 12:
            invader = "GGTGACTTTGAGGTTGA"

        if mismatchSelect == 14:
            invader = "GGTCAGTTTGAGGTTGA"

    if mismatchSelect == 3:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTTGAGGTGAT"
        target = "CCCTCCACATATCACCTCAAACTCACC"
        invader = "GGTGAGTTTGAGGTCAT"

    if mismatchSelect == 4:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTTGAGTGAGT"
        target = "CCCTCCACATACTCACTCAAACTCACC"
        invader = "GGTGAGTTTGAGTCAGT"

    if mismatchSelect == 5:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTTGATGAGGT"
        target = "CCCTCCACATACCTCATCAAACTCACC"
        invader = "GGTGAGTTTGATCAGGT"

    if mismatchSelect == 6:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTTGTGAAGGT"
        target = "CCCTCCACATACCTTCACAAACTCACC"
        invader = "GGTGAGTTTGTCAAGGT"

    if mismatchSelect == 7:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTTTGAGAGGT"
        target = "CCCTCCACATACCTCTCAAAACTCACC"
        invader = "GGTGAGTTTTCAGAGGT"

    if mismatchSelect == 8:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTTGATGAGGT"
        target = "CCCTCCACATACCTCATCAAACTCACC"
        invader = "GGTGAGTTTCATGAGGT"

    if mismatchSelect == 9:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTTGATTGAGGT"
        target = "CCCTCCACATACCTCAATCAACTCACC"
        invader = "GGTGAGTTCATTGAGGT"

    if mismatchSelect == 10:
        incumbent = "TGGTGTTTGTGGGTGTGGTGAGTGATTTGAGGT"
        target = "CCCTCCACATACCTCAAATCACTCACC"
        invader = "GGTGAGTCATTTGAGGT"

    invader = invader + toeholdSeq

    # set up the actual complexes
    strandIncumbent = Strand(name="incumbent", sequence=incumbent)
    strandTarget = Strand(name="target", sequence=target)
    strandInvader = Strand(name="invader", sequence=invader)

    intialDotParen = '.' * 16 + '(' * 17 + "+" + '.' * 10 + ')' * 17
    intialInvaderDotParen = '.' * len(invader)
    successDotParen = '.' * 33

    initialComplex = Complex(strands=[strandIncumbent, strandTarget],
                             structure=intialDotParen)
    initialInvader = Complex(strands=[strandInvader],
                             structure=intialInvaderDotParen)
    successComplex = Complex(strands=[strandIncumbent],
                             structure=successDotParen)

    # Turns Boltzmann sampling on for this complex and also does sampling more efficiently by sampling 'trials' states.
    if (trialsIn > 0):
        setBoltzmann(initialComplex, trialsIn)
        setBoltzmann(initialInvader, trialsIn)
        initialComplex.boltzmann_supersample = 25
        initialInvader.boltzmann_supersample = 25

    stopSuccess = StopCondition(
        Options.STR_SUCCESS, [(successComplex, Options.dissocMacrostate, 0)])
    stopFailed = StopCondition(Options.STR_FAILURE,
                               [(initialComplex, Options.dissocMacrostate, 0)])

    # actually set the intial and stopping states
    options.start_state = [initialComplex, initialInvader]
    options.stop_conditions = [stopSuccess, stopFailed]
コード例 #4
0
def show_interesting_trajectories(result_lists, seqs, type='fastest'):
    mintimes = []
    maxtimes = []
    slowseeds = []
    fastseeds = []
    for n in range(len(result_lists)):
        times = 1e6 * np.array([
            i.time for i in result_lists[n]
        ])  # convert from seconds to microseconds units.
        slowseeds.append(result_lists[n][np.argmax(
            times)].seed)  # find the seed used for the slowest simulation
        fastseeds.append(result_lists[n][np.argmin(
            times)].seed)  # find the seed used for the fastest simulation
        mintimes.append(np.min(times))
        maxtimes.append(np.max(times))

    # taken from hairpin_trajectories.py
    def print_trajectory(o):
        print o.full_trajectory[0][0][3]  # the strand sequence
        print o.start_state[0].structure
        for i in range(len(o.full_trajectory)):
            time = 1e6 * o.full_trajectory_times[i]
            state = o.full_trajectory[i][0]
            struct = state[4]
            dG = state[5]
            print struct + ' t=%11.9f microseconds, dG=%6.2f kcal/mol' % (time,
                                                                          dG)

    # take a look at the fastest folds.  to take a look at the more interesting slowest folds,
    # change "mintimes" to "maxtimes" and change "fastseeds" to "slowseeds"; do this based on 'type' argument
    seeds = fastseeds if type == 'fastest' else slowseeds
    times = mintimes if type == 'fastest' else maxtimes
    for (seq, seed, time) in zip(seqs, seeds, times):
        s1 = Strand(name="hairpin", sequence=seq)
        c1 = Complex(strands=[s1], structure=16 * '.')  # hard-coded length 16
        c2 = Complex(strands=[s1], structure="((((((....))))))"
                     )  # hard-coded stem length 6, loop length 4
        sc = StopCondition("CLOSED", [(c2, Literals.exact_macrostate, 0)])
        # For future reference, StopConditions and Macrostates (same thing) are provided as a list of match conditions,
        # all of which must be matched.  I.e. there is an implicit AND being evaluated.  E.g.
        # sc = StopCondition( "EXAMPLE", [(c2,Loose_Macrostate,8), (c1,Loose_Macrostate,4)]
        # would specify the intersection of those two macrostates, i.e. any 2 base pairs of the helix (and maybe more).

        o = Options(
            temperature=310.15,
            dangles='Some',
            start_state=[c1],
            simulation_time=
            0.1,  # 0.1 seconds  (lots more time than hairpin_trajectories, to accommodate slow folds)
            num_simulations=1,  # don't play it again, Sam
            output_interval=1,  # record every single step
            rate_method=
            'Metropolis',  # the default is 'Kawasaki' (numerically, these are 1 and 2 respectively)
            rate_scaling=
            'Calibrated',  # this is the same as 'Default'.  'Unitary' gives values 1.0 to both.  
            simulation_mode='Trajectory'
        )  # numerically 128.  See interface/_options/constants.py for more info about all this.
        o.stop_conditions = [sc]  # don't wait for the time-out
        o.initial_seed = seed  # start with the same random seed as before...

        s = SimSystem(o)
        s.start()
        print_trajectory(o)
        print "Original run's time: %g microseconds" % time