newick-reader
TypeScript icon, indicating that this package has built-in type declarations

1.3.0-1 • Public • Published

newick-reader

pipeline status coverage report

TypeScript support for newick library reader based on Miguel Pignatelli 2014, based on Jason Davies 2010.

Install

npm install newick-reader

Usage

To parse a newick string into an Object:

import * as newickReader from 'newick-reader';
 
const newickString:string = '(A,(B,C));';
const treeObject = newickReader.parseNewick(newickString);
 
/*
treeObject =
{
    children: [
        {
            name: 'A'
        },
        {
            children: [
                {
                    name: 'B'
                },
                {
                    name: 'C'
                }
            ],
            name: '',
        },
    ],
    name: '',
}
*/

Although this is supose to be a reader, it also comes with a writer:

import * as newickReader from 'newick-reader';
 
const treeObject:object = {
    children: [
        {
            name: 'A'
        },
        {
            children: [
                {
                    name: 'B'
                },
                {
                    name: 'C'
                }
            ],
            name: '',
        },
    ],
    name: '',
}
 
const  newickString = newickReader.parseJson(treeObject);
 
/*
newickString = '(A,(B,C));';
*/

Package Sidebar

Install

npm i newick-reader

Weekly Downloads

0

Version

1.3.0-1

License

MIT

Unpacked Size

12.3 kB

Total Files

4

Last publish

Collaborators

  • daviortega