#! /usr/bin/env python 
###################################
#    Davi Ortega 9/4/2013 
###################################
import ete2
import json
import sys
import os
import bitk



if '-h' in sys.argv:
    print 'Return mistid from tree. Input yourtree.nwk'
    sys.exit()

filename = sys.argv[1]
T = ete2.Tree(filename)

output = ''
for node in T.iter_leaves():
	if node.is_leaf():
            if "|" in node.name:
                org = node.name.split('|')[0]
                while "'" in org:
                    org = org.replace("'","")
                output += org + '\n'
			
with open(filename + '.mistid.list' , 'w') as f:
	f.write(output)

