Skip to content

Commit

Permalink
Merge pull request #41 from UC-Davis-molecular-computing/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dave-doty authored May 17, 2020
2 parents d617135 + ad7c0ff commit 08ad763
Show file tree
Hide file tree
Showing 72 changed files with 9,789 additions and 7,604 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
setup.cfg
setup.py
scadnano\__init__.py
scadnano\modifications.py
scadnano\origami_rectangle.py
scadnano\scadnano.py
Binary file added dist/scadnano-0.4.0.tar.gz
Binary file not shown.
84 changes: 42 additions & 42 deletions examples/16_helix_origami_barrel_from_algoSST_paper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main():

set_helix_major_tickets(design)
move_top_and_bottom_staples_within_column_boundaries(design)
add_substrands_for_barrel_seam(design)
add_domains_for_barrel_seam(design)
add_toeholds_for_seam_displacement(design)
add_adapters(design)
add_twist_correct_deletions(design)
Expand Down Expand Up @@ -51,53 +51,53 @@ def move_top_and_bottom_staples_within_column_boundaries(design: sc.DNADesign):
bot_staples.remove(design.scaffold)

for top_staple in top_staples:
current_end = top_staple.substrands[0].end
design.set_end(top_staple.substrands[0], current_end - 8)
current_end = top_staple.domains[0].end
design.set_end(top_staple.domains[0], current_end - 8)

for bot_staple in bot_staples:
current_start = bot_staple.substrands[0].start
design.set_start(bot_staple.substrands[0], current_start + 8)
current_start = bot_staple.domains[0].start
design.set_start(bot_staple.domains[0], current_start + 8)


def add_substrands_for_barrel_seam(design):
def add_domains_for_barrel_seam(design):
top_staples_5p = design.strands_starting_on_helix(2)
top_staples_3p = design.strands_ending_on_helix(2)
bot_staples_5p = design.strands_starting_on_helix(17)
bot_staples_3p = design.strands_ending_on_helix(17)

# remove scaffold
top_staples_5p = [st for st in top_staples_5p if len(st.substrands) <= 3]
top_staples_3p = [st for st in top_staples_3p if len(st.substrands) <= 3]
bot_staples_5p = [st for st in bot_staples_5p if len(st.substrands) <= 3]
bot_staples_3p = [st for st in bot_staples_3p if len(st.substrands) <= 3]
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.Substrand(helix=2, forward=False,
start=top_5p.first_substrand().end, end=top_3p.last_substrand().start)
ss_bot = sc.Substrand(helix=17, forward=True,
start=bot_3p.last_substrand().end, end=bot_5p.first_substrand().start)
design.insert_substrand(bot_5p, 0, ss_top)
design.insert_substrand(top_5p, 0, ss_bot)
ss_top = sc.Domain(helix=2, forward=False,
start=top_5p.first_domain().end, end=top_3p.last_domain().start)
ss_bot = sc.Domain(helix=17, 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 add_toeholds_for_seam_displacement(design: sc.DNADesign):
for helix in [2, 17]:
staples_5p = design.strands_starting_on_helix(helix)

# remove scaffold
staples_5p = [st for st in staples_5p if len(st.substrands) <= 3]
staples_5p = [st for st in staples_5p if len(st.domains) <= 3]

staples_5p.sort(key=lambda stap: stap.offset_5p())

for stap_5p in staples_5p:
toe_ss = sc.Substrand(helix=1 if helix == 2 else 18, forward=helix == 2,
start=stap_5p.first_substrand().start, end=stap_5p.first_substrand().end)
design.insert_substrand(stap_5p, 0, toe_ss)
toe_ss = sc.Domain(helix=1 if helix == 2 else 18, forward=helix == 2,
start=stap_5p.first_domain().start, end=stap_5p.first_domain().end)
design.insert_domain(stap_5p, 0, toe_ss)


def add_adapters(design):
Expand All @@ -106,27 +106,27 @@ def add_adapters(design):
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.Substrand(helix=top_helix, forward=True,
start=left_outside_seed, end=left_inside_seed)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=left_outside_seed, end=left_inside_seed)
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(substrands=[ss_bot, ss_top], idt=idt)
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.Substrand(helix=top_helix, forward=True,
start=right_inside_seed, end=right_outside_seed)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=right_inside_seed, end=right_outside_seed)
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(substrands=[ss_top, ss_bot], idt=idt)
adapter = sc.Strand(domains=[ss_top, ss_bot], idt=idt)
design.add_strand(adapter)


Expand Down Expand Up @@ -159,11 +159,11 @@ def add_tiles_and_assign_dna(design):
left_right = 32
for top_helix, seq in zip(range(2, 18, 2), tile_dna_seqs):
bot_helix = top_helix + 1
ss_top = sc.Substrand(helix=top_helix, forward=True,
start=left_left, end=left_right)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=left_left, end=left_right)
tile = sc.Strand(substrands=[ss_bot, ss_top], color=sc.Color(0, 0, 0))
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)

