UC-Davis-molecular-computing / scadnano-python-package

Python scripting library for generating designs readable by scadnano.
https://scadnano.org
MIT License
13 stars 7 forks source link

handle paranemic crossovers in cadnano export #185

Closed dave-doty closed 3 years ago

dave-doty commented 3 years ago

scadnano allows "paranemic" crossovers (https://doi.org/10.1021/ja038381e, https://doi.org/10.1021/acs.chemrev.8b00207), i.e., crossovers that connect two domains in the same direction:

image

Exporting to cadnano (Export --> cadnano v2 from menu) and then reimporting that same .json file (File --> Import cadnano v2 from menu) gives an error:

image

The first domain mentioned in the error exists, and is the 3'-most domain of the scaffold. But the second domain (helix=2, start=15, end=16) does not exist in the original design.

The scadnano file with this design is

{
  "version": "0.16.1",
  "grid": "square",
  "helices": [
    {"grid_position": [0, 0], "max_offset": 17},
    {"grid_position": [0, 1], "max_offset": 17},
    {"grid_position": [0, 2], "max_offset": 17}
  ],
  "strands": [
    {
      "color": "#0066cc",
      "is_scaffold": true,
      "domains": [
        {"helix": 0, "forward": true, "start": 0, "end": 8},
        {"helix": 2, "forward": true, "start": 7, "end": 16}
      ]
    }
  ]
}

Note that because the above strand is a scaffold, and we want the strand to be forward on both helices, we must have both helices be even due to cadnano limitations on directions scaffold/staple strands can go on helices based on their parity.

However, the same error happens if the strand is a staple, and is reversed on both helices:

image

tcosmo commented 3 years ago

Paranemic crossovers are possible in cadnano thus bug must be internal to conversion algorithm.

I added tests_inputs/cadnano_v2_import/test_paranemic_crossover.json which is valid cadnano file with 2 paranemic crossovers (one on staples, one on scaffold).

Screenshot 2021-08-02 at 14 13 12

After import then export:

Screenshot 2021-08-02 at 14 19 59

https://github.com/UC-Davis-molecular-computing/scadnano-python-package/tree/bug_paranemic_crossovers

tcosmo commented 3 years ago

Bug fixed:

  1. There was a subtle index setting error in the export code https://github.com/UC-Davis-molecular-computing/scadnano-python-package/pull/189/commits/a4747962181556dc0409c90bba5b956a0ce333ce
  2. Crossover placement codes assumed that crossovers where not paranemic, so cases (forward,forward) and (backward,backward) needed to be implemented https://github.com/UC-Davis-molecular-computing/scadnano-python-package/pull/189/commits/a4747962181556dc0409c90bba5b956a0ce333ce
dave-doty commented 3 years ago

Closed in #189.