├── .gitignore ├── LICENSE ├── README.md └── docs ├── about.html ├── acknowledgments.html ├── browser_compat.html ├── codon_plot.html ├── codon_usage.html ├── color_align_cons.html ├── color_align_prop.html ├── combine_fasta.html ├── cpg_islands.html ├── dna_mw.html ├── dna_pattern.html ├── dna_stats.html ├── embl_fasta.html ├── embl_feat.html ├── embl_trans.html ├── filter_dna.html ├── filter_protein.html ├── fuzzy_search_dna.html ├── fuzzy_search_protein.html ├── genbank_fasta.html ├── genbank_feat.html ├── genbank_trans.html ├── genetic_code.html ├── gnu_license.html ├── group_dna.html ├── group_protein.html ├── ident_sim.html ├── index.html ├── iupac.html ├── mirror.html ├── multi_rev_trans.html ├── mutate_dna.html ├── mutate_for_digest.html ├── mutate_protein.html ├── one_to_three.html ├── orf_find.html ├── pairwise_align_codons.html ├── pairwise_align_dna.html ├── pairwise_align_protein.html ├── pcr_primer_stats.html ├── pcr_products.html ├── primer_map.html ├── protein_gravy.html ├── protein_iep.html ├── protein_mw.html ├── protein_pattern.html ├── protein_stats.html ├── random_coding_dna.html ├── random_dna.html ├── random_dna_regions.html ├── random_protein.html ├── random_protein_regions.html ├── range_extract_dna.html ├── range_extract_protein.html ├── reference.html ├── rest_digest.html ├── rest_map.html ├── rest_summary.html ├── rev_comp.html ├── rev_trans.html ├── sample_dna.html ├── sample_protein.html ├── scripts ├── align_pair_codons_linear.js ├── align_pair_codons_quad.js ├── align_pair_linear.js ├── align_pair_quad.js ├── codon_plot.js ├── codon_usage.js ├── color_align_cons.js ├── color_align_prop.js ├── combine_fasta.js ├── cpg_islands.js ├── dna_mw.js ├── dna_pattern.js ├── dna_stats.js ├── embl_fasta.js ├── embl_feat.js ├── embl_trans.js ├── filter_dna.js ├── filter_protein.js ├── fuzzy_search.js ├── fuzzy_search_dna.js ├── fuzzy_search_protein.js ├── genbank_fasta.js ├── genbank_feat.js ├── genbank_trans.js ├── group_dna.js ├── group_protein.js ├── ident_sim.js ├── multi_rev_trans.js ├── mutate_dna.js ├── mutate_for_digest.js ├── mutate_protein.js ├── one_to_three.js ├── orf_find.js ├── pairwise_align_codons.js ├── pairwise_align_dna.js ├── pairwise_align_protein.js ├── pcr_primer_stats.js ├── pcr_products.js ├── primer_map.js ├── protein_gravy.js ├── protein_iep.js ├── protein_mw.js ├── protein_pattern.js ├── protein_stats.js ├── random_coding_dna.js ├── random_dna.js ├── random_dna_regions.js ├── random_protein.js ├── random_protein_regions.js ├── range_extract_dna.js ├── range_extract_protein.js ├── rest_digest.js ├── rest_map.js ├── rest_summary.js ├── rev_comp.js ├── rev_trans.js ├── sample_dna.js ├── sample_protein.js ├── shuffle_dna.js ├── shuffle_protein.js ├── sms_common.js ├── sms_genetic_codes.js ├── sms_restriction_sites.js ├── split_codons.js ├── split_fasta.js ├── three_to_one.js ├── trans_map.js ├── translate.js ├── window_extract_dna.js └── window_extract_protein.js ├── search_patterns.html ├── shuffle_dna.html ├── shuffle_protein.html ├── split_codons.html ├── split_fasta.html ├── styles └── stylesheet.css ├── three_to_one.html ├── trans_map.html ├── translate.html ├── window_extract_dna.html └── window_extract_protein.html /.gitignore: -------------------------------------------------------------------------------- 1 | deploy 2 | deploy/ 3 | .DS_Store 4 | .vscode/* 5 | .history/ 6 | *.vsix 7 | *.code-workspace -------------------------------------------------------------------------------- /docs/scripts/align_pair_quad.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | //This class should be used for small alignments, 23 | //since it uses O(nm) memory, where n and m are the sequence lengths. 24 | //For larger alignments use the linear space algorithm implemented 25 | //in align_pair_linear.js 26 | 27 | //To use this class: (see pairwise_dna.js for example) 28 | //var alignment = new AlignPairQuad(); 29 | //alignment.initializeMatrix(sequenceArrayM, sequenceArrayN, scoreSet); 30 | //alignment.fillMatrix(); 31 | //alignment.align(); 32 | //var alignedSequenceStringM = alignment.getAlignedM(); 33 | //var alignedSequenceStringN = alignment.getAlignedN(); 34 | 35 | //------------------------------------ Node class 36 | //Node class 37 | function Node() { 38 | this.value; 39 | this.tracebackI; 40 | this.tracebackJ; 41 | } 42 | //------------------------------------ 43 | 44 | //------------------------------------ AlignPairQuad class 45 | //AlignPairQuad class initializeMatrix method 46 | function initializeMatrix(sequenceOne, sequenceTwo, scoreSet) { 47 | this.scoreSet = scoreSet; 48 | 49 | this.M = sequenceOne; 50 | this.N = sequenceTwo; 51 | this.score = 0; 52 | 53 | //create an two-dimensional array of nodes 54 | this.nodes = new Array(this.M.length + 1); 55 | 56 | //row i 57 | for (var i = 0; i < this.nodes.length; i++) { 58 | this.nodes[i] = new Array(this.N.length + 1); 59 | //column j 60 | for (var j = 0; j < this.nodes[i].length; j++) { 61 | this.nodes[i][j] = new Node(); 62 | } 63 | } 64 | 65 | this.nodes[0][0].value = 0; 66 | 67 | //i rows 68 | for (var i = 1; i < this.nodes.length; i++) { 69 | if (this.scoreSet.useBeginGapLeft) { 70 | this.nodes[i][0].value = 71 | this.nodes[i - 1][0].value - this.scoreSet.beginGap; 72 | } else { 73 | this.nodes[i][0].value = this.nodes[i - 1][0].value - this.scoreSet.gap; 74 | } 75 | this.nodes[i][0].tracebackI = i - 1; 76 | this.nodes[i][0].tracebackJ = 0; 77 | } 78 | 79 | //j columns 80 | for (var j = 1; j < this.nodes[0].length; j++) { 81 | if (this.scoreSet.useBeginGapTop) { 82 | this.nodes[0][j].value = 83 | this.nodes[0][j - 1].value - this.scoreSet.beginGap; 84 | } else { 85 | this.nodes[0][j].value = this.nodes[0][j - 1].value - this.scoreSet.gap; 86 | } 87 | this.nodes[0][j].tracebackI = 0; 88 | this.nodes[0][j].tracebackJ = j - 1; 89 | } 90 | } 91 | 92 | //AlignPairQuad class dumpMatrix method 93 | function dumpMatrix() { 94 | outputWindow.document.write( 95 | "Dynamic programming matrix i=" + 96 | this.nodes.length + 97 | " and j=" + 98 | this.nodes[0].length 99 | ); 100 | outputWindow.document.write("\n"); 101 | for (var i = 0; i < this.nodes.length; i++) { 102 | for (var j = 0; j < this.nodes[i].length; j++) { 103 | var traceI = this.nodes[i][j].tracebackI; 104 | var traceJ = this.nodes[i][j].tracebackJ; 105 | 106 | if (traceI == undefined) { 107 | traceI = "u"; 108 | } 109 | if (traceJ == undefined) { 110 | traceJ = "u"; 111 | } 112 | var output = 113 | "(" + 114 | i + 115 | "," + 116 | j + 117 | ")[" + 118 | traceI + 119 | "," + 120 | traceJ + 121 | "]=" + 122 | this.nodes[i][j].value; 123 | outputWindow.document.write(rightNum(output, "", 20, " ")); 124 | } 125 | outputWindow.document.write("\n"); 126 | } 127 | outputWindow.document.write("\n"); 128 | } 129 | 130 | //AlignPairQuad class fillMatrix method 131 | function fillMatrix() { 132 | //i rows 133 | for (var i = 1; i < this.nodes.length; i++) { 134 | //j columns 135 | for (var j = 1; j < this.nodes[0].length; j++) { 136 | var a; 137 | var b; 138 | var c; 139 | 140 | //handle end gaps here 141 | 142 | if (i == this.nodes.length - 1 && j == this.nodes[0].length - 1) { 143 | if (this.scoreSet.useEndGapRight) { 144 | a = this.nodes[i - 1][j].value - this.scoreSet.endGap; 145 | } else { 146 | a = this.nodes[i - 1][j].value - this.scoreSet.gap; 147 | } 148 | 149 | if (this.scoreSet.useEndGapBottom) { 150 | b = this.nodes[i][j - 1].value - this.scoreSet.endGap; 151 | } else { 152 | b = this.nodes[i][j - 1].value - this.scoreSet.gap; 153 | } 154 | } else if (i == this.nodes.length - 1) { 155 | a = this.nodes[i - 1][j].value - this.scoreSet.gap; 156 | if (this.scoreSet.useEndGapBottom) { 157 | b = this.nodes[i][j - 1].value - this.scoreSet.endGap; 158 | } else { 159 | b = this.nodes[i][j - 1].value - this.scoreSet.gap; 160 | } 161 | } else if (j == this.nodes[0].length - 1) { 162 | if (this.scoreSet.useEndGapRight) { 163 | a = this.nodes[i - 1][j].value - this.scoreSet.endGap; 164 | } else { 165 | a = this.nodes[i - 1][j].value - this.scoreSet.gap; 166 | } 167 | b = this.nodes[i][j - 1].value - this.scoreSet.gap; 168 | } else { 169 | a = this.nodes[i - 1][j].value - this.scoreSet.gap; 170 | b = this.nodes[i][j - 1].value - this.scoreSet.gap; 171 | } 172 | 173 | c = 174 | this.nodes[i - 1][j - 1].value + 175 | this.scoreSet.getScore(this.M[i - 1], this.N[j - 1]); 176 | 177 | if (a >= b && a >= c) { 178 | this.nodes[i][j].value = a; 179 | this.nodes[i][j].tracebackI = i - 1; 180 | this.nodes[i][j].tracebackJ = j; 181 | } else if (b >= c && b >= a) { 182 | this.nodes[i][j].value = b; 183 | this.nodes[i][j].tracebackI = i; 184 | this.nodes[i][j].tracebackJ = j - 1; 185 | } else { 186 | this.nodes[i][j].value = c; 187 | this.nodes[i][j].tracebackI = i - 1; 188 | this.nodes[i][j].tracebackJ = j - 1; 189 | } 190 | } 191 | } 192 | this.score = this.nodes[this.nodes.length - 1][ 193 | this.nodes[0].length - 1 194 | ].value; 195 | } 196 | 197 | //AlignPairQuad class align() method 198 | function align() { 199 | this.alignedM = new Array(); 200 | this.alignedN = new Array(); 201 | 202 | var currentI = this.nodes.length - 1; 203 | var currentJ = this.nodes[0].length - 1; 204 | 205 | var currentNode = this.nodes[this.nodes.length - 1][this.nodes[0].length - 1]; 206 | 207 | while ( 208 | currentNode.tracebackI != undefined && 209 | currentNode.tracebackJ != undefined 210 | ) { 211 | if ( 212 | currentNode.tracebackI == currentI - 1 && 213 | currentNode.tracebackJ == currentJ - 1 214 | ) { 215 | this.alignedM.push(this.M.pop()); 216 | this.alignedN.push(this.N.pop()); 217 | } else if (currentNode.tracebackJ == currentJ - 1) { 218 | this.alignedM.push("-"); 219 | this.alignedN.push(this.N.pop()); 220 | } else { 221 | this.alignedM.push(this.M.pop()); 222 | this.alignedN.push("-"); 223 | } 224 | 225 | currentI = currentNode.tracebackI; 226 | currentJ = currentNode.tracebackJ; 227 | 228 | currentNode = this.nodes[currentNode.tracebackI][currentNode.tracebackJ]; 229 | } 230 | 231 | this.alignedM = this.alignedM.reverse(); 232 | this.alignedN = this.alignedN.reverse(); 233 | } 234 | 235 | //AlignPairQuad class getAlignedM() method 236 | function getAlignedM() { 237 | return this.alignedM.join(""); 238 | } 239 | 240 | //AlignPairQuad class getAlignedN() method 241 | function getAlignedN() { 242 | return this.alignedN.join(""); 243 | } 244 | 245 | //AlignPairQuad class 246 | function AlignPairQuad() { 247 | this.M; 248 | this.N; 249 | this.scoreSet; 250 | this.nodes; 251 | this.alignedM; 252 | this.alignedN; 253 | this.score; 254 | } 255 | 256 | //create and throw away a prototype object 257 | new AlignPairQuad(); 258 | 259 | //define object methods 260 | AlignPairQuad.prototype.initializeMatrix = initializeMatrix; 261 | AlignPairQuad.prototype.fillMatrix = fillMatrix; 262 | AlignPairQuad.prototype.align = align; 263 | AlignPairQuad.prototype.getAlignedM = getAlignedM; 264 | AlignPairQuad.prototype.getAlignedN = getAlignedN; 265 | AlignPairQuad.prototype.dumpMatrix = dumpMatrix; 266 | -------------------------------------------------------------------------------- /docs/scripts/codon_plot.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function codonPlot(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 50000000; 25 | var codonTable; 26 | var title; 27 | 28 | if (testScript() == false) { 29 | return false; 30 | } 31 | 32 | if ( 33 | checkFormElement(theDocument.forms[0].elements[0]) == false || 34 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 35 | false || 36 | checkCodonTable(theDocument.forms[0].elements[4].value) == false 37 | ) { 38 | return false; 39 | } 40 | 41 | codonTable = makeCodonTable(theDocument.forms[0].elements[4].value); 42 | if (codonTable == false) { 43 | return false; 44 | } 45 | 46 | newDna = getSequenceFromFasta(theDocument.forms[0].elements[0].value); 47 | title = getTitleFromFasta(theDocument.forms[0].elements[0].value); 48 | verifyDna(newDna); 49 | newDna = removeNonDna(newDna); 50 | 51 | openWindow("Codon Plot"); 52 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 53 | openPre(); 54 | 55 | writeCodonPlot(codonTable, newDna); 56 | closePre(); 57 | closeWindow(); 58 | return true; 59 | } 60 | 61 | function writeCodonPlot(codonTable, sequence) { 62 | var markString = 63 | "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 64 | var codon; 65 | var perThou; 66 | var fraction; 67 | var yValue; 68 | var aminoAcid; 69 | 70 | //replace 'u' with 't' 71 | sequence = sequence.replace(/u/gi, "t"); 72 | sequence = sequence.replace(/(...)/g, function (str, p1, offset, s) { 73 | try { 74 | aminoAcid = codonTable[p1.toString().toLowerCase()].aminoAcid; 75 | yValue = codonTable[p1.toString().toLowerCase()].fraction; 76 | } catch (e) { 77 | aminoAcid = "???"; 78 | yValue = 0; 79 | } 80 | return ( 81 | "" + 82 | p1.toString().toLowerCase() + 83 | ", " + 84 | (offset + 1) + 85 | " to " + 86 | (offset + 3) + 87 | " (" + 88 | aminoAcid + 89 | ")\n" + 90 | markString.substring(0, Math.round(yValue * markString.length)) + 91 | " " + 92 | yValue.toFixed(2) + 93 | "\n\n" 94 | ); 95 | }); 96 | 97 | outputWindow.document.write(sequence + "\n"); 98 | 99 | return true; 100 | } 101 | 102 | function makeCodonTable(gcgTable) { 103 | gcgTable = gcgTable.replace(/[^\.]*\.\./, ""); 104 | var tableArray = gcgTable.split(/[\f\n\r]/); 105 | var re = /(\w+)\s+(\w+)\s+(\S+)\s+(\S+)\s+(\S+)/g; 106 | var matchArray; 107 | var codonTable = new CodonTable(); 108 | 109 | for (var i = 0; i < tableArray.length; i++) { 110 | while ((matchArray = re.exec(tableArray[i]))) { 111 | try { 112 | codonTable[matchArray[2].toLowerCase()].fillCodon( 113 | matchArray[1], 114 | parseFloat(matchArray[3]), 115 | parseFloat(matchArray[4]), 116 | parseFloat(matchArray[5]) 117 | ); 118 | codonTable.codons.push(matchArray[2].toLowerCase()); 119 | } catch (e) { 120 | alert( 121 | "There is a problem with a line of the codon table: " + 122 | matchArray[1] + 123 | " " + 124 | matchArray[2] + 125 | " " + 126 | matchArray[3] + 127 | " " + 128 | matchArray[4] + 129 | " " + 130 | matchArray[5] 131 | ); 132 | return false; 133 | } 134 | } 135 | } 136 | 137 | codonTable.fixFraction(); 138 | 139 | return codonTable; 140 | } 141 | 142 | //class CodonTable 143 | function CodonTable() { 144 | this.codons = new Array(); 145 | this.ggg = new Codon(); 146 | this.gga = new Codon(); 147 | this.ggt = new Codon(); 148 | this.ggc = new Codon(); 149 | this.gag = new Codon(); 150 | this.gaa = new Codon(); 151 | this.gat = new Codon(); 152 | this.gac = new Codon(); 153 | this.gtg = new Codon(); 154 | this.gta = new Codon(); 155 | this.gtt = new Codon(); 156 | this.gtc = new Codon(); 157 | this.gcg = new Codon(); 158 | this.gca = new Codon(); 159 | this.gct = new Codon(); 160 | this.gcc = new Codon(); 161 | this.agg = new Codon(); 162 | this.aga = new Codon(); 163 | this.agt = new Codon(); 164 | this.agc = new Codon(); 165 | this.aag = new Codon(); 166 | this.aaa = new Codon(); 167 | this.aat = new Codon(); 168 | this.aac = new Codon(); 169 | this.atg = new Codon(); 170 | this.ata = new Codon(); 171 | this.att = new Codon(); 172 | this.atc = new Codon(); 173 | this.acg = new Codon(); 174 | this.aca = new Codon(); 175 | this.act = new Codon(); 176 | this.acc = new Codon(); 177 | this.tgg = new Codon(); 178 | this.tga = new Codon(); 179 | this.tgt = new Codon(); 180 | this.tgc = new Codon(); 181 | this.tag = new Codon(); 182 | this.taa = new Codon(); 183 | this.tat = new Codon(); 184 | this.tac = new Codon(); 185 | this.ttg = new Codon(); 186 | this.tta = new Codon(); 187 | this.ttt = new Codon(); 188 | this.ttc = new Codon(); 189 | this.tcg = new Codon(); 190 | this.tca = new Codon(); 191 | this.tct = new Codon(); 192 | this.tcc = new Codon(); 193 | this.cgg = new Codon(); 194 | this.cga = new Codon(); 195 | this.cgt = new Codon(); 196 | this.cgc = new Codon(); 197 | this.cag = new Codon(); 198 | this.caa = new Codon(); 199 | this.cat = new Codon(); 200 | this.cac = new Codon(); 201 | this.ctg = new Codon(); 202 | this.cta = new Codon(); 203 | this.ctt = new Codon(); 204 | this.ctc = new Codon(); 205 | this.ccg = new Codon(); 206 | this.cca = new Codon(); 207 | this.cct = new Codon(); 208 | this.ccc = new Codon(); 209 | } 210 | 211 | //class CodonTable method fixFraction() 212 | //added to address bug in http://www.kazusa.or.jp/codon/ that causes fraction values to all be given as 0. 213 | function fixFraction() { 214 | for (var i = 0; i < this.codons.length; i++) { 215 | var outerCodon = this.codons[i]; 216 | var perThouTotal = 0; 217 | for (var j = 0; j < this.codons.length; j++) { 218 | var innerCodon = this.codons[j]; 219 | if (this[outerCodon].aminoAcid == this[innerCodon].aminoAcid) { 220 | perThouTotal = perThouTotal + this[innerCodon].perThou; 221 | } 222 | } 223 | this[outerCodon].fraction = this[outerCodon].perThou / perThouTotal; 224 | } 225 | return true; 226 | } 227 | 228 | //create and throw away a prototype object 229 | new CodonTable(); 230 | 231 | // define object methods 232 | CodonTable.prototype.fixFraction = fixFraction; 233 | 234 | //class Codon method fillCodon() 235 | function fillCodon(aminoAcid, number, perThou, fraction) { 236 | this.aminoAcid = aminoAcid; 237 | this.number = number; 238 | this.perThou = perThou; 239 | this.fraction = fraction; 240 | } 241 | 242 | //class Codon 243 | function Codon() { 244 | this.aminoAcid; 245 | this.number; 246 | this.perThou; 247 | this.fraction; 248 | } 249 | 250 | //create and throw away a prototype object 251 | new Codon(); 252 | 253 | // define object methods 254 | Codon.prototype.fillCodon = fillCodon; 255 | -------------------------------------------------------------------------------- /docs/scripts/color_align_cons.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function colorAlignCons(theDocument) { 23 | var maxInput = 200000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | var theAlignment = ""; 30 | var alignArray = new Array(); 31 | var groupString = ""; 32 | var arrayOfGroups = new Array(); 33 | 34 | var titleArray = new Array(); 35 | var sequenceArray = new Array(); 36 | 37 | var longestTitle; 38 | 39 | if ( 40 | checkFormElement(theDocument.forms[0].elements[0]) == false || 41 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 42 | ) { 43 | return false; 44 | } 45 | 46 | theAlignment = "X" + theDocument.forms[0].elements[0].value; 47 | alignArray = theAlignment.split(/[>%#]/); 48 | 49 | if (earlyCheckAlign(alignArray) == false) { 50 | return false; 51 | } 52 | 53 | for (var i = 1; i < alignArray.length; i++) { 54 | titleArray[i - 1] = alignArray[i].match(/[^\f\n\r]+[\f\n\r]/); 55 | titleArray[i - 1] = filterFastaTitle(titleArray[i - 1].toString()).replace( 56 | /[\f\n\r]/g, 57 | "" 58 | ); 59 | titleArray[i - 1] = titleArray[i - 1].substring(0, 20); 60 | if (i == 1) { 61 | longestTitle = titleArray[i - 1].length; 62 | } else if (titleArray[i - 1].length > longestTitle) { 63 | longestTitle = titleArray[i - 1].length; 64 | } 65 | sequenceArray[i - 1] = alignArray[i].replace(/[^\f\n\r]+[\f\n\r]/, ""); 66 | sequenceArray[i - 1] = filterAlignSeqAllowAsterisk(sequenceArray[i - 1]); 67 | } 68 | 69 | //make titles equal length 70 | var spaceString = " "; 71 | for (var i = 0; i < titleArray.length; i++) { 72 | if (titleArray[i].length < longestTitle) { 73 | //add spaces 74 | titleArray[i] = 75 | titleArray[i] + 76 | spaceString.substring(0, longestTitle - titleArray[i].length); 77 | } 78 | } 79 | 80 | if (checkAlign(titleArray, sequenceArray) == false) { 81 | return false; 82 | } 83 | 84 | groupString = theDocument.forms[0].elements[7].value 85 | .replace(/\s/g, "") 86 | .toUpperCase(); 87 | arrayOfGroups = groupString.split(/,/); 88 | if (checkGroupInput(arrayOfGroups) == false) { 89 | return false; 90 | } 91 | 92 | var isBackground; 93 | if ( 94 | theDocument.forms[0].elements[6].options[ 95 | theDocument.forms[0].elements[6].selectedIndex 96 | ].value == "background" 97 | ) { 98 | isBackground = true; 99 | } else { 100 | isBackground = false; 101 | } 102 | 103 | _openWindowAlign("Color Align Conservation", isBackground); 104 | openPre(); 105 | colorAlign( 106 | titleArray, 107 | sequenceArray, 108 | theDocument.forms[0].elements[4].options[ 109 | theDocument.forms[0].elements[4].selectedIndex 110 | ].value, 111 | theDocument.forms[0].elements[5].options[ 112 | theDocument.forms[0].elements[5].selectedIndex 113 | ].value, 114 | arrayOfGroups, 115 | theDocument.forms[0].elements[8].value, 116 | longestTitle 117 | ); 118 | closePre(); 119 | closeWindow(); 120 | return true; 121 | } 122 | 123 | function colorAlign( 124 | arrayOfTitles, 125 | arrayOfSequences, 126 | basePerLine, 127 | consensus, 128 | arrayOfGroups, 129 | definedStarts, 130 | longestTitle 131 | ) { 132 | var positions = new Array(arrayOfSequences.length); 133 | if (definedStarts.search(/\S/) == -1) { 134 | definedStarts = "0,0"; 135 | } 136 | var definedStartsArray = definedStarts.split(/,/); 137 | for (var i = 0; i < positions.length; i++) { 138 | if (i >= definedStartsArray.length) { 139 | positions[i] = 0; 140 | } else { 141 | if (definedStartsArray[i].search(/\d/) != -1) { 142 | positions[i] = parseInt(definedStartsArray[i].replace(/[^\d\-]/g, "")); 143 | } else { 144 | alert( 145 | "An incorrect starting position was encountered. It was set to 0." 146 | ); 147 | outputWindow.focus(); 148 | positions[i] = 0; 149 | } 150 | } 151 | } 152 | var totalBasesShown = 0; 153 | consensus = parseInt(consensus) / 100; 154 | basePerLine = parseInt(basePerLine); 155 | var columnCount = 0; 156 | var arrayOfColumns = new Array(basePerLine); 157 | for (var i = 0; i < arrayOfColumns.length; i++) { 158 | arrayOfColumns[i] = new Array(arrayOfSequences.length); 159 | } 160 | 161 | var i = 0; 162 | var columnSeq; 163 | var re; 164 | var result; 165 | var output = ""; 166 | 167 | while (totalBasesShown < arrayOfSequences[0].length) { 168 | for (var jj = 0; jj < arrayOfSequences.length; jj++) { 169 | output = output + arrayOfTitles[jj] + " "; 170 | while ( 171 | i < totalBasesShown + basePerLine && 172 | i < arrayOfSequences[0].length 173 | ) { 174 | if (jj == 0) { 175 | //fill the column 176 | for (var k = 0; k < arrayOfSequences.length; k++) { 177 | arrayOfColumns[columnCount][k] = arrayOfSequences[k].charAt(i); 178 | } 179 | } 180 | if ( 181 | arrayOfSequences[jj].charAt(i) == "." || 182 | arrayOfSequences[jj].charAt(i) == "-" || 183 | arrayOfSequences[jj].charAt(i) == "*" 184 | ) { 185 | output = 186 | output + 187 | '' + 188 | arrayOfSequences[jj].charAt(i) + 189 | ""; 190 | i = i + 1; 191 | columnCount++; 192 | continue; 193 | } 194 | 195 | columnSeq = arrayOfColumns[columnCount].join(","); 196 | re = new RegExp(arrayOfSequences[jj].charAt(i), "gi"); 197 | if (columnSeq.match(re).length / arrayOfSequences.length >= consensus) { 198 | output = 199 | output + 200 | '' + 201 | arrayOfSequences[jj].charAt(i) + 202 | ""; 203 | i = i + 1; 204 | columnCount++; 205 | continue; 206 | } 207 | 208 | result = 1; 209 | for (var m = 0; m < arrayOfGroups.length; m++) { 210 | if (arrayOfGroups[m].search(re) != -1) { 211 | var re = new RegExp("[" + arrayOfGroups[m] + "]", "gi"); 212 | result = columnSeq.match(re).length; 213 | break; 214 | } 215 | } 216 | 217 | if (result / arrayOfSequences.length >= consensus) { 218 | output = 219 | output + 220 | '' + 221 | arrayOfSequences[jj].charAt(i) + 222 | ""; 223 | i = i + 1; 224 | columnCount++; 225 | continue; 226 | } 227 | 228 | output = 229 | output + 230 | '' + 231 | arrayOfSequences[jj].charAt(i) + 232 | ""; 233 | i = i + 1; 234 | columnCount++; 235 | } 236 | positions[jj] = 237 | positions[jj] + 238 | arrayOfSequences[jj].substring(totalBasesShown, i).replace(/\.|\-/g, "") 239 | .length; 240 | output = output + " " + positions[jj] + "\n"; 241 | outputWindow.document.write(output); 242 | output = ""; 243 | i = totalBasesShown; 244 | columnCount = 0; 245 | } 246 | totalBasesShown = totalBasesShown + basePerLine; 247 | i = totalBasesShown; 248 | outputWindow.document.write("\n"); 249 | } 250 | return true; 251 | } 252 | -------------------------------------------------------------------------------- /docs/scripts/color_align_prop.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function colorAlignProp(theDocument) { 23 | var maxInput = 200000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | var theAlignment = ""; 30 | var alignArray = new Array(); 31 | var groupString = ""; 32 | var arrayOfGroups = new Array(); 33 | 34 | var titleArray = new Array(); 35 | var sequenceArray = new Array(); 36 | 37 | var longestTitle; 38 | 39 | if ( 40 | checkFormElement(theDocument.forms[0].elements[0]) == false || 41 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 42 | ) { 43 | return false; 44 | } 45 | 46 | theAlignment = "X" + theDocument.forms[0].elements[0].value; 47 | alignArray = theAlignment.split(/[>%#]/); 48 | 49 | if (earlyCheckAlign(alignArray) == false) { 50 | return false; 51 | } 52 | 53 | for (var i = 1; i < alignArray.length; i++) { 54 | titleArray[i - 1] = alignArray[i].match(/[^\f\n\r]+[\f\n\r]/); 55 | titleArray[i - 1] = filterFastaTitle(titleArray[i - 1].toString()).replace( 56 | /[\f\n\r]/g, 57 | "" 58 | ); 59 | titleArray[i - 1] = titleArray[i - 1].substring(0, 20); 60 | if (i == 1) { 61 | longestTitle = titleArray[i - 1].length; 62 | } else if (titleArray[i - 1].length > longestTitle) { 63 | longestTitle = titleArray[i - 1].length; 64 | } 65 | sequenceArray[i - 1] = alignArray[i].replace(/[^\f\n\r]+[\f\n\r]/, ""); 66 | sequenceArray[i - 1] = filterAlignSeqAllowAsterisk(sequenceArray[i - 1]); 67 | } 68 | 69 | //make titles equal length 70 | var spaceString = " "; 71 | for (var i = 0; i < titleArray.length; i++) { 72 | if (titleArray[i].length < longestTitle) { 73 | //add spaces 74 | titleArray[i] = 75 | titleArray[i] + 76 | spaceString.substring(0, longestTitle - titleArray[i].length); 77 | } 78 | } 79 | 80 | if (checkAlign(titleArray, sequenceArray) == false) { 81 | return false; 82 | } 83 | 84 | groupString = "GAVLI, FYW, CM, ST, KRH, DE, NQ, P" 85 | .replace(/\s/g, "") 86 | .toUpperCase(); 87 | arrayOfGroups = groupString.split(/,/); 88 | if (checkGroupInput(arrayOfGroups) == false) { 89 | return false; 90 | } 91 | 92 | var isBackground; 93 | if ( 94 | theDocument.forms[0].elements[6].options[ 95 | theDocument.forms[0].elements[6].selectedIndex 96 | ].value == "background" 97 | ) { 98 | isBackground = true; 99 | } else { 100 | isBackground = false; 101 | } 102 | 103 | _openWindowAlign("Color Align Properties", isBackground); 104 | 105 | openPre(); 106 | outputWindow.document.write( 107 | '' + "G, A, V, L, I" + "\n" 108 | ); 109 | outputWindow.document.write('' + "F, Y, W" + "\n"); 110 | outputWindow.document.write('' + "C, M" + "\n"); 111 | outputWindow.document.write('' + "S, T" + "\n"); 112 | outputWindow.document.write('' + "K, R, H" + "\n"); 113 | outputWindow.document.write('' + "D, E" + "\n"); 114 | outputWindow.document.write('' + "N, Q" + "\n"); 115 | outputWindow.document.write('' + "P" + "\n"); 116 | outputWindow.document.write("\n"); 117 | colorAlign( 118 | titleArray, 119 | sequenceArray, 120 | theDocument.forms[0].elements[4].options[ 121 | theDocument.forms[0].elements[4].selectedIndex 122 | ].value, 123 | theDocument.forms[0].elements[5].options[ 124 | theDocument.forms[0].elements[5].selectedIndex 125 | ].value, 126 | arrayOfGroups, 127 | theDocument.forms[0].elements[7].value, 128 | longestTitle 129 | ); 130 | closePre(); 131 | closeWindow(); 132 | return true; 133 | } 134 | 135 | function colorAlign( 136 | arrayOfTitles, 137 | arrayOfSequences, 138 | basePerLine, 139 | consensus, 140 | arrayOfGroups, 141 | definedStarts, 142 | longestTitle 143 | ) { 144 | var positions = new Array(arrayOfSequences.length); 145 | if (definedStarts.search(/\S/) == -1) { 146 | definedStarts = "0,0"; 147 | } 148 | var definedStartsArray = definedStarts.split(/,/); 149 | for (var i = 0; i < positions.length; i++) { 150 | if (i >= definedStartsArray.length) { 151 | positions[i] = 0; 152 | } else { 153 | if (definedStartsArray[i].search(/\d/) != -1) { 154 | positions[i] = parseInt(definedStartsArray[i].replace(/[^\d\-]/g, "")); 155 | } else { 156 | alert( 157 | "An incorrect starting position was encountered. It was set to 0." 158 | ); 159 | outputWindow.focus(); 160 | positions[i] = 0; 161 | } 162 | } 163 | } 164 | var totalBasesShown = 0; 165 | consensus = parseInt(consensus) / 100; 166 | basePerLine = parseInt(basePerLine); 167 | var columnCount = 0; 168 | var arrayOfColumns = new Array(basePerLine); 169 | for (var i = 0; i < arrayOfColumns.length; i++) { 170 | arrayOfColumns[i] = new Array(arrayOfSequences.length); 171 | } 172 | 173 | var i = 0; 174 | var columnSeq; 175 | var re; 176 | var result; 177 | var output = ""; 178 | 179 | while (totalBasesShown < arrayOfSequences[0].length) { 180 | for (var jj = 0; jj < arrayOfSequences.length; jj++) { 181 | output = output + arrayOfTitles[jj] + " "; 182 | while ( 183 | i < totalBasesShown + basePerLine && 184 | i < arrayOfSequences[0].length 185 | ) { 186 | if (jj == 0) { 187 | //fill the column 188 | for (var k = 0; k < arrayOfSequences.length; k++) { 189 | arrayOfColumns[columnCount][k] = arrayOfSequences[k].charAt(i); 190 | } 191 | } 192 | if ( 193 | arrayOfSequences[jj].charAt(i) == "." || 194 | arrayOfSequences[jj].charAt(i) == "-" || 195 | arrayOfSequences[jj].charAt(i) == "*" 196 | ) { 197 | output = output + arrayOfSequences[jj].charAt(i); 198 | i = i + 1; 199 | columnCount++; 200 | continue; 201 | } 202 | 203 | columnSeq = arrayOfColumns[columnCount].join(","); 204 | re = new RegExp(arrayOfSequences[jj].charAt(i), "gi"); 205 | if (columnSeq.match(re).length / arrayOfSequences.length >= consensus) { 206 | output = 207 | output + 208 | '' + 211 | arrayOfSequences[jj].charAt(i) + 212 | ""; 213 | i = i + 1; 214 | columnCount++; 215 | continue; 216 | } 217 | 218 | result = 1; 219 | for (var m = 0; m < arrayOfGroups.length; m++) { 220 | if (arrayOfGroups[m].search(re) != -1) { 221 | var re = new RegExp("[" + arrayOfGroups[m] + "]", "gi"); 222 | result = columnSeq.match(re).length; 223 | break; 224 | } 225 | } 226 | 227 | if (result / arrayOfSequences.length >= consensus) { 228 | output = 229 | output + 230 | '' + 233 | arrayOfSequences[jj].charAt(i) + 234 | ""; 235 | i = i + 1; 236 | columnCount++; 237 | continue; 238 | } 239 | 240 | output = output + arrayOfSequences[jj].charAt(i); 241 | i = i + 1; 242 | columnCount++; 243 | } 244 | positions[jj] = 245 | positions[jj] + 246 | arrayOfSequences[jj].substring(totalBasesShown, i).replace(/\.|\-/g, "") 247 | .length; 248 | output = output + " " + positions[jj] + "\n"; 249 | outputWindow.document.write(output); 250 | output = ""; 251 | i = totalBasesShown; 252 | columnCount = 0; 253 | } 254 | totalBasesShown = totalBasesShown + basePerLine; 255 | i = totalBasesShown; 256 | outputWindow.document.write("\n"); 257 | } 258 | return true; 259 | } 260 | -------------------------------------------------------------------------------- /docs/scripts/combine_fasta.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function combineFasta(theDocument) { 23 | var maxInput = 500000000; 24 | var sequenceCount = 0; 25 | var sequences = new Array(); 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 34 | ) { 35 | return false; 36 | } 37 | 38 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 39 | 40 | for (var i = 0; i < arrayOfFasta.length; i++) { 41 | sequences.push(removeNonLetters(getSequenceFromFasta(arrayOfFasta[i]))); 42 | } 43 | 44 | var sequence = sequences.join(""); 45 | openWindow("Combine FASTA"); 46 | openPre(); 47 | if (sequences.length == 1) { 48 | outputWindow.document.write( 49 | ">results for " + 50 | sequence.length + 51 | " residue sequence made from " + 52 | sequences.length + 53 | ' records, starting "' + 54 | sequence.substring(0, 10) + 55 | '"\n' 56 | ); 57 | } else if (sequences.length > 1) { 58 | outputWindow.document.write( 59 | ">results for " + 60 | sequence.length + 61 | " residue sequence made from " + 62 | sequences.length + 63 | ' records, starting "' + 64 | sequence.substring(0, 10) + 65 | '"\n' 66 | ); 67 | } else { 68 | outputWindow.document.write( 69 | '
No sequence records were read
\n' 70 | ); 71 | } 72 | outputWindow.document.write(addReturns(sequence) + "\n"); 73 | closePre(); 74 | closeWindow(); 75 | return true; 76 | } 77 | -------------------------------------------------------------------------------- /docs/scripts/cpg_islands.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function cpgIslands(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 100000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | openWindow("CpG Islands"); 40 | openPre(); 41 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 42 | 43 | for (var i = 0; i < arrayOfFasta.length; i++) { 44 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 45 | title = getTitleFromFasta(arrayOfFasta[i]); 46 | newDna = removeNonDna(newDna); 47 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 48 | cpgIslandRegions(newDna, 200, 0.6); 49 | } 50 | 51 | closePre(); 52 | closeWindow(); 53 | return true; 54 | } 55 | 56 | function cpgIslandRegions(dnaSequence, windowSize, cutOff) { 57 | var islandFound = false; 58 | var numG = 0; 59 | var numC = 0; 60 | var numCG = 0; 61 | var valueY = 0; 62 | var gcContent = 0; 63 | dnaSequence = dnaSequence.toLowerCase(); 64 | windowSize = parseInt(windowSize); 65 | cutOff = parseFloat(cutOff); 66 | 67 | if (windowSize > dnaSequence.length) { 68 | outputWindow.document.write( 69 | "The input sequence must be longer than " + windowSize + " bases.
\n" 70 | ); 71 | return true; 72 | } 73 | 74 | //determine base counts for first window 75 | for (var i = 0; i < windowSize; i++) { 76 | if (dnaSequence.charAt(i) == "g") { 77 | numG = numG + 1; 78 | } 79 | if (dnaSequence.charAt(i) == "c") { 80 | numC = numC + 1; 81 | if (dnaSequence.charAt(i + 1) == "g") { 82 | numCG = numCG + 1; 83 | numG = numG + 1; 84 | i = i + 1; 85 | } 86 | } 87 | } 88 | if (numC != 0 && numG != 0) { 89 | valueY = numCG / ((numC * numG) / windowSize); 90 | } else { 91 | valueY = 0; 92 | } 93 | gcContent = (numG + numC) / windowSize; 94 | if (valueY >= cutOff && gcContent > 0.5) { 95 | //valueY = Math.round(valueY*100)/100; 96 | //gcContent = Math.round(gcContent*1000)/10; 97 | gcContent = gcContent * 100; 98 | valueY = valueY.toFixed(2); 99 | gcContent = gcContent.toFixed(2); 100 | outputWindow.document.write( 101 | "CpG island detected in region 1 to " + 102 | windowSize + 103 | " (Obs/Exp = " + 104 | valueY + 105 | " and %GC = " + 106 | gcContent + 107 | ")
\n" 108 | ); 109 | islandFound = true; 110 | } 111 | 112 | //now update values as window slides along at 1 base intervals 113 | start = windowSize; 114 | for (var j = start; j < dnaSequence.length; j++) { 115 | baseToAdd = dnaSequence.charAt(j); 116 | baseToLose = dnaSequence.charAt(j - windowSize); 117 | recentBaseAdded = dnaSequence.charAt(j - 1); 118 | nextToLose = dnaSequence.charAt(j - windowSize + 1); 119 | if (baseToAdd == "c") { 120 | numC = numC + 1; 121 | } 122 | if (baseToAdd == "g") { 123 | numG = numG + 1; 124 | if (recentBaseAdded == "c") { 125 | numCG = numCG + 1; 126 | } 127 | } 128 | if (baseToLose == "c") { 129 | numC = numC - 1; 130 | if (nextToLose == "g") { 131 | numCG = numCG - 1; 132 | } 133 | } 134 | if (baseToLose == "g") { 135 | numG = numG - 1; 136 | } 137 | if (numC != 0 && numG != 0) { 138 | valueY = numCG / ((numC * numG) / windowSize); 139 | } else { 140 | valueY = 0; 141 | } 142 | gcContent = (numG + numC) / windowSize; 143 | if (valueY > cutOff && gcContent > 0.5) { 144 | startRange = (j - windowSize + 2).toString(); 145 | endRange = (j + 1).toString(); 146 | //valueY = Math.round(valueY*100)/100; 147 | //gcContent = Math.round(gcContent*1000)/10; 148 | gcContent = gcContent * 100; 149 | valueY = valueY.toFixed(2); 150 | gcContent = gcContent.toFixed(2); 151 | outputWindow.document.write( 152 | "CpG island detected in region " + 153 | startRange + 154 | " to " + 155 | endRange + 156 | " (Obs/Exp = " + 157 | valueY + 158 | " and %GC = " + 159 | gcContent + 160 | ")
\n" 161 | ); 162 | islandFound = true; 163 | } 164 | } 165 | if (!islandFound) { 166 | outputWindow.document.write( 167 | "No CpG island regions were identified.
\n" 168 | ); 169 | } 170 | return true; 171 | } 172 | -------------------------------------------------------------------------------- /docs/scripts/dna_mw.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function dnaMw(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 200000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 33 | false 34 | ) { 35 | return false; 36 | } 37 | 38 | openWindow("DNA Molecular Weight"); 39 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 40 | 41 | for (var i = 0; i < arrayOfFasta.length; i++) { 42 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 43 | title = getTitleFromFasta(arrayOfFasta[i]); 44 | newDna = _removeNonPrimer(newDna); 45 | 46 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 47 | 48 | writeDnaMw( 49 | newDna, 50 | theDocument.forms[0].elements[4].options[ 51 | theDocument.forms[0].elements[4].selectedIndex 52 | ].value, 53 | theDocument.forms[0].elements[5].options[ 54 | theDocument.forms[0].elements[5].selectedIndex 55 | ].value 56 | ); 57 | 58 | outputWindow.document.write("
\n
\n"); 59 | } 60 | closeWindow(); 61 | return true; 62 | } 63 | 64 | function writeDnaMw(sequence, strandType, topology) { 65 | //calculates molecular weight of DNA. 66 | //ligation removes OH 67 | var OH = 17.01; 68 | var result = 0; 69 | 70 | if (strandType == "single") { 71 | var mw_direct_strand = _molecularWeight(sequence); 72 | if (mw_direct_strand.length == 1) { 73 | var mw = parseFloat(mw_direct_strand[0]); 74 | if (topology == "circular") { 75 | mw = mw - OH; 76 | } 77 | mw = mw.toFixed(2); 78 | outputWindow.document.write(mw + " Da"); 79 | } else if (mw_direct_strand.length == 2) { 80 | var mw_lower = parseFloat(mw_direct_strand[0]); 81 | var mw_upper = parseFloat(mw_direct_strand[1]); 82 | if (topology == "circular") { 83 | mw_lower = mw_lower - OH; 84 | mw_upper = mw_upper - OH; 85 | } 86 | mw_lower = mw_lower.toFixed(2); 87 | mw_upper = mw_upper.toFixed(2); 88 | outputWindow.document.write(mw_lower + " to " + mw_upper + " Da"); 89 | } 90 | } else if (strandType == "double") { 91 | var mw_direct_strand = _molecularWeight(sequence); 92 | var mw_reverse_strand = _molecularWeight(reverse(complement(sequence))); 93 | if (mw_direct_strand.length == 1 && mw_reverse_strand.length == 1) { 94 | var mw_direct = parseFloat(mw_direct_strand[0]); 95 | var mw_reverse = parseFloat(mw_reverse_strand[0]); 96 | if (topology == "circular") { 97 | mw_direct = mw_direct - OH; 98 | mw_reverse = mw_reverse - OH; 99 | } 100 | var mw = mw_direct + mw_reverse; 101 | mw = mw.toFixed(2); 102 | outputWindow.document.write(mw + " Da"); 103 | } else if (mw_direct_strand.length == 2 && mw_reverse_strand.length == 2) { 104 | var mw_direct_lower = parseFloat(mw_direct_strand[0]); 105 | var mw_reverse_lower = parseFloat(mw_reverse_strand[0]); 106 | var mw_direct_upper = parseFloat(mw_direct_strand[1]); 107 | var mw_reverse_upper = parseFloat(mw_reverse_strand[1]); 108 | if (topology == "circular") { 109 | mw_direct_lower = mw_direct_lower - OH; 110 | mw_reverse_lower = mw_reverse_lower - OH; 111 | 112 | mw_direct_upper = mw_direct_upper - OH; 113 | mw_reverse_upper = mw_reverse_upper - OH; 114 | } 115 | var mw_lower = mw_direct_lower + mw_reverse_lower; 116 | var mw_upper = mw_direct_upper + mw_reverse_upper; 117 | mw_lower = mw_lower.toFixed(2); 118 | mw_upper = mw_upper.toFixed(2); 119 | outputWindow.document.write(mw_lower + " to " + mw_upper + " Da"); 120 | } 121 | } 122 | 123 | return true; 124 | } 125 | 126 | function _containsOnlyNonDegenerates(sequence) { 127 | if (sequence.search(/[^gatc]/i) == -1) { 128 | return true; 129 | } 130 | return false; 131 | } 132 | 133 | function _molecularWeight(sequence) { 134 | if (_containsOnlyNonDegenerates(sequence)) { 135 | return _molecularWeightNonDegen(sequence); 136 | } else { 137 | return _molecularWeightDegen(sequence); 138 | } 139 | } 140 | 141 | function _molecularWeightNonDegen(sequence) { 142 | var results = new Array(); 143 | results[0] = _mw(sequence); 144 | return results; 145 | } 146 | 147 | function _mw(sequence) { 148 | //DNA molecular weight for linear strand of DNA with a 5' monophosphate 149 | var g = _getBaseCount(sequence, "g"); 150 | var a = _getBaseCount(sequence, "a"); 151 | var t = _getBaseCount(sequence, "t"); 152 | var c = _getBaseCount(sequence, "c"); 153 | return g * 329.21 + a * 313.21 + t * 304.2 + c * 289.18 + 17.01; 154 | } 155 | 156 | function _molecularWeightDegen(sequence) { 157 | var lowerBoundsSequence = sequence; 158 | var upperBoundsSequence = sequence; 159 | 160 | //replace all other degenerates with lightest base possible in lowerBoundsSequence 161 | lowerBoundsSequence = lowerBoundsSequence.replace(/r/gi, "a"); 162 | lowerBoundsSequence = lowerBoundsSequence.replace(/y/gi, "c"); 163 | lowerBoundsSequence = lowerBoundsSequence.replace(/s/gi, "c"); 164 | lowerBoundsSequence = lowerBoundsSequence.replace(/w/gi, "t"); 165 | lowerBoundsSequence = lowerBoundsSequence.replace(/k/gi, "t"); 166 | lowerBoundsSequence = lowerBoundsSequence.replace(/m/gi, "c"); 167 | lowerBoundsSequence = lowerBoundsSequence.replace(/b/gi, "c"); 168 | lowerBoundsSequence = lowerBoundsSequence.replace(/d/gi, "t"); 169 | lowerBoundsSequence = lowerBoundsSequence.replace(/h/gi, "c"); 170 | lowerBoundsSequence = lowerBoundsSequence.replace(/v/gi, "c"); 171 | lowerBoundsSequence = lowerBoundsSequence.replace(/n/gi, "c"); 172 | 173 | //replace all other degenerates with heaviest base possible in upperBoundsSequence 174 | upperBoundsSequence = upperBoundsSequence.replace(/r/gi, "g"); 175 | upperBoundsSequence = upperBoundsSequence.replace(/y/gi, "t"); 176 | upperBoundsSequence = upperBoundsSequence.replace(/s/gi, "g"); 177 | upperBoundsSequence = upperBoundsSequence.replace(/w/gi, "a"); 178 | upperBoundsSequence = upperBoundsSequence.replace(/k/gi, "g"); 179 | upperBoundsSequence = upperBoundsSequence.replace(/m/gi, "a"); 180 | upperBoundsSequence = upperBoundsSequence.replace(/b/gi, "g"); 181 | upperBoundsSequence = upperBoundsSequence.replace(/d/gi, "g"); 182 | upperBoundsSequence = upperBoundsSequence.replace(/h/gi, "a"); 183 | upperBoundsSequence = upperBoundsSequence.replace(/v/gi, "g"); 184 | upperBoundsSequence = upperBoundsSequence.replace(/n/gi, "g"); 185 | 186 | var results = new Array(); 187 | results[0] = _molecularWeightNonDegen(lowerBoundsSequence); 188 | results[1] = _molecularWeightNonDegen(upperBoundsSequence); 189 | return results; 190 | } 191 | 192 | function _getBaseCount(sequence, base) { 193 | var basePattern = new RegExp(base, "gi"); 194 | if (sequence.search(basePattern) != -1) { 195 | return sequence.match(basePattern).length; 196 | } else { 197 | return 0; 198 | } 199 | } 200 | 201 | function _removeNonPrimer(sequence) { 202 | sequence.replace(/u/g, "t"); 203 | sequence.replace(/U/g, "T"); 204 | return sequence.replace(/[^gatcryswkmbdhvnGATCRYSWKMBDHVN]/g, ""); 205 | } 206 | -------------------------------------------------------------------------------- /docs/scripts/dna_pattern.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function dnaPattern(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 500000000; 25 | var matches = new Array(); 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false || 35 | checkFormElement(theDocument.forms[0].elements[1]) == false 36 | ) { 37 | return false; 38 | } 39 | 40 | var re = 41 | "/" + theDocument.forms[0].elements[1].value.replace(/\//g, "") + "/gi"; 42 | re = removeWhiteSpace(re); 43 | try { 44 | re = eval(re); 45 | var testString = "teststring"; 46 | testString = testString.replace(re, ""); 47 | } catch (e) { 48 | alert("The regular expression is not formatted correctly."); 49 | return false; 50 | } 51 | 52 | openWindow("DNA Pattern Find"); 53 | openPre(); 54 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 55 | 56 | for (var i = 0; i < arrayOfFasta.length; i++) { 57 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 58 | title = getTitleFromFasta(arrayOfFasta[i]); 59 | newDna = removeNonDna(newDna); 60 | 61 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 62 | 63 | writeDnaPattern(newDna, re); 64 | 65 | outputWindow.document.write("\n\n"); 66 | } 67 | 68 | closePre(); 69 | closeWindow(); 70 | return true; 71 | } 72 | 73 | function writeDnaPattern(dnaSequence, re) { 74 | var matchArray; 75 | var matchCount = 0; 76 | var length = dnaSequence.length; 77 | var simplePattern = re.toString(); 78 | simplePattern = simplePattern.replace(/\/gi$|\/ig$|^\//gi, ""); 79 | 80 | while ((matchArray = re.exec(dnaSequence))) { 81 | matchCount++; 82 | var match_end = re.lastIndex; 83 | var match_start = match_end - RegExp.lastMatch.length + 1; 84 | 85 | outputWindow.document.write( 86 | ">match number " + 87 | matchCount + 88 | ' to "' + 89 | simplePattern + 90 | '" start=' + 91 | match_start + 92 | " end=" + 93 | match_end + 94 | " on the direct strand\n" + 95 | addReturns(matchArray[0]) + 96 | "\n\n" 97 | ); 98 | 99 | re.lastIndex = re.lastIndex - RegExp.lastMatch.length + 1; 100 | } 101 | 102 | //reset search to start of sequence 103 | re.lastIndex = 0; 104 | //now search the reverse-complement 105 | dnaSequence = reverse(complement(dnaSequence)); 106 | while ((matchArray = re.exec(dnaSequence))) { 107 | matchCount++; 108 | var match_start = length - re.lastIndex + 1; 109 | var match_end = match_start + RegExp.lastMatch.length - 1; 110 | 111 | outputWindow.document.write( 112 | ">match number " + 113 | matchCount + 114 | ' to "' + 115 | simplePattern + 116 | '" start=' + 117 | match_start + 118 | " end=" + 119 | match_end + 120 | " on the reverse strand\n" + 121 | addReturns(matchArray[0]) + 122 | "\n\n" 123 | ); 124 | re.lastIndex = re.lastIndex - RegExp.lastMatch.length + 1; 125 | } 126 | 127 | if (!(matchCount > 0)) { 128 | outputWindow.document.write("no matches found for this sequence.\n\n"); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /docs/scripts/dna_stats.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function dnaStats(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 500000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | var itemsToCheck = [ 40 | "/g/ (g)1", 41 | "/a/ (a)1", 42 | "/t/ (t)1", 43 | "/c/ (c)1", 44 | "/n/ (n)1", 45 | "/u/ (u)1", 46 | "/r/ (r)1", 47 | "/y/ (y)1", 48 | "/s/ (s)1", 49 | "/w/ (w)1", 50 | "/k/ (k)1", 51 | "/m/ (m)1", 52 | "/b/ (b)1", 53 | "/d/ (d)1", 54 | "/h/ (h)1", 55 | "/v/ (v)1", 56 | "/g(?=g)/ (gg)2", 57 | "/g(?=a)/ (ga)2", 58 | "/g(?=t)/ (gt)2", 59 | "/g(?=c)/ (gc)2", 60 | "/g(?=n)/ (gn)2", 61 | "/a(?=g)/ (ag)2", 62 | "/a(?=a)/ (aa)2", 63 | "/a(?=t)/ (at)2", 64 | "/a(?=c)/ (ac)2", 65 | "/a(?=n)/ (an)2", 66 | "/t(?=g)/ (tg)2", 67 | "/t(?=a)/ (ta)2", 68 | "/t(?=t)/ (tt)2", 69 | "/t(?=c)/ (tc)2", 70 | "/t(?=n)/ (tn)2", 71 | "/c(?=g)/ (cg)2", 72 | "/c(?=a)/ (ca)2", 73 | "/c(?=t)/ (ct)2", 74 | "/c(?=c)/ (cc)2", 75 | "/c(?=n)/ (cn)2", 76 | "/n(?=g)/ (ng)2", 77 | "/n(?=a)/ (na)2", 78 | "/n(?=t)/ (nt)2", 79 | "/n(?=c)/ (nc)2", 80 | "/n(?=n)/ (nn)2", 81 | "/g|c/ (g,c)1", 82 | "/a|t/ (a,t)1", 83 | "/r|y|s|w|k/ (r,y,s,w,k)1", 84 | "/b|h|d|v|n/ (b,h,d,v,n)1", 85 | "/r|y|s|w|k|m|b|d|h|v|n/ (r,y,s,w,k,m,b,d,h,v,n)1", 86 | ]; 87 | 88 | openWindow("DNA Stats"); 89 | 90 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 91 | 92 | for (var i = 0; i < arrayOfFasta.length; i++) { 93 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 94 | title = getTitleFromFasta(arrayOfFasta[i]); 95 | 96 | newDna = removeNonDna(newDna); 97 | 98 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 99 | 100 | writeSequenceStats(newDna, itemsToCheck); 101 | 102 | outputWindow.document.write("
\n
\n"); 103 | } 104 | 105 | closeWindow(); 106 | return true; 107 | } 108 | -------------------------------------------------------------------------------- /docs/scripts/embl_fasta.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function emblFasta(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 200000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | verifyEmbl(theDocument.forms[0].elements[0].value) == false || 33 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 34 | ) { 35 | return false; 36 | } 37 | 38 | openWindow("EMBL to FASTA"); 39 | openPre(); 40 | emblToFasta(theDocument.forms[0].elements[0].value); 41 | closePre(); 42 | closeWindow(); 43 | return true; 44 | } 45 | 46 | function emblToFasta(emblFile) { 47 | var title; 48 | emblFile = "_" + emblFile + "_"; 49 | var recordArray = emblFile.split(/ID\s\s\s[^\f\n\r]*/); 50 | for (var i = 1; i < recordArray.length; i++) { 51 | var mainArray = recordArray[i].split( 52 | /[\f\n\r]\s*FH Key Location\/Qualifiers[\f\n\r]+\s*FH|[\f\n\r]\s*XX[\s]*[\f\n\r]\s*SQ[^\f\n\r]*/ 53 | ); 54 | if (mainArray[0].search(/[\f\n\r]\s*DE[^\f\n\r]+/) != -1) { 55 | title = mainArray[0] 56 | .match(/[\f\n\r]\s*DE[^\f\n\r]+/) 57 | .toString() 58 | .replace(/[\f\n\r]\s*DE\s*/, ""); 59 | } else { 60 | title = "Untitled"; 61 | } 62 | title = filterFastaTitle(title.replace(/[\f\n\r\t]+$/g, "")) + "\n"; 63 | dnaArray = mainArray[2].split(/\/{2}/); 64 | if (dnaArray.length == 1) { 65 | alert("The entire EMBL file may not have been processed."); 66 | outputWindow.focus(); 67 | } 68 | dnaSequence = removeNonDna(dnaArray[0]); 69 | outputWindow.document.write( 70 | ">" + title + addReturns(dnaSequence) + "\n\n" 71 | ); 72 | } 73 | return true; 74 | } 75 | -------------------------------------------------------------------------------- /docs/scripts/embl_feat.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function emblFeat(theDocument) { 23 | var maxInput = 200000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | if ( 30 | checkFormElement(theDocument.forms[0].elements[0]) == false || 31 | verifyEmblFeat(theDocument.forms[0].elements[0].value) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | openWindow("EMBL Feature Extractor"); 38 | openPre(); 39 | emblFeatExtract( 40 | theDocument.forms[0].elements[0].value, 41 | theDocument.forms[0].elements[4].options[ 42 | theDocument.forms[0].elements[4].selectedIndex 43 | ].value 44 | ); 45 | closePre(); 46 | closeWindow(); 47 | return true; 48 | } 49 | 50 | function emblFeatExtract(emblFile, outputType) { 51 | var title; 52 | emblFile = "_" + emblFile + "_"; 53 | var recordArray = emblFile.split(/ID\s\s\s[^\f\n\r]*/); 54 | for (var i = 1; i < recordArray.length; i++) { 55 | var mainArray = recordArray[i].split( 56 | /[\f\n\r]\s*FH Key Location\/Qualifiers[\f\n\r]+\s*FH|[\f\n\r]\s*XX[\s]*[\f\n\r]\s*SQ[^\f\n\r]*/ 57 | ); 58 | if (mainArray[0].search(/[\f\n\r]\s*DE[^\f\n\r]+/) != -1) { 59 | title = mainArray[0] 60 | .match(/[\f\n\r]\s*DE[^\f\n\r]+/) 61 | .toString() 62 | .replace(/[\f\n\r]\s*DE\s*/, ""); 63 | } else { 64 | title = "Untitled"; 65 | } 66 | title = filterFastaTitle(title.replace(/[\f\n\r\t]+$/g, "")) + "\n"; 67 | var dnaSequenceArray = mainArray[2].split(/\/{2}/); 68 | outputWindow.document.write(title + "\n"); 69 | if (dnaSequenceArray.length == 1) { 70 | alert("The entire EMBL file may not have been processed."); 71 | outputWindow.focus(); 72 | } 73 | var dnaSequence = removeNonDna(dnaSequenceArray[0]); 74 | var featureArray = mainArray[1].split(/[\f\n\r]FT {3,12}\b/); 75 | prepareFeatures(featureArray, dnaSequence, outputType); 76 | } 77 | return true; 78 | } 79 | 80 | function prepareFeatures(arrayOfFeatures, dnaSequence, outputType) { 81 | var featureTitle = ""; 82 | var theTitle = ""; 83 | var removedTitle = ""; 84 | var firstQualifier = ""; 85 | var position = ""; 86 | var positionNoSpace = ""; 87 | var featureFound = false; 88 | for (var i = 1; i < arrayOfFeatures.length; i++) { 89 | arrayOfFeatures[i] = arrayOfFeatures[i].replace(/[\[\]\*]/g, ""); 90 | featureTitle = arrayOfFeatures[i].match(/[^ \f\n\r\t\v]+ /).toString(); 91 | theTitle = new RegExp(featureTitle); 92 | removedTitle = arrayOfFeatures[i].replace(theTitle, ""); 93 | if (arrayOfFeatures[i].search(/\/[^\f\n\r]+/) != -1) { 94 | firstQualifier = arrayOfFeatures[i].match(/\/[^\f\n\r]+/).toString(); 95 | } else { 96 | firstQualifier = "/no qualifier supplied"; 97 | } 98 | position = removedTitle.split(/\//); 99 | positionNoSpace = position[0].replace(/\s{2,}/g, " "); 100 | outputWindow.document.write( 101 | ">" + 102 | filterFastaTitle(featureTitle) + 103 | filterFastaTitle(firstQualifier) + 104 | "\n" 105 | ); 106 | printFeature(positionNoSpace, dnaSequence, outputType); 107 | featureFound = true; 108 | outputWindow.document.write("\n\n"); 109 | } 110 | if (featureFound == false) { 111 | outputWindow.document.write( 112 | "There were no features found or there was a problem reading the feature information." 113 | ); 114 | } 115 | return true; 116 | } 117 | 118 | function printFeature(featurePos, dnaSequence, outputType) { 119 | var feature; 120 | featurePos = featurePos.replace(/<|>/g, ""); 121 | featurePos = featurePos.replace(/FT/gi, ""); 122 | if ( 123 | featurePos.search(/[^a-z\d\.\(\)\,\s]/) != -1 || 124 | featurePos.search(/one/) != -1 || 125 | featurePos.search(/order/) != -1 126 | ) { 127 | outputWindow.document.write( 128 | "This feature specifies a sequence that cannot be represented:\n" 129 | ); 130 | outputWindow.document.write(featurePos); 131 | } else { 132 | var newFeaturePos = featurePos.replace(/\)/g, ""); 133 | if (newFeaturePos.search(/complement/) != -1) { 134 | feature = new Feature("complement"); 135 | } else { 136 | feature = new Feature("direct"); 137 | } 138 | 139 | var pairString = newFeaturePos; 140 | var pairArray = pairString.split(/\,/); 141 | 142 | if (newFeaturePos.search(/complement/) != -1) { 143 | pairArray.reverse(); 144 | } 145 | 146 | var digitArray = new Array(); 147 | var realStart = 0; 148 | var realStop = 0; 149 | var dnaToAdd = ""; 150 | 151 | for (var j = 0; j < pairArray.length; j++) { 152 | digitArray = pairArray[j].split(/\.\./); 153 | if (digitArray.length == 1) { 154 | digitArray[1] = digitArray[0]; 155 | } 156 | realStart = digitArray[0]; 157 | realStop = digitArray[1]; 158 | realStop = realStop.replace(/\D/g, ""); 159 | realStart = realStart.replace(/\D/g, ""); 160 | if (realStart.search(/\d/) == -1 || realStop.search(/\d/) == -1) { 161 | outputWindow.document.write( 162 | "There was a problem with this feature (one of the range values was missing)." 163 | ); 164 | return true; 165 | } 166 | realStart = parseInt(realStart) - 1; 167 | realStop = parseInt(realStop); 168 | if (realStart > realStop) { 169 | outputWindow.document.write( 170 | "There was a problem with this feature (the end position was before the start position)." 171 | ); 172 | return true; 173 | } 174 | if (realStart > dnaSequence.length || realStop > dnaSequence.length) { 175 | outputWindow.document.write( 176 | "The entire EMBL file was not processed, so this feature cannot be properly shown." 177 | ); //to handle case where web browser limits the number of characters that can be entered as input. 178 | return true; 179 | } else { 180 | if (outputType == "separated") { 181 | feature.addFragment(dnaSequence.substring(realStart, realStop)); 182 | } else { 183 | feature.addFragment( 184 | dnaSequence.substring(feature.lastAdded, realStart) 185 | ); 186 | feature.addFragment( 187 | dnaSequence.substring(realStart, realStop).toUpperCase() 188 | ); 189 | feature.lastAdded = realStop; 190 | } 191 | } 192 | } 193 | feature.writeFeature(); 194 | } 195 | return true; 196 | } 197 | 198 | //class Feature method writeFeature() 199 | function writeFeature() { 200 | if (this.strand == "complement") { 201 | outputWindow.document.write( 202 | addReturns(reverse(complement(this.fragments.join("")))) 203 | ); 204 | } else { 205 | outputWindow.document.write(addReturns(this.fragments.join(""))); 206 | } 207 | } 208 | 209 | //class Feature method addFragment() 210 | function addFragment(sequence) { 211 | this.fragments.push(sequence); 212 | } 213 | 214 | //class Feature 215 | function Feature(strand) { 216 | this.strand = strand; 217 | this.fragments = new Array(); 218 | this.lastAdded = 0; 219 | } 220 | 221 | //create and throw away a prototype object 222 | new Feature(); 223 | 224 | // define object methods 225 | Feature.prototype.writeFeature = writeFeature; 226 | Feature.prototype.addFragment = addFragment; 227 | -------------------------------------------------------------------------------- /docs/scripts/embl_trans.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function emblTrans(theDocument) { 23 | var maxInput = 200000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | if ( 30 | checkFormElement(theDocument.forms[0].elements[0]) == false || 31 | verifyEmblFeat(theDocument.forms[0].elements[0].value) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | openWindow("EMBL Trans Extractor"); 38 | openPre(); 39 | emblTransExtract(theDocument.forms[0].elements[0].value); 40 | closePre(); 41 | closeWindow(); 42 | return true; 43 | } 44 | function emblTransExtract(emblFile) { 45 | var title; 46 | emblFile = "_" + emblFile + "_"; 47 | var recordArray = emblFile.split(/ID\s\s\s[^\f\n\r]*/); 48 | for (var i = 1; i < recordArray.length; i++) { 49 | var mainArray = emblFile.split( 50 | /[\f\n\r]\s*FH Key Location\/Qualifiers[\f\n\r]+\s*FH|[\f\n\r]\s*XX[\s]*[\f\n\r]\s*SQ[^\f\n\r]*/ 51 | ); 52 | if (mainArray[0].search(/[\f\n\r]\s*DE[^\f\n\r]+/) != -1) { 53 | title = mainArray[0] 54 | .match(/[\f\n\r]\s*DE[^\f\n\r]+/) 55 | .toString() 56 | .replace(/[\f\n\r]\s*DE\s*/, ""); 57 | } else { 58 | title = "Untitled"; 59 | } 60 | title = filterFastaTitle(title.replace(/[\f\n\r\t]+$/g, "")) + "\n"; 61 | var dnaSequenceArray = mainArray[2].split(/\/{2}/); 62 | outputWindow.document.write(title + "\n"); 63 | if (dnaSequenceArray.length == 1) { 64 | alert("The entire EMBL file may not have been processed."); 65 | outputWindow.focus(); 66 | } 67 | var featureArray = mainArray[1].split(/[\f\n\r]FT {3,12}\b/); 68 | showFeatureTrans(featureArray); 69 | } 70 | return true; 71 | } 72 | 73 | function showFeatureTrans(arrayOfFeatures) { 74 | var featureTitle = ""; 75 | var theTitle = ""; 76 | var removedTitle = ""; 77 | var firstQualifier = ""; 78 | var translation = ""; 79 | var translationFound = false; 80 | for (var i = 1; i < arrayOfFeatures.length; i++) { 81 | if (arrayOfFeatures[i].search(/\/translation/) != -1) { 82 | arrayOfFeatures[i] = arrayOfFeatures[i].replace(/[\[\]\*]/g, ""); 83 | featureTitle = arrayOfFeatures[i].match(/[^ \f\n\r\t\v]+ /).toString(); 84 | theTitle = new RegExp(featureTitle); 85 | removedTitle = arrayOfFeatures[i].replace(theTitle, ""); 86 | firstQualifier = arrayOfFeatures[i].match(/\/[^\f\n\r]+/).toString(); 87 | outputWindow.document.write( 88 | ">" + 89 | filterFastaTitle(featureTitle) + 90 | filterFastaTitle(firstQualifier) + 91 | "\n" 92 | ); 93 | translation = arrayOfFeatures[i].match(/\/translation="[^"]+"/); 94 | translation = translation.toString(); 95 | translation = translation.replace(/\/translation/, ""); 96 | translation = translation.replace(/^FT\s+/gm, ""); 97 | translation = removeNonProtein(translation); 98 | translation = addReturns(translation); 99 | outputWindow.document.write(translation); 100 | translationFound = true; 101 | outputWindow.document.write("\n\n"); 102 | } 103 | } 104 | if (translationFound == false) { 105 | outputWindow.document.write("No translations were found.\n"); 106 | } 107 | return true; 108 | } 109 | -------------------------------------------------------------------------------- /docs/scripts/filter_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function filterDna(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 500000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | var re = new RegExp( 38 | theDocument.forms[0].elements[4].options[ 39 | theDocument.forms[0].elements[4].selectedIndex 40 | ].value, 41 | "g" 42 | ); 43 | newDna = theDocument.forms[0].elements[0].value.replace( 44 | re, 45 | theDocument.forms[0].elements[5].options[ 46 | theDocument.forms[0].elements[5].selectedIndex 47 | ].value 48 | ); 49 | if ( 50 | theDocument.forms[0].elements[6].options[ 51 | theDocument.forms[0].elements[6].selectedIndex 52 | ].value == "uppercase" 53 | ) { 54 | newDna = newDna.toUpperCase(); 55 | } else { 56 | if ( 57 | theDocument.forms[0].elements[6].options[ 58 | theDocument.forms[0].elements[6].selectedIndex 59 | ].value == "lowercase" 60 | ) { 61 | newDna = newDna.toLowerCase(); 62 | } 63 | } 64 | 65 | openWindow("Filter DNA"); 66 | openPre(); 67 | outputWindow.document.write( 68 | ">filtered DNA sequence consisting of " + newDna.length + " bases.\n" 69 | ); 70 | outputWindow.document.write(addReturns(newDna)); 71 | outputWindow.document.write("\n"); 72 | closePre(); 73 | closeWindow(); 74 | return true; 75 | } 76 | -------------------------------------------------------------------------------- /docs/scripts/filter_protein.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function filterProtein(theDocument) { 23 | var newProtein = ""; 24 | var maxInput = 500000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | var re = new RegExp( 38 | theDocument.forms[0].elements[4].options[ 39 | theDocument.forms[0].elements[4].selectedIndex 40 | ].value, 41 | "g" 42 | ); 43 | newProtein = theDocument.forms[0].elements[0].value.replace( 44 | re, 45 | theDocument.forms[0].elements[5].options[ 46 | theDocument.forms[0].elements[5].selectedIndex 47 | ].value 48 | ); 49 | if ( 50 | theDocument.forms[0].elements[6].options[ 51 | theDocument.forms[0].elements[6].selectedIndex 52 | ].value == "uppercase" 53 | ) { 54 | newProtein = newProtein.toUpperCase(); 55 | } else { 56 | if ( 57 | theDocument.forms[0].elements[6].options[ 58 | theDocument.forms[0].elements[6].selectedIndex 59 | ].value == "lowercase" 60 | ) { 61 | newProtein = newProtein.toLowerCase(); 62 | } 63 | } 64 | 65 | openWindow("Filter Protein"); 66 | openPre(); 67 | outputWindow.document.write( 68 | ">filtered protein sequence consisting of " + 69 | newProtein.length + 70 | " residues.\n" 71 | ); 72 | outputWindow.document.write(addReturns(newProtein)); 73 | outputWindow.document.write("\n"); 74 | closePre(); 75 | closeWindow(); 76 | return true; 77 | } 78 | -------------------------------------------------------------------------------- /docs/scripts/fuzzy_search_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function fuzzySearchDna(theDocument) { 23 | //var MATCH_SCORE = 2; 24 | //var MISMATCH_SCORE = -1; 25 | //var GAP_PENALTY = 2; 26 | //var HITS = 8; 27 | 28 | var targetSequence = ""; 29 | var targetTitle = ""; 30 | 31 | var querySequence = ""; 32 | var queryTitle = ""; 33 | 34 | var maxTarget = 2000000; 35 | var maxQuery = 30; 36 | 37 | if (testScript() == false) { 38 | return false; 39 | } 40 | 41 | if ( 42 | checkFormElement(theDocument.forms[0].elements[0]) == false || 43 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxTarget) == 44 | false || 45 | checkFormElement(theDocument.forms[0].elements[1]) == false || 46 | checkSequenceLength(theDocument.forms[0].elements[1].value, maxQuery) == 47 | false 48 | ) { 49 | return false; 50 | } 51 | 52 | var MATCH_SCORE = parseInt( 53 | theDocument.forms[0].elements[5].options[ 54 | theDocument.forms[0].elements[5].selectedIndex 55 | ].value 56 | ); 57 | var MISMATCH_SCORE = parseInt( 58 | theDocument.forms[0].elements[6].options[ 59 | theDocument.forms[0].elements[6].selectedIndex 60 | ].value 61 | ); 62 | var GAP_PENALTY = parseInt( 63 | theDocument.forms[0].elements[7].options[ 64 | theDocument.forms[0].elements[7].selectedIndex 65 | ].value 66 | ); 67 | var HITS = parseInt( 68 | theDocument.forms[0].elements[8].options[ 69 | theDocument.forms[0].elements[8].selectedIndex 70 | ].value 71 | ); 72 | 73 | openWindow("Fuzzy Search DNA"); 74 | openPre(); 75 | 76 | targetSequence = getSequenceFromFasta(theDocument.forms[0].elements[0].value); 77 | targetSequence = removeNonDna(targetSequence); 78 | targetTitle = getTitleFromFasta(theDocument.forms[0].elements[0].value); 79 | 80 | querySequence = getSequenceFromFasta(theDocument.forms[0].elements[1].value); 81 | querySequence = removeNonDna(querySequence); 82 | queryTitle = "query"; 83 | 84 | outputWindow.document.write( 85 | getFuzzySearchTitle(targetTitle, targetSequence, queryTitle, querySequence) 86 | ); 87 | 88 | //change to arrays for pass by reference, so that large sequence isn't copied 89 | if (targetSequence.search(/./) != -1) { 90 | targetSequence = targetSequence.match(/./g); 91 | } 92 | 93 | if (querySequence.search(/./) != -1) { 94 | querySequence = querySequence.match(/./g); 95 | } 96 | 97 | if (targetSequence.length == 0) { 98 | alert("The sequence contains no DNA bases."); 99 | return false; 100 | } 101 | 102 | if (querySequence.length == 0) { 103 | alert("The query sequence contains no DNA bases."); 104 | return false; 105 | } 106 | 107 | _fuzzySearchDna( 108 | queryTitle, 109 | querySequence, 110 | targetTitle, 111 | targetSequence, 112 | MATCH_SCORE, 113 | MISMATCH_SCORE, 114 | GAP_PENALTY, 115 | HITS 116 | ); 117 | closePre(); 118 | closeWindow(); 119 | return true; 120 | } 121 | 122 | function _fuzzySearchDna( 123 | queryTitle, 124 | querySequence, 125 | targetTitle, 126 | targetSequence, 127 | matchScore, 128 | mismatchScore, 129 | gapPenalty, 130 | hits 131 | ) { 132 | var matrix = new Identity(); 133 | matrix.setMatch(matchScore); 134 | matrix.setMismatch(mismatchScore); 135 | 136 | var scoreSet = new ScoreSet(); 137 | scoreSet.setScoreSetParam(matrix, gapPenalty, hits); 138 | 139 | var fuzzySearch = new FuzzySearch(); 140 | fuzzySearch.initializeMatrix(querySequence, targetSequence, scoreSet); 141 | fuzzySearch.search(); 142 | var hits = fuzzySearch.getHits(); 143 | 144 | if (hits.length > 0) { 145 | for (var i = 0; i < hits.length; i++) { 146 | outputWindow.document.write( 147 | ">" + 148 | queryTitle + 149 | " from " + 150 | hits[i].startM + 151 | " to " + 152 | hits[i].endM + 153 | "\n" 154 | ); 155 | outputWindow.document.write(hits[i].sequenceM + "\n"); 156 | outputWindow.document.write( 157 | ">" + 158 | targetTitle + 159 | " from " + 160 | hits[i].startN + 161 | " to " + 162 | hits[i].endN + 163 | "\n" 164 | ); 165 | outputWindow.document.write(hits[i].sequenceN + "\n"); 166 | outputWindow.document.write("Score: " + hits[i].score + "\n\n"); 167 | } 168 | } else { 169 | outputWindow.document.write("No hits were obtained.\n\n"); 170 | } 171 | } 172 | 173 | //------------------------------------ ScoreSet class 174 | 175 | //ScoreSet getScore 176 | function getScore(r1, r2) { 177 | return this.scoringMatrix.scoringMatrix_getScore(r1, r2); 178 | } 179 | 180 | //ScoreSet setScoreSetParam 181 | function setScoreSetParam(scoringMatrix, gapPenalty, hits) { 182 | this.scoringMatrix = scoringMatrix; 183 | this.gap = gapPenalty; 184 | this.hits = hits; 185 | } 186 | 187 | //ScoreSet class 188 | function ScoreSet() { 189 | this.scoringMatrix; 190 | this.gap; 191 | } 192 | 193 | //create and throw away a prototype object 194 | new ScoreSet(); 195 | 196 | //define object methods 197 | ScoreSet.prototype.getScore = getScore; 198 | ScoreSet.prototype.setScoreSetParam = setScoreSetParam; 199 | 200 | //------------------------------------ 201 | 202 | //------------------------------------ ScoringMatrix abstract class 203 | //ScoringMatrix getScore method 204 | function scoringMatrix_getScore(r1, r2) { 205 | r1 = r1.toLowerCase(); 206 | r2 = r2.toLowerCase(); 207 | if (r1 == r2) { 208 | return this.match; 209 | } else { 210 | return this.mismatch; 211 | } 212 | } 213 | 214 | //ScoringMatrix class 215 | function ScoringMatrix() { 216 | this.mismatch; 217 | this.match; 218 | } 219 | 220 | //create and throw away a prototype object 221 | new ScoringMatrix(); 222 | 223 | //define object methods 224 | ScoringMatrix.prototype.scoringMatrix_getScore = scoringMatrix_getScore; 225 | 226 | //------------------------------------ Identity class extends ScoringMatrix Class 227 | //Identity class setMismatch method 228 | function setMismatch(mismatchScore) { 229 | this.mismatch = mismatchScore; 230 | } 231 | 232 | //Identity class setMatch method 233 | function setMatch(matchScore) { 234 | this.match = matchScore; 235 | } 236 | 237 | //Identity class 238 | function Identity() {} 239 | 240 | Identity.prototype = new ScoringMatrix(); 241 | Identity.prototype.setMismatch = setMismatch; 242 | Identity.prototype.setMatch = setMatch; 243 | -------------------------------------------------------------------------------- /docs/scripts/genbank_fasta.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function genbankFasta(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 200000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | verifyGenBank(theDocument.forms[0].elements[0].value) == false || 33 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 34 | ) { 35 | return false; 36 | } 37 | 38 | openWindow("GenBank to FASTA"); 39 | openPre(); 40 | genbankToFasta(theDocument.forms[0].elements[0].value); 41 | closePre(); 42 | closeWindow(); 43 | return true; 44 | } 45 | 46 | function genbankToFasta(genBankFile) { 47 | genBankFile = "_" + genBankFile + "_"; 48 | var recordArray = genBankFile.split(/LOCUS\s\s\s[^\f\n\r]*/m); 49 | for (var i = 1; i < recordArray.length; i++) { 50 | var mainArray = recordArray[i].split( 51 | /DEFINITION|ACCESSION|ORIGIN[^\f\n\r]*/ 52 | ); 53 | var title = 54 | filterFastaTitle(mainArray[1].replace(/[\f\n\r\t]+$/g, "")) + "\n"; 55 | var dnaSequenceArray = mainArray[3].split(/\/{2}/); 56 | if (dnaSequenceArray.length == 1) { 57 | alert("The entire GenBank file may not have been processed."); 58 | outputWindow.focus(); 59 | } 60 | var dnaSequence = removeNonDna(dnaSequenceArray[0]); 61 | outputWindow.document.write( 62 | ">" + title + addReturns(dnaSequence) + "\n\n" 63 | ); 64 | } 65 | return true; 66 | } 67 | -------------------------------------------------------------------------------- /docs/scripts/genbank_feat.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function genbankFeat(theDocument) { 23 | var maxInput = 1000000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | if ( 30 | checkFormElement(theDocument.forms[0].elements[0]) == false || 31 | verifyGenBankFeat(theDocument.forms[0].elements[0].value) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | openWindow("GenBank Feature Extractor"); 38 | openPre(); 39 | genBankFeatExtract( 40 | theDocument.forms[0].elements[0].value, 41 | theDocument.forms[0].elements[4].options[ 42 | theDocument.forms[0].elements[4].selectedIndex 43 | ].value 44 | ); 45 | closePre(); 46 | closeWindow(); 47 | return true; 48 | } 49 | 50 | function genBankFeatExtract(genBankFile, outputType) { 51 | genBankFile = "_" + genBankFile + "_"; 52 | var recordArray = genBankFile.split(/LOCUS\s\s\s[^\f\n\r]*/m); 53 | for (var i = 1; i < recordArray.length; i++) { 54 | var mainArray = recordArray[i].split( 55 | /DEFINITION|ACCESSION|FEATURES|ORIGIN[^\f\n\r]*/ 56 | ); 57 | var title = 58 | filterFastaTitle(mainArray[1].replace(/[\f\n\r\t]+$/g, "")) + "\n"; 59 | var dnaSequenceArray = mainArray[4].split(/\/{2}/); 60 | outputWindow.document.write(title + "\n"); 61 | if (dnaSequenceArray.length == 1) { 62 | alert("The entire GenBank file may not have been processed."); 63 | outputWindow.focus(); 64 | } 65 | var dnaSequence = removeNonDna(dnaSequenceArray[0]); 66 | var featureArray = mainArray[3].split(/[\f\n\r] {5,12}\b/); 67 | prepareFeatures(featureArray, dnaSequence, outputType); 68 | } 69 | return true; 70 | } 71 | 72 | function prepareFeatures(arrayOfFeatures, dnaSequence, outputType) { 73 | var featureTitle = ""; 74 | var theTitle = ""; 75 | var removedTitle = ""; 76 | var firstQualifier = ""; 77 | var position = ""; 78 | var positionNoSpace = ""; 79 | var featureFound = false; 80 | for (var i = 1; i < arrayOfFeatures.length; i++) { 81 | arrayOfFeatures[i] = arrayOfFeatures[i].replace(/[\[\]\*]/g, ""); 82 | featureTitle = arrayOfFeatures[i].match(/[^ \f\n\r\t\v]+ /).toString(); 83 | theTitle = new RegExp(featureTitle); 84 | removedTitle = arrayOfFeatures[i].replace(theTitle, ""); 85 | if (arrayOfFeatures[i].search(/\/[^\f\n\r]+/) != -1) { 86 | firstQualifier = arrayOfFeatures[i].match(/\/[^\f\n\r]+/).toString(); 87 | } else { 88 | firstQualifier = "/no qualifier supplied"; 89 | } 90 | position = removedTitle.split(/\//); 91 | positionNoSpace = position[0].replace(/\s{2,}/g, " "); 92 | outputWindow.document.write( 93 | ">" + 94 | filterFastaTitle(featureTitle) + 95 | filterFastaTitle(firstQualifier) + 96 | "\n" 97 | ); 98 | printFeature(positionNoSpace, dnaSequence, outputType); 99 | featureFound = true; 100 | outputWindow.document.write("\n\n"); 101 | } 102 | if (featureFound == false) { 103 | outputWindow.document.write( 104 | "There were no features found or there was a problem reading the feature information." 105 | ); 106 | } 107 | return true; 108 | } 109 | 110 | function printFeature(featurePos, dnaSequence, outputType) { 111 | var feature; 112 | featurePos = featurePos.replace(/<|>/g, ""); 113 | if ( 114 | featurePos.search(/[^a-z\d\.\(\)\,\s]/) != -1 || 115 | featurePos.search(/one/) != -1 || 116 | featurePos.search(/order/) != -1 117 | ) { 118 | outputWindow.document.write( 119 | "This feature specifies a sequence that cannot be represented:\n" 120 | ); 121 | outputWindow.document.write(featurePos); 122 | } else { 123 | var newFeaturePos = featurePos.replace(/\)/g, ""); 124 | if (newFeaturePos.search(/complement/) != -1) { 125 | feature = new Feature("complement"); 126 | } else { 127 | feature = new Feature("direct"); 128 | } 129 | 130 | var posArray = newFeaturePos.split(/\(/); 131 | var last = posArray.length - 1; 132 | var pairString = posArray[last]; 133 | var pairArray = pairString.split(/\,/); 134 | var digitArray = new Array(); 135 | var realStart = 0; 136 | var realStop = 0; 137 | 138 | for (var j = 0; j < pairArray.length; j++) { 139 | digitArray = pairArray[j].split(/\.\./); 140 | if (digitArray.length == 1) { 141 | digitArray[1] = digitArray[0]; 142 | } 143 | realStart = digitArray[0]; 144 | realStop = digitArray[1]; 145 | realStop = realStop.replace(/\D/g, ""); 146 | realStart = realStart.replace(/\D/g, ""); 147 | if (realStart.search(/\d/) == -1 || realStop.search(/\d/) == -1) { 148 | outputWindow.document.write( 149 | "There was a problem with this feature (one of the range values was missing)." 150 | ); 151 | return true; 152 | } 153 | realStart = parseInt(realStart) - 1; 154 | realStop = parseInt(realStop); 155 | if (realStart > realStop) { 156 | outputWindow.document.write( 157 | "There was a problem with this feature (the end position was before the start position)." 158 | ); 159 | return true; 160 | } 161 | if (realStart > dnaSequence.length || realStop > dnaSequence.length) { 162 | outputWindow.document.write( 163 | "The entire GenBank file was not processed, so this feature cannot be properly shown." 164 | ); //to handle case where web browser limits the number of characters that can be entered as input. 165 | return true; 166 | } else { 167 | if (outputType == "separated") { 168 | feature.addFragment(dnaSequence.substring(realStart, realStop)); 169 | } else { 170 | feature.addFragment( 171 | dnaSequence.substring(feature.lastAdded, realStart) 172 | ); 173 | feature.addFragment( 174 | dnaSequence.substring(realStart, realStop).toUpperCase() 175 | ); 176 | feature.lastAdded = realStop; 177 | } 178 | } 179 | } 180 | feature.writeFeature(); 181 | } 182 | return true; 183 | } 184 | 185 | //class Feature method writeFeature() 186 | function writeFeature() { 187 | if (this.strand == "complement") { 188 | outputWindow.document.write( 189 | addReturns(reverse(complement(this.fragments.join("")))) 190 | ); 191 | } else { 192 | outputWindow.document.write(addReturns(this.fragments.join(""))); 193 | } 194 | } 195 | 196 | //class Feature method addFragment() 197 | function addFragment(sequence) { 198 | this.fragments.push(sequence); 199 | } 200 | 201 | //class Feature 202 | function Feature(strand) { 203 | this.strand = strand; 204 | this.fragments = new Array(); 205 | this.lastAdded = 0; 206 | } 207 | 208 | //create and throw away a prototype object 209 | new Feature(); 210 | 211 | // define object methods 212 | Feature.prototype.writeFeature = writeFeature; 213 | Feature.prototype.addFragment = addFragment; 214 | -------------------------------------------------------------------------------- /docs/scripts/genbank_trans.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function genbankTrans(theDocument) { 23 | var maxInput = 200000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | if ( 30 | checkFormElement(theDocument.forms[0].elements[0]) == false || 31 | verifyGenBankFeat(theDocument.forms[0].elements[0].value) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | openWindow("GenBank Trans Extractor"); 38 | openPre(); 39 | genBankTransExtract(theDocument.forms[0].elements[0].value); 40 | closePre(); 41 | closeWindow(); 42 | return true; 43 | } 44 | function genBankTransExtract(genBankFile) { 45 | genBankFile = "_" + genBankFile + "_"; 46 | var recordArray = genBankFile.split(/LOCUS\s\s\s[^\f\n\r]*/m); 47 | for (var i = 1; i < recordArray.length; i++) { 48 | var mainArray = recordArray[i].split( 49 | /DEFINITION|ACCESSION|FEATURES|ORIGIN[^\f\n\r]*/ 50 | ); 51 | var title = 52 | filterFastaTitle(mainArray[1].replace(/[\f\n\r\t]+$/g, "")) + "\n"; 53 | var dnaSequenceArray = mainArray[4].split(/\/{2}/); 54 | outputWindow.document.write(title + "\n"); 55 | if (dnaSequenceArray.length == 1) { 56 | alert("The entire GenBank file may not have been processed."); 57 | outputWindow.focus(); 58 | } 59 | var featureArray = mainArray[3].split(/[\f\n\r] {5,12}\b/); 60 | showFeatureTrans(featureArray); 61 | } 62 | return true; 63 | } 64 | 65 | function showFeatureTrans(arrayOfFeatures) { 66 | var featureTitle = ""; 67 | var theTitle = ""; 68 | var removedTitle = ""; 69 | var firstQualifier = ""; 70 | var translation = ""; 71 | var translationFound = false; 72 | for (var i = 1; i < arrayOfFeatures.length; i++) { 73 | if (arrayOfFeatures[i].search(/\/translation/) != -1) { 74 | arrayOfFeatures[i] = arrayOfFeatures[i].replace(/[\[\]\*]/g, ""); 75 | featureTitle = arrayOfFeatures[i].match(/[^ \f\n\r\t\v]+ /).toString(); 76 | theTitle = new RegExp(featureTitle); 77 | removedTitle = arrayOfFeatures[i].replace(theTitle, ""); 78 | firstQualifier = arrayOfFeatures[i].match(/\/[^\f\n\r]+/).toString(); 79 | outputWindow.document.write( 80 | ">" + 81 | filterFastaTitle(featureTitle) + 82 | filterFastaTitle(firstQualifier) + 83 | "\n" 84 | ); 85 | translation = arrayOfFeatures[i].match(/\/translation="[^"]+"/); 86 | translation = translation.toString(); 87 | translation = translation.replace(/\/translation/, ""); 88 | translation = removeNonProtein(translation); 89 | translation = addReturns(translation); 90 | outputWindow.document.write(translation); 91 | translationFound = true; 92 | outputWindow.document.write("\n\n"); 93 | } 94 | } 95 | if (translationFound == false) { 96 | outputWindow.document.write("No translations were found.\n"); 97 | } 98 | return true; 99 | } 100 | -------------------------------------------------------------------------------- /docs/scripts/group_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function groupDna(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 100000000; 26 | var adjustedStart; 27 | 28 | if (testScript() == false) { 29 | return false; 30 | } 31 | 32 | if ( 33 | checkFormElement(theDocument.forms[0].elements[0]) == false || 34 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 35 | false 36 | ) { 37 | return false; 38 | } 39 | 40 | adjustedStart = theDocument.forms[0].elements[8].value.replace( 41 | /[^\d\-]/g, 42 | "" 43 | ); 44 | if ( 45 | checkFormElement(theDocument.forms[0].elements[8]) == false || 46 | verifyMaxDigits(adjustedStart, 9999999999) == false 47 | ) { 48 | return false; 49 | } 50 | adjustedStart = parseInt(adjustedStart) - 1; 51 | 52 | openWindow("Group DNA"); 53 | openPre(); 54 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 55 | 56 | for (var i = 0; i < arrayOfFasta.length; i++) { 57 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 58 | title = getTitleFromFasta(arrayOfFasta[i]); 59 | 60 | newDna = removeNonDna(newDna); 61 | 62 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 63 | 64 | writeGroupNumDnaSetStart( 65 | newDna, 66 | "", 67 | theDocument.forms[0].elements[4].options[ 68 | theDocument.forms[0].elements[4].selectedIndex 69 | ].value, 70 | theDocument.forms[0].elements[5].options[ 71 | theDocument.forms[0].elements[5].selectedIndex 72 | ].value, 73 | 0, 74 | newDna.length, 75 | theDocument.forms[0].elements[6].options[ 76 | theDocument.forms[0].elements[6].selectedIndex 77 | ].value, 78 | theDocument.forms[0].elements[7].options[ 79 | theDocument.forms[0].elements[7].selectedIndex 80 | ].value, 81 | adjustedStart 82 | ); 83 | outputWindow.document.write("\n\n"); 84 | } 85 | 86 | closePre(); 87 | closeWindow(); 88 | return true; 89 | } 90 | -------------------------------------------------------------------------------- /docs/scripts/group_protein.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function groupProtein(theDocument) { 23 | var newProtein = ""; 24 | var title = ""; 25 | var maxInput = 100000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | openWindow("Group Protein"); 40 | openPre(); 41 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 42 | 43 | for (var i = 0; i < arrayOfFasta.length; i++) { 44 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 45 | title = getTitleFromFasta(arrayOfFasta[i]); 46 | 47 | newProtein = removeNonProtein(newProtein); 48 | 49 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newProtein)); 50 | 51 | writeGroupNumProtein( 52 | newProtein, 53 | "", 54 | theDocument.forms[0].elements[4].options[ 55 | theDocument.forms[0].elements[4].selectedIndex 56 | ].value, 57 | theDocument.forms[0].elements[5].options[ 58 | theDocument.forms[0].elements[5].selectedIndex 59 | ].value, 60 | 0, 61 | newProtein.length, 62 | theDocument.forms[0].elements[6].options[ 63 | theDocument.forms[0].elements[6].selectedIndex 64 | ].value 65 | ); 66 | outputWindow.document.write("\n\n"); 67 | } 68 | 69 | closePre(); 70 | closeWindow(); 71 | return true; 72 | } 73 | -------------------------------------------------------------------------------- /docs/scripts/ident_sim.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function identSim(theDocument) { 23 | var maxInput = 20000000; 24 | var theAlignment = ""; 25 | var alignArray = new Array(); 26 | var groupString = ""; 27 | var arrayOfGroups = new Array(); 28 | 29 | var titleArray = new Array(); 30 | var sequenceArray = new Array(); 31 | 32 | var longestTitle; 33 | 34 | if (testScript() == false) { 35 | return false; 36 | } 37 | 38 | if ( 39 | checkFormElement(theDocument.forms[0].elements[0]) == false || 40 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 41 | ) { 42 | return false; 43 | } 44 | 45 | theAlignment = "X" + theDocument.forms[0].elements[0].value; 46 | alignArray = theAlignment.split(/[>%#]/); 47 | 48 | if (earlyCheckAlign(alignArray) == false) { 49 | return false; 50 | } 51 | 52 | for (var i = 1; i < alignArray.length; i++) { 53 | titleArray[i - 1] = alignArray[i].match(/[^\f\n\r]+[\f\n\r]/); 54 | titleArray[i - 1] = filterFastaTitle(titleArray[i - 1].toString()).replace( 55 | /[\f\n\r]/g, 56 | "" 57 | ); 58 | titleArray[i - 1] = titleArray[i - 1].substring(0, 20); 59 | if (i == 1) { 60 | longestTitle = titleArray[i - 1].length; 61 | } else if (titleArray[i - 1].length > longestTitle) { 62 | longestTitle = titleArray[i - 1].length; 63 | } 64 | sequenceArray[i - 1] = alignArray[i].replace(/[^\f\n\r]+[\f\n\r]/, ""); 65 | sequenceArray[i - 1] = filterAlignSeq(sequenceArray[i - 1]); 66 | } 67 | 68 | if (checkAlign(titleArray, sequenceArray) == false) { 69 | return false; 70 | } 71 | 72 | groupString = theDocument.forms[0].elements[1].value 73 | .replace(/\s/g, "") 74 | .toUpperCase(); 75 | arrayOfGroups = groupString.split(/,/); 76 | if (checkGroupInput(arrayOfGroups) == false) { 77 | return false; 78 | } 79 | 80 | openWindowAlign("Ident and Sim"); 81 | openPre(); 82 | writeIdentAndSim(titleArray, sequenceArray, arrayOfGroups); 83 | closePre(); 84 | closeWindow(); 85 | return true; 86 | } 87 | 88 | function writeIdentAndSim(titleArray, sequenceArray, arrayOfGroups) { 89 | var identical = 0; 90 | var similar = 0; 91 | var alignLength = 0; 92 | for (var k = 0; k < sequenceArray.length; k++) { 93 | for (var m = k + 1; m < sequenceArray.length; m++) { 94 | for (var i = 0; i < sequenceArray[0].length; i++) { 95 | alignLength = alignLength + 1; 96 | if ( 97 | sequenceArray[k].charAt(i).toUpperCase() == 98 | sequenceArray[m].charAt(i).toUpperCase() && 99 | sequenceArray[k].charAt(i).toUpperCase() != "X" 100 | ) { 101 | if ( 102 | sequenceArray[k].charAt(i) != "-" && 103 | sequenceArray[k].charAt(i) != "." 104 | ) { 105 | identical = identical + 1; 106 | } else { 107 | alignLength = alignLength - 1; 108 | } 109 | } else { 110 | for (var j = 0; j < arrayOfGroups.length; j++) { 111 | if ( 112 | arrayOfGroups[j].search( 113 | sequenceArray[k].charAt(i).toUpperCase() 114 | ) != -1 && 115 | arrayOfGroups[j].search( 116 | sequenceArray[m].charAt(i).toUpperCase() 117 | ) != -1 118 | ) { 119 | similar = similar + 1; 120 | break; 121 | } 122 | } 123 | } 124 | } 125 | outputWindow.document.write( 126 | "Results for " + titleArray[k] + " vs " + titleArray[m] + ":\n" 127 | ); 128 | outputWindow.document.write(" Alignment length: " + alignLength + "\n"); 129 | outputWindow.document.write("Identical residues: " + identical + "\n"); 130 | outputWindow.document.write(" Similar residues: " + similar + "\n"); 131 | if (identical == 0) { 132 | outputWindow.document.write(" Percent identity: " + 0 + "\n"); 133 | } else { 134 | outputWindow.document.write( 135 | " Percent identity: " + 136 | ((identical / alignLength) * 100).toFixed(2) + 137 | "\n" 138 | ); 139 | } 140 | if (similar == 0 && identical == 0) { 141 | outputWindow.document.write("Percent similarity: " + 0 + "\n"); 142 | } else { 143 | outputWindow.document.write( 144 | "Percent similarity: " + 145 | (((identical + similar) / alignLength) * 100).toFixed(2) + 146 | "\n" 147 | ); 148 | } 149 | outputWindow.document.write("\n"); 150 | identical = 0; 151 | similar = 0; 152 | alignLength = 0; 153 | } 154 | } 155 | return true; 156 | } 157 | -------------------------------------------------------------------------------- /docs/scripts/mutate_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function mutateDna(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 1000000000; 26 | var maxDigitsInput = 100000000; 27 | 28 | if (testScript() == false) { 29 | return false; 30 | } 31 | 32 | var enteredNumber = theDocument.forms[0].elements[4].value.replace( 33 | /[^\d]/g, 34 | "" 35 | ); 36 | 37 | if ( 38 | checkFormElement(theDocument.forms[0].elements[0]) == false || 39 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 40 | false || 41 | verifyMaxDigits(enteredNumber, maxDigitsInput) == false 42 | ) { 43 | return false; 44 | } 45 | 46 | openWindow("Mutate DNA"); 47 | openPre(); 48 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 49 | 50 | for (var i = 0; i < arrayOfFasta.length; i++) { 51 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 52 | title = getTitleFromFasta(arrayOfFasta[i]); 53 | 54 | newDna = removeNonDna(newDna); 55 | 56 | outputWindow.document.write( 57 | getFastaTitleFromTitleAndSequence(title, newDna) 58 | ); 59 | writeMutatedSequence( 60 | newDna, 61 | ["g", "a", "c", "t"], 62 | enteredNumber, 63 | theDocument.forms[0].elements[5].options[ 64 | theDocument.forms[0].elements[5].selectedIndex 65 | ].value, 66 | newDna.length - 67 | theDocument.forms[0].elements[6].options[ 68 | theDocument.forms[0].elements[6].selectedIndex 69 | ].value - 70 | 1 71 | ); 72 | 73 | outputWindow.document.write("\n\n"); 74 | } 75 | 76 | closePre(); 77 | closeWindow(); 78 | return true; 79 | } 80 | -------------------------------------------------------------------------------- /docs/scripts/mutate_protein.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function mutateProtein(theDocument) { 23 | var newProtein = ""; 24 | var title = ""; 25 | var maxInput = 1000000000; 26 | var maxDigitsInput = 100000000; 27 | 28 | if (testScript() == false) { 29 | return false; 30 | } 31 | 32 | var enteredNumber = theDocument.forms[0].elements[4].value.replace( 33 | /[^\d]/g, 34 | "" 35 | ); 36 | 37 | if ( 38 | checkFormElement(theDocument.forms[0].elements[0]) == false || 39 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 40 | false || 41 | verifyMaxDigits(enteredNumber, maxDigitsInput) == false 42 | ) { 43 | return false; 44 | } 45 | 46 | openWindow("Mutate Protein"); 47 | openPre(); 48 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 49 | 50 | for (var i = 0; i < arrayOfFasta.length; i++) { 51 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 52 | title = getTitleFromFasta(arrayOfFasta[i]); 53 | 54 | newProtein = removeNonProteinAllowDegen(newProtein); 55 | 56 | outputWindow.document.write( 57 | getFastaTitleFromTitleAndSequence(title, newProtein) 58 | ); 59 | writeMutatedSequence( 60 | newProtein, 61 | [ 62 | "A", 63 | "C", 64 | "D", 65 | "E", 66 | "F", 67 | "G", 68 | "H", 69 | "I", 70 | "K", 71 | "L", 72 | "M", 73 | "N", 74 | "P", 75 | "Q", 76 | "R", 77 | "S", 78 | "T", 79 | "V", 80 | "W", 81 | "Y", 82 | ], 83 | enteredNumber, 84 | theDocument.forms[0].elements[5].options[ 85 | theDocument.forms[0].elements[5].selectedIndex 86 | ].value, 87 | newProtein.length - 1 88 | ); 89 | 90 | outputWindow.document.write("\n\n"); 91 | } 92 | 93 | closePre(); 94 | closeWindow(); 95 | return true; 96 | } 97 | -------------------------------------------------------------------------------- /docs/scripts/one_to_three.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function oneToThree(theDocument) { 23 | var newProtein = ""; 24 | var maxInput = 100000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | openWindow("One to Three"); 38 | openPre(); 39 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 40 | 41 | for (var i = 0; i < arrayOfFasta.length; i++) { 42 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 43 | title = getTitleFromFasta(arrayOfFasta[i]); 44 | newProtein = removeNonProteinAllowDegen(newProtein); 45 | 46 | outputWindow.document.write( 47 | getFastaTitleFromTitleAndSequence(title, newProtein) 48 | ); 49 | 50 | writeOneToThree(newProtein); 51 | 52 | outputWindow.document.write("\n\n"); 53 | } 54 | 55 | closePre(); 56 | closeWindow(); 57 | return true; 58 | } 59 | 60 | function writeOneToThree(proteinSequence) { 61 | proteinSequence = proteinSequence.toLowerCase(); 62 | proteinSequence = proteinSequence.replace(/(.)/g, function ( 63 | str, 64 | p1, 65 | offset, 66 | s 67 | ) { 68 | return " " + p1 + " "; 69 | }); 70 | 71 | proteinSequence = proteinSequence.replace(/a/g, "ALA"); 72 | proteinSequence = proteinSequence.replace(/b/g, "ASX"); 73 | proteinSequence = proteinSequence.replace(/c/g, "CYS"); 74 | proteinSequence = proteinSequence.replace(/d/g, "ASP"); 75 | proteinSequence = proteinSequence.replace(/e/g, "GLU"); 76 | proteinSequence = proteinSequence.replace(/f/g, "PHE"); 77 | proteinSequence = proteinSequence.replace(/g/g, "GLY"); 78 | proteinSequence = proteinSequence.replace(/h/g, "HIS"); 79 | proteinSequence = proteinSequence.replace(/i/g, "ILE"); 80 | proteinSequence = proteinSequence.replace(/k/g, "LYS"); 81 | proteinSequence = proteinSequence.replace(/l/g, "LEU"); 82 | proteinSequence = proteinSequence.replace(/m/g, "MET"); 83 | proteinSequence = proteinSequence.replace(/n/g, "ASN"); 84 | proteinSequence = proteinSequence.replace(/p/g, "PRO"); 85 | proteinSequence = proteinSequence.replace(/q/g, "GLN"); 86 | proteinSequence = proteinSequence.replace(/r/g, "ARG"); 87 | proteinSequence = proteinSequence.replace(/s/g, "SER"); 88 | proteinSequence = proteinSequence.replace(/t/g, "THR"); 89 | proteinSequence = proteinSequence.replace(/v/g, "VAL"); 90 | proteinSequence = proteinSequence.replace(/w/g, "TRP"); 91 | proteinSequence = proteinSequence.replace(/x/g, "XAA"); 92 | proteinSequence = proteinSequence.replace(/y/g, "TYR"); 93 | proteinSequence = proteinSequence.replace(/z/g, "GLX"); 94 | proteinSequence = proteinSequence.replace(/\*/g, "***"); 95 | 96 | proteinSequence = proteinSequence.replace(/\s*(.)(.)(.)\s*/g, function ( 97 | str, 98 | p1, 99 | p2, 100 | p3, 101 | offset, 102 | s 103 | ) { 104 | return p1 + p2.toLowerCase() + p3.toLowerCase(); 105 | }); 106 | 107 | outputWindow.document.write(addReturns(proteinSequence)); 108 | return true; 109 | } 110 | -------------------------------------------------------------------------------- /docs/scripts/orf_find.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function orfFind(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 100000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | var geneticCode = getGeneticCodeString( 32 | theDocument.forms[0].elements[8].options[ 33 | theDocument.forms[0].elements[8].selectedIndex 34 | ].value 35 | ); 36 | 37 | geneticCode = geneticCode.split(/,/); 38 | 39 | var enteredNumber = theDocument.forms[0].elements[7].value.replace( 40 | /[^\d]/g, 41 | "" 42 | ); 43 | if ( 44 | checkFormElement(theDocument.forms[0].elements[0]) == false || 45 | checkFormElement(theDocument.forms[0].elements[7]) == false || 46 | verifyDigits(enteredNumber) == false || 47 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 48 | false 49 | ) { 50 | return false; 51 | } 52 | 53 | if (checkGeneticCode(geneticCode) == false) { 54 | return false; 55 | } 56 | 57 | newDna = getSequenceFromFasta(theDocument.forms[0].elements[0].value); 58 | title = getTitleFromFasta(theDocument.forms[0].elements[0].value); 59 | verifyDna(newDna); 60 | newDna = removeNonDna(newDna); 61 | openWindow("ORF Finder"); 62 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 63 | openPre(); 64 | 65 | if ( 66 | theDocument.forms[0].elements[5].options[ 67 | theDocument.forms[0].elements[5].selectedIndex 68 | ].value == "all" 69 | ) { 70 | //rf 1 71 | writeOrfs( 72 | newDna, 73 | geneticCode, 74 | theDocument.forms[0].elements[4].options[ 75 | theDocument.forms[0].elements[4].selectedIndex 76 | ].value, 77 | 0, 78 | theDocument.forms[0].elements[6].options[ 79 | theDocument.forms[0].elements[6].selectedIndex 80 | ].value, 81 | enteredNumber 82 | ); 83 | //rf 2 84 | writeOrfs( 85 | newDna, 86 | geneticCode, 87 | theDocument.forms[0].elements[4].options[ 88 | theDocument.forms[0].elements[4].selectedIndex 89 | ].value, 90 | 1, 91 | theDocument.forms[0].elements[6].options[ 92 | theDocument.forms[0].elements[6].selectedIndex 93 | ].value, 94 | enteredNumber 95 | ); 96 | //rf 3 97 | writeOrfs( 98 | newDna, 99 | geneticCode, 100 | theDocument.forms[0].elements[4].options[ 101 | theDocument.forms[0].elements[4].selectedIndex 102 | ].value, 103 | 2, 104 | theDocument.forms[0].elements[6].options[ 105 | theDocument.forms[0].elements[6].selectedIndex 106 | ].value, 107 | enteredNumber 108 | ); 109 | } else { 110 | writeOrfs( 111 | newDna, 112 | geneticCode, 113 | theDocument.forms[0].elements[4].options[ 114 | theDocument.forms[0].elements[4].selectedIndex 115 | ].value, 116 | theDocument.forms[0].elements[5].options[ 117 | theDocument.forms[0].elements[5].selectedIndex 118 | ].value, 119 | theDocument.forms[0].elements[6].options[ 120 | theDocument.forms[0].elements[6].selectedIndex 121 | ].value, 122 | enteredNumber 123 | ); 124 | } 125 | 126 | closePre(); 127 | closeWindow(); 128 | return true; 129 | } 130 | 131 | function writeOrfs( 132 | dnaSequence, 133 | geneticCode, 134 | startCodons, 135 | startPos, 136 | strand, 137 | theLength 138 | ) { 139 | var i = 0; 140 | var k = 0; 141 | var codon = ""; 142 | var foundStart = false; 143 | var geneticCodeMatchExp = getGeneticCodeMatchExp(geneticCode); 144 | var geneticCodeMatchResult = getGeneticCodeMatchResult(geneticCode); 145 | var proteinLength = 0; 146 | var foundStop = false; 147 | 148 | var geneticCodeMatchExpStop; 149 | for (var j = 0; j < geneticCodeMatchExp.length; j++) { 150 | if (geneticCodeMatchResult[j] == "*") { 151 | geneticCodeMatchExpStop = geneticCodeMatchExp[j]; 152 | break; 153 | } 154 | } 155 | 156 | var startRe = new RegExp(startCodons, "i"); 157 | var sequenceToTranslate; 158 | 159 | startPos = parseInt(startPos); 160 | var rf = startPos + 1; 161 | theLength = parseInt(theLength); 162 | 163 | if (strand == "reverse") { 164 | dnaSequence = reverse(complement(dnaSequence)); 165 | } 166 | 167 | while (i <= dnaSequence.length - 3) { 168 | for (var i = startPos; i <= dnaSequence.length - 3; i = i + 3) { 169 | codon = dnaSequence.substring(i, i + 3); 170 | if ( 171 | startCodons != "any" && 172 | foundStart == false && 173 | codon.search(startRe) == -1 174 | ) { 175 | break; 176 | } 177 | foundStart = true; 178 | 179 | if (codon.search(geneticCodeMatchExpStop) != -1) { 180 | foundStop = true; 181 | } 182 | 183 | proteinLength++; 184 | 185 | if (foundStop && proteinLength < theLength) { 186 | break; 187 | } 188 | if ( 189 | (foundStop && proteinLength >= theLength) || 190 | (i >= dnaSequence.length - 5 && proteinLength >= theLength) 191 | ) { 192 | sequenceToTranslate = dnaSequence.substring(startPos, i + 3); 193 | 194 | outputWindow.document.write( 195 | ">ORF number " + 196 | (k + 1) + 197 | " in reading frame " + 198 | rf + 199 | " on the " + 200 | strand + 201 | " strand extends from base " + 202 | (startPos + 1) + 203 | " to base " + 204 | (i + 3) + 205 | ".\n" 206 | ); 207 | 208 | outputWindow.document.write(addReturns(sequenceToTranslate) + "\n\n"); 209 | 210 | outputWindow.document.write( 211 | ">Translation of ORF number " + 212 | (k + 1) + 213 | " in reading frame " + 214 | rf + 215 | " on the " + 216 | strand + 217 | " strand.\n" 218 | ); 219 | 220 | sequenceToTranslate = sequenceToTranslate.replace(/(...)/g, function ( 221 | str, 222 | p1, 223 | offset, 224 | s 225 | ) { 226 | return " " + p1 + " "; 227 | }); 228 | 229 | for (var m = 0; m < geneticCodeMatchExp.length; m++) { 230 | sequenceToTranslate = sequenceToTranslate.replace( 231 | geneticCodeMatchExp[m], 232 | geneticCodeMatchResult[m] 233 | ); 234 | } 235 | sequenceToTranslate = sequenceToTranslate.replace(/\S{3}/g, "X"); 236 | sequenceToTranslate = sequenceToTranslate.replace(/\s/g, ""); 237 | sequenceToTranslate = sequenceToTranslate.replace(/[a-z]/g, ""); 238 | outputWindow.document.write(addReturns(sequenceToTranslate) + "\n\n"); 239 | 240 | k = k + 1; 241 | break; 242 | } 243 | } 244 | startPos = i + 3; 245 | i = startPos; 246 | foundStart = false; 247 | foundStop = false; 248 | proteinLength = 0; 249 | } 250 | if (k == 0) { 251 | outputWindow.document.write( 252 | "No ORFs were found in reading frame " + rf + ".\n\n" 253 | ); 254 | } 255 | return true; 256 | } 257 | -------------------------------------------------------------------------------- /docs/scripts/pairwise_align_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function pairwiseAlignDna(theDocument) { 23 | //var MATCH_SCORE = 2; 24 | //var MISMATCH_SCORE = -1; 25 | //var GAP_PENALTY = 2; 26 | 27 | //var BEGIN_GAP_PENALTY = 0; 28 | //var END_GAP_PENALTY = 0; 29 | 30 | var newDnaOne = ""; 31 | var titleOne = ""; 32 | 33 | var newDnaTwo = ""; 34 | var titleTwo = ""; 35 | 36 | var maxInput = 20000; 37 | 38 | if (testScript() == false) { 39 | return false; 40 | } 41 | 42 | if ( 43 | checkFormElement(theDocument.forms[0].elements[0]) == false || 44 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 45 | false || 46 | checkFormElement(theDocument.forms[0].elements[1]) == false || 47 | checkSequenceLength(theDocument.forms[0].elements[1].value, maxInput) == 48 | false 49 | ) { 50 | return false; 51 | } 52 | 53 | var MATCH_SCORE = parseInt( 54 | theDocument.forms[0].elements[5].options[ 55 | theDocument.forms[0].elements[5].selectedIndex 56 | ].value 57 | ); 58 | var MISMATCH_SCORE = parseInt( 59 | theDocument.forms[0].elements[6].options[ 60 | theDocument.forms[0].elements[6].selectedIndex 61 | ].value 62 | ); 63 | var BEGIN_GAP_PENALTY = parseInt( 64 | theDocument.forms[0].elements[7].options[ 65 | theDocument.forms[0].elements[7].selectedIndex 66 | ].value 67 | ); 68 | var GAP_PENALTY = parseInt( 69 | theDocument.forms[0].elements[8].options[ 70 | theDocument.forms[0].elements[8].selectedIndex 71 | ].value 72 | ); 73 | var END_GAP_PENALTY = parseInt( 74 | theDocument.forms[0].elements[9].options[ 75 | theDocument.forms[0].elements[9].selectedIndex 76 | ].value 77 | ); 78 | 79 | openWindow("Pairwise Align DNA"); 80 | openPre(); 81 | 82 | newDnaOne = getSequenceFromFasta(theDocument.forms[0].elements[0].value); 83 | newDnaOne = removeNonDna(newDnaOne); 84 | titleOne = getTitleFromFasta(theDocument.forms[0].elements[0].value); 85 | 86 | newDnaTwo = getSequenceFromFasta(theDocument.forms[0].elements[1].value); 87 | newDnaTwo = removeNonDna(newDnaTwo); 88 | titleTwo = getTitleFromFasta(theDocument.forms[0].elements[1].value); 89 | 90 | outputWindow.document.write( 91 | getPairwiseAlignTitle(titleOne, newDnaOne, titleTwo, newDnaTwo) 92 | ); 93 | 94 | //change to arrays for pass by reference, so that large sequence isn't copied 95 | if (newDnaOne.search(/./) != -1) { 96 | newDnaOne = newDnaOne.match(/./g); 97 | } 98 | 99 | if (newDnaTwo.search(/./) != -1) { 100 | newDnaTwo = newDnaTwo.match(/./g); 101 | } 102 | 103 | pairwiseDna( 104 | titleOne, 105 | newDnaOne, 106 | titleTwo, 107 | newDnaTwo, 108 | MATCH_SCORE, 109 | MISMATCH_SCORE, 110 | GAP_PENALTY, 111 | BEGIN_GAP_PENALTY, 112 | END_GAP_PENALTY 113 | ); 114 | closePre(); 115 | closeWindow(); 116 | return true; 117 | } 118 | 119 | function pairwiseDna( 120 | titleOne, 121 | newDnaOne, 122 | titleTwo, 123 | newDnaTwo, 124 | matchScore, 125 | mismatchScore, 126 | gapPenalty, 127 | beginGapPenalty, 128 | endGapPenalty 129 | ) { 130 | //can use one or both. 131 | //can compare scores (should be identical) 132 | var useLinearSpace = true; 133 | var useQuadraticSpace = false; 134 | 135 | var matrix = new Identity(); 136 | matrix.setMatch(matchScore); 137 | matrix.setMismatch(mismatchScore); 138 | 139 | var scoreSet = new ScoreSet(); 140 | scoreSet.setScoreSetParam(matrix, gapPenalty, beginGapPenalty, endGapPenalty); 141 | 142 | var alignment; 143 | 144 | if (useLinearSpace) { 145 | alignment = new AlignPairLinear(); 146 | alignment.setAlignParam(newDnaOne, newDnaTwo, scoreSet); 147 | alignment.align(); 148 | 149 | outputWindow.document.write(">" + titleOne + "\n"); 150 | outputWindow.document.write(addReturns(alignment.getAlignedM())); 151 | outputWindow.document.write("\n"); 152 | outputWindow.document.write("\n"); 153 | outputWindow.document.write(">" + titleTwo + "\n"); 154 | outputWindow.document.write(addReturns(alignment.getAlignedN())); 155 | outputWindow.document.write("\n\n"); 156 | outputWindow.document.write("Alignment score: " + alignment.score + "\n\n"); 157 | } 158 | 159 | if (useQuadraticSpace) { 160 | alignment = new AlignPairQuad(); 161 | alignment.initializeMatrix(newDnaOne, newDnaTwo, scoreSet); 162 | alignment.fillMatrix(); 163 | //alignment.dumpMatrix(); 164 | alignment.align(); 165 | 166 | outputWindow.document.write(">" + titleOne + "\n"); 167 | outputWindow.document.write(addReturns(alignment.getAlignedM())); 168 | outputWindow.document.write("\n"); 169 | outputWindow.document.write("\n"); 170 | outputWindow.document.write(">" + titleTwo + "\n"); 171 | outputWindow.document.write(addReturns(alignment.getAlignedN())); 172 | outputWindow.document.write("\n\n"); 173 | outputWindow.document.write("Alignment score: " + alignment.score + "\n\n"); 174 | } 175 | } 176 | 177 | //------------------------------------ ScoreSet class 178 | 179 | //ScoreSet getScore 180 | function getScore(r1, r2) { 181 | return this.scoringMatrix.scoringMatrix_getScore(r1, r2); 182 | } 183 | 184 | //ScoreSet setScoreSetParam 185 | function setScoreSetParam( 186 | scoringMatrix, 187 | gapPenalty, 188 | beginGapPenalty, 189 | endGapPenalty 190 | ) { 191 | this.scoringMatrix = scoringMatrix; 192 | this.gap = gapPenalty; 193 | this.beginGap = beginGapPenalty; 194 | this.endGap = endGapPenalty; 195 | } 196 | 197 | //ScoreSet class 198 | function ScoreSet() { 199 | this.scoringMatrix; 200 | this.gap; 201 | this.beginGap; 202 | this.endGap; 203 | this.useBeginGapTop = true; 204 | this.useBeginGapLeft = true; 205 | this.useEndGapBottom = true; 206 | this.useEndGapRight = true; 207 | } 208 | 209 | //create and throw away a prototype object 210 | new ScoreSet(); 211 | 212 | //define object methods 213 | ScoreSet.prototype.getScore = getScore; 214 | ScoreSet.prototype.setScoreSetParam = setScoreSetParam; 215 | 216 | //------------------------------------ 217 | 218 | //------------------------------------ ScoringMatrix abstract class 219 | //ScoringMatrix getScore method 220 | function scoringMatrix_getScore(r1, r2) { 221 | r1 = r1.toLowerCase(); 222 | r2 = r2.toLowerCase(); 223 | if (r1 == r2) { 224 | return this.match; 225 | } else { 226 | return this.mismatch; 227 | } 228 | } 229 | 230 | //ScoringMatrix class 231 | function ScoringMatrix() { 232 | this.mismatch; 233 | this.match; 234 | } 235 | 236 | //create and throw away a prototype object 237 | new ScoringMatrix(); 238 | 239 | //define object methods 240 | ScoringMatrix.prototype.scoringMatrix_getScore = scoringMatrix_getScore; 241 | 242 | //------------------------------------ Identity class extends ScoringMatrix Class 243 | //Identity class setMismatch method 244 | function setMismatch(mismatchScore) { 245 | this.mismatch = mismatchScore; 246 | } 247 | 248 | //Identity class setMatch method 249 | function setMatch(matchScore) { 250 | this.match = matchScore; 251 | } 252 | 253 | //Identity class 254 | function Identity() {} 255 | 256 | Identity.prototype = new ScoringMatrix(); 257 | Identity.prototype.setMismatch = setMismatch; 258 | Identity.prototype.setMatch = setMatch; 259 | -------------------------------------------------------------------------------- /docs/scripts/protein_gravy.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function proteinGravy(theDocument) { 23 | var newProtein = ""; 24 | var title = ""; 25 | var maxInput = 500000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | openWindow("Protein GRAVY"); 40 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 41 | 42 | for (var i = 0; i < arrayOfFasta.length; i++) { 43 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 44 | 45 | title = getTitleFromFasta(arrayOfFasta[i]); 46 | 47 | newProtein = removeNonProtein(newProtein); 48 | 49 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newProtein)); 50 | 51 | outputWindow.document.write(getProteinGravy(newProtein)); 52 | 53 | outputWindow.document.write("
\n
\n"); 54 | } 55 | 56 | closeWindow(); 57 | return true; 58 | } 59 | 60 | function getProteinGravy(sequence) { 61 | sequence = sequence.toLowerCase(); 62 | var gravyResult = 0; 63 | //The GRAVY value for a peptide or protein is calculated as the sum of hydropathy values [9] 64 | //of all the amino acids, divided by the number of residues in the sequence. 65 | var gravyValues = _getGravyHash(); 66 | for (var i = 0; i < sequence.length; i++) { 67 | gravyResult = gravyResult + gravyValues[sequence.charAt(i)]; 68 | } 69 | if (sequence.length > 0) { 70 | gravyResult = gravyResult / sequence.length; 71 | } else { 72 | return "The sequence is too short"; 73 | } 74 | return gravyResult.toFixed(3); 75 | } 76 | 77 | function _getGravyHash() { 78 | //Author(s): Kyte J., Doolittle R.F. 79 | //Reference: J. Mol. Biol. 157:105-132(1982). 80 | var hash = {}; 81 | hash["a"] = 1.8; 82 | hash["r"] = -4.5; 83 | hash["n"] = -3.5; 84 | hash["d"] = -3.5; 85 | hash["c"] = 2.5; 86 | hash["q"] = -3.5; 87 | hash["e"] = -3.5; 88 | hash["g"] = -0.4; 89 | hash["h"] = -3.2; 90 | hash["i"] = 4.5; 91 | hash["l"] = 3.8; 92 | hash["k"] = -3.9; 93 | hash["m"] = 1.9; 94 | hash["f"] = 2.8; 95 | hash["p"] = -1.6; 96 | hash["s"] = -0.8; 97 | hash["t"] = -0.7; 98 | hash["w"] = -0.9; 99 | hash["y"] = -1.3; 100 | hash["v"] = 4.2; 101 | return hash; 102 | } 103 | -------------------------------------------------------------------------------- /docs/scripts/protein_iep.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function proteinIep(theDocument) { 23 | var newProtein = ""; 24 | var maxInput = 200000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 33 | false 34 | ) { 35 | return false; 36 | } 37 | 38 | openWindow("Protein Isoelectric Point"); 39 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 40 | 41 | for (var i = 0; i < arrayOfFasta.length; i++) { 42 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 43 | title = getTitleFromFasta(arrayOfFasta[i]); 44 | newProtein = removeNonProteinStrict(newProtein); 45 | 46 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newProtein)); 47 | 48 | writeProtIep( 49 | newProtein, 50 | theDocument.forms[0].elements[4].options[ 51 | theDocument.forms[0].elements[4].selectedIndex 52 | ].value, 53 | theDocument.forms[0].elements[5].options[ 54 | theDocument.forms[0].elements[5].selectedIndex 55 | ].value, 56 | theDocument.forms[0].elements[6].options[ 57 | theDocument.forms[0].elements[6].selectedIndex 58 | ].value 59 | ); 60 | 61 | outputWindow.document.write("
\n
\n"); 62 | } 63 | closeWindow(); 64 | return true; 65 | } 66 | 67 | function writeProtIep(proteinSequence, copies, fusion, pKSet) { 68 | //calculates pI of protein. 69 | var pH = 7.0; 70 | var step = 3.5; 71 | var charge = 0.0; 72 | var last_charge = 0.0; 73 | 74 | copies = parseInt(copies); 75 | for (var j = 0; j < copies; j++) { 76 | proteinSequence = proteinSequence + fusion; 77 | } 78 | 79 | var N_term_pK; 80 | var K_pK; 81 | var R_pK; 82 | var H_pK; 83 | var D_pK; 84 | var E_pK; 85 | var C_pK; 86 | var Y_pK; 87 | var C_term_pK; 88 | 89 | if (pKSet.toLowerCase() == "dtaselect") { 90 | //pK values from DTASelect 91 | N_term_pK = 8.0; 92 | K_pK = 10.0; 93 | R_pK = 12.0; 94 | H_pK = 6.5; 95 | D_pK = 4.4; 96 | E_pK = 4.4; 97 | C_pK = 8.5; 98 | Y_pK = 10.0; 99 | C_term_pK = 3.1; 100 | } else { 101 | //pK values from EMBOSS 102 | N_term_pK = 8.6; 103 | K_pK = 10.8; 104 | R_pK = 12.5; 105 | H_pK = 6.5; 106 | D_pK = 3.9; 107 | E_pK = 4.1; 108 | C_pK = 8.5; 109 | Y_pK = 10.1; 110 | C_term_pK = 3.6; 111 | } 112 | 113 | var K_count = 0; 114 | if (proteinSequence.search(/k/i) != -1) { 115 | K_count = proteinSequence.match(/k/gi).length; 116 | } 117 | 118 | var R_count = 0; 119 | if (proteinSequence.search(/r/i) != -1) { 120 | R_count = proteinSequence.match(/r/gi).length; 121 | } 122 | 123 | var H_count = 0; 124 | if (proteinSequence.search(/h/i) != -1) { 125 | H_count = proteinSequence.match(/h/gi).length; 126 | } 127 | 128 | var D_count = 0; 129 | if (proteinSequence.search(/d/i) != -1) { 130 | D_count = proteinSequence.match(/d/gi).length; 131 | } 132 | 133 | var E_count = 0; 134 | if (proteinSequence.search(/e/i) != -1) { 135 | E_count = proteinSequence.match(/e/gi).length; 136 | } 137 | 138 | var C_count = 0; 139 | if (proteinSequence.search(/c/i) != -1) { 140 | C_count = proteinSequence.match(/c/gi).length; 141 | } 142 | 143 | var Y_count = 0; 144 | if (proteinSequence.search(/y/i) != -1) { 145 | Y_count = proteinSequence.match(/y/gi).length; 146 | } 147 | 148 | while (1) { 149 | charge = 150 | partial_charge(N_term_pK, pH) + 151 | K_count * partial_charge(K_pK, pH) + 152 | R_count * partial_charge(R_pK, pH) + 153 | H_count * partial_charge(H_pK, pH) - 154 | D_count * partial_charge(pH, D_pK) - 155 | E_count * partial_charge(pH, E_pK) - 156 | C_count * partial_charge(pH, C_pK) - 157 | Y_count * partial_charge(pH, Y_pK) - 158 | partial_charge(pH, C_term_pK); 159 | 160 | if (charge.toFixed(2) == (last_charge * 100).toFixed(2)) { 161 | break; 162 | } 163 | 164 | if (charge > 0) { 165 | pH = pH + step; 166 | } else { 167 | pH = pH - step; 168 | } 169 | 170 | step = step / 2; 171 | 172 | last_charge = charge; 173 | } 174 | 175 | pH = pH.toFixed(2); 176 | outputWindow.document.write("pH " + pH); 177 | 178 | return true; 179 | } 180 | 181 | function partial_charge(first, second) { 182 | var charge = Math.pow(10, first - second); 183 | return charge / (charge + 1); 184 | } 185 | -------------------------------------------------------------------------------- /docs/scripts/protein_mw.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function proteinMw(theDocument) { 23 | var newProtein = ""; 24 | var maxInput = 200000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 33 | false 34 | ) { 35 | return false; 36 | } 37 | 38 | //the weights below have water subtracted 39 | var arrayOfMw = [ 40 | "/A/ (A)71.08", 41 | "/C/ (C)103.14", 42 | "/D/ (D)115.09", 43 | "/E/ (E)129.12", 44 | " /F/ (F)147.18", 45 | "/G/ (G)57.06", 46 | "/H/ (H)137.15", 47 | "/I/ (I)113.17", 48 | "/K/ (K)128.18", 49 | "/L/ (L)113.17", 50 | "/M/ (M)131.21", 51 | "/N/ (N)114.11", 52 | "/P/ (P)97.12", 53 | "/Q/ (Q)128.41", 54 | "/R/ (R)156.20", 55 | "/S/ (S)87.08", 56 | "/T/ (T)101.11", 57 | "/V/ (V)99.14", 58 | "/W/ (W)186.21", 59 | "/Y/ (Y)163.18", 60 | ]; 61 | 62 | openWindow("Protein Molecular Weight"); 63 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 64 | 65 | for (var i = 0; i < arrayOfFasta.length; i++) { 66 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 67 | title = getTitleFromFasta(arrayOfFasta[i]); 68 | newProtein = removeNonProteinStrict(newProtein); 69 | 70 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newProtein)); 71 | 72 | writeProtMw( 73 | newProtein, 74 | arrayOfMw, 75 | theDocument.forms[0].elements[4].options[ 76 | theDocument.forms[0].elements[4].selectedIndex 77 | ].value, 78 | theDocument.forms[0].elements[5].options[ 79 | theDocument.forms[0].elements[5].selectedIndex 80 | ].value 81 | ); 82 | 83 | outputWindow.document.write("
\n
\n"); 84 | } 85 | closeWindow(); 86 | return true; 87 | } 88 | 89 | function writeProtMw(proteinSequence, arrayOfMw, copies, fusion) { 90 | //calculates molecular weight of protein. 91 | var water = 18.015; 92 | var result = 0; 93 | copies = parseInt(copies); 94 | for (var j = 0; j < copies; j++) { 95 | proteinSequence = proteinSequence + fusion; 96 | } 97 | for (var j = 0; j < arrayOfMw.length; j++) { 98 | var tempNumber = 0; 99 | var matchExp = arrayOfMw[j].match(/\/[^\/]+\//) + "gi"; 100 | matchExp = eval(matchExp); 101 | if (proteinSequence.search(matchExp) != -1) { 102 | tempNumber = proteinSequence.match(matchExp).length; 103 | } 104 | result = 105 | result + 106 | tempNumber * parseFloat(arrayOfMw[j].match(/[\d\.]+/).toString()); 107 | } 108 | 109 | if (result == 0) { 110 | outputWindow.document.write(result + " kDa"); 111 | } else { 112 | result = result + water; //add the weight of water for the ends of the protein. 113 | result = result / 1000; //convert to kilodaltons. 114 | result = result.toFixed(2); 115 | outputWindow.document.write(result + " kDa"); 116 | } 117 | return true; 118 | } 119 | -------------------------------------------------------------------------------- /docs/scripts/protein_pattern.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function proteinPattern(theDocument) { 23 | var newProtein = ""; 24 | var maxInput = 500000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | var re; 31 | var matches = new Array(); 32 | 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 36 | false || 37 | checkFormElement(theDocument.forms[0].elements[1]) == false 38 | ) { 39 | return false; 40 | } 41 | 42 | var re = 43 | "/" + theDocument.forms[0].elements[1].value.replace(/\//g, "") + "/gi"; 44 | re = removeWhiteSpace(re); 45 | try { 46 | re = eval(re); 47 | var testString = "teststring"; 48 | testString = testString.replace(re, ""); 49 | } catch (e) { 50 | alert("The regular expression is not formatted correctly."); 51 | return false; 52 | } 53 | 54 | openWindow("Protein Pattern Find"); 55 | openPre(); 56 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 57 | 58 | for (var i = 0; i < arrayOfFasta.length; i++) { 59 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 60 | title = getTitleFromFasta(arrayOfFasta[i]); 61 | newProtein = removeNonProteinStrict(newProtein); 62 | 63 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newProtein)); 64 | 65 | writeProteinPattern(newProtein, re); 66 | 67 | outputWindow.document.write("\n\n"); 68 | } 69 | 70 | closePre(); 71 | closeWindow(); 72 | return true; 73 | } 74 | 75 | function writeProteinPattern(proteinSequence, re) { 76 | var matchArray; 77 | var matchPosition; 78 | var matchCount = 0; 79 | var simplePattern = re.toString(); 80 | simplePattern = simplePattern.replace(/\/gi$|\/ig$|^\//gi, ""); 81 | 82 | while ((matchArray = re.exec(proteinSequence))) { 83 | matchCount++; 84 | 85 | var match_end = re.lastIndex; 86 | var match_start = match_end - RegExp.lastMatch.length + 1; 87 | 88 | outputWindow.document.write( 89 | ">match number " + 90 | matchCount + 91 | ' to "' + 92 | simplePattern + 93 | '" start=' + 94 | match_start + 95 | " end=" + 96 | match_end + 97 | "\n" + 98 | addReturns(matchArray[0]) + 99 | "\n\n" 100 | ); 101 | 102 | re.lastIndex = re.lastIndex - RegExp.lastMatch.length + 1; 103 | } 104 | if (!(matchCount > 0)) { 105 | outputWindow.document.write("no matches found for this sequence.\n\n"); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /docs/scripts/protein_stats.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function proteinStats(theDocument) { 23 | var newProtein = ""; 24 | var title = ""; 25 | var maxInput = 500000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | var itemsToCheck = [ 40 | "/A/ (A)1", 41 | "/B/ (B)1", 42 | "/C/ (C)1", 43 | "/D/ (D)1", 44 | "/E/ (E)1", 45 | "/F/ (F)1", 46 | "/G/ (G)1", 47 | "/H/ (H)1", 48 | "/I/ (I)1", 49 | "/K/ (K)1", 50 | "/L/ (L)1", 51 | "/M/ (M)1", 52 | "/N/ (N)1", 53 | "/P/ (P)1", 54 | "/Q/ (Q)1", 55 | "/R/ (R)1", 56 | "/S/ (S)1", 57 | "/T/ (T)1", 58 | "/V/ (V)1", 59 | "/W/ (W)1", 60 | "/X/ (X)1", 61 | "/Y/ (Y)1", 62 | "/Z/ (Z)1", 63 | "/[GAVLI]/ (Aliphatic G,A,V,L,I)1", 64 | "/[FWY]/ (Aromatic F,W,Y)1", 65 | "/[CM]/ (Sulphur C,M)1", 66 | "/[KRH]/ (Basic K,R,H)1", 67 | "/[BDENQZ]/ (Acidic B,D,E,N,Q,Z)1", 68 | "/[ST]/ (Aliphatic hydroxyl S,T)1", 69 | "/[ZEQRCMVILYW]/ (tRNA synthetase class I Z,E,Q,R,C,M,V,I,L,Y,W)1", 70 | "/[BGAPSTHDNKF]/ (tRNA synthetase class II B,G,A,P,S,T,H,D,N,K,F)1", 71 | ]; 72 | 73 | openWindow("Protein Stats"); 74 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 75 | 76 | for (var i = 0; i < arrayOfFasta.length; i++) { 77 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 78 | 79 | title = getTitleFromFasta(arrayOfFasta[i]); 80 | 81 | newProtein = removeNonProteinAllowDegen(newProtein); 82 | 83 | outputWindow.document.write(getInfoFromTitleAndSequence(title, newProtein)); 84 | 85 | writeSequenceStats(newProtein, itemsToCheck); 86 | 87 | outputWindow.document.write("
\n
\n"); 88 | } 89 | 90 | closeWindow(); 91 | return true; 92 | } 93 | -------------------------------------------------------------------------------- /docs/scripts/random_coding_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function randomCodingDna(theDocument) { 23 | var maxInput = 4000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | var enteredNumber = theDocument.forms[0].elements[0].value.replace( 30 | /[^\d]/g, 31 | "" 32 | ); 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | verifyMaxDigits(enteredNumber, maxInput) == false 36 | ) { 37 | return false; 38 | } 39 | 40 | var seqNum = parseInt( 41 | theDocument.forms[0].elements[5].options[ 42 | theDocument.forms[0].elements[5].selectedIndex 43 | ].value 44 | ); 45 | var geneticCode = getGeneticCodeString( 46 | theDocument.forms[0].elements[4].options[ 47 | theDocument.forms[0].elements[4].selectedIndex 48 | ].value 49 | ); 50 | geneticCode = geneticCode.split(/,/); 51 | var codonListSet = new GeneticCode(geneticCode); 52 | codonListSet.parseGeneticCodeArray(); 53 | 54 | openWindow("Random Coding DNA"); 55 | openPre(); 56 | for (var i = 1; i <= seqNum; i++) { 57 | outputWindow.document.write( 58 | ">" + 59 | "random coding sequence " + 60 | i + 61 | " consisting of " + 62 | enteredNumber * 3 + 63 | " bases.\n" 64 | ); 65 | writeRandomCodingDna( 66 | codonListSet.startCodons, 67 | codonListSet.stopCodons, 68 | codonListSet.codingCodons, 69 | enteredNumber 70 | ); 71 | outputWindow.document.write("\n"); 72 | } 73 | closePre(); 74 | closeWindow(); 75 | return true; 76 | } 77 | 78 | function writeRandomCodingDna( 79 | startCodons, 80 | stopCodons, 81 | codingCodons, 82 | lengthInCodons 83 | ) { 84 | var sequence = ""; 85 | var tempNum = 0; 86 | var tempChar = ""; 87 | 88 | lengthInCodons = parseInt(lengthInCodons); 89 | 90 | //add start codon 91 | if (lengthInCodons > 0) { 92 | tempNum = Math.round(Math.random() * startCodons.length); 93 | if (tempNum == startCodons.length) { 94 | tempNum = 0; 95 | } 96 | sequence = sequence + startCodons[tempNum]; 97 | } 98 | 99 | //add coding codons 100 | for (var j = 0; j < lengthInCodons - 2; j++) { 101 | tempNum = Math.round(Math.random() * codingCodons.length); 102 | if (tempNum == codingCodons.length) { 103 | tempNum = 0; 104 | } 105 | sequence = sequence + codingCodons[tempNum]; 106 | if (sequence.length == 60) { 107 | outputWindow.document.write(sequence + "\n"); 108 | sequence = ""; 109 | } 110 | } 111 | 112 | //add stop codon 113 | if (lengthInCodons > 1) { 114 | tempNum = Math.round(Math.random() * stopCodons.length); 115 | if (tempNum == stopCodons.length) { 116 | tempNum = 0; 117 | } 118 | sequence = sequence + stopCodons[tempNum]; 119 | } 120 | 121 | outputWindow.document.write(sequence + "\n"); 122 | return true; 123 | } 124 | 125 | //class GeneticCode method parseGeneticCodeArray() 126 | function parseGeneticCodeArray() { 127 | var codonSequence = 128 | "gggggaggtggcgaggaagatgacgtggtagttgtcgcggcagctgccaggagaagtagcaagaaaaataacatgataattatcacgacaactacctggtgatgttgctagtaatattacttgttatttttctcgtcatcttcccggcgacgtcgccagcaacatcacctgctacttctcccgccacctccc"; 129 | var proteinSequence; 130 | var geneticCodeMatchExp = getGeneticCodeMatchExp(this.geneticCodeArray); 131 | var geneticCodeMatchResult = getGeneticCodeMatchResult(this.geneticCodeArray); 132 | 133 | codonSequence = codonSequence.replace(/(...)/g, function ( 134 | str, 135 | p1, 136 | offset, 137 | s 138 | ) { 139 | return " " + p1 + " "; 140 | }); 141 | 142 | var codonSequenceCopy = codonSequence; 143 | 144 | for (var i = 0; i < geneticCodeMatchExp.length; i++) { 145 | codonSequence = codonSequence.replace( 146 | geneticCodeMatchExp[i], 147 | geneticCodeMatchResult[i] 148 | ); 149 | } 150 | var codonArray = codonSequenceCopy.split(/\s+/); 151 | 152 | codonSequence = codonSequence.replace(/\*/g, "Z"); 153 | var proteinArray = codonSequence.split(/\s+/); 154 | 155 | for (var i = 0; i < codonArray.length; i++) { 156 | //on some systems there will be empty items because of split function 157 | if (proteinArray[i] == "" && codonArray[i] == "") { 158 | continue; 159 | } 160 | if (proteinArray[i].toLowerCase() == "z") { 161 | this.stopCodons.push(codonArray[i]); 162 | } else if (proteinArray[i].toLowerCase() == "m") { 163 | this.startCodons.push(codonArray[i]); 164 | this.codingCodons.push(codonArray[i]); 165 | } else { 166 | this.codingCodons.push(codonArray[i]); 167 | } 168 | } 169 | } 170 | 171 | //class GeneticCode 172 | function GeneticCode(geneticCodeArray) { 173 | this.geneticCodeArray = geneticCodeArray; 174 | this.startCodons = new Array(); 175 | this.stopCodons = new Array(); 176 | //coding will include starts 177 | this.codingCodons = new Array(); 178 | } 179 | 180 | //create and throw away a prototype object 181 | new GeneticCode(); 182 | 183 | // define object methods 184 | GeneticCode.prototype.parseGeneticCodeArray = parseGeneticCodeArray; 185 | -------------------------------------------------------------------------------- /docs/scripts/random_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function randomDna(theDocument) { 23 | var maxInput = 10000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | var enteredNumber = theDocument.forms[0].elements[0].value.replace( 30 | /[^\d]/g, 31 | "" 32 | ); 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | verifyMaxDigits(enteredNumber, maxInput) == false 36 | ) { 37 | return false; 38 | } 39 | 40 | var seqNum = parseInt( 41 | theDocument.forms[0].elements[4].options[ 42 | theDocument.forms[0].elements[4].selectedIndex 43 | ].value 44 | ); 45 | openWindow("Random DNA Sequence"); 46 | openPre(); 47 | for (var i = 1; i <= seqNum; i++) { 48 | outputWindow.document.write( 49 | ">" + 50 | "random sequence " + 51 | i + 52 | " consisting of " + 53 | enteredNumber + 54 | " bases.\n" 55 | ); 56 | writeRandomSequence(["g", "a", "c", "t"], enteredNumber); 57 | outputWindow.document.write("\n"); 58 | } 59 | closePre(); 60 | closeWindow(); 61 | return true; 62 | } 63 | -------------------------------------------------------------------------------- /docs/scripts/random_dna_regions.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function randomDnaRegions(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 500000000; 26 | var matchFound = false; 27 | var ranges = new Array(); 28 | 29 | if (testScript() == false) { 30 | return false; 31 | } 32 | 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 36 | false || 37 | checkFormElement(theDocument.forms[0].elements[1]) == false 38 | ) { 39 | return false; 40 | } 41 | 42 | var arrayOfRanges = theDocument.forms[0].elements[1].value.split(/,/); 43 | var arrayOfStartAndEnd; 44 | for (var i = 0; i < arrayOfRanges.length; i++) { 45 | arrayOfStartAndEnd = arrayOfRanges[i].split(/\.\.|\-/); 46 | if ( 47 | arrayOfStartAndEnd.length == 1 && 48 | arrayOfStartAndEnd[0].search(/\d/) != -1 49 | ) { 50 | matchFound = true; 51 | ranges.push(new Range(arrayOfStartAndEnd[0], arrayOfStartAndEnd[0])); 52 | } else if ( 53 | arrayOfStartAndEnd.length == 2 && 54 | arrayOfStartAndEnd[0].search(/\d/) != -1 && 55 | arrayOfStartAndEnd[1].search(/\d/) != -1 56 | ) { 57 | matchFound = true; 58 | ranges.push(new Range(arrayOfStartAndEnd[0], arrayOfStartAndEnd[1])); 59 | } 60 | } 61 | if (matchFound == false) { 62 | alert("No ranges were entered."); 63 | return false; 64 | } 65 | 66 | openWindow("Random DNA Regions"); 67 | openPre(); 68 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 69 | 70 | for (var i = 0; i < arrayOfFasta.length; i++) { 71 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 72 | title = getTitleFromFasta(arrayOfFasta[i]); 73 | 74 | newDna = removeNonDna(newDna); 75 | 76 | outputWindow.document.write( 77 | getFastaTitleFromTitleAndSequence(title, newDna) 78 | ); 79 | 80 | writeSequenceRanges( 81 | newDna, 82 | ranges, 83 | "direct", 84 | theDocument.forms[0].elements[5].options[ 85 | theDocument.forms[0].elements[5].selectedIndex 86 | ].value 87 | ); 88 | 89 | outputWindow.document.write("\n\n"); 90 | } 91 | 92 | closePre(); 93 | closeWindow(); 94 | return true; 95 | } 96 | -------------------------------------------------------------------------------- /docs/scripts/random_protein.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function randomProtein(theDocument) { 23 | var maxInput = 10000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | var enteredNumber = theDocument.forms[0].elements[0].value.replace( 30 | /[^\d]/g, 31 | "" 32 | ); 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | verifyMaxDigits(enteredNumber, maxInput) == false 36 | ) { 37 | return false; 38 | } 39 | 40 | var seqNum = parseInt( 41 | theDocument.forms[0].elements[4].options[ 42 | theDocument.forms[0].elements[4].selectedIndex 43 | ].value 44 | ); 45 | openWindow("Random Protein Sequence"); 46 | openPre(); 47 | for (var i = 1; i <= seqNum; i++) { 48 | outputWindow.document.write( 49 | ">" + 50 | "random sequence " + 51 | i + 52 | " consisting of " + 53 | enteredNumber + 54 | " residues.\n" 55 | ); 56 | writeRandomSequence( 57 | [ 58 | "A", 59 | "C", 60 | "D", 61 | "E", 62 | "F", 63 | "G", 64 | "H", 65 | "I", 66 | "K", 67 | "L", 68 | "M", 69 | "N", 70 | "P", 71 | "Q", 72 | "R", 73 | "S", 74 | "T", 75 | "V", 76 | "W", 77 | "Y", 78 | ], 79 | enteredNumber 80 | ); 81 | outputWindow.document.write("\n"); 82 | } 83 | closePre(); 84 | closeWindow(); 85 | return true; 86 | } 87 | -------------------------------------------------------------------------------- /docs/scripts/random_protein_regions.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function randomProteinRegions(theDocument) { 23 | var newProtein = ""; 24 | var title = ""; 25 | var maxInput = 500000000; 26 | var matchFound = false; 27 | var ranges = new Array(); 28 | 29 | if (testScript() == false) { 30 | return false; 31 | } 32 | 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 36 | false || 37 | checkFormElement(theDocument.forms[0].elements[1]) == false 38 | ) { 39 | return false; 40 | } 41 | 42 | var arrayOfRanges = theDocument.forms[0].elements[1].value.split(/,/); 43 | var arrayOfStartAndEnd; 44 | for (var i = 0; i < arrayOfRanges.length; i++) { 45 | arrayOfStartAndEnd = arrayOfRanges[i].split(/\.\.|\-/); 46 | if ( 47 | arrayOfStartAndEnd.length == 1 && 48 | arrayOfStartAndEnd[0].search(/\d/) != -1 49 | ) { 50 | matchFound = true; 51 | ranges.push(new Range(arrayOfStartAndEnd[0], arrayOfStartAndEnd[0])); 52 | } else if ( 53 | arrayOfStartAndEnd.length == 2 && 54 | arrayOfStartAndEnd[0].search(/\d/) != -1 && 55 | arrayOfStartAndEnd[1].search(/\d/) != -1 56 | ) { 57 | matchFound = true; 58 | ranges.push(new Range(arrayOfStartAndEnd[0], arrayOfStartAndEnd[1])); 59 | } 60 | } 61 | if (matchFound == false) { 62 | alert("No ranges were entered."); 63 | return false; 64 | } 65 | 66 | openWindow("Random Protein Regions"); 67 | openPre(); 68 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 69 | 70 | for (var i = 0; i < arrayOfFasta.length; i++) { 71 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 72 | title = getTitleFromFasta(arrayOfFasta[i]); 73 | 74 | newProtein = removeNonProteinAllowDegen(newProtein); 75 | 76 | outputWindow.document.write( 77 | getFastaTitleFromTitleAndSequence(title, newProtein) 78 | ); 79 | 80 | writeSequenceRanges( 81 | newProtein, 82 | ranges, 83 | theDocument.forms[0].elements[5].options[ 84 | theDocument.forms[0].elements[5].selectedIndex 85 | ].value 86 | ); 87 | 88 | outputWindow.document.write("\n\n"); 89 | } 90 | 91 | closePre(); 92 | closeWindow(); 93 | return true; 94 | } 95 | -------------------------------------------------------------------------------- /docs/scripts/rest_summary.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function restSummary(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 100000000; 26 | 27 | var restrictionSites = getRestrictionSiteString("standard"); 28 | 29 | if ( 30 | checkFormElement(theDocument.forms[0].elements[0]) == false || 31 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 32 | false 33 | ) { 34 | return false; 35 | } 36 | 37 | itemsToCheck = restrictionSites.split(/,/); 38 | if (checkRestPatterns(itemsToCheck) == false) { 39 | return false; 40 | } 41 | 42 | openWindow("Restriction Summary"); 43 | //openPre(); 44 | outputWindow.document.write( 45 | '' + "cuts once" + "
\n" 46 | ); 47 | outputWindow.document.write( 48 | '' + "cuts twice" + "
\n" 49 | ); 50 | outputWindow.document.write("\n"); 51 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 52 | 53 | for (var i = 0; i < arrayOfFasta.length; i++) { 54 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 55 | title = getTitleFromFasta(arrayOfFasta[i]); 56 | 57 | newDna = removeNonDna(newDna); 58 | 59 | outputWindow.document.write( 60 | getInfoFromTitleAndSequenceAndTopology( 61 | title, 62 | newDna, 63 | theDocument.forms[0].elements[4].options[ 64 | theDocument.forms[0].elements[4].selectedIndex 65 | ].value 66 | ) 67 | ); 68 | 69 | writeRestrictionSites( 70 | newDna, 71 | itemsToCheck, 72 | theDocument.forms[0].elements[4].options[ 73 | theDocument.forms[0].elements[4].selectedIndex 74 | ].value 75 | ); 76 | 77 | outputWindow.document.write("
\n
\n"); 78 | } 79 | 80 | //closePre(); 81 | closeWindow(); 82 | return true; 83 | } 84 | -------------------------------------------------------------------------------- /docs/scripts/rev_comp.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function revComp(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 100000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | openWindow("Reverse Complement"); 40 | openPre(); 41 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 42 | 43 | for (var i = 0; i < arrayOfFasta.length; i++) { 44 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 45 | title = getTitleFromFasta(arrayOfFasta[i]); 46 | newDna = removeNonDna(newDna); 47 | 48 | //outputWindow.document.write(getInfoFromTitleAndSequence(title, newDna)); 49 | 50 | if ( 51 | theDocument.forms[0].elements[4].options[ 52 | theDocument.forms[0].elements[4].selectedIndex 53 | ].value == "reverse-complement" 54 | ) { 55 | outputWindow.document.write(">" + title + " reverse complement\n"); 56 | newDna = reverse(complement(newDna)); 57 | } else if ( 58 | theDocument.forms[0].elements[4].options[ 59 | theDocument.forms[0].elements[4].selectedIndex 60 | ].value == "reverse" 61 | ) { 62 | outputWindow.document.write(">" + title + " reverse\n"); 63 | newDna = reverse(newDna); 64 | } else if ( 65 | theDocument.forms[0].elements[4].options[ 66 | theDocument.forms[0].elements[4].selectedIndex 67 | ].value == "complement" 68 | ) { 69 | outputWindow.document.write(">" + title + " complement\n"); 70 | newDna = complement(newDna); 71 | } 72 | 73 | outputWindow.document.write(addReturns(newDna) + "\n\n"); 74 | } 75 | 76 | closePre(); 77 | closeWindow(); 78 | return true; 79 | } 80 | -------------------------------------------------------------------------------- /docs/scripts/sample_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function sampleDna(theDocument) { 23 | var maxInput = 10000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | var enteredNumber = theDocument.forms[0].elements[0].value.replace( 30 | /[^\d]/g, 31 | "" 32 | ); 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | verifyMaxDigits(enteredNumber, maxInput) == false || 36 | checkFormElement(theDocument.forms[0].elements[1]) == false || 37 | checkSequenceLength(theDocument.forms[0].elements[1].value, maxInput) == 38 | false 39 | ) { 40 | return false; 41 | } 42 | 43 | var seqNum = parseInt( 44 | theDocument.forms[0].elements[5].options[ 45 | theDocument.forms[0].elements[5].selectedIndex 46 | ].value 47 | ); 48 | 49 | var newDna = getSequenceFromFasta(theDocument.forms[0].elements[1].value); 50 | var title = getTitleFromFasta(theDocument.forms[0].elements[1].value); 51 | verifyDna(newDna); 52 | newDna = removeNonDna(newDna); 53 | 54 | var components = new Array(newDna.length); 55 | if (newDna.search(/./) != -1) { 56 | components = newDna.match(/./g); 57 | } 58 | 59 | openWindow("Sample DNA"); 60 | openPre(); 61 | for (var i = 1; i <= seqNum; i++) { 62 | outputWindow.document.write( 63 | ">" + 64 | "sampled sequence " + 65 | i + 66 | " consisting of " + 67 | enteredNumber + 68 | " bases.\n" 69 | ); 70 | writeRandomSequence(components, enteredNumber); 71 | outputWindow.document.write("\n"); 72 | } 73 | closePre(); 74 | closeWindow(); 75 | return true; 76 | } 77 | -------------------------------------------------------------------------------- /docs/scripts/sample_protein.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function sampleProtein(theDocument) { 23 | var maxInput = 100000000; 24 | 25 | if (testScript() == false) { 26 | return false; 27 | } 28 | 29 | var enteredNumber = theDocument.forms[0].elements[0].value.replace( 30 | /[^\d]/g, 31 | "" 32 | ); 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | verifyMaxDigits(enteredNumber, maxInput) == false || 36 | checkFormElement(theDocument.forms[0].elements[1]) == false || 37 | checkSequenceLength(theDocument.forms[0].elements[1].value, maxInput) == 38 | false 39 | ) { 40 | return false; 41 | } 42 | 43 | var seqNum = parseInt( 44 | theDocument.forms[0].elements[5].options[ 45 | theDocument.forms[0].elements[5].selectedIndex 46 | ].value 47 | ); 48 | 49 | var newProtein = getSequenceFromFasta(theDocument.forms[0].elements[1].value); 50 | var title = getTitleFromFasta(theDocument.forms[0].elements[1].value); 51 | newProtein = removeNonProteinAllowDegen(newProtein); 52 | 53 | var components = new Array(newProtein.length); 54 | if (newProtein.search(/./) != -1) { 55 | components = newProtein.match(/./g); 56 | } 57 | 58 | openWindow("Sample Protein"); 59 | openPre(); 60 | for (var i = 1; i <= seqNum; i++) { 61 | outputWindow.document.write( 62 | ">" + 63 | "sampled sequence " + 64 | i + 65 | " consisting of " + 66 | enteredNumber + 67 | " residues.\n" 68 | ); 69 | writeRandomSequence(components, enteredNumber); 70 | outputWindow.document.write("\n"); 71 | } 72 | closePre(); 73 | closeWindow(); 74 | return true; 75 | } 76 | -------------------------------------------------------------------------------- /docs/scripts/shuffle_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function shuffleDna(theDocument) { 23 | var newDna = ""; 24 | var title = ""; 25 | var maxInput = 300000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | openWindow("Shuffle DNA"); 40 | openPre(); 41 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 42 | 43 | for (var i = 0; i < arrayOfFasta.length; i++) { 44 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 45 | title = getTitleFromFasta(arrayOfFasta[i]); 46 | 47 | newDna = removeNonDna(newDna); 48 | 49 | outputWindow.document.write( 50 | getFastaTitleFromTitleAndSequence(title, newDna) 51 | ); 52 | 53 | writeShuffledSequence(newDna); 54 | 55 | outputWindow.document.write("\n\n"); 56 | } 57 | 58 | closePre(); 59 | closeWindow(); 60 | return true; 61 | } 62 | -------------------------------------------------------------------------------- /docs/scripts/shuffle_protein.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function shuffleProtein(theDocument) { 23 | var newProtein = ""; 24 | var title = ""; 25 | var maxInput = 300000000; 26 | 27 | if (testScript() == false) { 28 | return false; 29 | } 30 | 31 | if ( 32 | checkFormElement(theDocument.forms[0].elements[0]) == false || 33 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 34 | false 35 | ) { 36 | return false; 37 | } 38 | 39 | openWindow("Shuffle Protein"); 40 | openPre(); 41 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 42 | 43 | for (var i = 0; i < arrayOfFasta.length; i++) { 44 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 45 | title = getTitleFromFasta(arrayOfFasta[i]); 46 | 47 | newProtein = removeNonProteinAllowDegen(newProtein); 48 | 49 | outputWindow.document.write( 50 | getFastaTitleFromTitleAndSequence(title, newProtein) 51 | ); 52 | 53 | writeShuffledSequence(newProtein); 54 | 55 | outputWindow.document.write("\n\n"); 56 | } 57 | 58 | closePre(); 59 | closeWindow(); 60 | return true; 61 | } 62 | -------------------------------------------------------------------------------- /docs/scripts/sms_restriction_sites.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function getRestrictionSiteString(type) { 23 | if (type.toLowerCase() == "standard") { 24 | return ( 25 | "/aggcct/ (AatI agg|cct)3," + 26 | "/gacgtc/ (AatII gacgt|c)1," + 27 | "/tgcgca/ (Acc16I tgc|gca)3," + 28 | "/cgcg/ (AccII cg|cg)2," + 29 | "/tccgga/ (AccIII t|ccgga)5," + 30 | "/aacgtt/ (AclI aa|cgtt)4," + 31 | "/cacgtg/ (AcvI cac|gtg)3," + 32 | "/gtac/ (AfaI gt|ac)2," + 33 | "/agcgct/ (AfeI agc|gct)3," + 34 | "/cttaag/ (AflII c|ttaag)5," + 35 | "/accggt/ (AgeI a|ccggt)5," + 36 | "/actagt/ (AhlI a|ctagt)5," + 37 | "/gtgcac/ (Alw441 g|tgcac)5," + 38 | "/agct/ (AluI ag|ct)2," + 39 | "/agcgct/ (Aor51HI agc|gct)3," + 40 | "/gggccc/ (ApaI gggcc|c)1," + 41 | "/gtgcac/ (ApaLI g|tgcac)5," + 42 | "/ggcgcgcc/ (AscI gg|cgcgcc)6," + 43 | "/attaat/ (AseI at|taat)4," + 44 | "/ggtacc/ (Asp718I g|gtacc)5," + 45 | "/ttcgaa/ (AsuII tt|cgaa)4," + 46 | "/c[cty]cg[agr]g/ (AvaI c|ycgrg)5," + 47 | "/tgcgca/ (AviII tgc|gca)3," + 48 | "/cctagg/ (AvrII c|ctagg)5," + 49 | "/tggcca/ (BalI tgg|cca)3," + 50 | "/ggatcc/ (BamHI g|gatcc)5," + 51 | "/atcgat/ (BanIII at|cgat)4," + 52 | "/ggcgcc/ (BbeI ggcgc|c)1," + 53 | "/cacgtg/ (BbrPI cac|gtg)3," + 54 | "/gcatgc/ (BbuI gcatg|c)1," + 55 | "/actagt/ (BcuI a|ctagt)5," + 56 | "/tgatca/ (BclI t|gatca)5," + 57 | "/ctag/ (BfaI c|tag)3," + 58 | "/cttaag/ (BfrI c|ttaag)5," + 59 | "/atgcat/ (BfrBI atg|cat)3," + 60 | "/agatct/ (BglII a|gatct)5," + 61 | "/cctagg/ (BlnI c|ctagg)5," + 62 | "/atcgat/ (BseCI at|cgat)4," + 63 | "/gcgcgc/ (BsePI g|cgcgc)5," + 64 | "/cggccg/ (BseX3I c|ggccg)5," + 65 | "/accggt/ (BshTI a|ccggt)5," + 66 | "/tgtaca/ (Bsp1407I t|gtaca)5," + 67 | "/ccatgg/ (Bsp19I c|catgg)5," + 68 | "/atcgat/ (BspDI at|cgat)4," + 69 | "/tccgga/ (BspEI t|ccgga)5," + 70 | "/tgtaca/ (BsrGI t|gtaca)5," + 71 | "/gcgcgc/ (BssHII g|cgcgc)5," + 72 | "/cgcg/ (BstUI cg|cg)2," + 73 | "/atcgat/ (ClaI at|cgat)4," + 74 | "/gatc/ (DpnII |gatc)4," + 75 | "/tttaaa/ (DraI ttt|aaa)3," + 76 | "/cggccg/ (EagI c|ggccg)5," + 77 | "/gaattc/ (EcoRI g|aattc)5," + 78 | "/gatatc/ (EcoRV gat|atc)3," + 79 | "/ggcgcc/ (EgeI ggc|gcc)3," + 80 | "/ggccggcc/ (FseI ggccgg|cc)2," + 81 | "/tgcgca/ (FspI tgc|gca)3," + 82 | "/ggcc/ (HaeIII gg|cc)2," + 83 | "/gt[cty][agr]ac/ (HincII gty|rac)3," + 84 | "/aagctt/ (HindIII a|agctt)5," + 85 | "/ga[acgturyswkmbdhvn]tc/ (HinfI g|antc)4," + 86 | "/gttaac/ (HpaI gtt|aac)3," + 87 | "/ccgg/ (HpaII c|cgg)3," + 88 | "/ggcgcc/ (KasI g|gcgcc)5," + 89 | "/ggtacc/ (KpnI ggtac|c)1," + 90 | "/[acgturyswkmbdhvn]gatc[acgturyswkmbdhvn]/ (MboI |gatc)5," + 91 | "/caattg/ (MfeI c|aattg)5," + 92 | "/acgcgt/ (MluI a|cgcgt)5," + 93 | "/tggcca/ (MscI tgg|cca)3," + 94 | "/ttaa/ (MseI t|taa)3," + 95 | "/ccgg/ (MspI c|cgg)3," + 96 | "/gccggc/ (NaeI gcc|ggc)3," + 97 | "/ggcgcc/ (NarI gg|cgcc)4," + 98 | "/ccatgg/ (NcoI c|catgg)5," + 99 | "/catatg/ (NdeI ca|tatg)4," + 100 | "/gatc/ (NdeII |gatc)4," + 101 | "/gccggc/ (NgoMIV g|ccggc)5," + 102 | "/gctagc/ (NheI g|ctagc)5," + 103 | "/catg/ (NlaIII catg|)0," + 104 | "/gcggccgc/ (NotI gc|ggccgc)6," + 105 | "/tcgcga/ (NruI tcg|cga)3," + 106 | "/atgcat/ (NsiI atgca|t)1," + 107 | "/ttaattaa/ (PacI ttaat|taa)3," + 108 | "/acatgt/ (PciI a|catgt)5," + 109 | "/ggcc/ (PhoI gg|cc)2," + 110 | "/gtttaaac/ (PmeI gttt|aaac)4," + 111 | "/cacgtg/ (PmlI cac|gtg)3," + 112 | "/ttataa/ (PsiI tta|taa)3," + 113 | "/ctgcag/ (PstI ctgca|g)1," + 114 | "/cgatcg/ (PvuI cgat|cg)2," + 115 | "/cagctg/ (PvuII cag|ctg)3," + 116 | "/gtac/ (RsaI gt|ac)2," + 117 | "/gagctc/ (SacI gagct|c)1," + 118 | "/ccgcgg/ (SacII ccgc|gg)2," + 119 | "/gtcgac/ (SalI g|tcgac)5," + 120 | "/cctgcagg/ (SbfI cctgca|gg)2," + 121 | "/agtact/ (ScaI agt|act)3," + 122 | "/ggcgcc/ (SfoI ggc|gcc)3," + 123 | "/cccggg/ (SmaI ccc|ggg)3," + 124 | "/tacgta/ (SnaBI tac|gta)3," + 125 | "/actagt/ (SpeI a|ctagt)5," + 126 | "/gcatgc/ (SphI gcatg|c)1," + 127 | "/aatatt/ (SspI aat|att)3," + 128 | "/gagctc/ (SstI gagct|c)1," + 129 | "/ccgcgg/ (SstII ccgc|gg)2," + 130 | "/aggcct/ (StuI agg|cct)3," + 131 | "/atttaaat/ (SwaI attt|aaat)4," + 132 | "/tcga/ (TaqI t|cga)3," + 133 | "/ctcgag/ (TliI c|tcgag)5," + 134 | "/attaat/ (VspI at|taat)4," + 135 | "/tctaga/ (XbaI t|ctaga)5," + 136 | "/ctcgag/ (XhoI c|tcgag)5," + 137 | "/cccggg/ (XmaI c|ccggg)5" 138 | ); 139 | } 140 | 141 | return true; 142 | } 143 | -------------------------------------------------------------------------------- /docs/scripts/split_codons.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function splitCodons(theDocument) { 23 | var maxInput = 500000000; 24 | var sequences = new Array(); 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | openWindow("Split Codons"); 38 | openPre(); 39 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 40 | 41 | for (var i = 0; i < arrayOfFasta.length; i++) { 42 | var sequence = getSequenceFromFasta(arrayOfFasta[i]); 43 | sequence = removeFormatting(sequence); 44 | var title = getTitleFromFasta(arrayOfFasta[i]); 45 | 46 | if (sequence.length % 3 != 0) { 47 | alert( 48 | "Sequence '" + title + "' ends in a partial codon that will be removed." 49 | ); 50 | } 51 | 52 | var length = sequence.length; 53 | var seqCount = 1; 54 | 55 | var position1 = getBasesBasedOnCodonPosition(sequence, 1); 56 | outputWindow.document.write( 57 | ">" + 58 | title + 59 | ";codon_positon_1_bases;length=" + 60 | position1.length + 61 | ";source_length=" + 62 | length + 63 | "\n" + 64 | addReturns(position1) + 65 | "\n\n" 66 | ); 67 | 68 | var position2 = getBasesBasedOnCodonPosition(sequence, 2); 69 | outputWindow.document.write( 70 | ">" + 71 | title + 72 | ";codon_positon_2_bases;length=" + 73 | position2.length + 74 | ";source_length=" + 75 | length + 76 | "\n" + 77 | addReturns(position2) + 78 | "\n\n" 79 | ); 80 | 81 | var position3 = getBasesBasedOnCodonPosition(sequence, 3); 82 | outputWindow.document.write( 83 | ">" + 84 | title + 85 | ";codon_positon_3_bases;length=" + 86 | position3.length + 87 | ";source_length=" + 88 | length + 89 | "\n" + 90 | addReturns(position3) + 91 | "\n\n" 92 | ); 93 | 94 | seqCount++; 95 | } 96 | 97 | closePre(); 98 | closeWindow(); 99 | return true; 100 | } 101 | 102 | function getBasesBasedOnCodonPosition(sequence, position) { 103 | var re; 104 | if (position == 1) { 105 | re = "((.)..)"; 106 | } else if (position == 2) { 107 | re = "(.(.).)"; 108 | } else if (position == 3) { 109 | re = "(..(.))"; 110 | } 111 | 112 | //remove partial codon from the end 113 | var partial_codon_length = sequence.length % 3; 114 | sequence = sequence.replace( 115 | new RegExp(".{" + partial_codon_length + "}$"), 116 | "" 117 | ); 118 | 119 | return sequence.replace(new RegExp(re, "g"), function ( 120 | str, 121 | p1, 122 | p2, 123 | offset, 124 | s 125 | ) { 126 | return p2; 127 | }); 128 | } 129 | -------------------------------------------------------------------------------- /docs/scripts/split_fasta.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function splitFasta(theDocument) { 23 | var maxInput = 500000000; 24 | var sequences = new Array(); 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | var newLength = theDocument.forms[0].elements[1].value.replace(/[^\d]/g, ""); 31 | var overlap = theDocument.forms[0].elements[2].value.replace(/[^\d]/g, ""); 32 | 33 | if ( 34 | checkFormElement(theDocument.forms[0].elements[0]) == false || 35 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == 36 | false || 37 | verifyMaxDigits(newLength, maxInput) == false || 38 | verifyMaxDigits(overlap, maxInput) == false 39 | ) { 40 | return false; 41 | } 42 | 43 | newLength = parseInt(newLength); 44 | overlap = parseInt(overlap); 45 | 46 | openWindow("Split FASTA"); 47 | openPre(); 48 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 49 | 50 | for (var i = 0; i < arrayOfFasta.length; i++) { 51 | var sequence = getSequenceFromFasta(arrayOfFasta[i]); 52 | sequence = removeNonLetters(sequence); 53 | var title = getTitleFromFasta(arrayOfFasta[i]); 54 | var length = sequence.length; 55 | var seqCount = 1; 56 | 57 | for (var j = 0; j < length; j = j + newLength) { 58 | //if using overlap adjust j 59 | if (j > overlap) { 60 | j = j - overlap; 61 | } 62 | var subseq = sequence.substring(j, j + newLength); 63 | 64 | var subseq_length = subseq.length; 65 | var start = j + 1; 66 | var end = start + subseq_length - 1; 67 | outputWindow.document.write( 68 | ">fragment_" + 69 | seqCount + 70 | ";" + 71 | title + 72 | "_start=" + 73 | start + 74 | ";end=" + 75 | end + 76 | ";length=" + 77 | subseq_length + 78 | ";source_length=" + 79 | length + 80 | "\n" + 81 | addReturns(subseq) + 82 | "\n\n" 83 | ); 84 | seqCount++; 85 | } 86 | } 87 | 88 | closePre(); 89 | closeWindow(); 90 | return true; 91 | } 92 | -------------------------------------------------------------------------------- /docs/scripts/three_to_one.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function threeToOne(theDocument) { 23 | var newProtein = ""; 24 | var maxInput = 100000000; 25 | 26 | if (testScript() == false) { 27 | return false; 28 | } 29 | 30 | if ( 31 | checkFormElement(theDocument.forms[0].elements[0]) == false || 32 | checkTextLength(theDocument.forms[0].elements[0].value, maxInput) == false 33 | ) { 34 | return false; 35 | } 36 | 37 | openWindow("Three to One"); 38 | openPre(); 39 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 40 | 41 | for (var i = 0; i < arrayOfFasta.length; i++) { 42 | newProtein = getTripletSequenceFromFasta(arrayOfFasta[i]); 43 | title = getFastaTitleFromTriplets(arrayOfFasta[i]); 44 | newProtein = filterTriplets(newProtein); 45 | 46 | outputWindow.document.write( 47 | getInfoFromTitleAndSequenceTriplets(title, newProtein) 48 | ); 49 | 50 | writeThreeToOne(newProtein); 51 | 52 | outputWindow.document.write("\n\n"); 53 | } 54 | 55 | closePre(); 56 | closeWindow(); 57 | return true; 58 | } 59 | 60 | function writeThreeToOne(proteinSequence) { 61 | proteinSequence = proteinSequence.replace(/(.)(.)(.)/g, function ( 62 | str, 63 | p1, 64 | p2, 65 | p3, 66 | offset, 67 | s 68 | ) { 69 | return p1.toUpperCase() + p2.toLowerCase() + p3.toLowerCase(); 70 | }); 71 | proteinSequence = proteinSequence.replace(/Ala/g, " A "); 72 | proteinSequence = proteinSequence.replace(/Asx/g, " B "); 73 | proteinSequence = proteinSequence.replace(/Cys/g, " C "); 74 | proteinSequence = proteinSequence.replace(/Asp/g, " D "); 75 | proteinSequence = proteinSequence.replace(/Glu/g, " E "); 76 | proteinSequence = proteinSequence.replace(/Phe/g, " F "); 77 | proteinSequence = proteinSequence.replace(/Gly/g, " G "); 78 | proteinSequence = proteinSequence.replace(/His/g, " H "); 79 | proteinSequence = proteinSequence.replace(/Ile/g, " I "); 80 | proteinSequence = proteinSequence.replace(/Lys/g, " K "); 81 | proteinSequence = proteinSequence.replace(/Leu/g, " L "); 82 | proteinSequence = proteinSequence.replace(/Met/g, " M "); 83 | proteinSequence = proteinSequence.replace(/Asn/g, " N "); 84 | proteinSequence = proteinSequence.replace(/Pro/g, " P "); 85 | proteinSequence = proteinSequence.replace(/Gln/g, " Q "); 86 | proteinSequence = proteinSequence.replace(/Arg/g, " R "); 87 | proteinSequence = proteinSequence.replace(/Ser/g, " S "); 88 | proteinSequence = proteinSequence.replace(/Thr/g, " T "); 89 | proteinSequence = proteinSequence.replace(/Val/g, " V "); 90 | proteinSequence = proteinSequence.replace(/Trp/g, " W "); 91 | proteinSequence = proteinSequence.replace(/Xaa/g, " X "); 92 | proteinSequence = proteinSequence.replace(/Tyr/g, " Y "); 93 | proteinSequence = proteinSequence.replace(/Glx/g, " Z "); 94 | proteinSequence = proteinSequence.replace(/\*\*\*/g, " * "); 95 | 96 | proteinSequence = proteinSequence.replace(/\s/g, ""); 97 | 98 | outputWindow.document.write(addReturns(proteinSequence)); 99 | return true; 100 | } 101 | 102 | function filterTriplets(tripletSequence) { 103 | tripletSequence = tripletSequence.replace(/\s|\d/gi, ""); 104 | return tripletSequence; 105 | } 106 | 107 | function getFastaTitleFromTriplets(tripletSequence) { 108 | fastaSequenceTitle = "Untitled"; 109 | if (tripletSequence.search(/\>[^\f\n\r]+[\f\n\r]/) != -1) { 110 | fastaSequenceTitle = tripletSequence 111 | .match(/\>[^\f\n\r]+[\f\n\r]/, "") 112 | .toString(); 113 | fastaSequenceTitle = fastaSequenceTitle.replace(/\>|[\f\n\r]/g, ""); 114 | fastaSequenceTitle = filterFastaTitle(fastaSequenceTitle); 115 | } 116 | return fastaSequenceTitle; 117 | } 118 | 119 | function getTripletSequenceFromFasta(tripletSequence) { 120 | if (tripletSequence.search(/\>[^\f\n\r]+[\f\n\r]/) != -1) { 121 | tripletSequence = tripletSequence.replace(/\>[^\f\n\r]+[\f\n\r]/, ""); 122 | } 123 | return tripletSequence; 124 | } 125 | 126 | function getInfoFromTitleAndSequenceTriplets(fastaSequenceTitle, sequence) { 127 | var stringToReturn = ">results for sequence "; 128 | if (fastaSequenceTitle.search(/[^\s]/) != -1) { 129 | stringToReturn = stringToReturn + '"' + fastaSequenceTitle + '"'; 130 | } 131 | stringToReturn = 132 | stringToReturn + ' starting "' + sequence.substring(0, 12) + '"'; 133 | return stringToReturn + "\n"; 134 | } 135 | -------------------------------------------------------------------------------- /docs/scripts/translate.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function translateDna(theDocument) { 23 | translate(theDocument); 24 | return true; 25 | } 26 | 27 | function translate(theDocument) { 28 | var newDna = ""; 29 | var title = ""; 30 | var maxInput = 200000000; 31 | 32 | if (testScript() == false) { 33 | return false; 34 | } 35 | 36 | var geneticCode = getGeneticCodeString( 37 | theDocument.forms[0].elements[6].options[ 38 | theDocument.forms[0].elements[6].selectedIndex 39 | ].value 40 | ); 41 | 42 | if ( 43 | checkFormElement(theDocument.forms[0].elements[0]) == false || 44 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 45 | false 46 | ) { 47 | return false; 48 | } 49 | 50 | geneticCode = geneticCode.split(/,/); 51 | 52 | if (checkGeneticCode(geneticCode) == false) { 53 | return false; 54 | } 55 | 56 | var rfText = 57 | theDocument.forms[0].elements[4].options[ 58 | theDocument.forms[0].elements[4].selectedIndex 59 | ].value; 60 | if ( 61 | theDocument.forms[0].elements[4].options[ 62 | theDocument.forms[0].elements[4].selectedIndex 63 | ].value.match(/^\d+$/) 64 | ) { 65 | rfText++; 66 | } else { 67 | rfText = 68 | '"' + 69 | theDocument.forms[0].elements[4].options[ 70 | theDocument.forms[0].elements[4].selectedIndex 71 | ].value + 72 | '"'; 73 | } 74 | 75 | openWindow("Translate"); 76 | openPre(); 77 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 78 | for (var i = 0; i < arrayOfFasta.length; i++) { 79 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 80 | title = getTitleFromFasta(arrayOfFasta[i]); 81 | newDna = removeNonDna(newDna); 82 | outputWindow.document.write(">rf " + rfText + " " + title + "\n"); 83 | writeTranslation( 84 | newDna, 85 | geneticCode, 86 | theDocument.forms[0].elements[4].options[ 87 | theDocument.forms[0].elements[4].selectedIndex 88 | ].value, 89 | theDocument.forms[0].elements[5].options[ 90 | theDocument.forms[0].elements[5].selectedIndex 91 | ].value 92 | ); 93 | outputWindow.document.write("\n\n"); 94 | } 95 | closePre(); 96 | closeWindow(); 97 | return true; 98 | } 99 | 100 | function writeTranslation(dnaSequence, geneticCode, startPos, strand) { 101 | var geneticCodeMatchExp = getGeneticCodeMatchExp(geneticCode); 102 | var geneticCodeMatchResult = getGeneticCodeMatchResult(geneticCode); 103 | 104 | if (strand == "reverse") { 105 | dnaSequence = reverse(complement(dnaSequence)); 106 | } 107 | if (startPos == "uppercase") { 108 | dnaSequence = dnaSequence.replace(/[a-z]/g, ""); 109 | } else { 110 | dnaSequence = dnaSequence.substring(parseInt(startPos), dnaSequence.length); 111 | } 112 | 113 | //don't translate if fewer than three bases 114 | if (dnaSequence.replace(/[^A-Za-z]/g, "").length < 3) { 115 | return ""; 116 | } 117 | 118 | dnaSequence = dnaSequence.replace(/(...)/g, function (str, p1, offset, s) { 119 | return " " + p1 + " "; 120 | }); 121 | 122 | for (var i = 0; i < geneticCodeMatchExp.length; i++) { 123 | dnaSequence = dnaSequence.replace( 124 | geneticCodeMatchExp[i], 125 | geneticCodeMatchResult[i] 126 | ); 127 | } 128 | 129 | dnaSequence = dnaSequence.replace(/\S{3}/g, "X"); 130 | dnaSequence = dnaSequence.replace(/\s\S{1,2}$/, ""); 131 | dnaSequence = dnaSequence.replace(/\s/g, ""); 132 | outputWindow.document.write(addReturns(dnaSequence)); 133 | return true; 134 | } 135 | -------------------------------------------------------------------------------- /docs/scripts/window_extract_dna.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function windowExtract(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 500000000; 25 | var matchFound = false; 26 | var ranges = new Array(); 27 | 28 | if (testScript() == false) { 29 | return false; 30 | } 31 | 32 | if ( 33 | checkFormElement(theDocument.forms[0].elements[0]) == false || 34 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 35 | false || 36 | checkFormElement(theDocument.forms[0].elements[1]) == false || 37 | checkFormElement(theDocument.forms[0].elements[3]) == false || 38 | verifyMaxDigits( 39 | theDocument.forms[0].elements[1].value.replace(/[^\d]/g, ""), 40 | maxInput 41 | ) == false || 42 | verifyMaxDigits( 43 | theDocument.forms[0].elements[3].value.replace(/[^\d]/g, ""), 44 | maxInput 45 | ) == false 46 | ) { 47 | return false; 48 | } 49 | 50 | //build single range 51 | var windowSize = parseInt( 52 | theDocument.forms[0].elements[1].value.replace(/[^\d]/g, "") 53 | ); 54 | var position = parseInt( 55 | theDocument.forms[0].elements[3].value.replace(/[^\d]/g, "") 56 | ); 57 | var orientation = theDocument.forms[0].elements[2].value; 58 | 59 | var start; 60 | var end; 61 | if (orientation == "ending") { 62 | end = position; 63 | start = end - windowSize + 1; 64 | } else if (orientation == "starting") { 65 | start = position; 66 | end = start + windowSize - 1; 67 | } else if (orientation == "centered") { 68 | start = position - Math.round(windowSize / 2) + 1; 69 | end = start + windowSize - 1; 70 | } 71 | 72 | ranges.push(new Range(start, end)); 73 | 74 | openWindow("Window Extractor DNA"); 75 | openPre(); 76 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 77 | for (var i = 0; i < arrayOfFasta.length; i++) { 78 | newDna = getSequenceFromFasta(arrayOfFasta[i]); 79 | title = getTitleFromFasta(arrayOfFasta[i]); 80 | verifyDna(newDna); 81 | newDna = removeNonDna(newDna); 82 | outputWindow.document.write( 83 | getFastaTitleFromTitleAndSequence(title, newDna) 84 | ); 85 | writeSequenceRanges( 86 | newDna, 87 | ranges, 88 | theDocument.forms[0].elements[7].options[ 89 | theDocument.forms[0].elements[7].selectedIndex 90 | ].value, 91 | theDocument.forms[0].elements[8].options[ 92 | theDocument.forms[0].elements[8].selectedIndex 93 | ].value 94 | ); 95 | } 96 | closePre(); 97 | closeWindow(); 98 | return true; 99 | } 100 | -------------------------------------------------------------------------------- /docs/scripts/window_extract_protein.js: -------------------------------------------------------------------------------- 1 | // Sequence Manipulation Suite. A collection of simple JavaScript programs 2 | // for generating, formatting, and analyzing short DNA and protein 3 | // sequences. 4 | // Copyright (C) 2020 Paul Stothard stothard@ualberta.ca 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program. If not, see . 18 | // 19 | 20 | //Written by Paul Stothard, University of Alberta, Canada 21 | 22 | function windowExtract(theDocument) { 23 | var newDna = ""; 24 | var maxInput = 500000000; 25 | var matchFound = false; 26 | var ranges = new Array(); 27 | 28 | if (testScript() == false) { 29 | return false; 30 | } 31 | 32 | if ( 33 | checkFormElement(theDocument.forms[0].elements[0]) == false || 34 | checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == 35 | false || 36 | checkFormElement(theDocument.forms[0].elements[1]) == false || 37 | checkFormElement(theDocument.forms[0].elements[3]) == false || 38 | verifyMaxDigits( 39 | theDocument.forms[0].elements[1].value.replace(/[^\d]/g, ""), 40 | maxInput 41 | ) == false || 42 | verifyMaxDigits( 43 | theDocument.forms[0].elements[3].value.replace(/[^\d]/g, ""), 44 | maxInput 45 | ) == false 46 | ) { 47 | return false; 48 | } 49 | 50 | //build single range 51 | var windowSize = parseInt( 52 | theDocument.forms[0].elements[1].value.replace(/[^\d]/g, "") 53 | ); 54 | var position = parseInt( 55 | theDocument.forms[0].elements[3].value.replace(/[^\d]/g, "") 56 | ); 57 | var orientation = theDocument.forms[0].elements[2].value; 58 | 59 | var start; 60 | var end; 61 | if (orientation == "ending") { 62 | end = position; 63 | start = end - windowSize + 1; 64 | } else if (orientation == "starting") { 65 | start = position; 66 | end = start + windowSize - 1; 67 | } else if (orientation == "centered") { 68 | start = position - Math.round(windowSize / 2) + 1; 69 | end = start + windowSize - 1; 70 | } 71 | 72 | ranges.push(new Range(start, end)); 73 | 74 | openWindow("Window Extractor Protein"); 75 | openPre(); 76 | var arrayOfFasta = getArrayOfFasta(theDocument.forms[0].elements[0].value); 77 | for (var i = 0; i < arrayOfFasta.length; i++) { 78 | newProtein = getSequenceFromFasta(arrayOfFasta[i]); 79 | title = getTitleFromFasta(arrayOfFasta[i]); 80 | newProtein = removeNonProteinAllowDegen(newProtein); 81 | outputWindow.document.write( 82 | getFastaTitleFromTitleAndSequence(title, newProtein) 83 | ); 84 | writeSequenceRanges( 85 | newProtein, 86 | ranges, 87 | theDocument.forms[0].elements[7].options[ 88 | theDocument.forms[0].elements[7].selectedIndex 89 | ].value 90 | ); 91 | } 92 | closePre(); 93 | closeWindow(); 94 | return true; 95 | } 96 | -------------------------------------------------------------------------------- /docs/styles/stylesheet.css: -------------------------------------------------------------------------------- 1 | td.links { 2 | vertical-align: top; 3 | min-width: 144px; 4 | width: 144px; 5 | font-family: arial, sans-serif; 6 | color: #000000; 7 | background: rgb(255, 255, 255); 8 | } 9 | body.main { 10 | background-color: #ffffff; 11 | } 12 | td.program { 13 | vertical-align: top; 14 | font-family: arial, sans-serif; 15 | color: #000000; 16 | background-color: rgb(255, 255, 255); 17 | } 18 | div.linkTitle { 19 | font-size: xx-large; 20 | color: #ffffff; 21 | text-align: center; 22 | background-color: #dddddd; 23 | } 24 | div.programTitle { 25 | font-size: x-large; 26 | color: #ffffff; 27 | text-align: left; 28 | background-color: #dddddd; 29 | } 30 | div.category { 31 | font-size: small; 32 | color: #3b4471; 33 | font-style: italic; 34 | text-align: left; 35 | background-color: #dddddd; 36 | } 37 | div.code_title { 38 | font-size: medium; 39 | color: #3b4471; 40 | font-style: italic; 41 | text-align: left; 42 | } 43 | div.program { 44 | font-size: x-small; 45 | color: #000099; 46 | } 47 | div.program a { 48 | font-size: x-small; 49 | color: #000099; 50 | text-decoration: none; 51 | } 52 | div.program a:visited { 53 | font-size: x-small; 54 | color: #000099; 55 | text-decoration: none; 56 | } 57 | div.program a:hover { 58 | font-size: x-small; 59 | color: #ff0000; 60 | text-decoration: underline; 61 | } 62 | div.program a:active { 63 | font-size: x-small; 64 | color: #000099; 65 | text-decoration: none; 66 | } 67 | p.code_title { 68 | font-size: medium; 69 | color: #000000; 70 | text-align: left; 71 | } 72 | p.pre_small { 73 | font-size: x-small; 74 | color: #000000; 75 | font-family: courier, sans-serif; 76 | white-space: pre; 77 | } 78 | p.pre { 79 | color: #000000; 80 | font-family: courier, sans-serif; 81 | white-space: pre; 82 | } 83 | p.pre_bold { 84 | font-size: medium; 85 | color: #000000; 86 | font-weight: bold; 87 | font-family: courier, sans-serif; 88 | white-space: pre; 89 | } 90 | div.warning { 91 | font-size: medium; 92 | color: #ff0000; 93 | } 94 | div.pre { 95 | font-size: medium; 96 | color: #000000; 97 | font-family: courier, sans-serif; 98 | white-space: pre; 99 | } 100 | div.pre_small { 101 | font-size: x-small; 102 | color: #000000; 103 | font-family: courier, sans-serif; 104 | white-space: pre; 105 | } 106 | div.title { 107 | font-size: x-large; 108 | color: #000000; 109 | text-align: left; 110 | background-color: #ffffff; 111 | } 112 | div.copyright { 113 | font-size: xx-small; 114 | color: #000000; 115 | } 116 | td.title { 117 | font-size: large; 118 | color: #006599; 119 | text-align: left; 120 | background-color: rgb(255, 255, 255); 121 | } 122 | td.sms { 123 | font-size: x-large; 124 | color: #006599; 125 | text-align: left; 126 | background-color: rgb(255, 255, 255); 127 | } 128 | td.description { 129 | font-size: 90%; 130 | font-family: arial, sans-serif; 131 | color: #000000; 132 | background: rgb(255, 255, 255); 133 | } 134 | td.description a { 135 | text-decoration: none; 136 | color: #000099; 137 | background: rgb(255, 255, 255); 138 | } 139 | td.description a:visited { 140 | text-decoration: none; 141 | color: #000099; 142 | background: rgb(255, 255, 255); 143 | } 144 | td.description a:hover { 145 | text-decoration: underline; 146 | color: #ff0000; 147 | background: rgb(255, 255, 255); 148 | } 149 | td.description a:active { 150 | text-decoration: none; 151 | color: #000099; 152 | background: rgb(255, 255, 255); 153 | } 154 | span.version { 155 | font-size: x-small; 156 | color: #808080; 157 | } 158 | span.valid { 159 | font-size: xx-small; 160 | color: #808080; 161 | } 162 | textarea { 163 | font-family: 'DejaVu Sans Mono', monospace; 164 | font-size: small; 165 | color: #000000; 166 | background: rgb(255, 255, 255); 167 | } --------------------------------------------------------------------------------