Skip to content

Commit 0a4e20c

Browse files
committed
fixes #1060: domain name mismatch warning stars shown in incorrect position
1 parent 329d6fd commit 0a4e20c

File tree

5 files changed

+41
-19
lines changed

5 files changed

+41
-19
lines changed

lib/src/util.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,8 @@ pprint(Map map) {
13871387
print('}');
13881388
}
13891389

1390+
String id_helix(Helix helix) => 'helix-H${helix.idx}';
1391+
13901392
String id_domain(Domain domain) =>
13911393
'domain-H${domain.helix}-S${domain.start}-E${domain.end}-${domain.forward ? 'forward' : 'reverse'}';
13921394

lib/src/view/design_main.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ class DesignMainComponent extends UiComponent2<DesignMainProps> {
105105
..design = design
106106
..only_display_selected_helices = ui_state.only_display_selected_helices
107107
..side_selected_helix_idxs = ui_state.side_selected_helix_idxs
108-
..helix_idx_to_svg_position_map = state.helix_idx_to_svg_position_map
108+
..helix_idx_to_svg_position_y_map = state.helix_idx_to_svg_position_map.map(
109+
(helix_idx, svg_position) => MapEntry(helix_idx, svg_position.y),
110+
)
109111
..key = 'domain-name-mismatches')(),
110112

111113
if (ui_state.show_unpaired_insertion_deletions)

lib/src/view/design_main_dna_mismatches.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ class DesignMainDNAMismatchesComponent extends UiComponent2<DesignMainDNAMismatc
3737
for (Domain domain in strand.domains) {
3838
BuiltList<Mismatch> mismatches = props.design.dna_mismatches_on_domain(domain);
3939

40-
List<ReactElement> domain_components = [];
40+
List<ReactElement> untransformed_mismatch_components = [];
4141
for (Mismatch mismatch in mismatches) {
4242
var helix = props.design.helices[domain.helix]!;
4343
if (!props.only_display_selected_helices || props.side_selected_helix_idxs.contains(helix.idx)) {
4444
var group = props.design.groups[helix.group]!;
4545
var geometry = group.geometry ?? props.design.geometry;
46+
var svg_position_y = props.helix_idx_to_svg_position_y_map[helix.idx]!;
4647
var base_svg_pos = helix.svg_base_pos(
4748
mismatch.offset,
4849
domain.forward,
49-
props.helix_idx_to_svg_position_y_map[helix.idx]!,
50+
svg_position_y,
5051
geometry,
5152
);
5253
// For now, if there is a mismatch in an insertion we simply display it for the whole insertion,
@@ -63,7 +64,7 @@ class DesignMainDNAMismatchesComponent extends UiComponent2<DesignMainDNAMismatc
6364
..forward = domain.forward
6465
..color = 'red'
6566
..key = key)();
66-
domain_components.add(mismatch_component);
67+
untransformed_mismatch_components.add(mismatch_component);
6768
}
6869
}
6970
}
@@ -72,12 +73,12 @@ class DesignMainDNAMismatchesComponent extends UiComponent2<DesignMainDNAMismatc
7273
HelixGroup group = props.design.groups[helix.group]!;
7374
String transform_str = group.transform_str(props.design.geometry);
7475

75-
if (domain_components.isNotEmpty) {
76+
if (untransformed_mismatch_components.isNotEmpty) {
7677
mismatch_components.add(
7778
(Dom.g()
7879
..transform = transform_str
7980
..className = 'mismatch-components-in-domain mismatch-${strand.id}'
80-
..key = util.id_domain(domain))(domain_components),
81+
..key = util.id_domain(domain))(untransformed_mismatch_components),
8182
);
8283
}
8384
}

lib/src/view/design_main_domain_name_mismatches.dart

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'package:built_collection/built_collection.dart';
66
import '../state/domain_name_mismatch.dart';
77
import '../state/design.dart';
88
import '../state/domain.dart';
9+
import '../state/helix.dart';
10+
import '../state/group.dart';
911
import 'pure_component.dart';
1012
import 'design_main_warning_star.dart';
1113
import '../util.dart' as util;
@@ -19,7 +21,7 @@ mixin DesignMainDomainNameMismatchesProps on UiProps {
1921
late Design design;
2022
late bool only_display_selected_helices;
2123
late BuiltSet<int> side_selected_helix_idxs;
22-
late BuiltMap<int, Point<double>> helix_idx_to_svg_position_map;
24+
late BuiltMap<int, num> helix_idx_to_svg_position_y_map;
2325
}
2426

