aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.html5
-rw-r--r--pnit-form.mjs5
-rw-r--r--worker.js16
3 files changed, 20 insertions, 6 deletions
diff --git a/index.html b/index.html
index 6e0aa55..d0da373 100644
--- a/index.html
+++ b/index.html
@@ -14,8 +14,11 @@
<label for='pni-threshold'>threshold:</label>
<input id='pni-threshold' name='pni-threshold' type='text' size='5' value='90.5'>%
<br>
+ <label for='strip-chevron'>strip leading chevron (<code>&gt;</code>)</label>
+ <input id='strip-chevron' name='strip-chevron' type='checkbox' checked>
+ <br>
<label for='ignore-header'>ignore header line:</label>
- <input id='ignore-header' name='ignore-header' type=checkbox checked>
+ <input id='ignore-header' name='ignore-header' type='checkbox'>
<br>
<label for='csv-input'>upload:</label>
<input id='csv-input' name='csv-input' type='file' accept='text/csv' required>
diff --git a/pnit-form.mjs b/pnit-form.mjs
index f85457b..50624c0 100644
--- a/pnit-form.mjs
+++ b/pnit-form.mjs
@@ -17,6 +17,10 @@ export default class extends HTMLElement {
return this.form.querySelector('input[name="ignore-header"]').checked;
}
+ get stripChevron() {
+ return this.form.querySelector('input[name="strip-chevron"]').checked;
+ }
+
get threshold() {
return Number(this.form.querySelector('input[name="pni-threshold"]').value);
}
@@ -81,6 +85,7 @@ export default class extends HTMLElement {
}
this.files.forEach(file => {
worker.postMessage({
+ stripChevron: this.stripChevron,
ignoreHeader: this.ignoreHeader,
threshold: this.threshold,
file
diff --git a/worker.js b/worker.js
index 4812203..b469e92 100644
--- a/worker.js
+++ b/worker.js
@@ -1,10 +1,12 @@
import CSVParse from './csv-parse.mjs';
+let stripChevron = true;
+let threshold = 0;
let ignoreLines = 0;
let sequenceNames = [];
-function process(threshold, row) {
- const name = row[0];
+function process(row) {
+ let name = row[0];
if (name === undefined || /^\s*$/.test(name)) {
return;
}
@@ -12,6 +14,9 @@ function process(threshold, row) {
ignoreLines--;
return;
}
+ if (stripChevron && name[0] === '>') {
+ name = name.substring(1);
+ }
sequenceNames.push(name);
let i = 0;
@@ -32,8 +37,9 @@ onmessage = e => {
console.debug('reading file');
console.debug('e.data', e.data);
- const { ignoreHeader, threshold, file } = e.data;
- console.debug('threshold', threshold, 'file', file);
+ stripChevron = e.data.stripChevron;
+ threshold = e.data.threshold;
+ const { ignoreHeader, file } = e.data;
const reader = new FileReader();
reader.onload = e => {
@@ -44,7 +50,7 @@ onmessage = e => {
if (ignoreHeader) {
ignoreLines = 1;
}
- parser.results.forEach(row => process(threshold, row));
+ parser.results.forEach(process);
}
reader.progress = e => {
console.debug('reader.progress', e);