forked from 23andMe/yhaplo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplotTree.py
executable file
·46 lines (38 loc) · 1.3 KB
/
plotTree.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
#
# David Poznik
# 2016.1.7
# plotTree.py
#
# To run: python -m yhaplo.plotTree
#----------------------------------------------------------------------
from __future__ import absolute_import
import argparse
import sys
try:
from Bio import Phylo
except ImportError:
sys.exit('\nERROR. Please install Biopython with the following command:\n\n\t' +
'pip install biopython\n')
from .config import Config
DESCRIPTION = 'plots a newick tree'
#----------------------------------------------------------------------
def main():
args = get_args()
phyloTree = Phylo.read(args.newickFN, 'newick')
if args.draw:
Phylo.draw(phyloTree)
else:
Phylo.draw_ascii(phyloTree)
def get_args():
parser = argparse.ArgumentParser(description=DESCRIPTION,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-d', '--draw', action='store_true', default=False,
help = 'draw tree, rather than printing ascii version')
parser.add_argument('-n', '--newickFN',
type=str, default=Config.primaryTreeFN,
help = 'name of file containing newick tree to plot')
args = parser.parse_args()
return args
if __name__ == '__main__':
main()