File: treecmp.py

package info (click to toggle)
veryfasttree 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,308 kB
  • sloc: cpp: 7,403; python: 209; sh: 38; makefile: 36
file content (26 lines) | stat: -rw-r--r-- 583 bytes parent folder | download
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
#!/usr/bin/env python3
import sys
try:
	from ete3 import Tree
except ImportError:
	print("Module ete3 required. Please install with pip install ete3", file=sys.stderr)
	exit(-1)


def main():
	if len(sys.argv) <= 2:
		exit("use " + sys.argv[0] + " tree1 tree2")

	try:
		tree1 = Tree(sys.argv[1])
		tree2 = Tree(sys.argv[2])

		rf, max_parts = tree1.robinson_foulds(tree2, unrooted_trees=True)[:2]
		accuracy = round((1 - (rf / max_parts)) * 100, 2)
		print("Accuracy: %.2f%%" % accuracy)

	except Exception as e:
		print(str(e), file=sys.stderr)

if __name__ == "__main__":
	main()