Skip to content

Commit

Permalink
Add ligate and half crossover error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
UnHumbleBen committed May 23, 2022
1 parent 06fe222 commit 2b485be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -7823,7 +7823,7 @@ def _convert_design_to_oxdna_system(design: Design) -> _OxdnaSystem:
else:
# we place the loopout nucleotides at temporary nonsense positions and orientations
# these will be updated later, for now we just need the base
for i in range(domain.num_bases):
for i in range(domain.length):
base = seq[i]
nuc = _OxdnaNucleotide(_OxdnaVector(), _OxdnaVector(0, -1, 0), _OxdnaVector(0, 0, 1),
base)
Expand Down
35 changes: 33 additions & 2 deletions tests/scadnano_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3268,14 +3268,27 @@ def test_add_nick_then_add_crossovers__6_helix_rectangle(self) -> None:
])
self.assertIn(scaf, self.origami.strands)

def test_ligate_on_middle_domain_should_error(self) -> None:
"""
[-----+[----->
|
<-----+
"""
design: sc.Design = sc.Design(helices=[sc.Helix(max_offset=100), sc.Helix(max_offset=100)])
design.draw_strand(0, 0).to(10).cross(1).to(0)
design.draw_strand(0, 10).to(20)

with self.assertRaises(sc.IllegalDesignError):
design.ligate(0, 10, True)

def test_ligate_on_extension_side_should_error(self) -> None:
"""
/
/
[-------[----->
^
|
^
|
error to ligate here
"""
design: sc.Design = sc.Design(helices=[sc.Helix(max_offset=100)])
Expand Down Expand Up @@ -3454,6 +3467,24 @@ def test_add_half_crossover_on_extension_error(self) -> None:
with self.assertRaises(sc.IllegalDesignError):
design.add_half_crossover(0, 1, 0, True)

def test_add_half_crossover_on_existing_crossover_should_error(self) -> None:
"""
0 +------]
|
1 +------>
2 <------]
"""
# Setup
design: sc.Design = sc.Design(
helices=[sc.Helix(max_offset=100), sc.Helix(max_offset=100), sc.Helix(max_offset=100)]
)
design.draw_strand(0, 10).to(0).cross(1).to(10)
design.draw_strand(2, 10).to(0)

with self.assertRaises(sc.IllegalDesignError):
design.add_half_crossover(1, 2, 0, True)

def test_nick_on_extension(self) -> None:
"""
Before:
Expand Down

0 comments on commit 2b485be

Please sign in to comment.