Skip to content

Commit

Permalink
In to, check for 3' extension; fixed some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
UnHumbleBen committed May 12, 2022
1 parent b8077c6 commit 122445c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -2351,6 +2351,9 @@ def to(self, offset: int) -> 'StrandBuilder[StrandLabel, DomainLabel]':
'(strictly increasing or strictly decreasing) '
'when calling to() twice in a row')

if self._contains_extension_3p():
raise IllegalDesignError('cannot make a new domain once 3\' extension has been added')

if offset > self.current_offset:
forward = True
start = self.current_offset
Expand All @@ -2374,6 +2377,12 @@ def to(self, offset: int) -> 'StrandBuilder[StrandLabel, DomainLabel]':

return self

def _contains_extension_3p(self) -> bool:
if self._strand is None:
return False
domains = self._strand.domains
return len(domains) > 1 and isinstance(domains[-1], Extension)

# remove quotes when Py3.6 support dropped
def update_to(self, offset: int) -> 'StrandBuilder[StrandLabel, DomainLabel]':
"""
Expand Down
10 changes: 6 additions & 4 deletions tests/scadnano_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,14 @@ def test_strand__5p_extension(self) -> None:

def test_strand__update_to_after_5p_extension_ok(self) -> None:
design = self.design_6helix
sb = design.draw_strand(0, 0, extension_5p_length=5)
sb = design.draw_strand(0, 0)
sb.extension_5p(5)

sb.to(10)
sb.update_to(15)

expected_strand: sc.Strand = sc.Strand([
sc.Extension(5, (-1, -1)),
sc.Extension(5),
sc.Domain(0, True, 0, 15),
])

Expand All @@ -136,12 +137,13 @@ def test_strand__update_to_after_5p_extension_ok(self) -> None:

def test_strand__move_after_5p_extension_ok(self) -> None:
design = self.design_6helix
sb = design.draw_strand(0, 0, extension_5p_length=5)
sb = design.draw_strand(0, 0)
sb.extension_5p(5)

sb.move(15)

expected_strand: sc.Strand = sc.Strand([
sc.Extension(5, (-1, -1)),
sc.Extension(5),
sc.Domain(0, True, 0, 15),
])

Expand Down

0 comments on commit 122445c

Please sign in to comment.