Created
November 8, 2016 03:27
-
-
Save ShaiberAlon/c7ee0e1cf94a3aa30363fdf1c2a6ffde to your computer and use it in GitHub Desktop.
Generate a newick formatted tree with numerical order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 | |
__author__ = "Alon Shaiber" | |
__copyright__ = "" | |
__credits__ = [] | |
__license__ = "" | |
__version__ = 1 | |
__maintainer__ = "Alon Shaiber" | |
__email__ = "alon.shaiber@gmail.com" | |
import argparse | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='Generate a newick formatted tree in which the nodes are ordered according to numerical order from 0 to N-1') | |
parser.add_argument(metavar='N',dest='N',type=int,help='Number of nodes for the tree') | |
args = parser.parse_args() | |
N=args.N | |
A='' | |
for i in range(2,N,1): | |
A=A+'('+str(i)+':0.1,' | |
B='' | |
for i in range(N,(N-1)*2): | |
B='Int'+str(i)+':0.1)'+B | |
tree=A+'(1:0.1,0:0.1)'+B+';' | |
print tree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment