def simulationYurke2(trialsIn): stdOptions = standardOptions(simMode=Literals.first_passage_time, trials=trialsIn) stdOptions.simulation_time = A_TIME_OUT stdOptions.DNA23Metropolis() domS = Domain(sequence="ACTAATCCTCAGATCCAGCTAGTGTC", name="d_S") domD = Domain(sequence="A", name="d_A") domT = Domain(sequence="CGTACT", name="d_T") strandQ = Strand(domains=[domS, domD]) strandT = Strand(domains=[domT, domS]) strandS = strandT.C # complexEndS = Complex(strands=[strandQ], structure="..") complexEndF = Complex(strands=[strandT], structure="..") complexEndFC = Complex(strands=[strandQ, strandS], structure="(.+).") complexAttached = Complex(strands=[strandQ, strandS, strandT], structure="**+*(+)*") stopSuccess = StopCondition( Literals.success, [(complexAttached, Literals.loose_macrostate, 1)]) stdOptions.start_state = [complexEndF, complexEndFC] stdOptions.stop_conditions = [stopSuccess] stdOptions.join_concentration = 0.0001 # 100 microMolar return stdOptions
def threewayDisplacement(options, toeholdSeq, domainSeq, myTrials=0, mySuperSample=1): toeholdDomain = Domain(name="toehold", sequence=toeholdSeq) disDomain = Domain(name="displacement", sequence=domainSeq) topS = Strand(name="top", domains=[disDomain]) invaderS = Strand(name="invader", domains=[disDomain, toeholdDomain]) botS = invaderS.C startComplex = Complex(strands=[topS, botS], structure="(+.)") invaderComplex = Complex(strands=[invaderS], structure="..") successComplex = Complex(strands=[botS, invaderS], structure="((+))") if (myTrials > 0): setBoltzmann(startComplex, myTrials, mySuperSample) setBoltzmann(invaderComplex, myTrials, mySuperSample) # stop when the invasion is complete, or when the invader dissociates stopSuccess = StopCondition( Options.STR_SUCCESS, [(successComplex, Options.dissocMacrostate, 0)]) # Declare the simulation unproductive if the invader becomes single-stranded again. stopFailed = StopCondition(Options.STR_FAILURE, [(invaderComplex, Options.dissocMacrostate, 0)]) #set the starting and stopping conditions options.start_state = [startComplex, invaderComplex] options.stop_conditions = [stopFailed, stopSuccess]
def simulationFlamm2000(trialsIn): seq = "GGCCCCTTTGGGGGCCAGACCCCTAAAGGGGTC" structStart = "................................." struct0 = "((((((((((((((.....))))))))))))))" struct1 = "((((((....)))))).((((((....))))))" stdOptions = standardOptions(simMode=Literals.trajectory, trials=trialsIn, tempIn=37.0) stdOptions.substrate_type = Literals.substrateRNA stdOptions.gt_enable = 1 stdOptions.simulation_time = A_TIME_OUT stdOptions.DNA23Metropolis() stemdomain1 = Domain(name="stemdomain1", sequence=seq) strand = Strand(name="top", domains=[stemdomain1]) startComplex = Complex(strands=[strand], structure=structStart) successComplex0 = Complex(strands=[strand], structure=struct0) successComplex1 = Complex(strands=[strand], structure=struct1) # Stop when the exact full duplex is achieved. stopSuccess0 = StopCondition( Literals.success, [(successComplex0, Literals.exact_macrostate, 0)]) stopSuccess1 = StopCondition( Literals.alt_success, [(successComplex1, Literals.exact_macrostate, 0)]) stdOptions.start_state = [startComplex] stdOptions.stop_conditions = [stopSuccess0, stopSuccess1] return stdOptions
def create_test4(): toehold_t = "CTGC" toehold_dd = "CATATC" domain_R = "CATTAAC" # build complexes with domain-level information toehold = Domain(name="toehold", sequence=toehold_t, length=6) toehold_2 = Domain(name="toehold", sequence=toehold_dd, length=6) branch_migration = Domain(name="branch_migration", sequence=domain_R, seq_length=7) incoming = branch_migration.C + toehold.C substrate = toehold + branch_migration # Note that "+" is used to indicate strand breaks. # So the initial structures represent the incoming strand bound by its toehold, # and we'll see that either it completes strand displacement, or it dissociates. start_complex = Complex(strands=[incoming, substrate], structure=".(+).") stop_complex = Complex(strands=[incoming, substrate], structure="..+..") full_sc = StopCondition("CLOSED", [(stop_complex, Literals.dissoc_macrostate, 2)]) return createOptions(start_complex, stop_complex, "First Passage Time")
def create_test2(): top0 = "T" top1 = "G" top2 = "G" bottom0 = "C" bottom1 = "C" bottom2 = "A" # build complexes with domain-level information strand0 = Domain(name="toehold0", sequence=top0, length=1) strand1 = Domain(name="toehold1", sequence=top1, length=1) strand2 = Domain(name="toehold2", sequence=top2, length=1) strand3 = Domain(name="toehold3", sequence=bottom0, length=1) strand4 = Domain(name="toehold4", sequence=bottom1, length=1) strand5 = Domain(name="toehold5", sequence=bottom2, length=1) substrate = strand3 + strand4 + strand5 invading = strand0 + strand1 + strand2 # start_complex = Complex(strands=[substrate, invading], structure="(..+..)") # start_complex = Complex(strands=[substrate, invading], structure=".(.+.).") start_complex = Complex(strands=[substrate, invading], structure="..(+)..") stop_complex = Complex(strands=[substrate, invading], structure="...+...") return createOptions(start_complex, stop_complex, "First Passage Time")
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 dangle = Strand(name="Dangle", domains=[onedomain, gdomain]) duplex_complex = Complex(strands=[top, bot], structure="(+)") invader_complex = Complex(strands=[dangle], structure="..") duplex_invaded = Complex(strands=[dangle, bot], structure="(.+)") # Declare the simulation complete if the strands become a perfect duplex. success_stop_condition = StopCondition( Options.STR_SUCCESS, [(duplex_invaded, Options.exactMacrostate, 0)]) failed_stop_condition = StopCondition( Options.STR_FAILURE, [(duplex_complex, Options.dissocMacrostate, 0)]) for x in [duplex_complex, invader_complex]: x.boltzmann_count = trials x.boltzmann_sample = True # the first argument has to be trials. def getOptions(trials, material, duplex_complex, dangle, success_stop_condition, failed_stop_condition): o = Options(simulation_mode="First Step", substrate_type=material, rate_method="Metropolis", num_simulations=trials, simulation_time=ATIME_OUT, temperature=T) o.start_state = [duplex_complex, dangle] o.stop_conditions = [success_stop_condition, failed_stop_condition] # FD: The result of this script depend significantly on JS or DNA23 parameterization. # o.JSMetropolis25() # o.DNA23Metropolis() setArrheniusConstantsDNA23(o) return o myMultistrand.setOptionsFactory6(getOptions, trials, material, duplex_complex, invader_complex, success_stop_condition, failed_stop_condition) myMultistrand.run() myFSR = myMultistrand.results # Now determine the reaction model parameters from the simulation results. # myFSR = FirstStepRate(dataset, 5e-9) print myFSR
def simulationYurke(trialsIn): stdOptions = standardOptions(simMode=Literals.first_passage_time, trials=trialsIn) stdOptions.simulation_time = A_TIME_OUT stdOptions.DNA23Metropolis() stdOptions.temperature = 25.0 domS = Domain(sequence="ACTAATCCTCAGATCCAGCTAGTGTC", name="d_S") domD = Domain(sequence="A", name="d_A") domT = Domain(sequence="CGTACT", name="d_T") strandQ = Strand(domains=[domS, domD]) strandT = Strand(domains=[domT, domS]) strandS = strandT.C complexStart = Complex(strands=[strandQ, strandS, strandT], structure="(.+)(+).") complexEndS = Complex(strands=[strandQ], structure="..") complexEndF = Complex(strands=[strandT], structure="..") # # ALT_SUCCESS is dissociation stopSuccess = StopCondition(Literals.success, [(complexEndS, Literals.dissoc_macrostate, 3)]) stopFailed = StopCondition(Literals.alt_success, [(complexEndF, Literals.dissoc_macrostate, 3)]) stdOptions.start_state = [complexStart] stdOptions.stop_conditions = [stopSuccess, stopFailed] return stdOptions
def setup_options_hairpin(trials, stem_seq, hairpin_seq): # Define the domains stem = Domain(name="stem", sequence=stem_seq, length=len(stem_seq)) hairpin = Domain(name="hairpin", sequence=hairpin_seq, length=len(hairpin_seq)) s = stem + hairpin + stem.C # We give domain-level structures for the open and closed hairpin configurations start_complex = Complex(strands=[s], structure="...") stop_complex = Complex(strands=[s], structure="(.)") full_sc = StopCondition("CLOSED", [(stop_complex, Literals.exact_macrostate, 0)]) # Note: unlike in Transition Mode, in First Passage Time Mode, no "stop:" prefix is needed in the macrostate name # in order for the StopCondition to trigger the end of the simulation. o = Options(simulation_mode="First Passage Time", parameter_type="Nupack", substrate_type="DNA", temperature=310.15, num_simulations=trials, simulation_time=0.1, rate_scaling='Calibrated', verbosity=0, start_state=[start_complex], stop_conditions=[full_sc]) return o
def create_test5(): top0 = "ACT" top1 = "GAC" toehold = "TG" bottom = "TG" connected = "ATA" # build complexes with domain-level information right_d = Domain(name="toehold0", sequence=top0, length=3) left_d = Domain(name="toehold1", sequence=top1, length=3) branch0 = Domain(name="branch_migration", sequence=bottom, seq_length=2) toehold = Domain(name="oToehold", sequence=toehold, length=2) connect = Domain(name="cToehold", sequence=connected, length=3) substrate = toehold.C + branch0.C + toehold.C left = toehold + left_d + connect right = connect.C + right_d + toehold # Note that "+" is used to indicate strand breaks. # So the initial structures represent the incoming strand bound by its toehold, # and we'll see that either it completes strand displacement, or it dissociates. start_complex = Complex(strands=[left, right, substrate], structure="(.(+).(+).)") stop_complex = Complex(strands=[left, right, substrate], structure="...+...+...") return createOptions(start_complex, stop_complex, "First Passage Time")
def create_test2B(): top0 = "T" top1 = "T" top2 = "T" bottom0 = "A" bottom1 = "A" bottom2 = "A" # build complexes with domain-level information strand0 = Domain(name="toehold0", sequence=top0, length=1) strand1 = Domain(name="toehold1", sequence=top1, length=1) strand2 = Domain(name="toehold2", sequence=top2, length=1) strand3 = Domain(name="toehold3", sequence=bottom0, length=1) strand4 = Domain(name="toehold4", sequence=bottom1, length=1) strand5 = Domain(name="toehold5", sequence=bottom2, length=1) substrate = strand3 + strand4 + strand5 invading = strand0 + strand1 + strand2 start_complex = Complex(strands=[substrate, invading], structure=".(.+.).") stop_complex = Complex(strands=[substrate, invading], structure="...+...") o1 = createOptions(start_complex, stop_complex, "First Passage Time") # o1.join_concentration = 8 # o1.bimolecular_scaling = 777.0 # o1.DNA23Metropolis() return o1
def leakInvasion(options, mySeq, myTrials=0, doFirstPassage=False): onedomain = Domain(name="d1", sequence=mySeq) top = Strand(name="top", domains=[onedomain]) bot = top.C initial_complex = Complex(strands=[top, bot], structure="(+)") invader_top = Complex(strands=[top], structure=".") # Turns Boltzmann sampling on for this complex and also does sampling more efficiently by sampling 'trials' states. if (myTrials > 0): setBoltzmann(initial_complex, myTrials) setBoltzmann(invader_top, myTrials) # Stop when the exact full duplex is achieved. stopSuccess = StopCondition( Literals.success, [(success_complex, Literals.exact_macrostate, 0)]) # Declare the simulation unproductive if the strands become single-stranded again. failed_complex = Complex(strands=[top], structure=".") stopFailed = StopCondition( Literals.failure, [(failed_complex, Literals.dissoc_macrostate, 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]
def create_test9(): seq0 = "GTGT" seq1 = "T" # build complexes with domain-level information branch = Domain(name="toehold0", sequence=seq0, length=3) toehold = Domain(name="toehold1", sequence=seq1, length=1) ghost = Domain(name="toeholdG", sequence="T", length=1) substrate = toehold + branch left = toehold.C + ghost right = branch.C + ghost # Note that "+" is used to indicate strand breaks. # So the initial structures represent the incoming strand bound by its toehold, # and we'll see that either it completes strand displacement, or it dissociates. start_complex = Complex(strands=[right, left, substrate], structure="(.+(.+))") stop_complex = Complex(strands=[left, right, substrate], structure="..+..+..") return createOptions(start_complex, stop_complex, "First Passage Time")
def create_test0C(): domain_seq = "AGT" domain_seq2 = "GTA" left = Domain(name="branch_migration", sequence=domain_seq, seq_length=3) right = Domain(name="branch_migration2", sequence=domain_seq2, seq_length=3) incoming = left + right substrate = incoming.C start_complex1 = Complex(strands=[incoming], structure="..") start_complex2 = Complex(strands=[substrate], structure="..") stop_complex = Complex(strands=[incoming, substrate], structure="((+))") full_sc = StopCondition("CLOSED", [(stop_complex, Literals.dissoc_macrostate, 2)]) o1 = Options(simulation_mode=Literals.first_passage_time, temperature=273.15 + 25.0, num_simulations=10, simulation_time=0.00001, rate_scaling='Calibrated', verbosity=0, join_concentration=1e-9, rate_method="Metropolis", start_state=[start_complex1, start_complex2], stop_conditions=[full_sc]) return o1
def placeMismatchInOutput(self, position): mismatched_strands = self.placeMismatchInDomain( position, self.output_domain.sequence) self.output_strand = mismatched_strands[0] + \ self.toehold_domain + self.base_domain self.gate_output_complex = Complex( strands=[self.base_strand, self.output_strand], structure=".((+...))") self.output_complex = Complex(strands=[self.output_strand], structure='.' * len(self.output_strand.sequence))
def ravan(options, trialsIn, selector): # we only allow first step mode at this point. if PENG_YIN == True: RAVAN_H1 = "GCTTGAGATGTTAGGGAGTAGTGCTCCAATCACAACGCACTACTCCCTAACATC" RAVAN_H2 = "AGGGAGTAGTGCGTTGTGATTGGAAACATCTCAAGCTCCAATCACAACGCACTA" RAVAN_H3 = "GTTGTGATTGGAGCTTGAGATGTTGCACTACTCCCTAACATCTCAAGCTCCAAT" RAVAN_I = "GCACTACTCCCTAACATCTCAAGC" strand_H1 = Strand(name="H1", sequence=RAVAN_H1) strand_H2 = Strand(name="H2", sequence=RAVAN_H2) strand_H3 = Strand(name="H3", sequence=RAVAN_H3) strand_I = Strand(name="I", sequence=RAVAN_I) dotparen_H1 = "." * len(RAVAN_H1) dotparen_H2 = "." * len(RAVAN_H2) dotparen_H3 = "." * len(RAVAN_H3) dotparen_I = "." * len(RAVAN_I) """ No special secondary structure, just a hack to make a connected complex composed of the correct set of strands """ dotparen_I_H1 = '(' + ("." * (len(RAVAN_I) - 1)) + "+" + ')' + ("." * (len(RAVAN_H1) - 1)) dotparen_I_H1_H2 = '(' + ("." * (len(RAVAN_I) - 1)) + "+" + ')' + ("." * (len(RAVAN_H1) - 2)) + "(" + "+" + ")" + ("." * (len(RAVAN_H2) - 1)) dotparen_H1_H2_H3 = '(' + ("." * (len(RAVAN_H1) - 1)) + "+" + ')' + ("." * (len(RAVAN_H2) - 2)) + '(' + "+" + ')' + ("." * (len(RAVAN_H3) - 1)) if selector == 0: target_complex = Complex(strands=[strand_H1], structure=dotparen_H1) complex_trigger = Complex(strands=[strand_I], structure=dotparen_I) success_complex = Complex(strands=[strand_I, strand_H1], structure=dotparen_I_H1) if selector == 1: target_complex = Complex(strands=[strand_I, strand_H1], structure=dotparen_I_H1) complex_trigger = Complex(strands=[strand_H2], structure=dotparen_H2) success_complex = Complex(strands=[strand_I, strand_H1, strand_H2], structure=dotparen_I_H1_H2) if selector == 2: target_complex = Complex(strands=[strand_I, strand_H1, strand_H2], structure=dotparen_I_H1_H2) complex_trigger = Complex(strands=[strand_H3], structure=dotparen_H3) success_complex = Complex(strands=[strand_H1, strand_H2, strand_H3], structure=dotparen_H1_H2_H3) setBoltzmann(complex_trigger, trialsIn) setBoltzmann(target_complex, trialsIn) stopSuccess = StopCondition(Literals.success, [(success_complex, Literals.dissoc_macrostate, 0)]) stopFailed = StopCondition(Literals.failure, [(complex_trigger, Literals.dissoc_macrostate, 0)]) # actually set the intial and stopping states options.start_state = [complex_trigger, target_complex] options.stop_conditions = [stopSuccess, stopFailed]
def simulationRickettsia(trialsIn): stdOptions = standardOptions(simMode=Literals.first_passage_time, trials=trialsIn) stdOptions.simulation_time = A_TIME_OUT stdOptions.DNA23Metropolis() stdOptions.temperature = 25.0 stdOptions.magnesium = 0.0125 stdOptions.sodium = 0.1 dom_a = Domain(sequence="ATTCAA", name="a") # length 6 dom_b = Domain(sequence="GCGACACCGTGGACGTGC", name="b") # length 18 dom_c = Domain(sequence="ACCCAC", name="c") # length 6 dom_x = Domain(sequence="GGT", name="x") # length 3 dom_y = Domain(sequence="AAC", name="y") # length 3 strand_H1 = Strand(domains=[dom_a, dom_b, dom_c, dom_b.C, dom_x.C]) strand_H2 = Strand(domains=[dom_y.C, dom_b.C, dom_a.C, dom_b, dom_c.C]) strand_A = Strand(domains=[dom_b.C, dom_a.C]) strand_B = Strand(domains=[dom_x, dom_b, dom_y]) strand_R = Strand(domains=[dom_x, dom_b, dom_y]) H1 = Complex(strands=[strand_H1], structure=".(.).", name="H1") H2 = Complex(strands=[strand_H2], structure=".(.).", name="H2") # state1 = Complex(strands=[strand_H1, strand_R, strand_A], structure="((.)*+*(.+))") # domain x does not have to be bound state2 = Complex(strands=[strand_H1, strand_R, strand_A], structure="((.((+)).+))", name="state2") state3 = Complex(strands=[strand_H1, strand_R, strand_H2, strand_A], structure="(((((+))(+)(.))+))") # state4 = Complex(strands=[strand_H1, strand_R, strand_H2, strand_A], structure="(((((+)((+)).))+))", name = "state4") state5 = Complex(strands=[strand_H1, strand_R, strand_H2, strand_A], structure="((((.+.((+)).))+))", name="state5") # state6 = Complex(strands=[strand_H1, strand_H1, strand_R, strand_H2, strand_A], structure="((((.+((.)*+*((+)))))+))") # domain x does not have to be bound # state6 = Complex(strands=[strand_H1, strand_H1, strand_R, strand_H2, strand_A], structure="((((.+((.).+.((+)))))+))", name = "state6") # state7 = Complex(strands=[strand_H1, strand_H1, strand_R, strand_H2, strand_A], structure="((((.+((.((+))*+*))))+))", name = "state7") stopFailure = StopCondition(Literals.failure, [(state2, Literals.dissoc_macrostate, 0)]) stopSuccess = StopCondition(Literals.success, [(state5, Literals.loose_macrostate, 6)]) stdOptions.start_state = [state3] stdOptions.stop_conditions = [stopSuccess, stopFailure] stdOptions.join_concentration = 0.001 return stdOptions
def _redefineMismatchedComplexes(self): # Redefine complexes # print "Warning: one of these complexes will be invalid! Must replace" self.threshold_free_waste_complex = Complex( strands=[self.base_dom_strand], structure='.' * len(self.base_dom_strand.sequence)) self.gate_output_complex = Complex( strands=[self.base_strand, self.output_strand], structure=".((((+.))))") self.gate_fuel_complex = Complex( strands=[self.base_strand, self.fuel_strand], structure=".((((+.))))") self.gate_input_complex = Complex( strands=[self.base_strand, self.input_strand], structure="((((.+)))).") self.threshold_complex = Complex( strands=[self.threshold_base, self.base_dom_strand], structure="..(((+)))") self.input_complex = Complex(strands=[self.input_strand], structure='.' * len(self.input_strand.sequence)) self.fuel_complex = Complex(strands=[self.fuel_strand], structure='.' * len(self.fuel_strand.sequence)) self.output_complex = Complex(strands=[self.output_strand], structure='.' * len(self.output_strand.sequence))
def placeMismatchInInputWire(self, position): mismatched_strands = self.placeMismatchInDomain( position, self.base_domain.sequence) # So now the input strand has a 'C' in the designated position recog_len = len(self.base_domain.sequence) # Place a mismatch in the input wire self.input_strand = mismatched_strands[0] + \ self.toehold_domain + self.input_domain # make the new base strand have a 'C-C' mismatch self.base_strand = self.toehold_domain.C + \ mismatched_strands[1] + self.toehold_domain.C # we want to keep our the gate self.base_domain = mismatched_strands[1].C # Update the relevant strands and complexes to take the mismatch into account # Use the convention of always adding 5' to 3' # Setup stuff for this type of gate self.fuel_strand = self.fuel_domain + self.toehold_domain + self.base_domain self.output_strand = self.output_domain + \ self.toehold_domain + self.base_domain # We do want the threshold to still act well!! self.threshold_base = self.input_partial.C + self.toehold_domain.C + \ mismatched_strands[0].C self.base_dom_strand = Strand(name="base strand", domains=[mismatched_strands[0]]) self._redefineMismatchedComplexes() self.gate_input_complex = Complex( strands=[self.base_strand, self.input_strand], structure="((.(.+).)).")
def doSims(strandSeq, numTraj=2): curr = time.time() o1 = standardOptions(tempIn=36.95) o1.num_simulations = numTraj o1.output_time = 0.0004 # output every .4 ms o1.simulation_time = 0.35 # unit: second o1.gt_enable = 1 o1.substrate_type = Literals.substrateRNA o1.simulation_mode = Literals.trajectory o1.cotranscriptional = True # enables the strand growing on the 3' end. onedomain = Domain(name="mydomain", sequence=strandSeq) top = Strand(name="top", domains=[onedomain]) startTop = Complex(strands=[top], structure=".") o1.start_state = [startTop] o1.DNA23Arrhenius() # o1.initial_seed = 1777+6 s = SimSystem(o1) s.start() printTrajectory(o1) print "Exe time is " + str(time.time() - curr)
def placeMismatchInFuelWireBase(self, position): # alter the base domain, as per usual mismatched_strands = self.placeMismatchInDomain( position, self.base_domain.sequence) # So now the input strand has a 'C' in the designated position # Get the standard recognition domain length recog_len = len(self.base_domain.sequence) self.fuel_strand = self.fuel_domain + \ self.toehold_domain + mismatched_strands[0] # make the new base strand have a 'C-C' mismatch with the fuel self.base_strand = self.toehold_domain.C + \ mismatched_strands[1] + self.toehold_domain.C # we want to keep our the gate - as above, the complement for the prime in most places! self.base_domain = mismatched_strands[1].C # Update the relevant strands and complexes to take the mismatch into account # Use the convention of always adding 5' to 3' # Setup stuff for this type of gate self.input_strand = self.base_domain + self.toehold_domain + self.input_domain self.output_strand = self.output_domain + \ self.toehold_domain + self.base_domain # We do want the threshold to still act well!! self.threshold_base = self.input_partial.C + self.toehold_domain.C + \ mismatched_strands[0].C self.base_dom_strand = Strand(name="base strand", domains=[mismatched_strands[0]]) self._redefineMismatchedComplexes() self.gate_fuel_complex = Complex( strands=[self.base_strand, self.fuel_strand], structure=".(.((+.)).)")
def first_step_simulation(strand_seq, trials, T=25, material="DNA"): print ("Running %i first step mode simulations for %s (with Boltzmann sampling)..." % (trials, 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 dangle = Strand(name="Dangle", domains=[onedomain, gdomain]) duplex_complex = Complex(strands=[top, bot], structure="(+)") invader_complex = Complex(strands=[dangle], structure="..") duplex_invaded = Complex(strands=[dangle, bot], structure="(.+)") # Declare the simulation complete if the strands become a perfect duplex. success_stop_condition = StopCondition(Options.STR_SUCCESS, [(duplex_invaded, Options.exactMacrostate, 0)]) failed_stop_condition = StopCondition(Options.STR_FAILURE, [(duplex_complex, Options.dissocMacrostate, 0)]) for x in [duplex_complex, invader_complex]: x.boltzmann_count = trials x.boltzmann_sample = True # the first argument has to be trials. def getOptions(trials, material, duplex_complex, dangle, success_stop_condition, failed_stop_condition): o = Options(simulation_mode="First Step", substrate_type=material, rate_method="Metropolis", num_simulations=trials, simulation_time=ATIME_OUT, temperature=T) o.start_state = [duplex_complex, dangle] o.stop_conditions = [success_stop_condition, failed_stop_condition] # FD: The result of this script depend significantly on JS or DNA23 parameterization. o.unimolecular_scaling = 5.0e6; o.bimolecular_scaling = 1.4e6; return o myOptions = getOptions(trials,material, duplex_complex, invader_complex, success_stop_condition, failed_stop_condition) s = SimSystem(myOptions) s.start() print "debug_mac2 finished running."
def create_options(): print "creating options..." d1 = Domain(name="d1", sequence="GTTGGTTTGTGTTTGGTGGG") s1 = Strand(name="s1", domains=[d1]) c1 = Complex(name="c1", strands=[s1], structure=".") c2 = Complex(name="c2", strands=[s1.C], structure=".") c3 = Complex(name="c3", strands=[s1, s1.C], structure="(+)") sc_rev = StopCondition("REVERSE", [(c1, 2, 0), (c2, 2, 0)]) sc_for = StopCondition("END", [(c3, 4, 6)]) o = Options(simulation_mode = 'First Step', num_simulations = 100, simulation_time = 0.5, start_state = [RestingState("1", [c1]), RestingState("2", [c2])], stop_conditions = [sc_rev, sc_for]) #o.initial_seed = random.SystemRandom().randrange(-2147483648, 2147483647) print "finished options. creating simsystem..." #print o.interface return o
def create_test8(): toehold_seq = "CTGC" domain_seq = "CATGCTACAG" # build complexes with domain-level information toehold = Domain(name="toehold", sequence=toehold_seq, length=6) branch_migration = Domain(name="branch_migration", sequence=domain_seq, seq_length=25) dangle = Domain(name="branch_migration", sequence="T", seq_length=1) incoming = toehold + branch_migration.C + toehold.C start_complex = Complex(strands=[incoming], structure="(.)") stop_complex = Complex(strands=[incoming], structure="...") return createOptions(start_complex, stop_complex, "First Passage Time")
def create_test0(): toehold_seq = "CCCC" domain_seq = "CATTAAC" # build complexes with domain-level information toehold = Domain(name="toehold", sequence=toehold_seq, length=4) branch_migration = Domain(name="branch_migration", sequence=domain_seq, seq_length=7) incoming = branch_migration.C + toehold.C substrate = toehold + branch_migration start_complex = Complex(strands=[incoming, substrate], structure="((+))") stop_complex = Complex(strands=[incoming, substrate], structure="..+..") return createOptions(start_complex, stop_complex, "First Passage Time")
def create_test3(): strand_seq = "CTGA" num_traj = 10 # Essentially, creates the options object and prepares to simulate the hybridization of the strand and its complement. onedomain = Domain(name="itall", sequence=strand_seq) 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. start_complex_top = Complex(strands=[top], structure=".") start_complex_bot = Complex(strands=[bot], structure=".") start_complex_top.boltzmann_count = num_traj start_complex_bot.boltzmann_count = num_traj start_complex_top.boltzmann_sample = True start_complex_bot.boltzmann_sample = True # Turns Boltzmann sampling on for this complex and also does sampling more efficiently by sampling 'num_traj' states. # Stop when the exact full duplex is achieved. (No breathing!) success_complex = Complex(strands=[top, bot], structure="(+)") success_stop_condition = StopCondition( "SUCCESS", [(success_complex, Literals.exact_macrostate, 0)]) # Declare the simulation unproductive if the strands become single-stranded again. failed_complex = Complex(strands=[top], structure=".") failed_stop_condition = StopCondition( "FAILURE", [(failed_complex, Literals.dissoc_macrostate, 0)]) o = Options(simulation_mode="First Step", parameter_type="Nupack", substrate_type="DNA", rate_method="Metropolis", num_simulations=num_traj, simulation_time=1.0, dangles="Some", temperature=273.15 + 25.0, rate_scaling="Calibrated", useArrRates=True, verbosity=0) o.start_state = [start_complex_top, start_complex_bot] o.stop_conditions = [success_stop_condition, failed_stop_condition] return o
def __init__(self, input_sequence, base_sequence, output_sequence, fuel_sequence, toehold_sequence): count_str = str(NormalSeesawGate.Gate_Count) self.input_domain = Domain(name="input_domain_" + count_str, sequence=input_sequence) self.base_domain = Domain(name="base_domain_" + count_str, sequence=base_sequence) self.output_domain = Domain(name="output_domain_" + count_str, sequence=output_sequence) self.fuel_domain = Domain(name="fuel_domain_" + count_str, sequence=fuel_sequence) self.toehold_domain = Domain(name="toehold_domain_" + count_str, sequence=toehold_sequence) # Use the convention of always adding 5' to 3' # Setup stuff for this type of gate self.input_strand = self.base_domain + self.toehold_domain + self.input_domain self.fuel_strand = self.fuel_domain + self.toehold_domain + self.base_domain self.base_strand = self.toehold_domain.C + \ self.base_domain.C + self.toehold_domain.C self.output_strand = self.output_domain + \ self.toehold_domain + self.base_domain self.input_partial = Domain( name="partial", sequence=self.input_domain.sequence[:SEESAW_DELTA]) self.threshold_base = self.input_partial.C + self.toehold_domain.C + \ self.base_domain.C self.base_dom_strand = Strand(name="base strand", domains=[self.base_domain]) self.threshold_free_waste_complex = Complex( strands=[self.base_dom_strand], structure='.' * len(self.base_dom_strand.sequence)) self.gate_output_complex = Complex( strands=[self.base_strand, self.output_strand], structure=".((+.))") self.gate_fuel_complex = Complex( strands=[self.base_strand, self.fuel_strand], structure=".((+.))") self.gate_input_complex = Complex( strands=[self.base_strand, self.input_strand], structure="((.+)).") self.threshold_complex = Complex( strands=[self.threshold_base, self.base_dom_strand], structure="..(+)") self.input_complex = Complex(strands=[self.input_strand], structure='.' * len(self.input_strand.sequence)) self.fuel_complex = Complex(strands=[self.fuel_strand], structure='.' * len(self.fuel_strand.sequence)) self.output_complex = Complex(strands=[self.output_strand], structure='.' * len(self.output_strand.sequence)) NormalSeesawGate.Gate_Count += 1
def create_test6B(): toehold_seq = "CCC" toehold_seq2 = "TTT" domain_seq = "AA" # build complexes with domain-level information toehold = Domain(name="toehold", sequence=toehold_seq, length=3) toehold2 = Domain(name="toehold", sequence=toehold_seq2, length=3) branch_migration = Domain(name="branch_migration", sequence=domain_seq, seq_length=2) incoming = toehold2.C + branch_migration.C + toehold.C substrate = toehold + branch_migration + toehold2 start_complex = Complex(strands=[incoming, substrate], structure="(.(+).)") stop_complex = Complex(strands=[incoming, substrate], structure="...+...") return createOptions(start_complex, stop_complex, "First Passage Time")
def hairpinopening(options, stemSeq, loopSeq, myTrials=0): # Using domain representation makes it easier to write secondary structures. stemdomain1 = Domain(name="stemdomain1", sequence=stemSeq) loopdomain = Domain(name="loopdomain", sequence=loopSeq) stemdomain2 = stemdomain1.C strand = Strand(name="top", domains=[stemdomain1, loopdomain, stemdomain2]) start_complex = Complex(strands=[strand], structure="(.)") success_complex = Complex(strands=[strand], structure="...") # N.B.: myTrials input signature is considered "default", # but in no circumstance will we enable Boltzmann sampling # Stop when the exact full duplex is achieved. stopSuccess = StopCondition( Literals.success, [(success_complex, Literals.exact_macrostate, 0)]) options.start_state = [start_complex] options.stop_conditions = [stopSuccess]
def create_setup(trials, toehold_seq, toehold_seq2, domain_seq): # build complexes with domain-level information toehold = Domain(name="toehold", sequence=toehold_seq, length=len(toehold_seq2)) toehold_2 = Domain(name="toehold", sequence=toehold_seq2, length=len(toehold_seq2)) branch_migration = Domain(name="branch_migration", sequence=domain_seq, seq_length=len(domain_seq)) incoming = branch_migration.C + toehold.C substrate = toehold + branch_migration + toehold_2 incumbent = Strand(name="incumbent", domains=[toehold_2.C, branch_migration.C]) # Note that "+" is used to indicate strand breaks. # So the initial structures represent the incoming strand bound by its toehold, # and we'll see that either it completes strand displacement, or it dissociates. start_complex = Complex(strands=[incoming, substrate, incumbent], structure=".(+)((+))") stop_complex = Complex(strands=[incoming, substrate, incumbent], structure="((+))(+).") full_sc = StopCondition("CLOSED", [(stop_complex, Literals.exact_macrostate, 0)]) o1 = Options(simulation_mode="First Passage Time", parameter_type="Nupack", substrate_type="DNA", temperature=273.15 + 25.0, num_simulations=trials, simulation_time=0.0001, rate_scaling='Calibrated', verbosity=0, start_state=[start_complex], stop_conditions=[full_sc]) return o1
def dissociation(options, mySeq, myTrials=0): # 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. duplex = Complex(strands=[top, bot], structure="(+)") # Turns Boltzmann sampling on for this complex and also does sampling more efficiently by sampling 'trials' states. if (myTrials > 0): setBoltzmann(duplex, myTrials) # Stop when the strands fall apart. successComplex = Complex(strands=[top], structure=".") stopSuccess = StopCondition( Options.STR_SUCCESS, [(successComplex, Options.dissocMacrostate, 0)]) options.start_state = [duplex] options.stop_conditions = [stopSuccess]