2527
class DesignMainDomainNameMismatchesComponent extends UiComponent2<DesignMainDomainNameMismatchesProps>
@@ -33,13 +35,14 @@ class DesignMainDomainNameMismatchesComponent extends UiComponent2<DesignMainDom
3335
List<ReactElement> _create_mismatch_components() {
3436
List<ReactElement> mismatch_components = [];
3537

36-
for (var helix in props.design.helices.values) {
38+
for (Helix helix in props.design.helices.values) {
3739
if (props.only_display_selected_helices && !props.side_selected_helix_idxs.contains(helix.idx)) {
3840
continue;
3941
}
4042

4143
BuiltList<DomainNameMismatch> domain_name_mismatches = props.design.domain_name_mismatches[helix.idx]!;
4244

45+
List<ReactElement> untransformed_mismatch_components = [];
4346
for (var domain_name_mismatch in domain_name_mismatches) {
4447
Domain forward_domain = domain_name_mismatch.forward_domain;
4548
Domain reverse_domain = domain_name_mismatch.reverse_domain;
@@ -52,12 +55,8 @@ class DesignMainDomainNameMismatchesComponent extends UiComponent2<DesignMainDom
5255
var helix = props.design.helices[domain.helix]!;
5356
var group = props.design.groups[helix.group]!;
5457
var geometry = group.geometry ?? props.design.geometry;
55-
var base_svg_pos = helix.svg_base_pos(
56-
mid,
57-
domain.forward,
58-
props.helix_idx_to_svg_position_map[helix.idx]!.y,
59-
geometry,
60-
);
58+
var svg_position_y = props.helix_idx_to_svg_position_y_map[helix.idx]!;
59+
var base_svg_pos = helix.svg_base_pos(mid, domain.forward, svg_position_y, geometry);
6160
String key = '${domain.helix};${domain.forward};${domain.start};${mid};${domain.end}';
6261
var mismatch_component =
6362
(DesignMainWarningStar()
@@ -67,9 +66,21 @@ class DesignMainDomainNameMismatchesComponent extends UiComponent2<DesignMainDom
6766
..color = 'blue'
6867
..domain_name_mismatch = domain_name_mismatch
6968
..key = key)();
70-
mismatch_components.add(mismatch_component);
69+
untransformed_mismatch_components.add(mismatch_component);
7170
}
7271
}
72+
73+
HelixGroup group = props.design.groups[helix.group]!;
74+
String transform_str = group.transform_str(props.design.geometry);
75+
76+
if (untransformed_mismatch_components.isNotEmpty) {
77+
mismatch_components.add(
78+
(Dom.g()
79+
..transform = transform_str
80+
..className = 'mismatch-domain-names-group'
81+
..key = util.id_helix(helix))(untransformed_mismatch_components),
82+
);
83+
}
7384
}
7485
return mismatch_components;
7586
}

lib/src/view/design_main_warning_star.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mixin DesignMainWarningStarProps on UiProps {
1414
late bool forward;
1515
late Geometry geometry;
1616
late String color;
17-
late DomainNameMismatch domain_name_mismatch;
17+
DomainNameMismatch? domain_name_mismatch;
1818
}
1919

2020
class DesignMainWarningStarComponent extends UiComponent2<DesignMainWarningStarProps> {
@@ -41,14 +41,20 @@ class DesignMainWarningStarComponent extends UiComponent2<DesignMainWarningStarP
4141
points.add('${xs[i].toStringAsFixed(2)},${ys[i].toStringAsFixed(2)}');
4242
}
4343

44-
var tooltip_text = '''\
44+
String tooltip_text;
45+
DomainNameMismatch? domain_name_mismatch = props.domain_name_mismatch;
46+
if (domain_name_mismatch != null) {
47+
tooltip_text = '''\
4548
Domain name mismatch:
46-
${props.domain_name_mismatch.forward_domain.toString()} vs.
47-
${props.domain_name_mismatch.reverse_domain.toString()}
49+
${domain_name_mismatch.forward_domain.toString()} vs.
50+
${domain_name_mismatch.reverse_domain.toString()}
4851
4952
Domain names are considered mismatched if they are not the same string, with one ending in *,
5053
or if the domains overlap partially but not totally (do not have identical start and end
5154
positions on the helix they share).''';
55+
} else {
56+
tooltip_text = '';
57+
}
5258

5359
// for SVG need nested title element, rather than title attribute
5460
return (Dom.polygon()

0 commit comments

Comments
 (0)