UC-Davis-molecular-computing / scadnano

Web application for designing DNA structures such as DNA origami.
https://scadnano.org
MIT License
21 stars 13 forks source link

fix bug where cannot draw strand bound to other strand #883

Closed dave-doty closed 12 months ago

dave-doty commented 12 months ago

Create a strand in the forward direction:

image

In Pencil mode, try to draw a reverse strand within the same offsets. The strand will appear, but dragging the mouse while the button is down will not expand the strand:

image

The same happens if a reverse strand is already present and you try to draw an overlapping forward strand:

image

dave-doty commented 12 months ago

I noticed that if you start drawing a strand outside the boundaries of another, it stops you from dragging it over the existing strand (despite one forward and the other reverse):

image

So it seems likely that the bug is some bounds-checking code that is not properly accounting for forward/reverse booleans in domains.

dave-doty commented 12 months ago

I fixed this by reverting the code in state/design.dart, in the method Design.domain_on_helix_at. It's currently

  /// Return [Domain] at [address], INCLUSIVE, or null if there is none.
  Domain domain_on_helix_at(Address address, [StrandCreation strand_creation = null]) {
    for (var domain in this.helix_idx_to_domains[address.helix_idx]) {
      if (domain.contains_offset(address.offset) && domain.forward == address.forward) {
        return domain;
      }
    }
    return null;
  }

But to fix the bug in #855, it was changed to this:

  /// Return [Domain] at [address], INCLUSIVE, or null if there is none.
  Domain domain_on_helix_at(Address address, [StrandCreation strand_creation = null]) {
    for (var domain in this.helix_idx_to_domains[address.helix_idx]) {
      if (domain.contains_offset(address.offset) && domain.forward == address.forward) {
        return domain;
      } else if (strand_creation != null && overlap(domain, address.offset, strand_creation.start)) {
        return domain;
      }
    }
    return null;
  }

I'm not sure how to reproduce the bug in #855, but I'm putting this comment here for help with fixing that bug.

dave-doty commented 12 months ago

In case we re-open this issue, see this comment for why I reverted the change for it: https://github.com/UC-Davis-molecular-computing/scadnano/issues/883#issuecomment-1646740743