Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

A python module to read and write the Newick format

Project description

python-newick

Build Status codecov.io PyPI

python package to read and write the Newick format.

Reading Newick

  • From a string:
>>> from newick import loads
>>> trees = loads('(A,B,(C,D)E)F;')
>>> trees[0].name
u'F'
>>> [n.name for n in trees[0].descendants]
[u'A', u'B', u'E']
  • From a file-like object:
>>> import io
>>> from newick import load
>>> with io.open('fname', encoding='utf8') as fp:
...     trees = load(fp)
  • From a file name:
>>> from newick import read
>>> trees = read('fname')

Writing Newick

In parallel to the read operations there are three functions to serialize a single Node object or a list of Node objects to Newick format:

  • dumps(trees) -> str
  • dump(trees, fp)
  • write(trees, 'fname')

A tree may be assembled using the factory methods of the Node class:

  • Node.__init__
  • Node.create
  • Node.add_descendant

Release history Release notifications

This version
History Node

0.9.2

History Node

0.9.1

History Node

0.9.0

History Node

0.8.0

History Node

0.7.0

History Node

0.6.0

History Node

0.5.0

History Node

0.4.0

History Node

0.3.0

History Node

0.2.0

History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
newick-0.9.2-py2.py3-none-any.whl (10.7 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Apr 9, 2018
newick-0.9.2.tar.gz (11.2 kB) Copy SHA256 hash SHA256 Source None Apr 9, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page