Skip to content

Commit

Permalink
Bug fix helix number was badly set in cadnano export
Browse files Browse the repository at this point in the history
  • Loading branch information
tcosmo committed Aug 2, 2021
1 parent ab4a541 commit 337fd1b
Show file tree
Hide file tree
Showing 12 changed files with 630 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.DS_Store
*.pyc
__pyache__/*
/venv/
Expand Down
4 changes: 3 additions & 1 deletion scadnano/scadnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -4706,7 +4706,8 @@ def _cadnano_v2_fill_blank(self, dct: dict, num_bases: int, design_grid: Grid) -
"""Creates blank cadnanov2 helices in and initialized all their fields.
"""
helices_ids_reverse = {}
for i, helix in self.helices.items():
i = 0
for _, helix in self.helices.items():
helix_dct: Dict[str, Any] = OrderedDict()
helix_dct['num'] = helix.idx

Expand All @@ -4732,6 +4733,7 @@ def _cadnano_v2_fill_blank(self, dct: dict, num_bases: int, design_grid: Grid) -

helices_ids_reverse[helix_dct['num']] = i
dct['vstrands'].append(helix_dct)
i += 1
return helices_ids_reverse

def to_cadnano_v2(self) -> Dict[str, Any]:
Expand Down
13 changes: 13 additions & 0 deletions tests/scadnano_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ def test_circular_auto_staple_hex(self) -> None:
design.write_scadnano_file(directory=self.output_path,
filename=f'{file_name}.{sc.default_scadnano_file_extension}')

def test_paranemic_crossover(self) -> None:
file_name = "test_paranemic_crossover"
design = sc.Design.from_cadnano_v2(directory=self.input_path,
filename=file_name + ".json")
design.write_scadnano_file(directory=self.output_path,
filename=f'{file_name}.{sc.default_scadnano_file_extension}')


class TestExportDNASequences(unittest.TestCase):

Expand Down Expand Up @@ -1034,6 +1041,12 @@ def test_big_circular_staples(self) -> None:
design.export_cadnano_v2(directory=self.output_path,
filename='test_big_circular_staples.json')

def test_paranemic_crossover(self) -> None:
design = sc.Design.from_scadnano_file(
os.path.join(self.input_path, f'test_paranemic_crossover.{self.ext}'))
design.export_cadnano_v2(directory=self.output_path,
filename='test_paranemic_crossover.json')

def test_bad_cases(self) -> None:
""" We do not handle Loopouts and design where the parity of the helix
does not correspond to the direction.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"grid": "square",
"helices": [
{"max_offset": 448, "grid_position": [0, 0]},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"grid": "square",
"helices": [
{"grid_position": [0, 0]},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"grid": "square",
"helices": [
{"grid_position": [0, 0]},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"grid": "square",
"helices": [
{"grid_position": [0, 0]},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"grid": "square",
"helices": [
{"max_offset": 192, "grid_position": [0, 0]},
Expand Down
2 changes: 1 addition & 1 deletion tests_inputs/cadnano_v2_export/test_circular_strand.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"grid": "square",
"helices": [
{"max_offset": 24, "grid_position": [0, 0]},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"groups": {
"east": {
"position": {"x": 10, "y": 0, "z": 0},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.1",
"version": "0.16.2",
"groups": {
"east": {
"position": {"x": 10, "y": 0, "z": 0},
Expand Down
Loading

0 comments on commit 337fd1b

Please sign in to comment.