dasi.design.graph_builder

Classes

AssemblyGraphBuilder(alignment_container[, …])

Class that builds an AssemblyGraph from an alignment container.

Classes

AssemblyGraphBuilder(alignment_container[, …])

Class that builds an AssemblyGraph from an alignment container.

AssemblyGraphPostProcessor(graph, query, …)

Pre-processing for assembly graphs.

class dasi.design.graph_builder.AssemblyGraphBuilder(alignment_container, span_cost=None)[source]

Bases: object

Class that builds an AssemblyGraph from an alignment container.

Methods

add_gap_edge(bnode, anode, query_region[, …])

Add a ‘gap’ edge to the graph.

add_internal_edges(groups)

Add ‘internal’ edges from a list of AlignmentGroups.

add_node(node)

Add node to the graph.

batch_add_edge_costs(graph, edges, span_cost)

Add costs to all edges at once.

create_edge(n1, n2, cost, material, time, …)

Add an edge between two assembly nodes.

make_gap_iterator(a, b)

Find all nodes that satisfy the below condition: b.

make_overlap_iterator(a, b)

Find all nodes that satisfy the below condition: b.

add_gap_edge(bnode, anode, query_region, origin=False, add_to_graph=True)[source]

Add a ‘gap’ edge to the graph.

Parameters
  • bnode – ending AssemblyNode from the previous edge

  • anode – starting AssemblyNode from the next edge

  • query_region – a query region to copy (indices a,b does not matter)

  • origin – whether this gap spans the origin or not

Returns

add_internal_edges(groups)[source]

Add ‘internal’ edges from a list of AlignmentGroups. This means.

Parameters

groups (List[Union[AlignmentGroup, PCRProductAlignmentGroup]]) –

Returns

add_node(node)[source]

Add node to the graph.

Parameters

node (AssemblyNode) – the assembly node to add

Return type

None

Returns

None

static batch_add_edge_costs(graph, edges, span_cost, cost_threshold=None)[source]

Add costs to all edges at once.

Returns

create_edge(n1, n2, cost, material, time, efficiency, span, type_def, internal_or_external, condition, group, notes=None, add_to_graph=False)[source]

Add an edge between two assembly nodes.

Parameters
  • n1 (AssemblyNode) – src node

  • n2 (AssemblyNode) – dest node

  • name – name of the edge

  • cost (Optional[float]) – overall cost of the edge

  • material (Optional[float]) – material cost of the edge. Used in path calculations.

  • time (Optional[float]) – time cost of the edge. Used in path calculations.

  • efficiency (Optional[float]) – efficiency of the edge. Used in path calculations.

  • span (int) – spanning distance (in bp) of the edge.

  • atype – alignment type of the edge.

  • kwargs – additional kwargs for the edge data

Returns

static make_gap_iterator(a, b)[source]

Find all nodes that satisfy the below condition: b.

|--------| |-------| a

Return type

Generator[Tuple[AssemblyNode, AssemblyNode], None, None]

static make_overlap_iterator(a, b)[source]

Find all nodes that satisfy the below condition: b.

|--------|

|-------| a

With the exception that when a.index == b.index, this is not considered an overlap, but covered in the make_gap_iterator, due to using bisect.bisect_right. Overlap is more computationally intensive.

Return type

Generator[Tuple[AssemblyNode, AssemblyNode], None, None]

class dasi.design.graph_builder.AssemblyGraphPostProcessor(graph, query, span_cost, seqdb, container, stats_repeat_window=None, stats_window=None, stats_hairpin_window=None, edge_threshold=None, stages=None)[source]

Bases: object

Pre-processing for assembly graphs. Evaluates:

  1. synthesis complexity and weights corresponding edge

  2. pcr product efficiency

  3. (optional) optimal partitions for synthesis fragments

Methods

optimize_partition(signatures, step[, i, j])

Optimize partition by minimizing the number of signatures in the given array.

score_complexity_edges([edges])

Score synthetic edges.

static optimize_partition(signatures, step, i=None, j=None)[source]

Optimize partition by minimizing the number of signatures in the given array.

Parameters
  • signatures (ndarray) – array of signatures

  • step (int) – step size

  • i (Optional[int]) –

  • j (Optional[int]) –

Returns

score_complexity_edges(edges=None)[source]

Score synthetic edges.

Return type

List[Tuple[AssemblyNode, AssemblyNode, Dict]]