A python module to read and write the Newick format
Project description
python-newick
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
'F'
>>> [n.name for n in trees[0].descendants]
['A', 'B', '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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
newick-1.1.0.tar.gz
(11.1 kB
view hashes)
Built Distribution
newick-1.1.0-py2.py3-none-any.whl
(10.8 kB
view hashes)
Close
Hashes for newick-1.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bb4712add4485114b243fca1f791428fcbc5aa5d71de74d3ef4f0d23e1b7437 |
|
MD5 | d092054651a9169ee1ceaf063f28d322 |
|
BLAKE2b-256 | 01647b68f57c5418572d7029981c9b35015a62bda00f3562cf7c4692d9853c2b |