def test_interface_01(self): PepperComplex.PREFIX = 'enum' complexes, reactions = read_pil(""" # Domain Specifications length a = 8 length b = 8 length c = 8 length d2 = 8 length d3 = 8 length t = 4 # Resting-set Complexes e0 = d2( d3( + ) a* + a*( b*( c ) ) ) t* e12 = d2 d3( + ) a* e13 = t( d2( d3 + a*( b*( c ) ) ) ) e21 = d2 d3 e22 = t( d2( d3( + ) a*( + a* b*( c ) ) ) ) e27 = t( d2( d3( + ) a* + a*( b*( c ) ) ) ) gate = d2( d3( + ) a*( + a* b*( c ) ) ) t* t23 = t d2 d3 # Transient Complexes e5 = t( d2 d3 + d2( d3( + ) a*( + a* b*( c ) ) ) ) e7 = t( d2 d3 + d2( d3( + ) a* + a*( b*( c ) ) ) ) e18 = t( d2( d3 + d2 d3( + ) a*( + a* b*( c ) ) ) ) # Detailed Reactions reaction [bind21 = 1.2e+06 /M/s ] e0 + t23 -> e7 reaction [branch-3way = 0.122307 /s ] e0 -> gate reaction [branch-3way = 41.6667 /s ] e5 -> e7 reaction [branch-3way = 41.6667 /s ] e5 -> e18 reaction [open = 306.345 /s ] e5 -> t23 + gate reaction [open = 306.345 /s ] e7 -> e0 + t23 reaction [branch-3way = 0.122307 /s ] e7 -> e5 reaction [branch-3way = 41.6667 /s ] e7 -> e12 + e13 reaction [branch-3way = 0.122307 /s ] e18 -> e5 reaction [branch-3way = 41.6667 /s ] e18 -> e12 + e13 reaction [branch-3way = 0.122307 /s ] e18 -> e22 + e21 reaction [branch-3way = 41.6667 /s ] e22 -> e27 reaction [branch-3way = 0.122307 /s ] e27 -> e22 reaction [branch-3way = 41.6667 /s ] gate -> e0 reaction [bind21 = 1.2e+06 /M/s ] t23 + gate -> e5 """) enum = Enumerator(complexes.values(), reactions) enum.release_cutoff = 7 enum.enumerate() self.assertEqual(sorted(enum.reactions), sorted(reactions))
def test_zhang_cooperative_binding(self): complexes, reactions = read_pil(""" # Figure 1 of David Yu Zhang, "Cooperative hybridization of oligonucleotides", JACS, 2012 # File generated by peppercorn-v0.5.0 # Domain Specifications length d1 = 8 length d2 = 18 length d3 = 18 length d4 = 8 # Resting-set Complexes C1 = d2( d3( + d4* ) ) d1* L1 = d1( d2 + d2( d3( + d4* ) ) ) L2 = d1( d2( + d2 d3( + d4* ) ) ) Out = d2 d3 R1 = d2( d3( + d3 d4( + ) ) ) d1* R2 = d2( d3 + d3( d4( + ) ) ) d1* T1 = d1 d2 T2 = d3 d4 Waste = d1( d2( + d3( d4( + ) ) ) ) # Transient Complexes L1R1 = d1( d2 + d2( d3( + d3 d4( + ) ) ) ) L1R2 = d1( d2 + d2( d3 + d3( d4( + ) ) ) ) L2R1 = d1( d2( + d2 d3( + d3 d4( + ) ) ) ) # Detailed Reactions reaction [bind21 = 2.4e+06 /M/s ] C1 + T2 -> R1 reaction [bind21 = 2.4e+06 /M/s ] L1 + T2 -> L1R1 reaction [branch-3way = 18.5185 /s ] L1 -> L2 reaction [branch-3way = 18.5185 /s ] L1R1 -> L1R2 reaction [branch-3way = 18.5185 /s ] L1R1 -> L2R1 reaction [branch-3way = 18.5185 /s ] L1R2 -> L1R1 reaction [branch-3way = 18.5185 /s ] L1R2 -> Waste + Out reaction [bind21 = 2.4e+06 /M/s ] L2 + T2 -> L2R1 reaction [branch-3way = 18.5185 /s ] L2 -> L1 reaction [branch-3way = 18.5185 /s ] L2R1 -> L1R1 reaction [branch-3way = 18.5185 /s ] L2R1 -> Waste + Out reaction [branch-3way = 18.5185 /s ] R1 -> R2 reaction [branch-3way = 18.5185 /s ] R2 -> R1 reaction [bind21 = 2.4e+06 /M/s ] T1 + C1 -> L1 reaction [bind21 = 2.4e+06 /M/s ] T1 + R1 -> L1R1 reaction [bind21 = 2.4e+06 /M/s ] T1 + R2 -> L1R2 """) enum = Enumerator(complexes.values(), reactions) enum.k_fast = 0.01 enum.release_cutoff = 10 #enum.enumerate() # or enum.dry_run() enum.dry_run() enumRG = PepperCondensation(enum) enumRG.condense() """ macrostate rC1 = [C1] macrostate rL2 = [L2, L1] macrostate rOut = [Out] macrostate rR1 = [R1, R2] macrostate rT1 = [T1] macrostate rT2 = [T2] macrostate rWaste = [Waste] reaction [condensed = 2.4e+06 /M/s ] rT1 + rC1 -> rL2 reaction [condensed = 2.4e+06 /M/s ] rL2 + rT2 -> rWaste + rOut reaction [condensed = 2.4e+06 /M/s ] rC1 + rT2 -> rR1 reaction [condensed = 2.4e+06 /M/s ] rT1 + rR1 -> rWaste + rOut reaction [condensed = 0.00316623 /s ] rL2 -> rT1 + rC1 reaction [condensed = 0.00316623 /s ] rR1 -> rC1 + rT2 """ L1 = complexes['L1'] L2 = complexes['L2'] rL2 = PepperMacrostate([L2, L1], memorycheck=False) Out = complexes['Out'] rOut = PepperMacrostate([Out], memorycheck=False) Waste = complexes['Waste'] rWaste = PepperMacrostate([Waste], memorycheck=False) T2 = complexes['T2'] rT2 = PepperMacrostate([T2], memorycheck=False) # calculated by hand... cr1 = PepperReaction([rL2, rT2], [rWaste, rOut], 'condensed', rate=2.4e6, memorycheck=False) found = False for r in enumRG.condensed_reactions: if r == cr1: found = True self.assertAlmostEqual(r.rate, cr1.rate) self.assertTrue(found)
def test_fate_example(self): PepperComplex.PREFIX = 'enum' complexes, reactions = read_pil(""" # File generated by peppercorn-v0.5.0 # Domain Specifications length a = 8 length b = 8 length c = 8 length d2 = 8 length d3 = 8 length t = 4 # Resting-set Complexes e0 = d2( d3( + ) a* + a*( b*( c ) ) ) t* e12 = d2 d3( + ) a* e13 = t( d2( d3 + a*( b*( c ) ) ) ) e21 = d2 d3 e22 = t( d2( d3( + ) a*( + a* b*( c ) ) ) ) e27 = t( d2( d3( + ) a* + a*( b*( c ) ) ) ) gate = d2( d3( + ) a*( + a* b*( c ) ) ) t* t23 = t d2 d3 # Transient Complexes e5 = t( d2 d3 + d2( d3( + ) a*( + a* b*( c ) ) ) ) e7 = t( d2 d3 + d2( d3( + ) a* + a*( b*( c ) ) ) ) e18 = t( d2( d3 + d2 d3( + ) a*( + a* b*( c ) ) ) ) # Detailed Reactions reaction [bind21 = 1.2e+06 /M/s ] e0 + t23 -> e7 reaction [branch-3way = 0.122307 /s ] e0 -> gate reaction [branch-3way = 41.6667 /s ] e5 -> e7 reaction [branch-3way = 41.6667 /s ] e5 -> e18 reaction [open = 306.345 /s ] e5 -> t23 + gate reaction [open = 306.345 /s ] e7 -> e0 + t23 reaction [branch-3way = 0.122307 /s ] e7 -> e5 reaction [branch-3way = 41.6667 /s ] e7 -> e12 + e13 reaction [branch-3way = 0.122307 /s ] e18 -> e5 reaction [branch-3way = 41.6667 /s ] e18 -> e12 + e13 reaction [branch-3way = 0.122307 /s ] e18 -> e22 + e21 reaction [branch-3way = 41.6667 /s ] e22 -> e27 reaction [branch-3way = 0.122307 /s ] e27 -> e22 reaction [branch-3way = 41.6667 /s ] gate -> e0 reaction [bind21 = 1.2e+06 /M/s ] t23 + gate -> e5 """) gate = complexes['gate'] t23 = complexes['t23'] enum = Enumerator(complexes.values()) enum.release_cutoff = 6 enum.enumerate() # or enum.dry_run() self.assertEqual(sorted(enum.reactions), sorted(reactions)) """ # Resting sets state re0 = [e0, gate] state re12 = [e12] state re13 = [e13] state re21 = [e21] state re22 = [e22, e27] state rt23 = [t23] reaction [condensed = 287342 /M/s ] re0 + rt23 -> re13 + re12 reaction [condensed = 2.45499 /M/s ] re0 + rt23 -> re21 + re22 """ enumRG = PepperCondensation(enum) enumRG.condense() self.assertEqual(len(list(enumRG.resting_macrostates)), 6) self.assertEqual(len(list(enumRG.condensed_reactions)), 2)
def test_zhang_cooperative_binding(self): complexes, reactions = read_pil(""" # Figure 1 of David Yu Zhang, "Cooperative hybridization of oligonucleotides", JACS, 2012 # File generated by peppercorn-v0.5.0 # Domain Specifications length d1 = 8 length d2 = 18 length d3 = 18 length d4 = 8 # Resting-set Complexes C1 = d2( d3( + d4* ) ) d1* L1 = d1( d2 + d2( d3( + d4* ) ) ) L2 = d1( d2( + d2 d3( + d4* ) ) ) Out = d2 d3 R1 = d2( d3( + d3 d4( + ) ) ) d1* R2 = d2( d3 + d3( d4( + ) ) ) d1* T1 = d1 d2 T2 = d3 d4 Waste = d1( d2( + d3( d4( + ) ) ) ) # Transient Complexes L1R1 = d1( d2 + d2( d3( + d3 d4( + ) ) ) ) L1R2 = d1( d2 + d2( d3 + d3( d4( + ) ) ) ) L2R1 = d1( d2( + d2 d3( + d3 d4( + ) ) ) ) # Detailed Reactions reaction [bind21 = 2.4e+06 /M/s ] C1 + T2 -> R1 reaction [bind21 = 2.4e+06 /M/s ] L1 + T2 -> L1R1 reaction [branch-3way = 18.5185 /s ] L1 -> L2 reaction [branch-3way = 18.5185 /s ] L1R1 -> L1R2 reaction [branch-3way = 18.5185 /s ] L1R1 -> L2R1 reaction [branch-3way = 18.5185 /s ] L1R2 -> L1R1 reaction [branch-3way = 18.5185 /s ] L1R2 -> Waste + Out reaction [bind21 = 2.4e+06 /M/s ] L2 + T2 -> L2R1 reaction [branch-3way = 18.5185 /s ] L2 -> L1 reaction [branch-3way = 18.5185 /s ] L2R1 -> L1R1 reaction [branch-3way = 18.5185 /s ] L2R1 -> Waste + Out reaction [branch-3way = 18.5185 /s ] R1 -> R2 reaction [branch-3way = 18.5185 /s ] R2 -> R1 reaction [bind21 = 2.4e+06 /M/s ] T1 + C1 -> L1 reaction [bind21 = 2.4e+06 /M/s ] T1 + R1 -> L1R1 reaction [bind21 = 2.4e+06 /M/s ] T1 + R2 -> L1R2 """) enum = Enumerator(complexes.values(), reactions) enum.k_fast = 0.01 enum.release_cutoff = 10 enum.enumerate() # or enum.dry_run() enumRG = PepperCondensation(enum) enumRG.condense() """ macrostate rC1 = [C1] macrostate rL2 = [L2, L1] macrostate rOut = [Out] macrostate rR1 = [R1, R2] macrostate rT1 = [T1] macrostate rT2 = [T2] macrostate rWaste = [Waste] reaction [condensed = 2.4e+06 /M/s ] rT1 + rC1 -> rL2 reaction [condensed = 2.4e+06 /M/s ] rL2 + rT2 -> rWaste + rOut reaction [condensed = 2.4e+06 /M/s ] rC1 + rT2 -> rR1 reaction [condensed = 2.4e+06 /M/s ] rT1 + rR1 -> rWaste + rOut reaction [condensed = 0.00316623 /s ] rL2 -> rT1 + rC1 reaction [condensed = 0.00316623 /s ] rR1 -> rC1 + rT2 """ try: L1 = complexes['L1'] L2 = complexes['L2'] L = PepperMacrostate([L1, L2]) except SingletonError as err: L = err.existing O = PepperMacrostate([complexes['Out']]) W = PepperMacrostate([complexes['Waste']]) T = PepperMacrostate([complexes['T2']]) # calculated by hand... cr1 = PepperReaction([L, T], [W, O], 'condensed') assert cr1 in enumRG.condensed_reactions assert cr1.rate_constant == (2.4e6, '/M/s')