Skip to content

Commit

Permalink
Extension name, label, and sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
UnHumbleBen committed May 13, 2022
1 parent 5610cf8 commit 185d097
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 8 additions & 0 deletions scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,14 @@ def dna_length(self) -> int:
"""Length of this :any:`Extension`; same as field :py:data:`Extension.length`."""
return self.num_bases

def set_label(self, label: Optional[DomainLabel]) -> None:
"""Sets label of this :any:`Extension`."""
self.label = label

def set_name(self, name: str) -> None:
"""Sets name of this :any:`Extension`."""
self.name = name

@dataclass
class ExtensionBuilder(Generic[DomainLabel]):
length: Optional[int] = None
Expand Down
18 changes: 10 additions & 8 deletions tests/scadnano_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,20 @@ def test_strand__extension_3p_with_label(self) -> None:

expected_strand: sc.Strand = sc.Strand([
sc.Domain(0, True, 0, 10),
sc.Extension(5, (1, -1), label="ext1"),
sc.Extension(5, label="ext1"),
])
self.assertEqual(1, len(design.strands))
self.assertEqual(expected_strand, design.strands[0])

def test_strand__extension_5p_with_label(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.with_domain_label("ext1")
sb.to(10)

expected_strand: sc.Strand = sc.Strand([
sc.Extension(5, (-1, -1), label="ext1"),
sc.Extension(5, label="ext1"),
sc.Domain(0, True, 0, 10)
])

Expand All @@ -273,19 +274,20 @@ def test_strand__with_sequence_on_3p_extension(self) -> None:

expected_strand: sc.Strand = sc.Strand([
sc.Domain(0, True, 0, 10, dna_sequence="A"*10),
sc.Extension(5, (1, -1), dna_sequence="G"*5),
sc.Extension(5, dna_sequence="G"*5),
])
self.assertEqual(1, len(design.strands))
self.assertEqual(expected_strand, design.strands[0])

def test_strand__with_sequence_on_5p_extension(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.with_sequence("C"*5 + "T"*10)

expected_strand: sc.Strand = sc.Strand([
sc.Extension(5, (-1, -1), dna_sequence="C"*5),
sc.Extension(5, dna_sequence="C"*5),
sc.Domain(0, True, 0, 10, dna_sequence="T"*10),
])
self.assertEqual(1, len(design.strands))
Expand All @@ -300,7 +302,7 @@ def test_strand__with_domain_sequence_on_extension(self) -> None:

expected_strand: sc.Strand = sc.Strand([
sc.Domain(0, True, 0, 10, dna_sequence="?"*10),
sc.Extension(5, (1, -1), dna_sequence="G"*5),
sc.Extension(5, dna_sequence="G"*5),
])
self.assertEqual(1, len(design.strands))
self.assertEqual(expected_strand, design.strands[0])
Expand All @@ -314,7 +316,7 @@ def test_strand__extension_with_name(self) -> None:

expected_strand: sc.Strand = sc.Strand([
sc.Domain(0, True, 0, 10),
sc.Extension(5, (1, -1), name="ext1"),
sc.Extension(5, name="ext1"),
])
self.assertEqual(1, len(design.strands))
self.assertEqual(expected_strand, design.strands[0])
Expand Down

0 comments on commit 185d097

Please sign in to comment.