diff --git a/src/lib.rs b/src/lib.rs index 3dfb584..fa781a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,6 @@ extern { fn alert(s: &str); } -//#[wasm_bindgen] pub fn transcription(dna: String) -> String { let char_vec: Vec = dna.chars().collect(); let mut transcribed_vec: Vec = Vec::new(); @@ -28,7 +27,6 @@ pub fn transcription(dna: String) -> String { 'C' => transcribed_vec.push('G'), 'G' => transcribed_vec.push('C'), _ => { - // println!("Incorrect char"); break; } } @@ -38,7 +36,6 @@ pub fn transcription(dna: String) -> String { return transcribed_string; } -//#[wasm_bindgen] pub fn find_start(messenger_rna: String) -> String { let start_codon = "AUG"; let start_index = messenger_rna.find(start_codon).unwrap(); @@ -46,7 +43,6 @@ pub fn find_start(messenger_rna: String) -> String { return inter_rna; } -//#[wasm_bindgen] pub fn break_into_codons(inter_rna: String) -> Vec { let sub_len = 3; let subs = inter_rna.as_bytes() @@ -63,7 +59,6 @@ pub fn break_into_codons(inter_rna: String) -> Vec { return string_vec; } -//#[wasm_bindgen] pub fn find_stop(inter_codons: &[String]) -> usize { let mut stop_index_1: usize = usize::MAX; let mut stop_index_2: usize = usize::MAX; @@ -84,7 +79,6 @@ pub fn find_stop(inter_codons: &[String]) -> usize { return stop_index; } -//#[wasm_bindgen] pub fn find_first(stop_index_1: usize, stop_index_2: usize, stop_index_3: usize) -> usize { let mut stop_index: usize = 1; @@ -114,7 +108,6 @@ pub fn find_first(stop_index_1: usize, stop_index_2: usize, stop_index_3: usize) return stop_index; } -//#[wasm_bindgen] pub fn translation(inter_codons: Vec) -> Vec { let mut amino_acids_list: Vec = Vec::new(); @@ -143,7 +136,6 @@ pub fn translation(inter_codons: Vec) -> Vec { "AAU" | "AAC" => amino_acids_list.push("Asparginine".to_string()), "AAA" | "AAG" => amino_acids_list.push("Lysine".to_string()), _ => { - // println!("Incorrect char"); break; } } @@ -156,7 +148,6 @@ pub fn translation(inter_codons: Vec) -> Vec { pub fn main(mut strand: String) { println!("Enter the DNA strand to be transcribed and translated: "); - //let mut strand: String = "TACATGCCATACGAGACGAGCGCGCCTAAGCGGCGCAGACTCATGGTCATT".to_string(); strand = strand.to_string().to_uppercase(); let messenger_rna = transcription(strand); diff --git a/www/app.html b/www/app.html index c3de0d4..7bfb954 100644 --- a/www/app.html +++ b/www/app.html @@ -7,6 +7,6 @@ -

Hello

+

DNA Transcription & Translation

diff --git a/www/app.js b/www/app.js index b41e838..14cba27 100644 --- a/www/app.js +++ b/www/app.js @@ -3,6 +3,9 @@ import * as wasm from "wasm-dna-transcription-translation"; const urlParams = new URLSearchParams(window.location.search); const strand = urlParams.get('strand'); -console.log(strand) - -wasm.main(strand); +try { + wasm.main(strand); +} catch(err) { + alert('Oh no! Something went wrong. Please check that your DNA strand only uses valid characters, and has a stop & start codon. You will now be redirected to the homepage.') + window.location.href = '/'; +} diff --git a/www/webpack.config.js b/www/webpack.config.js index 80ad814..fad305a 100644 --- a/www/webpack.config.js +++ b/www/webpack.config.js @@ -2,6 +2,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin"); const path = require('path'); module.exports = { + devtool: 'eval-source-map', entry: "./bootstrap.js", output: { path: path.resolve(__dirname, "dist"), @@ -10,5 +11,6 @@ module.exports = { mode: "development", plugins: [ new CopyWebpackPlugin(['index.html']) + new CopyWebpackPlugin(['app.html']) ], };