Skip to content

Commit

Permalink
Merge pull request #951 from UC-Davis-molecular-computing/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dave-doty authored Oct 13, 2023
2 parents 433e709 + 0f73968 commit af78cb4
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 98 deletions.
99 changes: 11 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,10 @@ It is instructive to see how that example design is represented as a `.sc` file
{
"grid": "square",
"helices": [
{
"max_offset": 48,
"grid_position": [
0,
0
]
},
{
"max_offset": 48,
"grid_position": [
0,
1
]
}
{ "max_offset": 48, "grid_position": [0,0] },
{ "max_offset": 48, "grid_position": [0,1] }
],
"modifications_in_design": {
"modifications_5p_in_design": {
"/5Biosg/": {
"display_text": "B",
"vendor_code": "/5Biosg/",
Expand All @@ -209,92 +197,27 @@ It is instructive to see how that example design is represented as a `.sc` file
"color": "#0066cc",
"sequence": "AACGTAACGTAACGTAACGTAACGTAACGTAACGTAACGTAACGTAACGTAACGTAACGTAACGTAACG",
"domains": [
{
"helix": 1,
"forward": false,
"start": 8,
"end": 24,
"deletions": [
20
]
},
{
"helix": 0,
"forward": true,
"start": 8,
"end": 40,
"insertions": [
[
14,
1
],
[
26,
2
]
]
},
{
"loopout": 3
},
{
"helix": 1,
"forward": false,
"start": 24,
"end": 40
}
{ "helix": 1, "forward": false, "start": 8, "end": 24, "deletions": [20] },
{ "helix": 0, "forward": true, "start": 8, "end": 40, "insertions": [[14,1], [26,2]] },
{ "loopout": 3 },
{ "helix": 1, "forward": false, "start": 24, "end": 40 }
],
"is_scaffold": true
},
{
"color": "#f74308",
"sequence": "ACGTTACGTTACGTTTTACGTTACGTTACGTT",
"domains": [
{
"helix": 1,
"forward": true,
"start": 8,
"end": 24,
"deletions": [
20
]
},
{
"helix": 0,
"forward": false,
"start": 8,
"end": 24,
"insertions": [
[
14,
1
]
]
}
{ "helix": 1, "forward": true, "start": 8, "end": 24, "deletions": [20] },
{ "helix": 0, "forward": false, "start": 8, "end": 24, "insertions": [[14,1]] }
]
},
{
"color": "#57bb00",
"sequence": "ACGTTACGTTACGTTACGCGTTACGTTACGTTAC",
"domains": [
{
"helix": 0,
"forward": false,
"start": 24,
"end": 40,
"insertions": [
[
26,
2
]
]
},
{
"helix": 1,
"forward": true,
"start": 24,
"end": 40
}
{ "helix": 0, "forward": false, "start": 24, "end": 40, "insertions": [[26,2]] },
{ "helix": 1, "forward": true, "start": 24, "end": 40 }
],
"5prime_modification": "/5Biosg/"
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import 'state/grid.dart';

// WARNING: Do not modify line below, except for the version string
// (and also add new version string to scadnano_versions_to_link).
const String CURRENT_VERSION = "0.19.0";
const String CURRENT_VERSION = "0.19.1";
const String INITIAL_VERSION = "0.1.0";

// scadnano versions that we deploy so that older versions can be used.
final scadnano_older_versions_to_link = [
"0.19.0",
"0.18.10",
"0.17.14",
// "0.17.13",
Expand Down
4 changes: 3 additions & 1 deletion lib/src/middleware/edit_select_mode_change.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const selectable_css_style_non_domain_or_end = {
};

const selectable_css_style_domain = {
'filter': 'url("#shadow")',
'stroke': 'hotpink',
'stroke-width': '5pt',
// 'filter': 'url("#shadow")',
};

const selectable_css_style_end = {
Expand Down
67 changes: 64 additions & 3 deletions lib/src/state/design.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1409,17 +1409,61 @@ abstract class Design with UnusedFields implements Built<Design, DesignBuilder>,
return;
}

// lots of ugly checks below for backwards compatibility since we used to write
// "5'-" or "3'-" or "internal-" at the start of keys in the modifications map
for (int i = 0; i < strands.length; i++) {
var strand = strands[i];
var strand_json = strand_jsons[i];
if (strand_json.containsKey(constants.modification_5p_key)) {
var mod_name = strand_json[constants.modification_5p_key];
Modification5Prime mod = legacy ? all_mods[mod_name] : mods_5p[mod_name];
Modification5Prime mod;
if (legacy) {
var key = mod_name;
if (!all_mods.containsKey(mod_name)) {
if (key.substring(0, 3) == "5'-") {
key = mod_name.substring(3);
} else {
key = "5'-${mod_name}";
}
}
mod = all_mods[key];
} else {
var key = mod_name;
if (!mods_5p.containsKey(mod_name)) {
if (key.substring(0, 3) == "5'-") {
key = mod_name.substring(3);
} else {
key = "5'-${mod_name}";
}
}
mod = mods_5p[key];
}
strand = strand.rebuild((b) => b..modification_5p.replace(mod));
}
if (strand_json.containsKey(constants.modification_3p_key)) {
var mod_name = strand_json[constants.modification_3p_key];
Modification3Prime mod = legacy ? all_mods[mod_name] : mods_3p[mod_name];
Modification3Prime mod;
if (legacy) {
var key = mod_name;
if (!all_mods.containsKey(mod_name)) {
if (key.substring(0, 3) == "3'-") {
key = mod_name.substring(3);
} else {
key = "3'-${mod_name}";
}
}
mod = all_mods[key];
} else {
var key = mod_name;
if (!mods_3p.containsKey(mod_name)) {
if (key.substring(0, 3) == "3'-") {
key = mod_name.substring(3);
} else {
key = "3'-${mod_name}";
}
}
mod = mods_3p[key];
}
strand = strand.rebuild((b) => b..modification_3p.replace(mod));
}
if (strand_json.containsKey(constants.modifications_int_key)) {
Expand All @@ -1428,7 +1472,24 @@ abstract class Design with UnusedFields implements Built<Design, DesignBuilder>,
for (var idx_str in mod_names_by_idx_json.keys) {
int offset = int.parse(idx_str);
String mod_name = mod_names_by_idx_json[idx_str];
ModificationInternal mod = legacy ? all_mods[mod_name] : mods_int[mod_name];
ModificationInternal mod;
if (legacy) {
var key = mod_name;
if (!all_mods.containsKey(mod_name)) {
if (key.substring(0, 9) == "internal-") {
key = mod_name.substring(9);
} else {
key = "internal-${mod_name}";
}
}
mod = all_mods[key];
} else {
var key = mod_name;
if (!mods_int.containsKey(mod_name)) {
key = "internal-${mod_name}";
}
mod = mods_int[key];
}
mods_by_idx[offset] = mod;
}
strand = strand.rebuild((b) => b..modifications_int.replace(mods_by_idx));
Expand Down
6 changes: 3 additions & 3 deletions lib/src/state/selectable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ class SelectableTrait extends EnumClass {
static const SelectableTrait modification_3p = _$modification_3p;
static const SelectableTrait modification_int = _$modification_int;
static const SelectableTrait dna_sequence = _$dna_sequence;
static const SelectableTrait idt = _$idt;
static const SelectableTrait vendor_fields = _$vendor_fields;
static const SelectableTrait circular = _$circular;
static const SelectableTrait helices = _$helices;

Expand All @@ -588,7 +588,7 @@ class SelectableTrait extends EnumClass {
if (this == modification_3p) return "3' modification";
if (this == modification_int) return "internal modification";
if (this == dna_sequence) return 'DNA sequence';
if (this == idt) return 'IDT fields';
if (this == vendor_fields) return 'vendor fields';
if (this == circular) return 'circular';
if (this == helices) return 'helices';
throw AssertionError('unrecognized trait ${this}');
Expand All @@ -602,7 +602,7 @@ class SelectableTrait extends EnumClass {
if (this == modification_3p) return strand.modification_3p;
if (this == modification_int) return strand.modifications_int;
if (this == dna_sequence) return strand.dna_sequence;
if (this == idt) return strand.vendor_fields;
if (this == vendor_fields) return strand.vendor_fields;
if (this == circular) return strand.circular;
if (this == helices) return [for (var domain in strand.domains) domain.helix];
throw AssertionError('unrecognized trait ${this}');
Expand Down
11 changes: 10 additions & 1 deletion lib/src/view/svg_filters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ add_shadow_filter(svg.SvgSvgElement elt) {
'y': '-100%',
'width': '300%',
'height': '300%',
'filterUnits': 'userSpaceOnUse',
// 'filterUnits': 'userSpaceOnUse',

// The above line has been commented because use of this line caused the strands outside the width x height area to disappear on 'hover'.
// Reverting this change and the changes mentioned below from an old PR #480 (Fixes #20, add shadow filter for domains).
// selectable_css_style_domain has been changed in src/middleware/edit_select_mode_change.dart file
// web/scadnano-styles.css has been changed
// .selected ----> .selected:not(.domain-line)

// However, after making the above mentioned changes, the old issue of domains being highlighted with hotpink on 'hover' instead of shadow comes back. This happens because of issues in SVG Filters that cannot apply the shadow filter to a straight line. Hence, the hotpink substitute is used.
// Because of this, hovering of doamins is slightly different in appearance (hotpink) than the other selectable elements (shadow).
};
// not sure why there's no setter provided for this
// filter_element.setAttribute('filterUnits', 'userSpaceOnUse');
Expand Down
3 changes: 2 additions & 1 deletion web/scadnano-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ label + select {
fill: lightgray;
}

.selected {
/* .selected { */
.selected:not(.domain-line) {
filter: url("#shadow");
}

Expand Down

0 comments on commit af78cb4

Please sign in to comment.