Expand All @@ -172,11 +172,11 @@ def add_tiles_and_assign_dna(design):
right_right = 501
for top_helix, seq in zip(range(2, 18, 2), tile_dna_seqs):
bot_helix = top_helix + 1
ss_top = sc.Substrand(helix=top_helix, forward=True,
start=right_left, end=right_right)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=right_left, end=right_right)
tile = sc.Strand(substrands=[ss_bot, ss_top], color=sc.Color(0, 0, 0))
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)

Expand Down Expand Up @@ -233,11 +233,11 @@ def assign_dna_to_unzipper_toeholds(design):
uz_toes = [sc.wc(seq) for seq in uz_toes_wc]

strands_h1 = design.strands_starting_on_helix(1)
strands_h1.sort(key=lambda _strand: _strand.first_substrand().offset_5p())
strands_h1.sort(key=lambda _strand: _strand.first_domain().offset_5p())
strands_h1.reverse()

strands_h18 = design.strands_starting_on_helix(18)
strands_h18.sort(key=lambda _strand: _strand.first_substrand().offset_5p())
strands_h18.sort(key=lambda _strand: _strand.first_domain().offset_5p())

for strand, toe in zip(strands_h1 + strands_h18, uz_toes):
seq = toe + sc.DNA_base_wildcard * (strand.dna_length() - 8)
Expand Down
48 changes: 24 additions & 24 deletions examples/16_helix_origami_rectangle_seed_tiles_grow_from_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def move_top_and_bottom_staples_within_column_boundaries(design: sc.DNADesign):
bot_staples.remove(design.scaffold)

for top_staple in top_staples:
current_end = top_staple.substrands[0].end
design.set_end(top_staple.substrands[0], current_end - 8)
current_end = top_staple.domains[0].end
design.set_end(top_staple.domains[0], current_end - 8)

for bot_staple in bot_staples:
current_start = bot_staple.substrands[0].start
design.set_start(bot_staple.substrands[0], current_start + 8)
current_start = bot_staple.domains[0].start
design.set_start(bot_staple.domains[0], current_start + 8)


def add_adapters(design):
Expand All @@ -69,27 +69,27 @@ def add_adapters(design):
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.Substrand(helix=top_helix, forward=True,
start=left_outside_seed, end=left_inside_seed)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=left_outside_seed, end=left_inside_seed)
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(substrands=[ss_bot, ss_top], idt=idt)
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.Substrand(helix=top_helix, forward=True,
start=right_inside_seed, end=right_outside_seed)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=right_inside_seed, end=right_outside_seed)
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(substrands=[ss_top, ss_bot], idt=idt)
adapter = sc.Strand(domains=[ss_top, ss_bot], idt=idt)
design.add_strand(adapter)


Expand Down Expand Up @@ -122,11 +122,11 @@ def add_tiles_and_assign_dna(design):
left_right = 32
for col, seq in zip(range(2, 18, 2), tile_dna_seqs):
bot_helix = top_helix + 1
ss_top = sc.Substrand(helix=top_helix, forward=True,
start=left_left, end=left_right)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=left_left, end=left_right)
tile = sc.Strand(substrands=[ss_bot, ss_top], color=sc.Color(0, 0, 0))
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)

Expand All @@ -135,11 +135,11 @@ def add_tiles_and_assign_dna(design):
right_right = 501
for top_helix, seq in zip(range(2, 18, 2), tile_dna_seqs):
bot_helix = top_helix + 1
ss_top = sc.Substrand(helix=top_helix, forward=True,
start=right_left, end=right_right)
ss_bot = sc.Substrand(helix=bot_helix, forward=False,
start=right_left, end=right_right)
tile = sc.Strand(substrands=[ss_bot, ss_top], color=sc.Color(0, 0, 0))
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)

Expand Down
4 changes: 2 additions & 2 deletions examples/1_staple_1_helix_origami.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
def main():
length = 9
helices = [sc.Helix(max_offset=length, major_ticks=[2,5])]
stap_ss = sc.Substrand(0, sc.forward, 0, length)
scaf_ss = sc.Substrand(0, sc.reverse, 0, length)
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]
Expand Down
8 changes: 4 additions & 4 deletions examples/1_staple_1_helix_origami_idt_duplicate_names.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import scadnano as sc

def main():
ss1_r = sc.Substrand(0, sc.forward, 0, 4)
ss2_r = sc.Substrand(0, sc.forward, 4, 8)
ss3_r = sc.Substrand(0, sc.forward, 8, 12)
ss_l = sc.Substrand(0, sc.reverse, 0, 12)
ss1_r = sc.Domain(0, sc.forward, 0, 4)
ss2_r = sc.Domain(0, sc.forward, 4, 8)
ss3_r = sc.Domain(0, sc.forward, 8, 12)
ss_l = sc.Domain(0, sc.reverse, 0, 12)

s1_r = sc.Strand([ss1_r], idt=sc.IDTFields('s1_r'))
s2_r = sc.Strand([ss2_r], idt=sc.IDTFields('s1_r'))
Expand Down
4 changes: 2 additions & 2 deletions examples/1_staple_1_helix_origami_mismatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

