from optparse import OptionParser from spruce.unrooted import * from spruce.metrics import * from spruce.mrp import readTreesFromRatchet from newick_modified import parse_tree desc = ' '.join(['This script prints the FP rate, FN rate, and Robinson-Foulds', 'distance between a pair of trees. Each tree must be', 'specified in Newick format.']) parser = OptionParser(usage = "usage: %prog [options]", description = desc) parser.add_option("-t", "--true", dest = "true_tree", help = "read true tree from FILE", metavar = "FILE") parser.add_option("-e", "--estimate", dest = "estimate_tree", help = "read estimate tree from FILE", metavar = "FILE") (options, args) = parser.parse_args() if (options.estimate_tree == None or options.true_tree == None): parser.error("values for both options must be specified\ntry running with the --help flag") try: trueTree = readNewickFile(options.true_tree) except: trueTree = parse_tree(readTreesFromRatchet(options.true_tree)[0]) try: estimateTree = readNewickFile(options.estimate_tree) except: estimateTree = parse_tree(readTreesFromRatchet(options.estimate_tree)[0]) print getFpFnRfRates(trueTree, estimateTree)
parser = OptionParser(usage="usage: %prog [options]", description=desc) parser.add_option("-t", "--true", dest="true_tree", help="read true tree from FILE", metavar="FILE") parser.add_option("-e", "--estimate", dest="estimate_tree", help="read estimate tree from FILE", metavar="FILE") (options, args) = parser.parse_args() if (options.estimate_tree == None or options.true_tree == None): parser.error( "values for both options must be specified\ntry running with the --help flag" ) try: trueTree = readNewickFile(options.true_tree) except: trueTree = parse_tree(readTreesFromRatchet(options.true_tree)[0]) try: estimateTree = readNewickFile(options.estimate_tree) except: estimateTree = parse_tree(readTreesFromRatchet(options.estimate_tree)[0]) print getFpFnRfRates(trueTree, estimateTree)
#!/usr/bin/env python from newick_modified import parse_tree from spruce.unrooted import restrict, readMultipleTreesFromFile trees = [ parse_tree(tree) for tree in readMultipleTreesFromFile('kennedy.source_trees') ] taxaToRemove = set([ 'Pelecanus erythrorhynchos', 'Sula bassana', 'Phalacrocorax aristoteles', 'Larus dominicanus', 'Stictocarbo punctatus', 'Fregata minor', 'Fregata ariel', 'Fregata magnificens' ]) for i in range(len(trees)): trees[i] = restrict(trees[i], set(trees[i].get_leaves_identifiers()) - taxaToRemove) f = open('kennedy.source_trees_manual', 'w') for tree in trees: f.write(str(tree)) f.write(';\n') f.close()