biojs-io-newick

WebJar for biojs-io-newick

License

License

Categories

Categories

JavaScript Languages
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

biojs-io-newick
Last Version

Last Version

1.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

biojs-io-newick
WebJar for biojs-io-newick
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/daviddao/biojs-io-newick

Download biojs-io-newick

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/biojs-io-newick/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>biojs-io-newick</artifactId>
    <version>1.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/biojs-io-newick/
implementation 'org.webjars.npm:biojs-io-newick:1.5.0'
// https://jarcasting.com/artifacts/org.webjars.npm/biojs-io-newick/
implementation ("org.webjars.npm:biojs-io-newick:1.5.0")
'org.webjars.npm:biojs-io-newick:jar:1.5.0'
<dependency org="org.webjars.npm" name="biojs-io-newick" rev="1.5.0">
  <artifact name="biojs-io-newick" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='biojs-io-newick', version='1.5.0')
)
libraryDependencies += "org.webjars.npm" % "biojs-io-newick" % "1.5.0"
[org.webjars.npm/biojs-io-newick "1.5.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.5.0