Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from dendropy import DnaCharacterMatrix, Tree
- import sys
- mat=sys.argv[1]
- mattype=sys.argv[2]
- tre=sys.argv[3]
- tretype=sys.argv[4]
- d = DnaCharacterMatrix.get(path=mat,
- schema=mattype)
- # make the taxon_namespace mutable,
- # so that tree can be read even if different
- d.taxon_namespace.is_mutable = True
- tree = Tree.get(path=tre,
- schema=tretype,
- preserve_underscores=True,
- taxon_namespace=d.taxon_namespace)
- # get all of the taxa associated with tips of the tree, and make sure that
- # they include all of the members of the data's taxon_namespace...
- treed_taxa = [i.taxon for i in tree.leaf_nodes()]
- if set(treed_taxa) != d.poll_taxa():
- tree_missing = [i.label for i in d.taxon_namespace if i not in treed_taxa]
- emf = 'Some of the taxa in the matrix are not in the tree. Missing "{}"\n'
- em = emf.format('", "'.join(tree_missing))
- raise ValueError(em)
- if set(treed_taxa) != d.poll_taxa():
- mat_missing = [i.label for i in d.taxon_namespace if i not in d.poll_taxa()]
- emf = 'Some of the taxa in the tree are not in the data matrix. Missing "{}"\n'
- em = emf.format('", "'.join(mat_missing))
- raise ValueError(em)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement