Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from dendropy import DnaCharacterMatrix, Tree
  3. import sys
  4.  
  5. mat=sys.argv[1]
  6. mattype=sys.argv[2]
  7. tre=sys.argv[3]
  8. tretype=sys.argv[4]
  9.  
  10.  
  11. d = DnaCharacterMatrix.get(path=mat,
  12. schema=mattype)
  13. # make the taxon_namespace mutable,
  14. # so that tree can be read even if different
  15. d.taxon_namespace.is_mutable = True
  16.  
  17. tree = Tree.get(path=tre,
  18. schema=tretype,
  19. preserve_underscores=True,
  20. taxon_namespace=d.taxon_namespace)
  21. # get all of the taxa associated with tips of the tree, and make sure that
  22. # they include all of the members of the data's taxon_namespace...
  23. treed_taxa = [i.taxon for i in tree.leaf_nodes()]
  24.  
  25. if set(treed_taxa) != d.poll_taxa():
  26. tree_missing = [i.label for i in d.taxon_namespace if i not in treed_taxa]
  27. emf = 'Some of the taxa in the matrix are not in the tree. Missing "{}"\n'
  28. em = emf.format('", "'.join(tree_missing))
  29. raise ValueError(em)
  30.  
  31. if set(treed_taxa) != d.poll_taxa():
  32. mat_missing = [i.label for i in d.taxon_namespace if i not in d.poll_taxa()]
  33. emf = 'Some of the taxa in the tree are not in the data matrix. Missing "{}"\n'
  34. em = emf.format('", "'.join(mat_missing))
  35. raise ValueError(em)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement