src.strand package

Submodules

src.strand.bond module

class src.strand.bond.Bond(node1, node2, dom, dom2)[source]

Bases: object

Data structure of bonds between two domains

appenddom(dom, dom2)[source]

append domain numbers

Parameters
  • dom – domain number on the start strand

  • dom2 – domain number on the end strand

dom = []

domain of the startnode

dom2 = []

domain of the endnode

node1 = 0

start node

node2 = 0

end node

transform_E()[source]

flatten the edges

Returns

edges in list

src.strand.bond_graph module

class src.strand.bond_graph.BondGraph(V, color, E)[source]

Bases: object

Data structure of the bond graph, undirected graph with loops

E = []

edges

V = []

vertices

add_edges(v1, v2, d1, d2)[source]

add edges to the bond graph

Parameters
  • v1 – strand 1

  • v2 – strand 2

  • d1 – domain 1, corresponds to strand 1

  • d2 – domain 2, corresponds to strand 2

adj = []

adjacency list

call_spanning(mark, edge, times, depth)[source]

find a spanning forest of the bond graph and store the loops existing in it

Parameters
  • mark – list of boolean numbers of vertices to show if they have been visited

  • edge – edges of a spanning tree of the bond graph

  • times – list of integers of vertices indicating the times of spanning() is called

  • depth – current cycle number of calling spanning()

check_bonded(node)[source]

check if the node is bonded to another node

Parameters

node – a domain on a strand

Returns

the domain it binds to if True, otherwise None

check_following_migration(edges, p=0)[source]

UNDER TESTING. :param edges: :return:

check_in_loop(startnode, endnode)[source]

check if the two vertices are in the same loop

Parameters
  • startnode – start vertex

  • endnode – end vertex

Returns

True if in the same loop, False otherwise

check_junction(startnode, endnode, toehold)[source]

check if the bond between startnode and endnode is a part of junction

Parameters
  • startnode

  • endnode

Returns

check_strand_is_bonded(v)[source]

check if the strand is bonded

Parameters

v – strand

Returns

domains on strand that is bonded

color = []

inherit from StrandGraph

create_bond(v1, v2, d1, d2)[source]

create bond

Parameters
  • v1 – the strand to be examined

  • v2 – the target strand to check

  • d1 – the domain position on the examining strand of the bond

  • d2 – the domain position on the target strand of the bond

Returns

find_loops()[source]

find loops in the bond graph

get_bond(startstrand, endstrand)[source]

get the bond between the two vertices

Parameters
  • startstrand – start strand

  • endstrand – end strand

Returns

get the bond between two strands

get_connection(startnode, endstrand)[source]

get connection nodes from the startnode to the endstrand

Parameters
  • startnode – starting node

  • endstrand – end strand

Returns

path from startnode to end strand

get_direction(startstrand, endstrand)[source]

Note that we don’t consider loops here. :param endstrand: :param startstrand: :return:

get_species()[source]

get all species in one bondgraph

:return:all species

hidden = []

hidden domains of strands

loop = []

loops in the graph

merge_bonds_ignoring_nodes(v, nodes)[source]

merge bonds on v ignoring bonds connected to nodes

Parameters
  • v – a strand

  • nodes – a set of strands

Returns

bonds

potential_junction(node1, node2)[source]

Check if node1 and node2 can be a part of junction :param node1: :param node2: :return:

search_path(startstrand, stack, endstrand, edge)[source]

search a path from the start node to the end node in the spanning tree

spanning(mark, edge, startstrand, times, depth)[source]

building a spanning tree of the bond graph

Parameters
  • mark – list of boolean numbers of vertices to show if they have been visited

  • edge – edges of a spanning tree of the bond graph

  • startstrand – starting strand to find spanning tree

  • times – list of integers of vertices indicating the times of this function is called

  • depth – current cycle number of calling this function

species = []

species of the graph

speciesnum = 0

species number

store_hidden()[source]

store all the hidden domains in hidden[]

class src.strand.bond_graph.SubBondGraph(V, color, adj, Vp)[source]

Bases: src.strand.bond_graph.BondGraph

