diff --git a/src/index.js b/src/index.js index 8a4b392f..b825cab7 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,7 @@ export * as model from "./model"; // extra plugins, extensions export * as menu from "./menu"; -export {default as utils} from "./utils"; +export * as utils from "./utils"; // probably needed more often export {default as selection} from "./g/selection/Selection"; diff --git a/src/menu/views/ExportMenu.js b/src/menu/views/ExportMenu.js index 742c2a12..435fe6cb 100644 --- a/src/menu/views/ExportMenu.js +++ b/src/menu/views/ExportMenu.js @@ -1,5 +1,5 @@ import MenuBuilder from "../menubuilder"; -import Exporter from "../../utils/export"; +import Exporter from "../../utils/exporter"; const FastaExporter = require("biojs-io-fasta").writer; diff --git a/src/utils/export.js b/src/utils/exporter.js similarity index 100% rename from src/utils/export.js rename to src/utils/exporter.js diff --git a/src/utils/index.js b/src/utils/index.js index 75d2fa5f..05c097eb 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,5 +1,5 @@ -module.exports.bmath = require("./bmath"); -module.exports.proxy = require("./proxy"); -module.exports.seqgen = require("./seqgen"); -module.exports.file = require("./file"); -module.exports.export = require("./export"); +export bmath from "./bmath"; +export proxy from "./proxy"; +export seqgen from "./seqgen"; +export file from "./file"; +export exporter from "./exporter"; diff --git a/src/utils/seqgen.js b/src/utils/seqgen.js index 63be37ba..e02982a7 100644 --- a/src/utils/seqgen.js +++ b/src/utils/seqgen.js @@ -2,12 +2,12 @@ const Sequence = require("biojs-model").seq; import BMath from "./bmath"; const Stat = require("stat.seqs"); -const SeqGen = - {_generateSequence: function(len) { - var text = ""; - var end = len - 1; - for (var i = 0; 0 < end ? i <= end : i >= end; 0 < end ? i++ : i--) { - text += seqgen.getRandomChar(); +const SeqGen = { + _generateSequence: (len) => { + let text = ""; + const end = len - 1; + for (let i = 0; 0 < end ? i <= end : i >= end; 0 < end ? i++ : i--) { + text += SeqGen.getRandomChar(); } return text; }, @@ -16,50 +16,51 @@ const SeqGen = // @param len [int] number of generated sequences // @param seqLen [int] length of the generated sequences getDummySequences: function(len, seqLen) { - var seqs = []; + const seqs = []; if (!(typeof len !== "undefined" && len !== null)) { len = BMath.getRandomInt(3,5); } if (!(typeof seqLen !== "undefined" && seqLen !== null)) { seqLen = BMath.getRandomInt(50,200); } for (var i = 1; 1 < len ? i <= len : i >= len; 1 < len ? i++ : i--) { - seqs.push(new Sequence(seqgen._generateSequence(seqLen), "seq" + i,"r" + i)); + seqs.push(new Sequence(SeqGen._generateSequence(seqLen), "seq" + i,"r" + i)); } return seqs; }, - getRandomChar: function(dict) { - var possible = dict || "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + getRandomChar: (dict) => { + const possible = dict || "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; return possible.charAt(Math.floor(Math.random() * possible.length)); }, // generates a dummy sequences // @param len [int] number of generated sequences // @param seqLen [int] length of the generated sequences - genConservedSequences: function(len, seqLen, dict) { - var seqs = []; + genConservedSequences: (len, seqLen, dict) => { + const seqs = []; if (!(typeof len !== "undefined" && len !== null)) { len = BMath.getRandomInt(3,5); } if (!(typeof seqLen !== "undefined" && seqLen !== null)) { seqLen = BMath.getRandomInt(50,200); } dict = dict || "ACDEFGHIKLMNPQRSTVWY---"; - for (var i = 1; 1 < len ? i <= len : i >= len; 1 < len ? i++ : i--) { + for (let i = 1; 1 < len ? i <= len : i >= len; 1 < len ? i++ : i--) { seqs[i-1] = ""; } - var tolerance = 0.2; + const tolerance = 0.2; - var conservAim = 1; - var end = seqLen - 1; - for (var i = 0; 0 < end ? i <= end : i >= end; 0 < end ? i++ : i--) { + let conservAim = 1; + const end = seqLen - 1; + for (let i = 0; 0 < end ? i <= end : i >= end; 0 < end ? i++ : i--) { if (i % 3 === 0) { conservAim = (BMath.getRandomInt(50,100)) / 100; } - var observed = []; - var end1 = len - 1; - for (var j = 0; 0 < end1 ? j <= end1 : j >= end1; 0 < end1 ? j++ : j--) { - var counter = 0; + const observed = []; + const end1 = len - 1; + for (let j = 0; 0 < end1 ? j <= end1 : j >= end1; 0 < end1 ? j++ : j--) { + let counter = 0; + let c; while (counter < 100) { - var c = seqgen.getRandomChar(dict); - var cConserv = Stat(observed); + c = SeqGen.getRandomChar(dict); + const cConserv = Stat(observed); cConserv.addSeq(c); counter++; if (Math.abs(conservAim - cConserv.scale(cConserv.conservation())[0]) < tolerance) { @@ -71,12 +72,12 @@ const SeqGen = } } - var pseqs = []; + const pseqs = []; for (var i = 1; 1 < len ? i <= len : i >= len; 1 < len ? i++ : i--) { pseqs.push(new Sequence(seqs[i-1], "seq" + i, "r" + i)); } return pseqs; } - }; +}; export default SeqGen;