stickydesign package

Subpackages

Submodules

stickydesign.endclasses module

class stickydesign.endclasses.Energetics[source]

Bases: object

class stickydesign.endclasses.endarray[source]

Bases: numpy.ndarray

This is a class for arrays full ends (of type adjacent+end+wc-adjacent-of-complementary-end).

At present, it also handles adjacent+end style ends, but self.end and self.comp will return bogus information. It eventually needs to be split up into two classes in order to deal with this problem.

adjs
append(s2)[source]
cadjs
comps
concat(a2)[source]
endlen
ends
fcomps
seqlen
strings
tolist()[source]

Return the array as an a.ndim-levels deep nested list of Python scalars.

Return a copy of the array data as a (nested) Python list. Data items are converted to the nearest compatible builtin Python type, via the ~numpy.ndarray.item function.

If a.ndim is 0, then since the depth of the nested list is 0, it will not be a list at all, but a simple Python scalar.

Parameters:none
Returns:y – The possibly nested list of array elements.
Return type:object, or list of object, or list of list of object, or ..

Notes

The array may be recreated via a = np.array(a.tolist()), although this may sometimes lose precision.

Examples

For a 1D array, a.tolist() is almost the same as list(a), except that tolist changes numpy scalars to Python scalars:

>>> a = np.uint32([1, 2])
>>> a_list = list(a)
>>> a_list
[1, 2]
>>> type(a_list[0])
<class 'numpy.uint32'>
>>> a_tolist = a.tolist()
>>> a_tolist
[1, 2]
>>> type(a_tolist[0])
<class 'int'>

Additionally, for a 2D array, tolist applies recursively:

>>> a = np.array([[1, 2], [3, 4]])
>>> list(a)
[array([1, 2]), array([3, 4])]
>>> a.tolist()
[[1, 2], [3, 4]]

The base case for this recursion is a 0D array:

>>> a = np.array(1)
>>> list(a)
Traceback (most recent call last):
  ...
TypeError: iteration over a 0-d array
>>> a.tolist()
1
class stickydesign.endclasses.pairseqa[source]

Bases: numpy.ndarray

revcomp()[source]
tolist()[source]

Return the array as an a.ndim-levels deep nested list of Python scalars.

Return a copy of the array data as a (nested) Python list. Data items are converted to the nearest compatible builtin Python type, via the ~numpy.ndarray.item function.

If a.ndim is 0, then since the depth of the nested list is 0, it will not be a list at all, but a simple Python scalar.

Parameters:none
Returns:y – The possibly nested list of array elements.
Return type:object, or list of object, or list of list of object, or ..

Notes

The array may be recreated via a = np.array(a.tolist()), although this may sometimes lose precision.

Examples

For a 1D array, a.tolist() is almost the same as list(a), except that tolist changes numpy scalars to Python scalars:

>>> a = np.uint32([1, 2])
>>> a_list = list(a)
>>> a_list
[1, 2]
>>> type(a_list[0])
<class 'numpy.uint32'>
>>> a_tolist = a.tolist()
>>> a_tolist
[1, 2]
>>> type(a_tolist[0])
<class 'int'>

Additionally, for a 2D array, tolist applies recursively:

>>> a = np.array([[1, 2], [3, 4]])
>>> list(a)
[array([1, 2]), array([3, 4])]
>>> a.tolist()
[[1, 2], [3, 4]]

The base case for this recursion is a 0D array:

>>> a = np.array(1)
>>> list(a)
Traceback (most recent call last):
  ...
TypeError: iteration over a 0-d array
>>> a.tolist()
1
stickydesign.endclasses.tops(s)[source]

stickydesign.energetics_basic module

class stickydesign.energetics_basic.EnergeticsBasic(temperature=37, coaxparams=False, singlepair=False, danglecorr=True, version=None, enclass=None)[source]

Bases: stickydesign.endclasses.Energetics

Energy functions based on several sources, primarily SantaLucia’s 2004 paper. This class uses the same parameters and algorithms as EnergeticsDAOE, bet does not make DX-specific assumptions. Instead, it assumes that each energy should simply be that of two single strands attaching/detaching, without consideration of nicks, stacking, or other effects related to the beginning/end of each sequence. Dangles and tails are still included in mismatched binding calculations when appropriate.

Relevant arguments:

singlepair (bool, default False) — treat single base pair pairings as possible. temperature (float in degrees Celsius, default 37) — temperature to use for the model, in C.

info
matching_uniform(seqs)[source]
temperature
uniform(seqs1, seqs2, debug=False)[source]

stickydesign.energetics_basic_old module

class stickydesign.energetics_basic_old.EnergeticsBasicOld(mismatchtype='max')[source]

Bases: object

Energy functions based on SantaLucia’s 2004 paper. This is the “old” energetics class, which was originally used in Stickydesign. It models DX-tile style sticky ends, but does not do so as specifically as the newer EnergeticsDAOE.

You probably don’t want to use this, unless you have preexisting code or systems that rely on this model:

  • for DX tiles, consider using EnergeticsDAOE
  • for toeholds, consider using EnergeticsBasic

mismatchtype is one of ‘max’, ‘loop’, or ‘dangle’, specifying how to consider mismatches. ‘max’ is probably the best choice, but is slowest - it takes the maximum interaction of the ‘loop’ and ‘dangle’ options.

matching_uniform(seqs)[source]
uniform_danglemismatch(seqs1, seqs2, fast=True)[source]
uniform_loopmismatch(seqs1, seqs2)[source]

stickydesign.energetics_daoe module

class stickydesign.energetics_daoe.EnergeticsDAOE(temperature=37, mismatchtype=None, coaxparams=False, singlepair=False, danglecorr=True, version=None, enclass=None)[source]

Bases: stickydesign.endclasses.Energetics

Energy functions based on several sources, primarily SantaLucia’s 2004 paper, along with handling of dangles, tails, and nicks specifically for DX tile sticky ends.

Parameters:
  • coaxparams (str or False, optional) – choose the coaxial stacking parameters to use. False is no coaxial stacking adjustment, other options are ‘protozanova’, ‘peyret’, and ‘pyshni’.
  • singlepair (bool, optional) – Treat single base pair pairing as possible (defaults to False).
  • temperature (float, optional) – Temperature to use for the model, in degress Celsius (defaults to 37).
info
matching_uniform(seqs)[source]
temperature
uniform(seqs1, seqs2, debug=False)[source]

stickydesign.multimodel module

stickydesign.multimodel.deviation_score(all_ends, all_energetics, devmethod='dev')[source]
stickydesign.multimodel.endchooser(all_energetics, target_vals=None, templates=None, init_wigglefraction=1, next_wigglefraction=0.1, devmethod='dev')[source]

An endchooser generator that chooses ends while trying to optimize for multiple energy models simultaneously.

Arguments:

all_energetics: a list of energetics models to optimize for.

target_vals: if provided, a list or numpy array of target energy values for each model. This is primarily useful if you have already generated sticky ends, and want to choose ends that match (eg, if you chose DT ends and now want to choose TD ones).

stickydesign.newparams module

stickydesign.plots module

stickydesign.plots.box_multi(all_ends, all_energetics, energetics_names=None, title='', **kwargs)[source]
stickydesign.plots.heatmap(ends, energetics, title='', **kwargs)[source]
stickydesign.plots.hist_multi(all_ends, all_energetics, energetics_names=None, title='', **kwargs)[source]

stickydesign.stickydesign module

stickydesign.stickydesign.easy_space(endtype, endlength, interaction=None, fdev=0.05, maxspurious=0.5, maxendspurious=None, tries=1, oldends=[], adjs=['n', 'n'], energetics=None, alphabet='n', echoose=None)[source]
stickydesign.stickydesign.easyends(endtype, endlength, number=0, interaction=None, fdev=0.05, maxspurious=0.5, maxendspurious=None, tries=1, oldends=[], adjs=['n', 'n'], energetics=None, alphabet='n', echoose=None, absolute=False, _presetavail=False)[source]

Easyends is an attempt at creating an easy-to-use function for finding sets of ends.

  • endtype: specifies the type of end being considered. The system for classifying end types goes from 5’ to 3’, and consists of letters describing each side of the end. For example, an end that starts after a double-stranded region on the 5’ side and ends at the end of the strand would be ‘DT’, while one that starts at the beginning of a strand on the 5’ side and ends in a double-stranded region would be ‘TD’. ‘T’ stands for terminal, ‘D’ stands for double-stranded region, and ‘S’ stands for single-stranded region. ‘S’, however, is not currently supported.
  • endlength: specifies the length of end being considered, not including adjacent bases.
  • number (optional): specifies the number of ends to find. If zero or not provided, easyends tries to find as many ends as possible.
  • interaction (optional): a positive number corresponding to the desired standard free energy for hybridization of matching sticky ends. If not provided, easyends calculates an optimal value based on the sequence space.
  • fdev (default 0.05): the fractional deviation (above or below) of allowable matching energies. maxspurious (default 0.5): the maximum spurious interaction, as a fraction of the matching interaction.
  • maxendspurious (default None): if provided, maxspurious is only used for spurious interactions between ends defined as ends, and ends defined as complements. Maxendspurious is then the maximum spurious interaction between ends and ends, and complements and complements. In a system where spurious interactions between ends and complements are more important than other spurious interactions, this can allow for better sets of ends.
  • tries (default 1): if > 1, easyends will return a list of sets of ends, all satisfying the constraints.
  • oldends (optional): a list of ends to be considered as already part of the set.
  • adjacents (default [‘n’,’n’]): allowable adjacent bases for ends and complements.
  • absolute (default False): fdev, maxspurious, and maxendspurious to be interpreted as absolute kcal/mol values rather than fractional values.
  • energetics (optional): an energetics class providing the energy calculation functions. You probably don’t need to change this.
  • alphabet (default ‘n’): The alphabet to use for ends, allowing for three-letter codes.
stickydesign.stickydesign.endchooser_random()[source]

An endchooser function: return a random end with end-comp energy closest to desint.

stickydesign.stickydesign.endchooser_standard(desint, wiggle=0.0)[source]

An endchooser function: return a random end with end-comp energy closest to desint.

stickydesign.stickydesign.endfilter_standard(maxspurious)[source]

An endfilter function: filters out ends that have any (end-end, end-comp, comp-end, comp-comp) interactions with new ends above maxspurious.

stickydesign.stickydesign.endfilter_standard_advanced(maxcompspurious, maxendspurious)[source]

An endfilter function: filters out ends that have end-comp or comp-end interactions above maxcompspurious, and end-end or comp-comp interactions above maxendspurious.

stickydesign.stickydesign.energy_array_uniform(seqs, energetics)[source]

Given an endarray and a set of sequences, return an array of the interactions between them, including their complements.

stickydesign.stickydesign.enhist(endtype, length, adjacents=['n', 'n'], alphabet='n', bins=None, energetics=None, plot=False, color='b')[source]
stickydesign.stickydesign.find_end_set_uniform(endtype, length, spacefilter, endfilter, endchooser, energetics, adjacents=['n', 'n'], num=0, numtries=1, oldendfilter=None, oldends=[], alphabet='n', _presetavail=False)[source]

Find a set of ends of uniform length and type satisfying uniform constraint functions (eg, constrant functions are the same for each end).

This function is intended to be complicated and featureful. If you want something simpler, try easy_ends

Parameters:
  • endtype (str) – right now ‘DT’ for 3’-terminal ends, and ‘TD’ for 5’-terminal ends,
  • length (int) – length of ends, not including adjacent bases, if applicable.
  • adjacents (list of str) – (defaults to [‘n’,’n’]): acceptable bases for adjacents (eg, [‘n’,’n’] or [‘c’, ‘c’]) for the ends and their complements,
  • num (int) – (defaults to 0): number of ends to find (0 keeps finding until available ends are exhausted)
  • numtries (int) – (defaults to 1): if > 1, the function will return a list of sets of ends that all individually satisfy the constraints, so that the best one can be selected manually
  • spacefilter (function) – a “spacefilter” function that takes endarrays and filters them down to ends that, not considering spurious interactions, are acceptable.
  • endfilter (function) – an “endfilter” function that takes current ends in the set, available ends (filtered with current ends), and new ends added, and filters the available ends, considering interactions between ends (eg, spurious interactions).
  • endchooser (function) – an “endchooser” function that takes current ends in the set and available ends, and returns a new end to add to the set.
  • energetics (function) – an “energyfunctions” class that provides the energy functions for everything to use.
  • oldends (endarray) – an endarray of old ends to consider as part of the set
  • alphabet (str) – a single letter specifying what the alphabet for the ends should be (eg, four or three-letter code)
  • oldendfilter (str) – a different “endfilter” function for use when filtering the available ends using interactions with old ends. This is normally not useful, but can be useful if you want, for example, to create a sets with higher cross-interactions between two subsets than within the two subsets.
Returns:

an endarray of generated ends, including provided old ends

Return type:

endarray

stickydesign.stickydesign.get_accept_set(endtype, length, interaction, fdev, maxendspurious, spacefilter=None, adjacents=['n', 'n'], alphabet='n', energetics=None)[source]
stickydesign.stickydesign.spacefilter_standard(desint, dev, maxself)[source]

A spacefilter function: filters to ends that have a end-complement interaction of between desint-dev and desint+dev, and a self-interaction (end-end or comp-comp) of less than maxself.

stickydesign.stickydesign.values_chunked(items, endtype, chunk_dim=10)[source]

Given a list of lists of acceptable numbers for each position in a row of an array, create every possible row, and return an iterator that returns chunks of every possible row up to chunk_dim, iterating dimensions higher than chunk_dim. This probably doesn’t need to be called directly, and may have a _ added in the future.

Return this as an endarray, with set endtype. This can be easily emoved for use elsewhere.

stickydesign.test_general module

class stickydesign.test_general.test_energetics[source]

Bases: object

setup()[source]
test_matching_energies_match()[source]
test_symmetry()[source]
class stickydesign.test_general.test_energetics_basic[source]

Bases: object

setup()[source]
test_matching_energies_match()[source]
test_symmetry()[source]
class stickydesign.test_general.test_energetics_daoe[source]

Bases: object

setup()[source]
test_matching_energies_match()[source]
test_symmetry()[source]

stickydesign.version module

Module contents