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

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

fix crash error in assignment of DNA to design with deletion on one domain but not other #203

Open dave-doty opened 2 years ago

dave-doty commented 2 years ago

Create a design where one domain has a deletion but the domain it is bound to does not:

image

Assign DNA to the strand with the deletion:

image

I'm showing this above in the web interface to help visualize, but you get the same error in the Python package:

design = sc.Design(grid=sc.square, helices=[sc.Helix(max_offset=100)], strands=[])
design.strand(0, 0).move(8)
design.strand(0, 8).move(-8)
design.strands[0].domains[0].deletions.append(4)
design.assign_dna(design.strands[0], 'AAAAAAA')

Expected behavior

Generally we don't encourage putting isolated deletions/insertions. But in this case, it makes sense to put a wildcard symbol. However, we should first add a (default True) boolean paramater to Design.assign_dna that raises an exception if some pair of Domains mismatch deletions or insertions in this way. Only if the user explicitly sets it to False would we assign the wildcard, since this could mask a subtle bug in the design.


This error was originally identified in the following design, but the minimal reproducible example is above.

Import this cadnano design and run

design.assign_dna(design.scaffold, sc.m13())

(Calling design.assign_m13_to_scaffold raises an exception because that design has two scaffolds, one is a small isolated strand on helix 37.)

It raises this exception:

  File "C:\Dropbox\git\scadnano-python-package\tests\scadnano_tests.py", line 595, in test_minitri_assign_m13
    design.assign_dna(design.scaffold, sc.m13())
  File "C:\Dropbox\git\scadnano-python-package\scadnano\scadnano.py", line 5499, in assign_dna
    other_strand.assign_dna_complement_from(strand)
  File "C:\Dropbox\git\scadnano-python-package\scadnano\scadnano.py", line 3107, in assign_dna_complement_from
    merged_domain_self_dna_sequence = _string_merge_wildcard(domain_self_dna_sequence,
  File "C:\Dropbox\git\scadnano-python-package\scadnano\scadnano.py", line 3426, in _string_merge_wildcard
    raise ValueError(f'\ns1={s1} and\ns2={s2}\nare not the same length.')
ValueError: 
s1=CTGGAAG and
s2=????????
are not the same length.