def create_design(): length = 10 helices = [ sc.Helix(max_offset=length, position=sc.Position3D(x=0, y=0, z=2.5), pitch=0, roll=0, yaw=0), sc.Helix(max_offset=length, position=sc.Position3D(x=3, y=3, z=0), pitch=0, roll=0, yaw=0), sc.Helix(max_offset=length, position=sc.Position3D(x=8, y=-3, z=0), pitch=0, roll=0, yaw=0), sc.Helix(max_offset=length, position=sc.Position3D(x=11, y=1, z=0), pitch=0, roll=0, yaw=0), ] stap_ss = sc.Domain(0, True, 0, length) scaf_ss = sc.Domain(0, False, 0, length) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.Design(helices=helices, strands=strands, grid=sc.Grid.none) return design
def add_domains_for_barrel_seam(design: sc.DNADesign): top_staples_5p = design.strands_starting_on_helix(0) top_staples_3p = design.strands_ending_on_helix(0) bot_staples_5p = design.strands_starting_on_helix(15) bot_staples_3p = design.strands_ending_on_helix(15) # remove scaffold top_staples_5p = [st for st in top_staples_5p if len(st.domains) <= 3] top_staples_3p = [st for st in top_staples_3p if len(st.domains) <= 3] bot_staples_5p = [st for st in bot_staples_5p if len(st.domains) <= 3] bot_staples_3p = [st for st in bot_staples_3p if len(st.domains) <= 3] top_staples_5p.sort(key=lambda stap: stap.offset_5p()) top_staples_3p.sort(key=lambda stap: stap.offset_3p()) bot_staples_5p.sort(key=lambda stap: stap.offset_5p()) bot_staples_3p.sort(key=lambda stap: stap.offset_3p()) for top_5p, top_3p, bot_5p, bot_3p in zip(top_staples_5p, top_staples_3p, bot_staples_5p, bot_staples_3p): ss_top = sc.Domain(helix=0, forward=False, start=top_5p.first_domain().end, end=top_3p.last_domain().start) ss_bot = sc.Domain(helix=15, forward=True, start=bot_3p.last_domain().end, end=bot_5p.first_domain().start) design.insert_domain(bot_5p, 0, ss_top) design.insert_domain(top_5p, 0, ss_bot)
def main(): length = 16 helices = [ sc.Helix(major_tick_distance=4, max_offset=length, position=sc.Position3D(x=0, y=0, z=0), min_offset=0), sc.Helix(major_tick_distance=4, max_offset=length, position=sc.Position3D(x=0, y=3, z=3), min_offset=8), sc.Helix(major_tick_distance=4, max_offset=length, position=sc.Position3D(x=2.5, y=-3, z=8), min_offset=0), sc.Helix(major_tick_distance=4, max_offset=length, position=sc.Position3D(x=2.5, y=1, z=11), min_offset=8), ] design = sc.DNADesign(helices=helices, strands=[ sc.Strand([sc.Domain(0, True, 0, length)]), sc.Strand([sc.Domain(1, True, 8, length)]), sc.Strand([sc.Domain(2, True, 0, length)]), sc.Strand([sc.Domain(3, True, 8, length)]), ], grid=sc.Grid.none) return design
def precursor_scaffolds() -> sc.Design: #2D design has to be topologically a circle helices = [sc.Helix(max_offset=int(block * cmax)) for _ in range(maxhelix)] scaffolds = [] for helix in range(len(img)): if (1 in img[helix]): for dom in range(len(img[helix])): if (img[helix][dom] == 1) and (img[helix][dom - 1] == 0): start = block * dom if (img[helix][dom] == 0) and (img[helix][dom - 1] == 1): end = block * dom scaffolds.append( sc.Strand([ sc.Domain(helix=2 * helix, forward=((2 * helix) % 2 == 0), start=start, end=end) ])) scaffolds.append( sc.Strand([ sc.Domain(helix=(2 * helix) + 1, forward=((2 * helix + 1) % 2 == 0), start=start, end=end) ])) return sc.Design(helices=helices, strands=scaffolds, grid=sc.square)
def precursor_staples(design: sc.Design): #2D design has to be topologically a circle # helices = [sc.Helix(max_offset=int(block*cmax)) for _ in range(maxhelix)] staples = [] for helix in range(len(img)): if (1 in img[helix]): for dom in range(len(img[helix])): if (img[helix][dom] == 1) and (img[helix][dom - 1] == 0): start = block * dom if (img[helix][dom] == 0) and (img[helix][dom - 1] == 1): end = block * dom staples.append( sc.Strand([ sc.Domain(helix=2 * helix, forward=((2 * helix) % 2 == 1), start=start, end=end) ])) staples.append( sc.Strand([ sc.Domain(helix=(2 * helix) + 1, forward=((2 * helix + 1) % 2 == 1), start=start, end=end) ])) for staple in staples: design.add_strand(staple)
def main(): blue = sc.Color(r=0, g=0, b=255) black = sc.Color(r=0, g=0, b=0) red = sc.Color(r=255, g=0, b=0) green = sc.Color(r=0, g=150, b=0) cols = 8 rows = 8 # helices = [sc.Helix(major_tick_distance=10) for _ in range(rows+1)] strands = [] for col in range(cols): for row in range(rows): helix = row forward = row % 2 == 0 if forward: offset = col * 20 ss1 = sc.Domain(helix, forward, offset, offset + 20) ss2 = sc.Domain(helix + 1, forward, offset + 20, offset + 40) else: offset = col * 20 ss1 = sc.Domain(helix, forward, offset + 30, offset + 50) ss2 = sc.Domain(helix + 1, forward, offset + 10, offset + 30) if forward: color = blue if col % 2 == 0 else black else: color = red if col % 2 == 0 else green strand = sc.Strand([ss1, ss2], color=color) strands.append(strand) # design = sc.DNADesign(helices=helices, strands=strands, grid=sc.square) design = sc.DNADesign(major_tick_distance=10, strands=strands, grid=sc.square) return design
def _create_scaffold(offset_start: int, offset_end: int, offset_mid: int, num_helices: int, num_flanking_helices: int, scaffold_nick_offset: int) -> sc.Strand: # top domain is continguous top_domain = sc.Domain(helix=0 + num_flanking_helices, forward=True, start=offset_start, end=offset_end) domains_left = [] domains_right = [] if scaffold_nick_offset < 0: scaffold_nick_offset = offset_mid for helix in range(1 + num_flanking_helices, num_helices + num_flanking_helices): # otherwise there's a nick (bottom helix) or the seam crossover (all other than top and bottom) # possibly nick on bottom helix is not along seam center_offset = offset_mid if helix < num_helices + num_flanking_helices - 1 else scaffold_nick_offset forward = (helix % 2 == num_flanking_helices % 2) left_domain = sc.Domain(helix=helix, forward=forward, start=offset_start, end=center_offset) right_domain = sc.Domain(helix=helix, forward=forward, start=center_offset, end=offset_end) domains_left.append(left_domain) domains_right.append(right_domain) domains_left.reverse() domains = cast( List[Union[sc.Domain, sc.Loopout]], # noqa domains_left + [top_domain] + domains_right) # type: ignore return sc.Strand(domains=domains, color=sc.default_scaffold_color, is_scaffold=True)
def add_adapters(design): # left adapters left_inside_seed = 48 left_outside_seed = left_inside_seed - 26 for bot_helix in range(2, 18, 2): top_helix = bot_helix - 1 if bot_helix != 2 else 17 ss_top = sc.Domain(helix=top_helix, forward=True, start=left_outside_seed, end=left_inside_seed) ss_bot = sc.Domain(helix=bot_helix, forward=False, start=left_outside_seed, end=left_inside_seed) idt = sc.IDTFields(name=f'adap-left-{top_helix}-{bot_helix}', scale='25nm', purification='STD') adapter = sc.Strand(domains=[ss_bot, ss_top], idt=idt) design.add_strand(adapter) # right adapters right_inside_seed = 464 right_outside_seed = right_inside_seed + 26 for bot_helix in range(2, 18, 2): top_helix = bot_helix - 1 if bot_helix != 2 else 17 ss_top = sc.Domain(helix=top_helix, forward=True, start=right_inside_seed, end=right_outside_seed) ss_bot = sc.Domain(helix=bot_helix, forward=False, start=right_inside_seed, end=right_outside_seed) idt = sc.IDTFields(name=f'adap-right-{top_helix}-{bot_helix}', scale='25nm', purification='STD') adapter = sc.Strand(domains=[ss_top, ss_bot], idt=idt) design.add_strand(adapter)
def add_tiles_and_assign_dna(design): # left tiles left_left = 11 left_right = 32 for col, seq in zip(range(2, 18, 2), tile_dna_seqs): bot_helix = top_helix + 1 ss_top = sc.Domain(helix=top_helix, forward=True, start=left_left, end=left_right) ss_bot = sc.Domain(helix=bot_helix, forward=False, start=left_left, end=left_right) tile = sc.Strand(domains=[ss_bot, ss_top], color=sc.Color(0, 0, 0)) design.add_strand(tile) design.assign_dna(tile, seq) # right tiles right_left = 480 right_right = 501 for top_helix, seq in zip(range(2, 18, 2), tile_dna_seqs): bot_helix = top_helix + 1 ss_top = sc.Domain(helix=top_helix, forward=True, start=right_left, end=right_right) ss_bot = sc.Domain(helix=bot_helix, forward=False, start=right_left, end=right_right) tile = sc.Strand(domains=[ss_bot, ss_top], color=sc.Color(0, 0, 0)) design.add_strand(tile) design.assign_dna(tile, seq)
def main(): ss_f = sc.Domain(helix=0, forward=True, start=0, end=10) loop = sc.Loopout(length=5) ss_r = sc.Domain(helix=0, forward=False, start=0, end=10) hairpin = sc.Strand([ss_f, loop, ss_r]) design = sc.DNADesign(strands=[hairpin], grid=sc.square) design.assign_dna(hairpin, 'AAAAACCCCCTGCAT') return design
def create_design() -> sc.Design: length = 9 helices = [sc.Helix(max_offset=length, roll=90)] stap_ss = sc.Domain(0, True, 0, length) scaf_ss = sc.Domain(0, False, 0, length) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.Design(helices=helices, strands=strands, grid=sc.square) design.assign_dna(scaf, 'AACT' * (length // 4)) return design
def main(): length = 9 helices = [sc.Helix(max_offset=length, major_ticks=[2, 5])] stap_ss = sc.Domain(0, True, 0, length) scaf_ss = sc.Domain(0, False, 0, length) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.DNADesign(helices=helices, strands=strands, grid=sc.square) design.assign_dna(scaf, 'AACT' * (length // 4)) return design
def _create_right_edge_staples(offset_end: int, num_helices: int, num_flanking_helices: int, idt: bool): staples = [] crossover_left = offset_end - BASES_PER_COLUMN for helix in range(0 + num_flanking_helices, num_helices + num_flanking_helices, 2): bot_helix_forward = True ss_5p_top = sc.Domain(helix=helix, forward=not bot_helix_forward, start=crossover_left, end=offset_end) ss_3p_bot = sc.Domain(helix=helix + 1, forward=bot_helix_forward, start=crossover_left, end=offset_end) staple = sc.Strand(domains=[ss_5p_top, ss_3p_bot]) staples.append(staple) return staples
def main(): length = 9 helices = [sc.Helix(max_offset=length, rotation=math.pi/2, rotation_anchor=2)] stap_ss = sc.Domain(0, sc.forward, 0, length) scaf_ss = sc.Domain(0, sc.reverse, 0, length) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.DNADesign(helices=helices, strands=strands, grid=sc.square) design.assign_dna(scaf, 'AACT' * (length // 4)) return design
def create_design() -> sc.Design: # multiple-domain ss0_1 = sc.Domain(helix=0, forward=False, start=0, end=4) ss1 = sc.Domain(helix=1, forward=True, start=0, end=8) ss0_2 = sc.Domain(helix=0, forward=False, start=4, end=8) strand_multi = sc.Strand(domains=[ss0_1, ss1, ss0_2]) # single domain ss0_single = sc.Domain(helix=0, forward=True, start=0, end=8) strand_single = sc.Strand(domains=[ss0_single]) # whole design design = sc.Design(strands=[strand_multi, strand_single], grid=sc.square) return design
def create_design() -> sc.Design: length = 10 stap_ss = sc.Domain(0, True, 0, length) scaf_ss = sc.Domain(0, False, 0, length) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.Design(strands=strands, grid=sc.square) insertion_length = 4 design.add_insertion(helix=0, offset=2, length=insertion_length) design.add_insertion(helix=0, offset=8, length=insertion_length) scaf.set_dna_sequence('AG' + 'A' * (length + 2 * insertion_length - 2)) stap.set_dna_sequence('ATTCTCTTGCTTTTTTCA') return design
def main(): helices = [sc.Helix(0, 25), sc.Helix(1, 25)] s1_left_ss0 = sc.Domain(0, sc.reverse, 0, 5) s1_ss1 = sc.Domain(0, sc.forward, 0, 15) s1_right_ss0 = sc.Domain(0, sc.reverse, 5, 15) s1 = sc.Strand([s1_left_ss0, s1_ss1, s1_right_ss0]) s2_ss1 = sc.Domain(0, sc.forward, 10, 20) s2_ss0 = sc.Domain(0, sc.reverse, 10, 20) s2 = sc.Strand([s2_ss1, s2_ss0]) strands = [s1, s2] design = sc.Design(helices=helices, strands=strands, grid=sc.square) return design
def create_design(): length = 30 helices = [ sc.Helix(min_offset=0, max_offset=length, grid_position=(0, 0)), sc.Helix(min_offset=1, max_offset=length, grid_position=(0, 1)), sc.Helix(min_offset=2, max_offset=length, grid_position=(0, 2)), sc.Helix(min_offset=3, max_offset=length, grid_position=(0, 3)), ] stap_ss = sc.Domain(0, True, 0, length - 1) scaf_ss = sc.Domain(0, False, 0, length - 1) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.Design(helices=helices, strands=strands, grid=sc.Grid.square) return design
def add_fringe(design, fringe_seqs, left_right): """Given the design, and fringe sequence, adds the fringe to the design""" fringe_num = len(fringe_seqs) if left_right == 'left': helix_st = 1 else: helix_st = 0 for i in range(fringe_num): print(helix_st) if helix_st == 11: helix2 = 0 else: helix2 = helix_st + 1 forward = sc_general.forward_strand(helix_st, 'staple') forward2 = sc_general.forward_strand(helix2, 'staple') if forward: helix = helix_st else: helix, helix2 = helix2, helix_st forward, forward2 = forward2, forward staple = sc.Strand([sc.Domain(helix = helix, forward = forward, start = 0, end = 16), sc.Domain(helix = helix2, forward = forward2, start = 0, end = 16)], dna_sequence= fringe_seqs[i]) design.add_strand(staple) helix_st += 2
def add_precursor_staples(design: sc.DNADesign): staples = [ sc.Strand( [sc.Domain(helix=helix, forward=helix % 2 == 1, start=8, end=296)]) for helix in range(24) ] for staple in staples: design.add_strand(staple)
def create_design(): length = 9 helices = [ sc.Helix(max_offset=length, major_ticks=[2, 5], position=sc.Position3D(x=1, y=2, z=3), pitch=90) ] stap_ss = sc.Domain(0, True, 0, length) scaf_ss = sc.Domain(0, False, 0, length) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.Design(helices=helices, strands=strands, grid=sc.Grid.none) design.assign_dna(scaf, 'AACT' * (length // 4)) return design
def main(): length = 9 helices = [ sc.Helix(max_offset=length, major_ticks=[2, 5], position3d=sc.Position3D(x=3, y=2, z=1), pitch=90) ] stap_ss = sc.Domain(0, sc.forward, 0, length) scaf_ss = sc.Domain(0, sc.reverse, 0, length) stap = sc.Strand([stap_ss]) scaf = sc.Strand([scaf_ss], color=sc.default_scaffold_color) strands = [stap, scaf] design = sc.DNADesign(helices=helices, strands=strands, grid=sc.square) design.assign_dna(scaf, 'AACT' * (length // 4)) return design
def precursor_scaffolds() -> sc.DNADesign: helices = [sc.Helix(max_offset=304) for _ in range(24)] scaffolds = [ sc.Strand( [sc.Domain(helix=helix, forward=helix % 2 == 0, start=8, end=296)]) for helix in range(24) ] return sc.DNADesign(helices=helices, strands=scaffolds, grid=sc.square)
def create_design(): # left staple stap_left_ss1 = sc.Domain(helix=1, forward=True, start=0, end=16) stap_left_ss0 = sc.Domain(helix=0, forward=False, start=0, end=16) stap_left = sc.Strand(domains=[stap_left_ss1, stap_left_ss0]) # right staple stap_right_ss0 = sc.Domain(helix=0, forward=False, start=16, end=32) stap_right_ss1 = sc.Domain(helix=1, forward=True, start=16, end=32) stap_right = sc.Strand(domains=[stap_right_ss0, stap_right_ss1]) # scaffold scaf_ss1_left = sc.Domain(helix=1, forward=False, start=0, end=16) scaf_ss0 = sc.Domain(helix=0, forward=True, start=0, end=32) loopout = sc.Loopout(length=3) scaf_ss1_right = sc.Domain(helix=1, forward=False, start=16, end=32) scaf = sc.Strand(domains=[scaf_ss1_left, scaf_ss0, loopout, scaf_ss1_right], is_scaffold=True) # whole design design = sc.Design(strands=[scaf, stap_left, stap_right], grid=sc.square) # deletions and insertions added to design so they can be added to both strands on a helix design.add_deletion(helix=0, offset=11) design.add_deletion(helix=0, offset=12) design.add_deletion(helix=0, offset=24) design.add_deletion(helix=1, offset=12) design.add_deletion(helix=1, offset=24) design.add_insertion(helix=0, offset=6, length=1) design.add_insertion(helix=0, offset=18, length=2) design.add_insertion(helix=1, offset=6, length=3) design.add_insertion(helix=1, offset=18, length=4) return design
def main(): # helices helices = [sc.Helix(max_offset=48), sc.Helix(max_offset=48)] # left staple stap_left_ss1 = sc.Domain(helix=1, forward=True, start=8, end=24) stap_left_ss0 = sc.Domain(helix=0, forward=False, start=8, end=24) stap_left = sc.Strand(domains=[stap_left_ss1, stap_left_ss0]) # right staple stap_right_ss0 = sc.Domain(helix=0, forward=False, start=24, end=40) stap_right_ss1 = sc.Domain(helix=1, forward=True, start=24, end=40) stap_right = sc.Strand(domains=[stap_right_ss0, stap_right_ss1]) stap_right.set_modification_5p(mod.biotin_5p) # scaffold scaf_ss1_left = sc.Domain(helix=1, forward=False, start=8, end=24) scaf_ss0 = sc.Domain(helix=0, forward=True, start=8, end=40) loopout = sc.Loopout(length=3) scaf_ss1_right = sc.Domain(helix=1, forward=False, start=24, end=40) scaf = sc.Strand(domains=[scaf_ss1_left, scaf_ss0, loopout, scaf_ss1_right], is_scaffold=True) # whole design design = sc.DNADesign(helices=helices, strands=[scaf, stap_left, stap_right], grid=sc.square) # deletions and insertions added to design are added to both strands on a helix design.add_deletion(helix=1, offset=20) design.add_insertion(helix=0, offset=14, length=1) design.add_insertion(helix=0, offset=26, length=2) # also assigns complement to strands other than scaf bound to it design.assign_dna(scaf, 'AACGT' * 18) return design
def _create_left_edge_staples(offset_start: int, num_helices: int, num_flanking_helices: int) -> List[sc.Strand]: staples = [] crossover_right = offset_start + BASES_PER_COLUMN for helix in range(0 + num_flanking_helices, num_helices + num_flanking_helices, 2): bot_helix_forward = True ss_5p_bot = sc.Domain(helix=helix + 1, forward=bot_helix_forward, start=offset_start, end=crossover_right) ss_3p_top = sc.Domain(helix=helix, forward=not bot_helix_forward, start=offset_start, end=crossover_right) staple = sc.Strand(domains=[ss_5p_bot, ss_3p_top]) staples.append(staple) return staples
def create_design() -> sc.Design: ss1_r = sc.Domain(0, True, 0, 4) ss2_r = sc.Domain(0, True, 4, 8) ss3_r = sc.Domain(0, True, 8, 12) ss_l = sc.Domain(0, False, 0, 12) s1_r = sc.Strand([ss1_r], idt=sc.IDTFields(), name='s1_r') s2_r = sc.Strand([ss2_r], idt=sc.IDTFields(), name='s1_r') s3_r = sc.Strand([ss3_r], idt=sc.IDTFields(), name='s1_r') s_l = sc.Strand([ss_l], idt=sc.IDTFields(), name='s_l') strands = [s1_r, s2_r, s3_r, s_l] design = sc.Design(strands=strands, grid=sc.square) design.assign_dna(s_l, 'AGTT'*3) return design
def add_staple_precursors(design: sc.Design) -> None: staples = [ sc.Strand( [sc.Domain(helix=helix, forward=helix % 2 == 1, start=0, end=288)]) # noqa for helix in range(24) ] for staple in staples: design.add_strand(staple)
def add_tiles_and_assign_dna(design): # left tiles left_left = 11 left_right = 32 for top_helix, seq in zip(range(2, 18, 2), tile_dna_seqs): bot_helix = top_helix + 1 ss_top = sc.Domain(helix=top_helix, forward=True, start=left_left, end=left_right) ss_bot = sc.Domain(helix=bot_helix, forward=False, start=left_left, end=left_right) idt = sc.IDTFields(name=f'tile-left-{top_helix}-{bot_helix}', scale='25nm', purification='STD') tile = sc.Strand(domains=[ss_bot, ss_top], color=sc.Color(0, 0, 0), idt=idt) design.add_strand(tile) design.assign_dna(tile, seq) # right tiles right_left = 480 right_right = 501 for top_helix, seq in zip(range(2, 18, 2), tile_dna_seqs): bot_helix = top_helix + 1 ss_top = sc.Domain(helix=top_helix, forward=True, start=right_left, end=right_right) ss_bot = sc.Domain(helix=bot_helix, forward=False, start=right_left, end=right_right) idt = sc.IDTFields(name=f'tile-right-{top_helix}-{bot_helix}', scale='25nm', purification='STD') tile = sc.Strand(domains=[ss_bot, ss_top], color=sc.Color(0, 0, 0), idt=idt) design.add_strand(tile) design.assign_dna(tile, seq)
def main(): num_helices = 16 bases = 48 helices = [sc.Helix() for _ in range(num_helices)] strands = [] for bot in range(num_helices // 2): top = num_helices - bot - 1 helix_top = helices[bot] helix_bot = helices[top] stap_left_ss_top = sc.Domain(top, sc.forward, 0, bases // 3) stap_left_ss_bot = sc.Domain(bot, sc.reverse, 0, bases // 3) stap_mid_ss_bot = sc.Domain(bot, sc.reverse, bases // 3, bases * 2 // 3) stap_mid_ss_top = sc.Domain(top, sc.forward, bases // 3, bases * 2 // 3) stap_right_ss_top = sc.Domain(top, sc.forward, bases * 2 // 3, bases) stap_right_ss_bot = sc.Domain(bot, sc.reverse, bases * 2 // 3, bases) stap_left = sc.Strand([stap_left_ss_bot, stap_left_ss_top]) stap_mid = sc.Strand([stap_mid_ss_top, stap_mid_ss_bot]) stap_right = sc.Strand([stap_right_ss_bot, stap_right_ss_top]) strands.append(stap_left) strands.append(stap_mid) strands.append(stap_right) design = sc.DNADesign(helices=helices, strands=strands, grid=sc.square) return design