def main():
length = 10
stap_ss = sc.Substrand(0, sc.forward, 0, length)
scaf_ss = sc.Substrand(0, sc.reverse, 0, length)
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]
Expand Down
4 changes: 2 additions & 2 deletions examples/1_staple_1_helix_origami_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
def main():
length = 9
helices = [sc.Helix(max_offset=length, rotation=math.pi/2, rotation_anchor=2)]
stap_ss = sc.Substrand(0, sc.forward, 0, length)
scaf_ss = sc.Substrand(0, sc.reverse, 0, length)
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]
Expand Down
4 changes: 2 additions & 2 deletions examples/24_helix_origami_rectangle_twist_corrected.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def add_staple_nicks(design: sc.DNADesign):


def add_precursor_staples(design: sc.DNADesign):
staples = [sc.Strand([sc.Substrand(helix=helix, forward=helix % 2 == 1, start=8, end=296)])
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 precursor_scaffolds() -> sc.DNADesign:
helices = [sc.Helix(max_offset=304) for _ in range(24)]
scaffolds = [sc.Strand([sc.Substrand(helix=helix, forward=helix % 2 == 0, start=8, end=296)])
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)

Expand Down
16 changes: 8 additions & 8 deletions examples/2_helix_2_strands_multiple_substrands_no_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# If running in scadnano, define a function called main() that returns design.
# It will be displayed in the browser by scadnano.
def main():
# multiple-substrand
ss0_1 = sc.Substrand(helix=0, forward=False, start=0, end=4)
ss1 = sc.Substrand(helix=1, forward=True, start=0, end=8)
ss0_2 = sc.Substrand(helix=0, forward=False, start=4, end=8)
strand_multi = sc.Strand(substrands=[ss0_1, ss1, ss0_2])
# 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 substrand
ss0_single = sc.Substrand(helix=0, forward=True, start=0, end=8)
strand_single = sc.Strand(substrands=[ss0_single])
# 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.DNADesign(strands=[strand_multi, strand_single], grid=sc.square)
Expand Down
14 changes: 7 additions & 7 deletions examples/2_staple_2_helix_modifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import dataclasses

def main():
stap_left_ss1 = sc.Substrand(1, sc.forward, 0, 16)
stap_left_ss0 = sc.Substrand(0, sc.reverse, 0, 16)
stap_right_ss0 = sc.Substrand(0, sc.reverse, 16, 32)
stap_right_ss1 = sc.Substrand(1, sc.forward, 16, 32)
scaf_ss1_left = sc.Substrand(1, sc.reverse, 0, 16)
scaf_ss0 = sc.Substrand(0, sc.forward, 0, 32)
scaf_ss1_right = sc.Substrand(1, sc.reverse, 16, 32)
stap_left_ss1 = sc.Domain(1, sc.forward, 0, 16)
stap_left_ss0 = sc.Domain(0, sc.reverse, 0, 16)
stap_right_ss0 = sc.Domain(0, sc.reverse, 16, 32)
stap_right_ss1 = sc.Domain(1, sc.forward, 16, 32)
scaf_ss1_left = sc.Domain(1, sc.reverse, 0, 16)
scaf_ss0 = sc.Domain(0, sc.forward, 0, 32)
scaf_ss1_right = sc.Domain(1, sc.reverse, 16, 32)
stap_left = sc.Strand([stap_left_ss1, stap_left_ss0])
stap_right = sc.Strand([stap_right_ss0, stap_right_ss1])
scaf = sc.Strand([scaf_ss1_left, scaf_ss0, scaf_ss1_right], color=sc.default_scaffold_color)
Expand Down
14 changes: 7 additions & 7 deletions examples/2_staple_2_helix_origami_6bases_wide.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
def main():
width = 6
width_h = width // 2
stap_left_ss1 = sc.Substrand(1, sc.forward, 0, width_h)
stap_left_ss0 = sc.Substrand(0, sc.reverse, 0, width_h)
stap_right_ss0 = sc.Substrand(0, sc.reverse, width_h, width)
stap_right_ss1 = sc.Substrand(1, sc.forward, width_h, width)
scaf_ss1_left = sc.Substrand(1, sc.reverse, 0, width_h)
scaf_ss0 = sc.Substrand(0, sc.forward, 0, width)
scaf_ss1_right = sc.Substrand(1, sc.reverse, width_h, width)
stap_left_ss1 = sc.Domain(1, sc.forward, 0, width_h)
stap_left_ss0 = sc.Domain(0, sc.reverse, 0, width_h)
stap_right_ss0 = sc.Domain(0, sc.reverse, width_h, width)
stap_right_ss1 = sc.Domain(1, sc.forward, width_h, width)
scaf_ss1_left = sc.Domain(1, sc.reverse, 0, width_h)
scaf_ss0 = sc.Domain(0, sc.forward, 0, width)
scaf_ss1_right = sc.Domain(1, sc.reverse, width_h, width)
stap_left = sc.Strand([stap_left_ss1, stap_left_ss0])
stap_right = sc.Strand([stap_right_ss0, stap_right_ss1])
scaf = sc.Strand([scaf_ss1_left, scaf_ss0, scaf_ss1_right], color=sc.default_scaffold_color)
Expand Down
Loading

0 comments on commit 08ad763

Please sign in to comment.