UNPKG

phylojs

Version:

A simple typescript library for phylogenetic trees

31 lines (30 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.read = void 0; const __1 = require("../../"); /** * Reads trees from a string according to the specified `schema`. TODO: add support for getting trees from a URL. * @param {string} text * @param {Schema='newick'} schema newick, nexus, phyloXML, or NeXML * @returns {Tree[]} */ function read(text, schema = 'newick') { if (text.startsWith('http://') || text.startsWith('https://')) { throw new Error('Fetching trees from the internet is not yet supported'); } switch (schema) { case 'newick': return (0, __1.readTreesFromNewick)(text); case 'nexus': return (0, __1.readTreesFromNexus)(text); case 'phyloxml': return (0, __1.readTreesFromPhyloXML)(text); case 'nexml': return (0, __1.readTreesFromNeXML)(text); case 'phyjson': return (0, __1.readTreesFromPhyJSON)(text); default: throw new Error('Invalid schema'); } } exports.read = read;