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

Debugging cadnanov2 export of paranemic crossovers when both segments… #311

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from

Conversation

tcosmo
Copy link
Collaborator

@tcosmo tcosmo commented Oct 17, 2024

… are in the 3' direction

  • Paranemic crossovers when both segments were in the 3p direction was bugged
  • Added test for this case (paranemic crossovers in the 5p direction were already tested)
  • Added raise ValueError when the parity of helix row is not the same for paranemic crossover as this is not valid in cadnanov2

Description

Related Issue

#308

Motivation and Context

How Has This Been Tested?

  • TestExportCadnanoV2.test_paranemic_crossover_other_direction

Screenshots (if appropriate):

Capture d’écran 2024-10-17 à 13 54 34

@tcosmo tcosmo requested a review from dave-doty as a code owner October 17, 2024 11:54
@tcosmo tcosmo linked an issue Oct 17, 2024 that may be closed by this pull request
@dave-doty dave-doty changed the base branch from main to dev October 26, 2024 20:16
@dave-doty dave-doty changed the title Debbuging cadnanov2 export of paranemic crossovers when both segments… Debugging cadnanov2 export of paranemic crossovers when both segments… Oct 26, 2024
Copy link
Member

@dave-doty dave-doty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's something I don't understand. If I run this code:

import scadnano as sc
design = sc.Design(helices=[
    sc.Helix(max_offset=50, idx=0), 
    sc.Helix(max_offset=50, idx=2),
], grid=sc.square)
design.draw_strand(2, 8).move(-8).cross(0, move=8).move(-8)
design.write_scadnano_file('paranemic_crossover_generated.sc')

it generates this design:

image

Then I add this line:

design.write_cadnano_v2_file(filename='paranemic_crossover_generated.json')

and it generates this error:

ValueError: Paranemic crossovers are only allowed between helices that have the same parity of 
row number, here helix num 2 and helix num 0 
have different parity of row number: respectively 1 and 0

What's going wrong? I gave the helices indices 0 and 2 so that they have the same parity. But somehow it's getting translated to cadnano helix num of 0 and 1 instead of 0 and 2. I can fix it if I add an unused helix 1:

design = sc.Design(helices=[
    sc.Helix(max_offset=50, idx=0), 
    sc.Helix(max_offset=50, idx=1), 
    sc.Helix(max_offset=50, idx=2),
], grid=sc.square)

before drawing the strand.

Is this intended behavior? I don't remember how cadnano works. Does it disallow helix indices from being non-consecutive? (i.e., you can have helices 0,1,2,...,n but no strict subset of that?)

If so, we should probably be more specific in specifying the constraints on scadnano designs in doc/index.rst to emphasize this constraint of consecutive helix indices.

But if that's not a constraint of cadnano, then this seems like a bug in the cadnano export code, where it is looking at the helix's order in the dict Design.helices, instead of at its field Helix.idx, to generate cadnano helix num's.

I'm also confused about the distinction between scadnano helix index, and what you call num and row number in the error message. What's the difference between num and row number, and which is supposed to correspond to the field Helix.idx? I think we should also change the error message to use scadnano terms instead of cadnano terms, since we are describing a constraint on the scadnano design for it to be exportable, and scadnano designs have no concept of num or row number.

One guess I have is that by "row number", you mean the order in which the helix appears in the dict Design.helices? But it would be better to more precisely define these terms.

@dave-doty
Copy link
Member

dave-doty commented Oct 26, 2024

UPDATE: Sorry, I just now read your comments on issue #308 to see the explanation of the export rules. I also noticed that the current explanation says something about the helix's "y-coordinate" but I'm not sure what that means. [UPDATE: Oh, I think you mean its y-coordinate in the square grid?]

So it seems the export is fine, given the constraints of cadnano. But I still think the documentation is confusing for the reasons I explained above. I guessed that "row number" means "order helix appears in the dict Design.helices" and that num is the cadnano term for scadnano index. But please check the currently explanation in doc/index.rst and correct it if I explained it incorrectly.

@tcosmo
Copy link
Collaborator Author

tcosmo commented Oct 27, 2024

Hello Dave, yes, I mean y-coordinate in the square grid, i.e. what you can set in scadnano by doing "right click on helix -> set grid position -> v". This referred as "row" using cadnanov2 vocabulary (instead of "num" which is the helix's idx).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import (previously exported) cadnano design with paranemic crossover
2 participants