Skip to content

Commit

Permalink
closes #964: exclude selected strands from export DNA sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-doty committed Feb 22, 2024
1 parent 34ba098 commit 33a5630
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lib/src/actions/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,8 @@ abstract class ExportDNA with BuiltJsonSerializable implements Action, Built<Exp

bool get include_only_selected_strands;

bool get exclude_selected_strands;

ExportDNAFormat get export_dna_format;

@nullable
Expand All @@ -2097,16 +2099,19 @@ abstract class ExportDNA with BuiltJsonSerializable implements Action, Built<Exp
factory ExportDNA({
bool include_scaffold,
bool include_only_selected_strands,
bool exclude_selected_strands,
ExportDNAFormat export_dna_format,
String delimiter,
String domain_delimiter,
StrandOrder strand_order = null,
bool column_major_strand = true,
bool column_major_plate = true,
}) {
assert(!(include_only_selected_strands && exclude_selected_strands));
return ExportDNA.from((b) => b
..include_scaffold = include_scaffold
..include_only_selected_strands = include_only_selected_strands
..exclude_selected_strands = exclude_selected_strands
..export_dna_format = export_dna_format
..delimiter = delimiter
..domain_delimiter = domain_delimiter
Expand Down
31 changes: 23 additions & 8 deletions lib/src/middleware/export_dna_sequences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export_dna_sequences_middleware(Store<AppState> store, action, NextDispatcher ne
List<Strand> strands;
if (action.include_only_selected_strands) {
strands = state.ui_state.selectables_store.selected_strands.toList();
} else if (action.exclude_selected_strands) {
strands = state.design.strands.toList();
for (var strand in state.ui_state.selectables_store.selected_strands) {
strands.remove(strand);
}
} else {
strands = state.design.strands.toList();
}
Expand Down Expand Up @@ -107,15 +112,16 @@ Future<void> export_dna() async {

int idx_include_scaffold = 0;
int idx_include_only_selected_strands = 1;
int idx_format_str = 2;
int idx_delimiter = 3;
int idx_domain_delimiter = 4;
int idx_column_major_plate = 5;
int idx_sort = 6;
int idx_column_major_strand = 7;
int idx_strand_order_str = 8;
int idx_exclude_selected_strands = 2;
int idx_format_str = 3;
int idx_delimiter = 4;
int idx_domain_delimiter = 5;
int idx_column_major_plate = 6;
int idx_sort = 7;
int idx_column_major_strand = 8;
int idx_strand_order_str = 9;

List<DialogItem> items = List<DialogItem>.filled(9, null);
List<DialogItem> items = List<DialogItem>.filled(idx_strand_order_str + 1, null);

items[idx_delimiter] = DialogText(label: 'delimiter between IDT fields', value: ',', tooltip: '''\
Delimiter to separate IDT fields in a "bulk input" text file, for instance if set to ";", then a line
Expand All @@ -132,6 +138,7 @@ if it had three domains each of length 5.''');
items[idx_include_scaffold] = DialogCheckbox(label: 'include scaffold', value: false);
items[idx_include_only_selected_strands] =
DialogCheckbox(label: 'include only selected strands', value: false);
items[idx_exclude_selected_strands] = DialogCheckbox(label: 'exclude selected strands', value: false);
items[idx_format_str] = DialogRadio(
label: 'export format',
options: export_options,
Expand Down Expand Up @@ -178,6 +185,10 @@ which part of the strand to use as the address.
title: 'export DNA sequences',
type: DialogType.export_dna_sequences,
items: items,
disable_when_any_checkboxes_on: {
idx_include_only_selected_strands: [idx_exclude_selected_strands],
idx_exclude_selected_strands: [idx_include_only_selected_strands],
},
disable_when_any_checkboxes_off: {
idx_column_major_strand: [idx_sort],
idx_strand_order_str: [idx_sort],
Expand All @@ -199,6 +210,7 @@ which part of the strand to use as the address.

bool include_scaffold = (results[idx_include_scaffold] as DialogCheckbox).value;
bool include_only_selected_strands = (results[idx_include_only_selected_strands] as DialogCheckbox).value;
bool exclude_selected_strands = (results[idx_exclude_selected_strands] as DialogCheckbox).value;
String format_str = (results[idx_format_str] as DialogRadio).value;
bool sort = (results[idx_sort] as DialogCheckbox).value;
StrandOrder strand_order = null;
Expand All @@ -213,9 +225,12 @@ which part of the strand to use as the address.
String delimiter = (results[idx_delimiter] as DialogText).value;
String domain_delimiter = (results[idx_domain_delimiter] as DialogText).value;

assert(!(include_only_selected_strands && exclude_selected_strands));

app.dispatch(actions.ExportDNA(
include_scaffold: include_scaffold,
include_only_selected_strands: include_only_selected_strands,
exclude_selected_strands: exclude_selected_strands,
export_dna_format: format,
delimiter: delimiter,
domain_delimiter: domain_delimiter,
Expand Down

0 comments on commit 33a5630

Please sign in to comment.