phylojs
Version:
A simple typescript library for phylogenetic trees
19 lines (18 loc) • 701 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeNexus = void 0;
const newick_1 = require("./newick");
/** Writes tree in .nexus format. Undefined branch lengths set to 0.
* @param {tree} tree The tree to write
* @param {boolean} annotate Boolean to include annotations. Default is true.
*/
function writeNexus(tree, annotationWriter = _annotation => '') {
let nexusStr = '#NEXUS\n\nbegin trees;\n';
if (tree.root !== undefined)
nexusStr +=
`\ttree tree_1 = [&R] ${(0, newick_1.newickRecurse)(tree.root, annotationWriter)};` +
'\n';
nexusStr += 'end;';
return nexusStr;
}
exports.writeNexus = writeNexus;