Skip to content

Commit

Permalink
fixed edit mod dialog to account for base vs. linker
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-doty committed Aug 25, 2023
1 parent c9698af commit eff3768
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 17 deletions.
22 changes: 13 additions & 9 deletions lib/src/view/design_main_strand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -952,15 +952,11 @@ PAGEHPLC : Dual PAGE & HPLC

items[index_of_dna_base_idx] = DialogInteger(label: 'index of DNA base', value: strand_dna_idx);

items[attached_to_base_idx] = DialogCheckbox(label: 'attached to base?', value: true, tooltip: '''\
If checked, then this internal modification is attached to a DNA base (such as internal biotin /iBiodT/).
In that case the list of allowed DNA bases to which it can attach must be specified in the field
"allowed bases". If unchecked, then this internal modification goes in between bases (e.g., a carbon linker
such as /iSp9/).''');
items[attached_to_base_idx] =
DialogCheckbox(label: 'attached to base?', value: true, tooltip: tooltip_attached_to_base_checkbox);

items[allowed_bases_idx] = DialogText(label: 'allowed bases', value: 'ACGT', tooltip: '''\
TODO
''');
items[allowed_bases_idx] =
DialogText(label: 'allowed bases', value: 'ACGT', tooltip: tooltip_allowed_bases_textfield);

// don't allow to modify index of DNA base when 3' or 5' is selected
var dialog = Dialog(
Expand Down Expand Up @@ -1018,7 +1014,6 @@ TODO
allowed_bases_str = allowed_bases_str.replaceAll(RegExp(r'[^(A|C|G|T|a|c|g|t)]'), '');
allowed_bases =
{for (int i = 0; i < allowed_bases_str.length; i++) allowed_bases_str[i].toUpperCase()}.build();
print('allowed_bases = ${allowed_bases}');
}
mod = ModificationInternal(
// id: id,
Expand Down Expand Up @@ -1334,3 +1329,12 @@ Future<void> ask_for_color(Strand strand, BuiltSet<Strand> selected_strands) asy
color_set_strand_action_creator(color_hex), strand, selected_strands, "set strand color");
app.dispatch(action);
}

String tooltip_attached_to_base_checkbox = '''\
If checked, then this internal modification is attached to a DNA base (such as internal biotin /iBiodT/).
In that case the list of allowed DNA bases to which it can attach must be specified in the field
"allowed bases". If unchecked, then this internal modification goes in between bases (e.g., a carbon linker
such as /iSp9/).''';

String tooltip_allowed_bases_textfield = '''\
TODO''';
47 changes: 39 additions & 8 deletions lib/src/view/design_main_strand_modification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../util.dart' as util;
import '../state/strand.dart';
import '../state/helix.dart';
import '../constants.dart' as constants;
import 'design_main_strand.dart';

part 'design_main_strand_modification.over_react.g.dart';

Expand Down Expand Up @@ -157,19 +158,42 @@ class DesignMainStrandModificationComponent extends UiComponent2<DesignMainStran
int display_text_idx = 0;
int idt_text_idx = 1;
int connector_length_idx = 2;
// int id_idx = 2;
var items = List<DialogItem>.filled(3, null);
int attached_to_base_idx = 3;
int allowed_bases_idx = 4;

bool is_internal = props.modification is ModificationInternal;
int num_items = is_internal ? 5 : 3;
var items = List<DialogItem>.filled(num_items, null);
items[display_text_idx] = DialogText(label: 'display text', value: props.modification.display_text);
items[idt_text_idx] = DialogText(label: 'idt text', value: props.modification.idt_text);
items[connector_length_idx] =
DialogInteger(label: 'connector length', value: props.modification.connector_length);
// items[id_idx] = DialogText(label: 'id', value: props.modification.id);

if (is_internal) {
ModificationInternal mod = (props.modification as ModificationInternal);
bool attached_to_base_old = mod.allowed_bases != null;
items[attached_to_base_idx] = DialogCheckbox(
label: 'attached to base?',
value: attached_to_base_old,
tooltip: tooltip_attached_to_base_checkbox);

var allowed_bases_old = attached_to_base_old ? mod.allowed_bases.join('') : 'ACGT';
items[allowed_bases_idx] = DialogText(
label: 'allowed bases', value: allowed_bases_old, tooltip: tooltip_allowed_bases_textfield);
}

var dialog = Dialog(
title: 'edit modification',
type: DialogType.edit_modification,
items: items,
use_saved_response: false);
title: 'edit modification',
type: DialogType.edit_modification,
items: items,
use_saved_response: false,
disable_when_any_checkboxes_off: is_internal
? {
allowed_bases_idx: [attached_to_base_idx]
}
: {},
);
List<DialogItem> results = await util.dialog(dialog);
if (results == null) return;

Expand All @@ -181,24 +205,31 @@ class DesignMainStrandModificationComponent extends UiComponent2<DesignMainStran
Modification new_mod;
if (props.modification is Modification3Prime) {
new_mod = Modification3Prime(
//id: id,
display_text: display_text,
idt_text: idt_text,
connector_length: connector_length,
);
} else if (props.modification is Modification5Prime) {
new_mod = Modification5Prime(
//id: id,
display_text: display_text,
idt_text: idt_text,
connector_length: connector_length,
);
} else {
bool attached_to_base = (results[attached_to_base_idx] as DialogCheckbox).value;
String allowed_bases_str = (results[allowed_bases_idx] as DialogText).value;
var allowed_bases = null;
if (attached_to_base) {
allowed_bases_str = allowed_bases_str.replaceAll(RegExp(r'[^(A|C|G|T|a|c|g|t)]'), '');
allowed_bases =
{for (int i = 0; i < allowed_bases_str.length; i++) allowed_bases_str[i].toUpperCase()}.build();
}
new_mod = ModificationInternal(
// id: props.modification.id,
display_text: display_text,
idt_text: props.modification.idt_text,
connector_length: connector_length,
allowed_bases: allowed_bases,
);
}

Expand Down

0 comments on commit eff3768

Please sign in to comment.