From 2b485beecad86d0167eba2a532bfa61888221ca9 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Sun, 22 May 2022 21:29:45 -0700 Subject: [PATCH] Add ligate and half crossover error cases --- scadnano/scadnano.py | 2 +- tests/scadnano_tests.py | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/scadnano/scadnano.py b/scadnano/scadnano.py index 8fa1aa71..8f5b1db4 100644 --- a/scadnano/scadnano.py +++ b/scadnano/scadnano.py @@ -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) diff --git a/tests/scadnano_tests.py b/tests/scadnano_tests.py index 231468c6..03e85c82 100644 --- a/tests/scadnano_tests.py +++ b/tests/scadnano_tests.py @@ -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)]) @@ -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: