thtools.core.ToeholdTest

class thtools.core.ToeholdTest

A class to test different trigger sets against the toehold switch for activation, in order to find specificity.

All parameters are safe to be mutated after instantiation but before the simulation is run.

Parameters
thsstr

Your toehold switch.

ths_concfloat

The concentration of your toehold switch.

rbs_sliceslice

The slice of the toehold switch containing the RBS.

trigger_setsCollection[Collection[str]]

An array-like of trigger sets. Each trigger set will be tested seperately from the others.

conc_setsCollection[Collection[float]]

Concentrations of the above triggers in each trigger set.

const_rnaMapping[str, float], default={}

Mapping of {sequence : concentration} for any RNAs you want to be present/constant in all test tube simulations.

modelnupack.Model, default=nupack.Model()

The thermodynamic model to use.

namesCollection[str | Collection[str]], optional

The names of each trigger set. If a collection of names is given for each trigger set, they will be joined with ‘+’ signs. This can also be set through the names attribute of ToeholdResult or passed as an argument to one of the ToeholdResult methods.

Raises
AssertionError

If trigger_sets has a different shape to conc_sets.

See also

ToeholdResult

Data container for the result of a ToeholdTest.

autoconfig()

Quick configuration of ToeholdTests, assuming every RNA has the concentration of thtools.utils.ASSUMED_STRAND_CONC.

Notes

  • Runs a test tube simulation for each trigger set using NUPACK.

  • Analyzes the complexes and their concentrations up to a complex size of max_size.

  • Each complex has n_samples Boltzmann samples taken.

  • Hence the probability of the toehold being properly unbound is calculated.

Examples

>>> import thtools as tt
>>> ths = "UUAGCCGCUGUCACACGCACAGGGAUUUACAAAAAGAGGAGAGUAAAAUGCUGUGCGUGCACCAUAAAACGAACAUAGAC"
>>> ths_conc = 1e-7
>>> rbs_slice = slice(34, 42)
>>> trigger_sets = [["CUGUGCGUGUGACAGCGGCUGA"],
...                 ["CUAUACAAUCUACUGUCUUUCC"],
...                 ["UGUACAGCCUCCUAGCUUUCC"]]
>>> conc_sets = [[1e-7],
...              [1e-7],
...              [1e-7]]
>>> my_test = tt.ToeholdTest(ths, ths_conc, rbs_slice, trigger_sets, conc_sets)
>>> my_result = my_test.run(max_size=3, n_samples=100)
>>> my_result.specificity # gives as decimal, not percentage
0.9999999801562275
Attributes
thsstr
ths_concfloat
rbs_sliceslice
trigger_setsCollection[Collection[str]]
conc_setsCollection[Collection[float]]
const_rnaMapping[str, float], default = {}
modelnupack.Model, default = nupack.Model()
namesCollection[str | Collection[str]], optional
resultToeholdResult
copy()

Return a copy of self.

generate(max_size, n_samples, n_nodes, chunks_per_node)

Run the test, returning a generator that the user must iterate through.

This generator allows the display of progress bars for the work, but is slower than the run() method. It stores a ToeholdResult to the result attribute.

Parameters
max_sizeint

The maximum RNA complex size to simulate.

n_samplesint, default = 100

The number of Boltzmann samples to take of each complex’s secondary structure.

n_nodesint, default = os.cpu_count()

The number of CPU cores to distribute work across using Pathos.

chunks_per_nodeint, default = 1

The number of chunks to split each node’s work into. Increasing this will produce a smoother progress bar, but a slower simulation.

Yields
np.ndarray

[activation, RBS unbinding, start codon unbinding, post-start codon unbinding, activation standard error] for each trigger set in trigger_sets.

Notes

This method is significantly slower than run() (>20% slower for large jobs).

run(max_size, n_samples, n_nodes)

Run the test.

Parameters
max_sizeint

The maximum RNA complex size to simulate.

n_samplesint, default = 100

The number of Boltzmann samples to take of each complex’s secondary structure.

n_nodesint, default = os.cpu_count()

The number of CPU cores to distribute work across using pathos.

Returns
ToeholdResult

A container for the data.

Notes

The result is also stored in the result attribute.