Skip to content

notung-agi/nearley-newick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nearley-newick

Newick tree format parser using nearley.js. This attempts to solve parsing issues that are common in other Newick parsers that rely on stacks to track the most recent (. Due to the naturally nested nature of trees, recursion should be leveraged to parse deeply-nested trees. This library uses Nearley.js parser to convert Newick string into Abstract Syntax Tree to encode the tree structure and metadata (node name, edge length, whether the node is leaf or internal).

Folder structure

├── lib  
│   ├── newick_grammar.ne # nearley grammar for parsing newick format  
│   ├── newick_grammar.js # parser from nearley compilation, generated by `npm run compile`  
│   ├
│   ├── index.js          # main
│   ├── parser.js         # newick format parser
│   ├── grammar.js        # grammar used for `parser.js`

Compile grammar and parse Newick

Edit lib/newick_grammar.ne and run npm run compile to generate lib/newick_grammar.js.

Compilation should be done at library development. nearley-newick library user should only use the compiled grammar newick_grammar.js via grammar.js.

Run test

npm run test

About

Newick tree format parser using nearley.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published