Skip to content

daviddao/biojs-io-newick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BioJS Newick Parser

How to build it

npm i 
npm start
npm test

Documentation

Now include biojs-io-newick.min.js in the build folder into your html (see example.html). Just call method parse_newick(string) for parsing a newick string into JSON.

var parser = require("biojs-io-newick");
parser.parse_newick('((A,B),C)');

Call the method parse_nhx(string) for parsing an extended newick formats into JSON.

var parser = require("biojs-io-newick");
parser.parse_nhx('((A,B),C)');

Call the method parse_json(string) for parsing a json string back into newick format.

var parser = require("biojs-io-newick");
parser.parse_json(json);

Example tree:

Newick format:

(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F

Converted to JSON:

{name : "F",
  children: [
    {name: "A", branch_length: 0.1},
    {name: "B", branch_length: 0.2},
    {
      name: "E",
      length: 0.5,
      children: [
        {name: "C", branch_length: 0.3},
        {name: "D", branch_length: 0.4}
      ]
    }
  ]
}

Contributions

Kudos to @alanrice for the parse_json method

About

Newick Parser in JS - parses newick strings into JSON and JSON into newick

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published