A python tool for generating a Newick formatted tree from alist of classifications
Project description
# treemaker
A python library for creating a Newick formatted tree from a set of classification strings (e.g. a taxonomy)
[![Build Status](https://travis-ci.org/SimonGreenhill/treemaker.svg?branch=master)](https://travis-ci.org/SimonGreenhill/treemaker)
[![Coverage Status](https://coveralls.io/repos/SimonGreenhill/treemaker/badge.svg?branch=master&service=github)](https://coveralls.io/github/SimonGreenhill/treemaker?branch=master)
[![DOI](https://zenodo.org/badge/22704/SimonGreenhill/treemaker.svg)](https://zenodo.org/badge/latestdoi/22704/SimonGreenhill/treemaker)
## Usage: Command line
Basic usage:
```shell
> treemaker
usage: treemaker [-h] filename
```
e.g. Given a text file:
```
LangA Indo-European, Germanic
LangB Indo-European, Germanic
LangC Indo-European, Romance
LangD Indo-European, Anatolian
```
... then you can build a taxonomy/classification tree from that as follows:
```shell
> treemaker classification.txt
(LangD,(LangA,LangB),LangC)
> treemaker -m nexus classification.txt
#NEXUS
begin trees;
tree root = (LangD,(LangA,LangB),LangC);
end;
```
To write to file:
```shell
> treemaker classification.txt
(LangD,(LangA,LangB),LangC)
> treemaker classification.txt -o classification.nex
```
## Usage: Library
```python
from treemaker import TreeMaker
```
### generate a tree manually
```python
from treemaker import TreeMaker
t = TreeMaker()
t.add('A1', 'family a, subgroup 1')
t.add('A2', 'family a, subgroup 2')
t.add('B1a', 'family b, subgroup 1')
t.add('B1b', 'family b, subgroup 1')
t.add('B2', 'family b, subgroup 2')
print(t.write())
```
### Add from a list
```python
from treemaker import TreeMaker
taxa = [
('A1', 'family a, subgroup 1'),
('A2', 'family a, subgroup 2'),
('B1a', 'family b, subgroup 1'),
('B1b', 'family b, subgroup 1'),
('B2', 'family b, subgroup 2'),
]
t = TreeMaker()
t.add_from(taxa)
print(t.write())
```
A python library for creating a Newick formatted tree from a set of classification strings (e.g. a taxonomy)
[![Build Status](https://travis-ci.org/SimonGreenhill/treemaker.svg?branch=master)](https://travis-ci.org/SimonGreenhill/treemaker)
[![Coverage Status](https://coveralls.io/repos/SimonGreenhill/treemaker/badge.svg?branch=master&service=github)](https://coveralls.io/github/SimonGreenhill/treemaker?branch=master)
[![DOI](https://zenodo.org/badge/22704/SimonGreenhill/treemaker.svg)](https://zenodo.org/badge/latestdoi/22704/SimonGreenhill/treemaker)
## Usage: Command line
Basic usage:
```shell
> treemaker
usage: treemaker [-h] filename
```
e.g. Given a text file:
```
LangA Indo-European, Germanic
LangB Indo-European, Germanic
LangC Indo-European, Romance
LangD Indo-European, Anatolian
```
... then you can build a taxonomy/classification tree from that as follows:
```shell
> treemaker classification.txt
(LangD,(LangA,LangB),LangC)
> treemaker -m nexus classification.txt
#NEXUS
begin trees;
tree root = (LangD,(LangA,LangB),LangC);
end;
```
To write to file:
```shell
> treemaker classification.txt
(LangD,(LangA,LangB),LangC)
> treemaker classification.txt -o classification.nex
```
## Usage: Library
```python
from treemaker import TreeMaker
```
### generate a tree manually
```python
from treemaker import TreeMaker
t = TreeMaker()
t.add('A1', 'family a, subgroup 1')
t.add('A2', 'family a, subgroup 2')
t.add('B1a', 'family b, subgroup 1')
t.add('B1b', 'family b, subgroup 1')
t.add('B2', 'family b, subgroup 2')
print(t.write())
```
### Add from a list
```python
from treemaker import TreeMaker
taxa = [
('A1', 'family a, subgroup 1'),
('A2', 'family a, subgroup 2'),
('B1a', 'family b, subgroup 1'),
('B1b', 'family b, subgroup 1'),
('B2', 'family b, subgroup 2'),
]
t = TreeMaker()
t.add_from(taxa)
print(t.write())
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
treemaker-1.0.3.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for treemaker-1.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13fda907ccf7e33d13ef8ce5b12c99cdf4b4352310ae3bd386e39a554937dd86 |
|
MD5 | ed9ab88a2ad85ea2b1f9bde25c26c564 |
|
BLAKE2b-256 | 5943c77ea7ea3ec428f703585b7d08c986234d0c96ef30f6070ee30924a5e81d |