Skip to content

Commit

Permalink
closes #219: change Design.strand to Design.draw_strand
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-doty committed Mar 6, 2022
1 parent fad3b98 commit 9d9538d
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 137 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ def create_design():

# for absolute offsets, call method "to"
# left staple
design.strand(1, 8).to(24).cross(0).to(8)
design.draw_strand(1, 8).to(24).cross(0).to(8)

# for relative offsets, call method "move"
# right staple
design.strand(0, 40).move(-16).cross(1).move(16).with_modification_5p(mod.biotin_5p)
design.draw_strand(0, 40).move(-16).cross(1).move(16).with_modification_5p(mod.biotin_5p)

# scaffold
design.strand(1, 24).move(-16).cross(0).move(32).loopout(1, 3).move(-16).as_scaffold()
design.draw_strand(1, 24).move(-16).cross(0).move(32).loopout(1, 3).move(-16).as_scaffold()

# deletions and insertions added to design are added to both strands on a helix
design.add_deletion(helix=1, offset=20)
Expand All @@ -257,7 +257,7 @@ if __name__ == '__main__':
design.write_scadnano_file(directory='output_designs')
```

Documentation is available in the [API docs](https://scadnano-python-package.readthedocs.io/en/latest/#scadnano.Design.strand).
Documentation is available in the [API docs](https://scadnano-python-package.readthedocs.io/en/latest/#scadnano.Design.draw_strand).



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def create_design() -> sc.Design:
# whole design
design = sc.Design(helices=helices, strands=[], grid=sc.square)

design.strand(1, 8).to(24).cross(0).to(8) # left staple
design.strand(0, 40).to(24).cross(1).to(40).with_modification_5p(mod.biotin_5p) # right staple
design.strand(1, 24).to(8).cross(0).to(40).loopout(1, 3).to(24).as_scaffold()
design.draw_strand(1, 8).to(24).cross(0).to(8) # left staple
design.draw_strand(0, 40).to(24).cross(1).to(40).with_modification_5p(mod.biotin_5p) # right staple
design.draw_strand(1, 24).to(8).cross(0).to(40).loopout(1, 3).to(24).as_scaffold()

# deletions and insertions added to design are added to both strands on a helix
design.add_deletion(helix=1, offset=20)
Expand Down
6 changes: 3 additions & 3 deletions examples/circular.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ def create_design() -> sc.Design:
helices = [sc.Helix(max_offset=24) for _ in range(2)]
design = sc.Design(helices=helices, grid=sc.square)

design.strand(0,0).move(8).cross(1).move(-8).as_circular()
design.strand(0,8).move(8).loopout(1, 5).move(-8).as_circular()
design.strand(0,16).move(8).cross(1).move(-8)
design.draw_strand(0, 0).move(8).cross(1).move(-8).as_circular()
design.draw_strand(0, 8).move(8).loopout(1, 5).move(-8).as_circular()
design.draw_strand(0, 16).move(8).cross(1).move(-8)

return design

Expand Down
16 changes: 8 additions & 8 deletions examples/helix_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ def create_design() -> sc.Design:

design = sc.Design(helices=helices, groups=groups, strands=[])

design.strand(0, 0).to(8) \
design.draw_strand(0, 0).to(8) \
.cross(1).to(0) \
.cross(2).to(8) \
.cross(3).to(0) \
.cross(4).to(8) \
.cross(5).to(0)

design.strand(4, 10).to(13)
design.draw_strand(4, 10).to(13)

design.strand(6, 0).to(8).cross(7).to(0)
design.strand(8, 0).to(8).cross(9).to(0)
design.strand(13, 0).to(8).cross(15).to(0)
design.draw_strand(6, 0).to(8).cross(7).to(0)
design.draw_strand(8, 0).to(8).cross(9).to(0)
design.draw_strand(13, 0).to(8).cross(15).to(0)

design.strand(8, 8).to(11)
design.strand(13, 8).to(11)
design.draw_strand(8, 8).to(11)
design.draw_strand(13, 8).to(11)


if include_rot:
design.strand(10, 0).to(8).cross(11).to(0)
design.draw_strand(10, 0).to(8).cross(11).to(0)

return design

Expand Down
16 changes: 8 additions & 8 deletions examples/names_domains_strands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def create_design() -> sc.Design:
num_domains = 9
helices = [sc.Helix(max_offset=(num_domains) * 8)]
design: sc.Design = sc.Design(helices=helices, strands=[], grid=sc.square)
design.strand(0, (num_domains - 1) * 8) \
design.draw_strand(0, (num_domains - 1) * 8) \
.move(-8).with_domain_name('domain 8*') \
.move(-8).with_domain_name('domain 7*') \
.move(-8).with_domain_name('domain 6*') \
Expand All @@ -17,25 +17,25 @@ def create_design() -> sc.Design:
.with_name('bottom strand')

# domain names match
design.strand(0, 0).move(8).with_domain_name('domain 1').with_name('top strand 1')
design.draw_strand(0, 0).move(8).with_domain_name('domain 1').with_name('top strand 1')

# domains are aligns but names mismatch
design.strand(0, 8).move(8).with_domain_name('domain 50').with_name('top strand 2')
design.draw_strand(0, 8).move(8).with_domain_name('domain 50').with_name('top strand 2')

# domain names match
design.strand(0, 16).move(8).with_domain_name('domain 3').with_name('top strand 3')
design.draw_strand(0, 16).move(8).with_domain_name('domain 3').with_name('top strand 3')

# domain names are the same, not complementary
design.strand(0, 24).move(8).with_domain_name('domain 4*').with_name('top strand 4')
design.draw_strand(0, 24).move(8).with_domain_name('domain 4*').with_name('top strand 4')

# domain names match but domains are mis-aligned
design.strand(0, 32).move(9).with_domain_name('domain 5').with_name('top strand 5')
design.draw_strand(0, 32).move(9).with_domain_name('domain 5').with_name('top strand 5')

# domain names match but domains are mis-aligned
design.strand(0, 48).move(7).with_domain_name('domain 7').with_name('top strand 7')
design.draw_strand(0, 48).move(7).with_domain_name('domain 7').with_name('top strand 7')

# no overlap so no mismatch
design.strand(0, 64).move(8).with_domain_name('domain 9').with_name('top strand 9')
design.draw_strand(0, 64).move(8).with_domain_name('domain 9').with_name('top strand 9')

return design

Expand Down
8 changes: 4 additions & 4 deletions examples/tutorial-examples/24_helix_rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def create_design() -> sc.Design:

def add_scaffold_precursors(design: sc.Design) -> None:
for helix in range(0, 23, 2): # scaffold goes forward on even helices
design.strand(helix, 0).move(288).as_scaffold()
design.draw_strand(helix, 0).move(288).as_scaffold()
for helix in range(1, 23, 2): # scaffold goes reverse on odd helices
design.strand(helix, 288).move(-288).as_scaffold()
design.strand(23, 288).move(-144).as_scaffold() # bottom part of scaffold has a "nick"
design.strand(23, 144).move(-144).as_scaffold() #
design.draw_strand(helix, 288).move(-288).as_scaffold()
design.draw_strand(23, 288).move(-144).as_scaffold() # bottom part of scaffold has a "nick"
design.draw_strand(23, 144).move(-144).as_scaffold() #


def add_scaffold_crossovers(design: sc.Design) -> None:
Expand Down
17 changes: 14 additions & 3 deletions scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -4859,14 +4859,14 @@ def _ensure_mods_unique_names(all_mods: Set[Modification]) -> None:
raise IllegalDesignError(f'two different modifications share the id {mod.id}; '
f'one is\n {mod}\nand the other is\n {other_mod}')

def strand(self, helix: int, offset: int) -> StrandBuilder:
def draw_strand(self, helix: int, offset: int) -> StrandBuilder:
"""Used for chained method building by calling
:py:meth:`Design.strand` to build the :any:`Strand` domain by domain, in order from 5' to 3'.
For example
.. code-block:: Python
design.strand(0, 7).to(10).cross(1).to(5).cross(2).to(15)
design.draw_strand(0, 7).to(10).cross(1).to(5).cross(2).to(15)
This creates a :any:`Strand` in this :any:`Design` equivalent to
Expand All @@ -4882,7 +4882,7 @@ def strand(self, helix: int, offset: int) -> StrandBuilder:
.. code-block:: Python
design.strand(0, 7).to(10).cross(1).to(5).loopout(2, 3).to(15)
design.draw_strand(0, 7).to(10).cross(1).to(5).loopout(2, 3).to(15)
This creates a :any:`Strand` in this :any:`Design` equivalent to
Expand Down Expand Up @@ -4918,6 +4918,17 @@ def strand(self, helix: int, offset: int) -> StrandBuilder:
"""
return StrandBuilder(self, helix, offset)

# def strand(self, helix: int, offset: int) -> StrandBuilder:
# """
# Same as :meth:`Design.draw_strand`.
#
# .. deprecated:: 0.18.0
# Use :meth:`Design.draw_strand` instead. This method will be removed.
# """
# print('WARNING: The method Design.strand is deprecated. Use Design.draw_strand instead, '
# 'which has the same functionality.')
# return self.draw_strand(helix, offset)

def assign_m13_to_scaffold(self, rotation: int = 5587, variant: M13Variant = M13Variant.p7249) -> None:
"""Assigns the scaffold to be the sequence of M13: :py:func:`m13` with the given `rotation`
and :any:`M13Variant`.
Expand Down
Loading

0 comments on commit 9d9538d

Please sign in to comment.