@euphrasiologist/lwphylo 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1131,6 +1131,27 @@ function subTree (tree, node) {
|
|
|
1131
1131
|
return Object.fromEntries(data.concat(filtered));
|
|
1132
1132
|
}
|
|
1133
1133
|
|
|
1134
|
+
/**
|
|
1135
|
+
* Serialize a parsed tree (the parent/children node shape produced by
|
|
1136
|
+
* readTree() and randomTree()) back into a Newick string.
|
|
1137
|
+
*/
|
|
1138
|
+
|
|
1139
|
+
function toNewick(node) {
|
|
1140
|
+
return `${serialize(node)};`;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
function serialize(node) {
|
|
1144
|
+
const label = node.label || '';
|
|
1145
|
+
const branch = node.branchLength == null ? '' : `:${node.branchLength}`;
|
|
1146
|
+
|
|
1147
|
+
if (node.children.length === 0) {
|
|
1148
|
+
return `${label}${branch}`;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
const children = node.children.map(serialize).join(',');
|
|
1152
|
+
return `(${children})${label}${branch}`;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1134
1155
|
function drawPhylogeny(
|
|
1135
1156
|
treeText,
|
|
1136
1157
|
{
|
|
@@ -1913,5 +1934,5 @@ function drawPhylogeny(
|
|
|
1913
1934
|
}
|
|
1914
1935
|
}
|
|
1915
1936
|
|
|
1916
|
-
export { describeArc, describeArcSweep, drawPhylogeny, parentFisheye, phisheye, polarToCartesian, radialLayout, randomTree, readTree, rectangleLayout, subTree, unrooted };
|
|
1937
|
+
export { describeArc, describeArcSweep, drawPhylogeny, parentFisheye, phisheye, polarToCartesian, radialLayout, randomTree, readTree, rectangleLayout, subTree, toNewick, unrooted };
|
|
1917
1938
|
//# sourceMappingURL=index.js.map
|