UNPKG

bioseq-ts

Version:

Biological Sequence in Javascript, written in Typescript.

72 lines 2.81 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.PhylipUtils = void 0; var loglevel_colored_prefix_1 = require("loglevel-colored-prefix"); var BioSeqSet_1 = require("./BioSeqSet"); var ParseUtilsAbstract_1 = require("./ParseUtilsAbstract"); /** * Utils for PHYLIP format as defined by [PHYLIP] (http://evolution.genetics.washington.edu/phylip/doc/sequence.html) * * @class PhylipUtils * @extends {ParseUtils} */ var PhylipUtils = /** @class */ (function (_super) { __extends(PhylipUtils, _super); function PhylipUtils(logLevel) { if (logLevel === void 0) { logLevel = 'INFO'; } var _this = _super.call(this) || this; _this.logLevel = logLevel; _this.log = new loglevel_colored_prefix_1.Logger(logLevel); return _this; } /** * Parse PHYLIP string chunk to a BioSeqSet object * * @param {string} chunk * @returns * @memberof PhylipUtils */ PhylipUtils.prototype.parse = function (chunk) { var log = this.log.getLogger('PhylipUtils::parse'); log.error('Not implemented'); throw new Error('Not implemented'); return new BioSeqSet_1.BioSeqSet(); }; /** * Writes BioSeqSet in PHYLIP format * * @param {BioSeqSet} input * @returns * @memberof PhylipUtils */ PhylipUtils.prototype.write = function (input) { var log = this.log.getLogger('PhylipUtils::write'); if (!input.isAligned()) { log.error('Not an alignment. Sequences must be all the same length (with gaps).'); throw new Error('Not an alignment. Sequences must be all the same length (with gaps).'); } var bioSeqs = input.getBioSeqs(); var phylip = bioSeqs.length + " " + input.maxLength() + "\n"; bioSeqs.forEach(function (bioSeq) { var header = "" + bioSeq.header.slice(0, 9) + (bioSeq.header.length < 9 ? ' '.repeat(9 - bioSeq.header.length) : ''); phylip += header + " " + bioSeq.seq + "\n"; }); return phylip; }; return PhylipUtils; }(ParseUtilsAbstract_1.ParseUtils)); exports.PhylipUtils = PhylipUtils; //# sourceMappingURL=PhylipUtils.js.map