Subgraph of bondgraph

Vsub = []

vertices

adj = []

adjacency list

colormap = {}

map colors to vertices

colorset = {}

set of colors

map_colors(edge)[source]

src.strand.strand module

class src.strand.strand.Domain(name, toehold, comp, bond, bondname)[source]

Bases: object

Data structure of the domain

bond = False

boolean variable indicating if the domain is bonded

bondname = ''

name of the bond, empty if not bonded

check_same_domain(domain1)[source]

check if domain1 is equivalent to the current domain

Parameters

domain1

Returns

True if equivalent, False otherwise

comp = False

boolean variable indicating if the domain is a complementary domain to some other domain

name = ''

name of the domain

set_bond(bondname)[source]
toehold = False

boolean variable indicating if the domain is a toehold

class src.strand.strand.Strand[source]

Bases: object

Data structure of the strand

add_color(color)[source]
add_domain(domain)[source]
check_same_strand(strand1)[source]

check if strand1 is equivalent to the current strand

Parameters

strand1

Returns

True if equivalent, False otherwise

color = 0

color of the strand

domains = []

domains of the strand

src.strand.strand_graph module

class src.strand.strand_graph.StrandGraph(strands, merge=0)[source]

Bases: object

Data structure of the strand graph

A = []

admissible edges, edges that bonds can exist in

E = []

actual edges, edges that already exist

V = []

vertices

anchored(e)[source]

check if e is anchored

Parameters

e – an edge

Returns

True if anchored, False otherwise

anti_parallel(node1, node2)[source]

check if the bond satisfies the anti-parallel schema

Parameters
  • node1

  • node2

Returns

True if satisfy, False otherwise

available(e)[source]

check if a binding is available for binding

Parameters

e – a bond

Returns

True if available, False otherwise

bondgraph = None

bond graph derived from this graph

build_bond_graph()[source]

build bond graph for the strand graph

check_bonded(strand1, strand2)[source]

check if strand1 is bonded to strand2

Parameters
  • strand1

  • strand2

Returns

bonded domains in format [{(strand1, dom1), (strand2, dom2)}, …]

check_candidate(e1)[source]

check if e1 is a candidate for rule migration

Parameters

e1 – an admissible edge

Returns

check_complementary(domain1, domain2)[source]
Parameters
  • domain1

  • domain2

Returns

check_hidden_all(edge)[source]
Parameters

edge

Returns

check_switchable(notbond, tbr, i)[source]

check if it is possible to do 3-way migration

Parameters
  • notbond – notbond domain

  • r – replace domain

Returns

True if possible, False otherwise

check_switchable_2(r1, tbr)[source]

check if it is possible for 4-way migration

Parameters
  • r1 – replacing bond

  • tbr – bond to be replaced

Returns

True if possible, False otherwise

check_toehold(e)[source]

check if the binding domains are toehold domains

Parameters

e – a bond

Returns

True if are toehold domains, False otherwise

color = []

strand type

delete_edge(e, prevE)[source]
delete_edges_regarding_v(v, prevE)[source]

delete a vertex v and all edges link to it in strandgraph

Parameters
  • v

  • prevE

delete_vertex(v)[source]
find_mediated_toehold(node, depth, visited)[source]
get_connect_toehold(notbond, potbondto)[source]

get the toeholds that connect the two domains of edge

Parameters
  • edge

  • notbond

  • potbondto

Returns

get_domain_comp(domain)[source]
get_domain_obj(domain)[source]
Parameters

domain

Returns

have_anchor(startstrand, endstrand, domlow, domhigh)[source]
hidden(e)[source]

check if domains in the bond are hidden in a cycle of strands

Parameters

e – bond

Returns

True if hidden, False otherwise

length = []

length of the vertices (in length of domains)

reconstruct(E)[source]

reconstruct the graph using the set of edges

Parameters

E – edges

same_species(e)[source]

check if the edge is from the same species

Parameters

e – edge

Returns

True if it is, False otherwise

strands = []

strands in this graph

toehold = []

a list of dictionaries to store if toehold exist in an edge

Module contents