pydna.assembly2
Slightly different assembly implementation
- pydna.assembly2.gather_overlapping_locations(locs: list[Location], fragment_length: int) list[tuple[Location, ...]] [source]
Turn a list of locations into a list of tuples of those locations, where each tuple contains locations that overlap. For example, if locs = [loc1, loc2, loc3], and loc1 and loc2 overlap, the output will be [(loc1, loc2), (loc3,)].
- pydna.assembly2.ends_from_cutsite(cutsite: Tuple[Tuple[int, int], _AbstractCut | None], seq: Dseq) tuple[tuple[str, str], tuple[str, str]] [source]
Get the sticky or blunt ends created by a restriction enzyme cut.
- Parameters:
cutsite (CutSiteType) – A tuple ((cut_watson, ovhg), enzyme) describing where the cut occurs
seq (_Dseq) – The DNA sequence being cut
- Raises:
ValueError – If cutsite is None
- Returns:
A tuple of two tuples, each containing the type of end (‘5’’, ‘3’’, or ‘blunt’) and the sequence of the overhang. The first tuple is for the left end, second for the right end.
- Return type:
>>> from Bio.Restriction import NotI >>> x = _Dseq("ctcgGCGGCCGCcagcggccg") >>> x.get_cutsites(NotI) [((6, -4), NotI)] >>> ends_from_cutsite(x.get_cutsites(NotI)[0], x) (("5'", 'ggcc'), ("5'", 'ggcc'))
- pydna.assembly2.restriction_ligation_overlap(seqx: Dseqrecord, seqy: Dseqrecord, enzymes=RestrictionBatch, partial=False, allow_blunt=False) list[Tuple[int, int, int]] [source]
Assembly algorithm to find overlaps that would result from restriction and ligation.
Like in sticky and gibson, the order matters (see example below of partial overlap)
- Parameters:
- Returns:
A list of overlaps between the two sequences
- Return type:
list[SequenceOverlap]
>>> from pydna.dseqrecord import Dseqrecord >>> from pydna.assembly2 import restriction_ligation_overlap >>> from Bio.Restriction import EcoRI, RgaI, DrdI, EcoRV >>> x = Dseqrecord("ccGAATTCaa") >>> y = Dseqrecord("aaaaGAATTCgg") >>> restriction_ligation_overlap(x, y, [EcoRI]) [(3, 5, 4)] >>> restriction_ligation_overlap(y, x, [EcoRI]) [(5, 3, 4)]
Partial overlap, note how it is not symmetric
>>> x = Dseqrecord("GACTAAAGGGTC") >>> y = Dseqrecord("AAGCGATCGCAAGCGATCGCAA") >>> restriction_ligation_overlap(x, y, [RgaI, DrdI], partial=True) [(6, 5, 1), (6, 15, 1)] >>> restriction_ligation_overlap(y, x, [RgaI, DrdI], partial=True) []
Blunt overlap, returns length of the overlap 0
>>> x = Dseqrecord("aaGATATCcc") >>> y = Dseqrecord("ttttGATATCaa") >>> restriction_ligation_overlap(x, y, [EcoRV], allow_blunt=True) [(5, 7, 0)] >>> restriction_ligation_overlap(y, x, [EcoRV], allow_blunt=True) [(7, 5, 0)]
- pydna.assembly2.combine_algorithms(*algorithms: Callable[[Dseqrecord, Dseqrecord, int], list[Tuple[int, int, int]]]) Callable[[Dseqrecord, Dseqrecord, int], list[Tuple[int, int, int]]] [source]
Combine assembly algorithms, if any of them returns a match, the match is returned.
This can be used for example in a ligation where you want to allow both sticky and blunt end ligation.
- pydna.assembly2.blunt_overlap(seqx: Dseqrecord, seqy: Dseqrecord, limit=None) list[Tuple[int, int, int]] [source]
Assembly algorithm to find blunt overlaps. Used for blunt ligation.
It basically returns [(len(seqx), 0, 0)] if the right end of seqx is blunt and the left end of seqy is blunt (compatible with blunt ligation). Otherwise, it returns an empty list.
- Parameters:
seqx (_Dseqrecord) – The first sequence
seqy (_Dseqrecord) – The second sequence
limit (int) – There for compatibility, but it is ignored
- Returns:
A list of overlaps between the two sequences
- Return type:
list[SequenceOverlap]
>>> from pydna.assembly2 import blunt_overlap >>> from pydna.dseqrecord import Dseqrecord >>> x = Dseqrecord("AAAAAA") >>> y = Dseqrecord("TTTTTT") >>> blunt_overlap(x, y) [(6, 0, 0)]
- pydna.assembly2.common_sub_strings(seqx: Dseqrecord, seqy: Dseqrecord, limit=25) list[Tuple[int, int, int]] [source]
Assembly algorithm to find common substrings of length == limit. see the docs of the function common_sub_strings_str for more details. It is case insensitive.
>>> from pydna.dseqrecord import Dseqrecord >>> x = Dseqrecord("TAAAAAAT") >>> y = Dseqrecord("CCaAaAaACC") >>> common_sub_strings(x, y, limit=5) [(1, 2, 6), (1, 3, 5), (2, 2, 5)]
- pydna.assembly2.gibson_overlap(seqx: Dseqrecord, seqy: Dseqrecord, limit=25)[source]
Assembly algorithm to find terminal overlaps (e.g. for Gibson assembly). The order matters, we want alignments like:
``` seqx: oooo——xxxx seqy: xxxx——oooo Product: oooo——xxxx——oooo
Not like:
seqx: oooo——xxxx seqy: xxxx——oooo Product (unwanted): oooo ```
- Parameters:
seqx (_Dseqrecord) – The first sequence
seqy (_Dseqrecord) – The second sequence
limit (int) – Minimum length of the overlap
- Returns:
A list of overlaps between the two sequences
- Return type:
list[SequenceOverlap]
>>> from pydna.dseqrecord import Dseqrecord >>> from pydna.assembly2 import gibson_overlap >>> x = Dseqrecord("ttactaAAAAAA") >>> y = Dseqrecord("AAAAAAcgcacg") >>> gibson_overlap(x, y, limit=5) [(6, 0, 6), (7, 0, 5)] >>> gibson_overlap(y, x, limit=5) []
- pydna.assembly2.sticky_end_sub_strings(seqx: Dseqrecord, seqy: Dseqrecord, limit=0)[source]
Assembly algorithm for ligation of sticky ends.
For now, if limit 0 / False (default) only full overlaps are considered. Otherwise, partial overlaps are also returned.
- Parameters:
seqx (_Dseqrecord) – The first sequence
seqy (_Dseqrecord) – The second sequence
limit (int) – Minimum length of the overlap
- Returns:
A list of overlaps between the two sequences
- Return type:
list[SequenceOverlap]
Ligation of fully overlapping sticky ends, note how the order matters
>>> from pydna.dseq import Dseq >>> from pydna.dseqrecord import Dseqrecord >>> from pydna.assembly2 import sticky_end_sub_strings >>> x = Dseqrecord(Dseq.from_full_sequence_and_overhangs("AAAAAA", 0, 3)) >>> y = Dseqrecord(Dseq.from_full_sequence_and_overhangs("AAAAAA", 3, 0)) >>> sticky_end_sub_strings(x, y, limit=0) [(3, 0, 3)] >>> sticky_end_sub_strings(y, x, limit=0) []
Ligation of partially overlapping sticky ends, specified with limit=True
>>> x = Dseqrecord(Dseq.from_full_sequence_and_overhangs("AAAAAA", 0, 2)) >>> y = Dseqrecord(Dseq.from_full_sequence_and_overhangs("AAAAAA", 3, 0)) >>> sticky_end_sub_strings(x, y, limit=0) [] >>> sticky_end_sub_strings(x, y, limit=True) [(4, 0, 2)]
- pydna.assembly2.zip_match_leftwards(seqx: SeqRecord, seqy: SeqRecord, match: Tuple[int, int, int]) Tuple[int, int, int] [source]
Starting from the rightmost edge of the match, return a new match encompassing the max number of bases. This can be used to return a longer match if a primer aligns for longer than the limit or a shorter match if there are mismatches. This is convenient to maintain as many features as possible. It is used in PCR assembly.
>>> seq = _Dseqrecord('AAAAACGTCCCGT') >>> primer = _Dseqrecord('ACGTCCCGT') >>> match = (13, 9, 0) # an empty match at the end of each >>> zip_match_leftwards(seq, primer, match) (4, 0, 9)
Works in circular molecules if the match spans the origin: >>> seq = _Dseqrecord(‘TCCCGTAAAAACG’, circular=True) >>> primer = _Dseqrecord(‘ACGTCCCGT’) >>> match = (6, 9, 0) >>> zip_match_leftwards(seq, primer, match) (10, 0, 9)
- pydna.assembly2.zip_match_rightwards(seqx: Dseqrecord, seqy: Dseqrecord, match: Tuple[int, int, int]) Tuple[int, int, int] [source]
Same as zip_match_leftwards, but towards the right.
- pydna.assembly2.seqrecord2_uppercase_DNA_string(seqr: SeqRecord) str [source]
Transform a Dseqrecord to a sequence string where U is replaced by T, everything is upper case and circular sequences are repeated twice. This is used for PCR, to support primers with U’s (e.g. for USER cloning).
- pydna.assembly2.primer_template_overlap(seqx: Dseqrecord | Primer, seqy: Dseqrecord | Primer, limit=25, mismatches=0) list[Tuple[int, int, int]] [source]
Assembly algorithm to find overlaps between a primer and a template. It accepts mismatches. When there are mismatches, it only returns the common part between the primer and the template.
If seqx is a primer and seqy is a template, it represents the binding of a forward primer. If seqx is a template and seqy is a primer, it represents the binding of a reverse primer, where the primer has been passed as its reverse complement (see examples).
- Parameters:
- Returns:
A list of overlaps between the primer and the template
- Return type:
list[SequenceOverlap]
>>> from pydna.dseqrecord import Dseqrecord >>> from pydna.primer import Primer >>> from pydna.assembly2 import primer_template_overlap >>> template = Dseqrecord("AATTAGCAGCGATCGAGT", circular=True) >>> primer = Primer("TTAGCAGC") >>> primer_template_overlap(primer, template, limit=8, mismatches=0) [(0, 2, 8)]
This actually represents the binding of the primer GCTGCTAA (reverse complement) >>> primer_template_overlap(template, primer, limit=8, mismatches=0) [(2, 0, 8)] >>> primer_template_overlap(primer, template.reverse_complement(), limit=8, mismatches=0) [] >>> primer_template_overlap(primer.reverse_complement(), template, limit=8, mismatches=0) []
- pydna.assembly2.fill_left(seq: Dseq) Dseq [source]
Fill the left overhang of a sequence with the complementary sequence.
- pydna.assembly2.fill_right(seq: Dseq) Dseq [source]
Fill the right overhang of a sequence with the complementary sequence.
- pydna.assembly2.fill_dseq(seq: Dseq) Dseq [source]
Fill the overhangs of a sequence with the complementary sequence.
- pydna.assembly2.reverse_complement_assembly(assembly: list[Tuple[int, int, _Location | None, _Location | None]], fragments: list[Dseqrecord]) list[Tuple[int, int, _Location | None, _Location | None]] [source]
Complement an assembly, i.e. reverse the order of the fragments and the orientation of the overlaps.
- pydna.assembly2.filter_linear_subassemblies(linear_assemblies: list[list[Tuple[int, int, _Location | None, _Location | None]]], circular_assemblies: list[list[Tuple[int, int, _Location | None, _Location | None]]], fragments: list[Dseqrecord]) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
Remove linear assemblies which are sub-assemblies of circular assemblies
- pydna.assembly2.remove_subassemblies(assemblies: list[list[Tuple[int, int, _Location | None, _Location | None]]]) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
Filter out subassemblies, i.e. assemblies that are contained within another assembly.
- For example:
[(1, 2, ‘1[8:14]:2[1:7]’), (2, 3, ‘2[10:17]:3[1:8]’)] [(1, 2, ‘1[8:14]:2[1:7]’)]
The second one is a subassembly of the first one.
- pydna.assembly2.assembly2str(assembly: list[Tuple[int, int, _Location | None, _Location | None]]) str [source]
Convert an assembly to a string representation, for example: ((1, 2, [8:14], [1:7]),(2, 3, [10:17], [1:8])) becomes: (‘1[8:14]:2[1:7]’, ‘2[10:17]:3[1:8]’)
The reason for this is that by default, a feature ‘[8:14]’ when present in a tuple is printed to the console as SimpleLocation(ExactPosition(8), ExactPosition(14), strand=1) (very long).
- pydna.assembly2.assembly2str_tuple(assembly: list[Tuple[int, int, _Location | None, _Location | None]]) str [source]
Convert an assembly to a string representation, like ((1, 2, [8:14], [1:7]),(2, 3, [10:17], [1:8]))
- pydna.assembly2.assembly_has_mismatches(fragments: list[Dseqrecord], assembly: list[Tuple[int, int, _Location | None, _Location | None]]) bool [source]
Check if an assembly has mismatches. This should never happen and if so it returns an error.
- pydna.assembly2.assembly_is_circular(assembly: list[Tuple[int, int, _Location | None, _Location | None]], fragments: list[Dseqrecord]) bool [source]
Based on the topology of the locations of an assembly, determine if it is circular. This does not work for insertion assemblies, that’s why assemble takes the optional argument is_insertion.
- pydna.assembly2.assemble(fragments: list[Dseqrecord], assembly: list[Tuple[int, int, _Location | None, _Location | None]], is_insertion: bool = False) Dseqrecord [source]
Generate a Dseqrecord from an assembly and a list of fragments.
- pydna.assembly2.annotate_primer_binding_sites(input_dseqr: Dseqrecord, fragments: list[Dseqrecord]) Dseqrecord [source]
Annotate the primer binding sites in a Dseqrecord.
- pydna.assembly2.edge_representation2subfragment_representation(assembly: list[Tuple[int, int, _Location | None, _Location | None]], is_circular: bool) list[Tuple[int, _Location | None, _Location | None]] [source]
Turn this kind of edge representation fragment 1, fragment 2, right edge on 1, left edge on 2 a = [(1, 2, ‘loc1a’, ‘loc2a’), (2, 3, ‘loc2b’, ‘loc3b’), (3, 1, ‘loc3c’, ‘loc1c’)] Into this: fragment 1, left edge on 1, right edge on 1 b = [(1, ‘loc1c’, ‘loc1a’), (2, ‘loc2a’, ‘loc2b’), (3, ‘loc3b’, ‘loc3c’)]
- pydna.assembly2.subfragment_representation2edge_representation(assembly: list[Tuple[int, _Location | None, _Location | None]], is_circular: bool) list[Tuple[int, int, _Location | None, _Location | None]] [source]
Turn this kind of subfragment representation fragment 1, left edge on 1, right edge on 1 a = [(1, ‘loc1c’, ‘loc1a’), (2, ‘loc2a’, ‘loc2b’), (3, ‘loc3b’, ‘loc3c’)] Into this: fragment 1, fragment 2, right edge on 1, left edge on 2 b = [(1, 2, ‘loc1a’, ‘loc2a’), (2, 3, ‘loc2b’ ‘loc3b’), (3, 1, ‘loc3c’, ‘loc1c’)]
- pydna.assembly2.get_assembly_subfragments(fragments: list[Dseqrecord], subfragment_representation: list[Tuple[int, _Location | None, _Location | None]]) list[Dseqrecord] [source]
From the fragment representation returned by edge_representation2subfragment_representation, get the subfragments that are joined together.
Subfragments are the slices of the fragments that are joined together
–A–
- TACGTAAT
–B–
TCGTAACGA
Gives: TACGTAA / CGTAACGA
` To reproduce: `
a = Dseqrecord(‘TACGTAAT’) b = Dseqrecord(‘TCGTAACGA’) f = Assembly([a, b], limit=5) a0 = f.get_linear_assemblies()[0] print(assembly2str(a0)) a0_subfragment_rep =edge_representation2subfragment_representation(a0, False) for f in get_assembly_subfragments([a, b], a0_subfragment_rep):print(f.seq)
# prints TACGTAA and CGTAACGA ```
Subfragments: cccccgtatcgtgt, atcgtgtactgtcatattc
- pydna.assembly2.extract_subfragment(seq: Dseqrecord, start_location: Location, end_location: Location) Dseqrecord [source]
Extract a subfragment from a sequence for an assembly, given the start and end locations of the subfragment.
- pydna.assembly2.is_sublist(sublist: list, my_list: list, my_list_is_cyclic: bool = False) bool [source]
Returns True if argument sublist is a sublist of argument my_list (can be treated as cyclic), False otherwise.
Examples
>>> is_sublist([1, 2], [1, 2, 3], False) True >>> is_sublist([1, 2], [1, 3, 2], False) False
# See the case here for cyclic lists >>> is_sublist([3, 1], [1, 2, 3], False) False >>> is_sublist([3, 1], [1, 2, 3], True) True
- pydna.assembly2.circular_permutation_min_abs(lst: list) list [source]
Returns the circular permutation of lst with the smallest absolute value first.
Examples
>>> circular_permutation_min_abs([1, 2, 3]) [1, 2, 3] >>> circular_permutation_min_abs([3, 1, 2]) [1, 2, 3]
- class pydna.assembly2.Assembly(frags: list[Dseqrecord], limit: int = 25, algorithm: Callable[[Dseqrecord, Dseqrecord, int], list[Tuple[int, int, int]]] = common_sub_strings, use_fragment_order: bool = True, use_all_fragments: bool = False)[source]
Bases:
object
Assembly of a list of DNA fragments into linear or circular constructs. Accepts a list of Dseqrecords (source fragments) to initiate an Assembly object. Several methods are available for analysis of overlapping sequences, graph construction and assembly.
The assembly contains a directed graph, where nodes represent fragments and edges represent overlaps between fragments. : - The node keys are integers, representing the index of the fragment in the input list of fragments. The sign of the node key represents the orientation of the fragment, positive for forward orientation, negative for reverse orientation. - The edges contain the locations of the overlaps in the fragments. For an edge (u, v, key):
u and v are the nodes connected by the edge.
key is a string that represents the location of the overlap. In the format:
‘u[start:end](strand):v[start:end](strand)’. - Edges have a ‘locations’ attribute, which is a list of two FeatureLocation objects, representing the location of the overlap in the u and v fragment, respectively. - You can think of an edge as a representation of the join of two fragments.
If fragment 1 and 2 share a subsequence of 6bp, [8:14] in fragment 1 and [1:7] in fragment 2, there will be 4 edges representing that overlap in the graph, for all possible orientations of the fragments (see add_edges_from_match for details): - (1, 2, ‘1[8:14]:2[1:7]’) - (2, 1, ‘2[1:7]:1[8:14]’) - (-1, -2, ‘-1[0:6]:-2[10:16]’) - (-2, -1, ‘-2[10:16]:-1[0:6]’)
An assembly can be thought of as a tuple of graph edges, but instead of representing them with node indexes and keys, we represent them as u, v, locu, locv, where u and v are the nodes connected by the edge, and locu and locv are the locations of the overlap in the first and second fragment. Assemblies are then represented as: - Linear: ((1, 2, [8:14], [1:7]), (2, 3, [10:17], [1:8])) - Circular: ((1, 2, [8:14], [1:7]), (2, 3, [10:17], [1:8]), (3, 1, [12:17], [1:6])) Note that the first and last fragment are the same in a circular assembly.
The following constrains are applied to remove duplicate assemblies: - Circular assemblies: the first subfragment is not reversed, and has the smallest index in the input fragment list.
use_fragment_order is ignored.
- Linear assemblies:
Using uid (see add_edges_from_match) to identify unique edges.
- Parameters:
frags (list) – A list of Dseqrecord objects.
limit (int, optional) – The shortest shared homology to be considered, this is passed as the third argument to the algorithm function. For certain algorithms, this might be ignored.
algorithm (function, optional) – The algorithm used to determine the shared sequences. It’s a function that takes two Dseqrecord objects as inputs, and will get passed the third argument (limit), that may or may not be used. It must return a list of overlaps (see common_sub_strings for an example).
use_fragment_order (bool, optional) – It’s set to True by default to reproduce legacy pydna behaviour: only assemblies that start with the first fragment and end with the last are considered. You should set it to False.
use_all_fragments (bool, optional) – Constrain the assembly to use all fragments.
Examples
from assembly2 import Assembly, assembly2str from pydna.dseqrecord import Dseqrecord
- example_fragments = (
Dseqrecord(‘AacgatCAtgctcc’, name=’a’), Dseqrecord(‘TtgctccTAAattctgc’, name=’b’), Dseqrecord(‘CattctgcGAGGacgatG’, name=’c’),
)
asm = Assembly(example_fragments, limit=5, use_fragment_order=False) print(‘Linear ===============’) for assembly in asm.get_linear_assemblies():
print(’ ‘, assembly2str(assembly))
print(‘Circular =============’) for assembly in asm.get_circular_assemblies():
print(’ ‘, assembly2str(assembly))
# Prints Linear ===============
(‘1[8:14]:2[1:7]’, ‘2[10:17]:3[1:8]’) (‘2[10:17]:3[1:8]’, ‘3[12:17]:1[1:6]’) (‘3[12:17]:1[1:6]’, ‘1[8:14]:2[1:7]’) (‘1[1:6]:3[12:17]’,) (‘2[1:7]:1[8:14]’,) (‘3[1:8]:2[10:17]’,)
- Circular =============
(‘1[8:14]:2[1:7]’, ‘2[10:17]:3[1:8]’, ‘3[12:17]:1[1:6]’)
- classmethod assembly_is_valid(fragments: list[Dseqrecord | Primer], assembly: list[Tuple[int, int, _Location | None, _Location | None]], is_circular: bool, use_all_fragments: bool, is_insertion: bool = False) bool [source]
Returns True if the assembly is valid, False otherwise. See function comments for conditions tested.
- add_edges_from_match(match: Tuple[int, int, int], u: int, v: int, first: Dseqrecord, secnd: Dseqrecord)[source]
Add edges to the graph from a match returned by the algorithm function (see pydna.common_substrings). For format of edges (see documentation of the Assembly class).
Matches are directional, because not all algorithm functions return the same match for (u,v) and (v,u). For example, homologous recombination does but sticky end ligation does not. The function returns two edges: - Fragments in the orientation they were passed, with locations of the match (u, v, loc_u, loc_v) - Reverse complement of the fragments with inverted order, with flipped locations (-v, -u, flip(loc_v), flip(loc_u))/
- format_assembly_edge(graph_edge: tuple[int, int, str]) Tuple[int, int, _Location | None, _Location | None] [source]
Go from the (u, v, key) to the (u, v, locu, locv) format.
- get_linear_assemblies(only_adjacent_edges: bool = False, max_assemblies: int = 50) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
Get linear assemblies, applying the constrains described in __init__, ensuring that paths represent real assemblies (see assembly_is_valid). Subassemblies are removed (see remove_subassemblies).
- node_path2assembly_list(cycle: list[int], circular: bool) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
- Convert a node path in the format [1, 2, 3] (as returned by _nx.cycles.simple_cycles) to a list of all
possible assemblies.
There may be multiple assemblies for a given node path, if there are several edges connecting two nodes, for example two overlaps between 1 and 2, and single overlap between 2 and 3 should return 3 assemblies.
- get_unique_linear_paths(G_with_begin_end: MultiDiGraph, max_paths=10000) list[list[int]] [source]
Get unique linear paths from the graph, removing those that contain the same node twice.
- get_possible_assembly_number(paths: list[list[int]]) int [source]
Get the number of possible assemblies from a list of node paths. Basically, for each path passed as a list of integers / nodes, we calculate the number of paths possible connecting the nodes in that order, given the graph (all the edges connecting them).
- get_circular_assemblies(only_adjacent_edges: bool = False, max_assemblies: int = 50) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
Get circular assemblies, applying the constrains described in __init__, ensuring that paths represent real assemblies (see assembly_is_valid).
- format_insertion_assembly(assembly: list[Tuple[int, int, _Location | None, _Location | None]]) list[Tuple[int, int, _Location | None, _Location | None]] | None [source]
Sorts the fragment representing a cycle so that they represent an insertion assembly if possible, else returns None.
Here we check if one of the joins between fragments represents the edges of an insertion assembly The fragment must be linear, and the join must be as indicated below
- format_insertion_assembly_edge_case(assembly: list[Tuple[int, int, _Location | None, _Location | None]]) list[Tuple[int, int, _Location | None, _Location | None]] [source]
Edge case from https://github.com/manulera/OpenCloning_backend/issues/329
- get_insertion_assemblies(only_adjacent_edges: bool = False, max_assemblies: int = 50) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
Assemblies that represent the insertion of a fragment or series of fragment inside a linear construct. For instance, digesting CCCCGAATTCCCCGAATTC with EcoRI and inserting the fragment with two overhangs into the EcoRI site of AAAGAATTCAAA. This is not so much meant for the use-case of linear fragments that represent actual linear fragments, but for linear fragments that represent a genome region. This can then be used to simulate homologous recombination.
- assemble_linear(only_adjacent_edges: bool = False, max_assemblies: int = 50) list[Dseqrecord] [source]
Assemble linear constructs, from assemblies returned by self.get_linear_assemblies.
- assemble_circular(only_adjacent_edges: bool = False, max_assemblies: int = 50) list[Dseqrecord] [source]
Assemble circular constructs, from assemblies returned by self.get_circular_assemblies.
- assemble_insertion(only_adjacent_edges: bool = False) list[Dseqrecord] [source]
Assemble insertion constructs, from assemblies returned by self.get_insertion_assemblies.
- get_locations_on_fragments() dict[int, dict[str, list[Location]]] [source]
Get a dictionary where the keys are the nodes in the graph, and the values are dictionaries with keys left, right, containing (for each fragment) the locations where the fragment is joined to another fragment on its left and right side. The values in left and right are often the same, except in restriction-ligation with partial overlap enabled, where we can end up with a situation like this:
GGTCTCCCCAATT and aGGTCTCCAACCAA as fragments
# Partial overlap in assembly 1[9:11]:2[8:10] GGTCTCCxxAACCAA CCAGAGGGGTTxxTT
# Partial overlap in 2[10:12]:1[7:9] aGGTCTCCxxCCAATT tCCAGAGGTTGGxxAA
Would return {
1: {‘left’: [7:9], ‘right’: [9:11]}, 2: {‘left’: [8:10], ‘right’: [10:12]}, -1: {‘left’: [2:4], ‘right’: [4:6]}, -2: {‘left’: [2:4], ‘right’: [4:6]}
}
- assembly_uses_only_adjacent_edges(assembly, is_circular: bool) bool [source]
Check whether only adjacent edges within each fragment are used in the assembly. This is useful to check if a cut and ligate assembly is valid, and prevent including partially digested fragments. For example, imagine the following fragment being an input for a digestion and ligation assembly, where the enzyme cuts at the sites indicated by the vertical lines:
We would only want assemblies that contain subfragments start-x, x-y, y-z, z-end, and not start-x, y-end, for instance. The latter would indicate that the fragment was partially digested.
- class pydna.assembly2.PCRAssembly(frags: list[Dseqrecord | Primer], limit=25, mismatches=0)[source]
Bases:
Assembly
An assembly that represents a PCR, where fragments is a list of primer, template, primer (in that order). It always uses the primer_template_overlap algorithm and accepts the mismatches argument to indicate the number of mismatches allowed in the overlap. Only supports substitution mismatches, not indels.
- get_linear_assemblies(only_adjacent_edges: bool = False, max_assemblies: int = 50) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
Get linear assemblies, applying the constrains described in __init__, ensuring that paths represent real assemblies (see assembly_is_valid). Subassemblies are removed (see remove_subassemblies).
- get_circular_assemblies(only_adjacent_edges: bool = False)[source]
Get circular assemblies, applying the constrains described in __init__, ensuring that paths represent real assemblies (see assembly_is_valid).
- get_insertion_assemblies(only_adjacent_edges: bool = False)[source]
Assemblies that represent the insertion of a fragment or series of fragment inside a linear construct. For instance, digesting CCCCGAATTCCCCGAATTC with EcoRI and inserting the fragment with two overhangs into the EcoRI site of AAAGAATTCAAA. This is not so much meant for the use-case of linear fragments that represent actual linear fragments, but for linear fragments that represent a genome region. This can then be used to simulate homologous recombination.
- class pydna.assembly2.SingleFragmentAssembly(frags: [<class 'pydna.dseqrecord.Dseqrecord'>], limit=25, algorithm=common_sub_strings)[source]
Bases:
Assembly
An assembly that represents the circularisation or splicing of a single fragment.
- get_circular_assemblies(only_adjacent_edges: bool = False, max_assemblies: int = 50) list[list[Tuple[int, int, _Location | None, _Location | None]]] [source]
Get circular assemblies, applying the constrains described in __init__, ensuring that paths represent real assemblies (see assembly_is_valid).