Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import (previously exported) cadnano design with paranemic crossover #308

Open
dave-doty opened this issue Oct 13, 2024 · 6 comments · May be fixed by #311
Open

import (previously exported) cadnano design with paranemic crossover #308

dave-doty opened this issue Oct 13, 2024 · 6 comments · May be fixed by #311
Assignees
Labels
bug Something isn't working

Comments

@dave-doty
Copy link
Member

dave-doty commented Oct 13, 2024

A paranemic crossover is one where the domains before and after the crossover are in the same direction, e.g.

image

See the attached scadnano and cadnano designs: paranemic_crossover.zip

The cadnano design in the zip file was generated by running the following code:

import scadnano as sc

def main():
    design = sc.Design.from_scadnano_file('paranemic_crossover.sc')
    design.write_cadnano_v2_file(filename='paranemic_crossover.json')

if __name__ == '__main__':
    main()

This bug can also be reproduced by loading the scadnano design in the web interface, selected Export-->cadnano v2, and then File-->Import cadnano v2.

If you load that file paranemic_crossover.json in the scadnano web interface via File-->Import cadnano v2, it gives this error:

******************
* illegal design *
******************

The design has the following problem:

two domains overlap on helix 0: 
Domain {
  helix=0,
  forward=false,
  start=0,
  end=8,
  deletions=[],
  insertions=[],
  is_first=true,
  is_last=true,
  is_scaffold=false,
  strand_id=strand-H0-7-reverse,
  unused_fields={},
}
  and
Domain {
  helix=0,
  forward=false,
  start=0,
  end=8,
  deletions=[],
  insertions=[],
  is_first=false,
  is_last=true,
  is_scaffold=false,
  strand_id=strand-H2-7-reverse,
  unused_fields={},
}
  but have the same direction

I don't know for sure that the issue is the paranemic crossover, but it does not happen, for instance, in this very similar design:

image

@tcosmo
Copy link
Collaborator

tcosmo commented Oct 16, 2024

Find attached:

  1. A paranemic crossover created with the cadnanov2 interface (which I used for debugging)
  2. The debugged version of the exported design

Performing a diff on the bugged version in your .zip and debugged design attached reveals that:

  1. The export code messes up the crossover: [-1,-1,0,6] should be [2,0,0,6].
  2. The export code messes up the helix row placement: the second helix's row should be of same parity than the first one (e.g. 0 and 2) but is currently not (0 and 1).

Hopefully the fix should be easy, I'm looking into it now.

paranemic_crossover_made_with_cadnano2.json
paranemic_crossover_debugged.json

@tcosmo
Copy link
Collaborator

tcosmo commented Oct 16, 2024

I've made good progress on the fix but must stop for the day now. Hopefully I will push fix and new additional tests tomorrow!

@dave-doty
Copy link
Member Author

Cool, no rush, thanks for looking into it!

@tcosmo
Copy link
Collaborator

tcosmo commented Oct 17, 2024

I have fixed the issue in this PR: #311

@dave-doty
Copy link
Member Author

dave-doty commented Oct 26, 2024

  • NOTE: the weird thing is that cadnano2 does not allow for paranemic crossovers when the helix rows (and not nums, rows) are not of the same parity. That way, the design you shared in this issue is not exportable to cadnanov2 because helices are on row 0 and 1. If you move them to row 0 and 2 then its OK. I modified the documentation in consequence.

It sounds like you're saying there's no bug, just an extra constraint we need to have in place when exporting. That appears to be the case from the modified code in the PR, since it just adds new checks but doesn't appear to change the logic of the export method.

However, the original issue (before I shrunk it to what I thought was a minimal reproducible example) is that Sarah had a cadnano design, imported to scadnano (in the web interface), exported from that to cadnano, then tried importing that cadnano design in scadnano, and she saw this error.

So perhaps we should look at Sarah's original design and see if there's not a more subtle bug, because she started with an apparently legal cadnano design, but then going through importing to scadnano and then exporting to cadnano again changed something. I'll ask her to email it to you (or post it here) and maybe you can see what's wrong? Or maybe I'm not thinking about something correctly here.

@tcosmo
Copy link
Collaborator

tcosmo commented Oct 27, 2024

It sounds like you're saying there's no bug, just an extra constraint we need to have in place when exporting. That appears to be the case from the modified code in the PR, since it just adds new checks but doesn't appear to change the logic of the export method.

There was a bug that I solved for paranemic crossovers where both strands go in the 3p direction, see this commit:

Capture d’écran 2024-10-27 à 10 05 37

As per our email thread, the bugfix solves the following chain of import/exports for the minimal example (which did not work prior to this fix):

tests_inputs/cadnano_v2_export/test_paranemic_crossover_other_direction.sc -> test_paranemic_crossover_other_direction.json -> test_paranemic_crossover_other_direction.sc -> test_paranemic_crossover_other_direction.json

However it does not solve the bug for Sarah's initial design. I should inspect further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants