diff --git a/Cargo.lock b/Cargo.lock index b43d49e..1515473 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2764,7 +2764,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plascad" -version = "0.7.6" +version = "0.7.7" dependencies = [ "bincode", "bio", diff --git a/Cargo.toml b/Cargo.toml index d005c61..96eec3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plascad" -version = "0.7.6" +version = "0.7.7" edition = "2021" authors = ["David O'Connor "] #description = "Tools for plasmid and primer design, PCR, and related." diff --git a/src/gui/ab1.rs b/src/gui/ab1.rs index 87cf683..75128a8 100644 --- a/src/gui/ab1.rs +++ b/src/gui/ab1.rs @@ -13,7 +13,12 @@ use na_seq::{seq_to_str_lower, Nucleotide}; use crate::{ ab1::SeqRecordAb1, + feature_db_load::find_features, + file_io::GenericData, gui::{BACKGROUND_COLOR, COL_SPACING, ROW_SPACING}, + misc_types::Metadata, + state::State, + util::merge_feature_sets, }; const NT_COLOR: Color32 = Color32::from_rgb(180, 220, 220); @@ -165,16 +170,59 @@ fn plot(data: &SeqRecordAb1, to_screen: &RectTransform, ui: &mut Ui) -> Vec p.file_name().unwrap().to_str().unwrap_or_default(), + None => "Plasmid from AB1", // This shouldn't happen, I believe. + }.to_owned().replace(".ab1", ""); + + let generic = GenericData { + seq: data.sequence.clone(), + metadata: Metadata { + plasmid_name, + ..Default::default() + }, + ..Default::default() + }; + + + state.generic.push(generic); + + state.portions.push(Default::default()); + state.volatile.push(Default::default()); + state.tabs_open.push(Default::default()); + state.ab1_data.push(Default::default()); + + state.active = state.generic.len() - 1; + + // state.sync_seq_related(None); + + // Annotate. Don't add duplicates. + let features = find_features(&state.get_seq()); + merge_feature_sets(&mut state.generic[state.active].features, &features) + + } }); ui.add_space(ROW_SPACING / 2.); @@ -183,6 +231,8 @@ pub fn ab1_page(data: &SeqRecordAb1, ui: &mut Ui) { Frame::canvas(ui.style()) .fill(BACKGROUND_COLOR) .show(ui, |ui| { + let data = &state.ab1_data[state.active]; + let (response, _painter) = { let desired_size = vec2(ui.available_width(), ui.available_height()); ui.allocate_painter(desired_size, Sense::click()) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 9dafc18..ea9fcd7 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -411,12 +411,7 @@ pub fn draw(state: &mut State, ctx: &Context) { metadata::metadata_page(&mut state.generic[state.active].metadata, ui) } Page::Portions => portions::portions_page(&mut state.portions[state.active], ui), - Page::Ab1 => { - if state.ab1_data.len() > 0 { - // todo: Fix index, and this hack in general. - ab1::ab1_page(&state.ab1_data[0], ui) - } - } + Page::Ab1 => ab1::ab1_page(state, ui), } }); } diff --git a/src/gui/save.rs b/src/gui/save.rs index 26ed538..68261b3 100644 --- a/src/gui/save.rs +++ b/src/gui/save.rs @@ -131,6 +131,7 @@ pub fn save_section(state: &mut State, ui: &mut Ui) { ab1: false, }; set_window_title(&state.tabs_open[state.active], ui); + state.save_prefs(); // Save opened tabs. } Err(e) => eprintln!("Error saving in PlasCAD format: {:?}", e), }; @@ -146,6 +147,7 @@ pub fn save_section(state: &mut State, ui: &mut Ui) { ab1: false, }; set_window_title(&state.tabs_open[state.active], ui); + state.save_prefs(); // Save opened tabs. } Err(e) => eprintln!("Error exporting to FASTA: {:?}", e), } @@ -164,6 +166,7 @@ pub fn save_section(state: &mut State, ui: &mut Ui) { ab1: false, }; set_window_title(&state.tabs_open[state.active], ui); + state.save_prefs(); // Save opened tabs. } Err(e) => eprintln!("Error exporting to GenBank: {:?}", e), } @@ -175,6 +178,7 @@ pub fn save_section(state: &mut State, ui: &mut Ui) { ab1: false, }; set_window_title(&state.tabs_open[state.active], ui); + state.save_prefs(); // Save opened tabs. } Err(e) => eprintln!("Error exporting to SnapGene: {:?}", e), };