def dist_counter(l,listofgenetrees):
M = listofgenetrees.taxon_set
t1 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[1]+'),' +l[2]+ ',(' +l[3]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t2 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[1]+'),' +l[3]+ ',(' +l[2]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t3 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[1]+'),' +l[4]+ ',(' +l[2]+ ',' +l[3]+ '))', schema = 'newick', taxon_set = M)
t4 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[2]+'),' +l[1]+ ',(' +l[3]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t5 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[2]+'),' +l[3]+ ',(' +l[1]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t6 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[2]+'),' +l[4]+ ',(' +l[1]+ ',' +l[3]+ '))', schema = 'newick', taxon_set = M)
t7 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[3]+'),' +l[1]+ ',(' +l[2]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t8 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[3]+'),' +l[2]+ ',(' +l[1]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t9 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[3]+'),' +l[4]+ ',(' +l[1]+ ',' +l[2]+ '))', schema = 'newick', taxon_set = M)
t10 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[4]+'),' +l[1]+ ',(' +l[2]+ ',' +l[3]+ '))', schema = 'newick', taxon_set = M)
t11 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[4]+'),' +l[2]+ ',(' +l[1]+ ',' +l[3]+ '))', schema = 'newick', taxon_set = M)
t12 = dendropy.Tree.get_from_string('((' +l[0]+ ',' +l[4]+'),' +l[3]+ ',(' +l[1]+ ',' +l[2]+ '))', schema = 'newick', taxon_set = M)
t13 = dendropy.Tree.get_from_string('((' +l[1]+ ',' +l[2]+'),' +l[0]+ ',(' +l[3]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t14 = dendropy.Tree.get_from_string('((' +l[1]+ ',' +l[3]+'),' +l[0]+ ',(' +l[2]+ ',' +l[4]+ '))', schema = 'newick', taxon_set = M)
t15 = dendropy.Tree.get_from_string('((' +l[1]+ ',' +l[4]+'),' +l[0]+ ',(' +l[2]+ ',' +l[3]+ '))', schema = 'newick', taxon_set = M)
counter1 = [t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15]
counter2 = [0 for i in range(15)]
return [counter1, counter2]
# I should merge this next with dist_counter after I test them both
def get_dist(l,treelist):
#treelist = dendropy.TreeList(inputtreelist)
dist = dist_counter(l, treelist)
#pp.pprint(dist)
viztrees = [dist[0][k].as_string("newick") for k in range(15)]
print viztrees
garbage = []
for i in range(len(treelist)):
smalltree = dendropy.Tree(treelist[i])
smalltree.retain_taxa_with_labels(l)
smalltree.update_splits()
trace = [dendropy.treecalc.symmetric_difference(smalltree,dist[0][j]) for j in range(15)]
if trace.count(0) > 1:
garbage.append(['error: too many zeroes', smalltree.as_string("newick"), smalltree, treelist[i], trace])
elif 0 in trace:
dist[1][trace.index(0)] = dist[1][trace.index(0)] + 1
else:
garbage.append([smalltree.as_newick_string(), treelist[i].as_newick_string(), min(trace)])
return [dist, garbage]
>>> import dendropy
>>> import InvariantScores
>>> treelist = dendropy.TreeList.get_from_path("nardtest_song_mammals.424.gene.tre", "newick")
>>> S = dendropy.Tree.get_from_path("nardtest_song_mammals.species.tre", "newick", taxon_set = treelist.taxon_set)
>>> leaves = [n.get_node_str() for n in S.leaf_iter()]
>>> L = [leaves[i] for i in range(5)]
>>> M = [leaves[i] for i in range(3,8)]
>>> A = InvariantScores.get_dist(L,treelist)
['[&U] ((Chicken,Platypus),Opossum,(Wallaby,Sloth));\n', '[&U] ((Chicken,Platypus),Wallaby,(Opossum,Sloth));\n', '[&U] ((Chicken,Platypus),Sloth,(Opossum,Wallaby));\n', '[&U] ((Chicken,Opossum),Platypus,(Wallaby,Sloth));\n', '[&U] ((Chicken,Opossum),Wallaby,(Platypus,Sloth));\n', '[&U] ((Chicken,Opossum),Sloth,(Platypus,Wallaby));\n', '[&U] ((Chicken,Wallaby),Platypus,(Opossum,Sloth));\n', '[&U] ((Chicken,Wallaby),Opossum,(Platypus,Sloth));\n', '[&U] ((Chicken,Wallaby),Sloth,(Platypus,Opossum));\n', '[&U] ((Chicken,Sloth),Platypus,(Opossum,Wallaby));\n', '[&U] ((Chicken,Sloth),Opossum,(Platypus,Wallaby));\n', '[&U] ((Chicken,Sloth),Wallaby,(Platypus,Opossum));\n', '[&U] ((Platypus,Opossum),Chicken,(Wallaby,Sloth));\n', '[&U] ((Platypus,Wallaby),Chicken,(Opossum,Sloth));\n', '[&U] ((Platypus,Sloth),Chicken,(Opossum,Wallaby));\n']
>>> A[0]
[[<Tree object at 0x1075e28d0>, <Tree object at 0x1075e2a50>, <Tree object at 0x1075e2f50>, <Tree object at 0x1075e2e50>, <Tree object at 0x1075d93d0>, <Tree object at 0x1075e9bd0>, <Tree object at 0x1075ec110>, <Tree object at 0x1075ec610>, <Tree object at 0x1075ecb10>, <Tree object at 0x1075f0050>, <Tree object at 0x1075ecf10>, <Tree object at 0x1075e9b10>, <Tree object at 0x1075f0a10>, <Tree object at 0x1075f0f10>, <Tree object at 0x1075f4450>], [0, 1, 312, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 59]]
>>> B = InvariantScores.get_dist(M,treelist)
['[&U] ((Wallaby,Sloth),Armadillos,(LesserHedgehogTenrec,Hyrax));\n', '[&U] ((Wallaby,Sloth),LesserHedgehogTenrec,(Armadillos,Hyrax));\n', '[&U] ((Wallaby,Sloth),Hyrax,(Armadillos,LesserHedgehogTenrec));\n', '[&U] ((Wallaby,Armadillos),Sloth,(LesserHedgehogTenrec,Hyrax));\n', '[&U] ((Wallaby,Armadillos),LesserHedgehogTenrec,(Sloth,Hyrax));\n', '[&U] ((Wallaby,Armadillos),Hyrax,(Sloth,LesserHedgehogTenrec));\n', '[&U] ((Wallaby,LesserHedgehogTenrec),Sloth,(Armadillos,Hyrax));\n', '[&U] ((Wallaby,LesserHedgehogTenrec),Armadillos,(Sloth,Hyrax));\n', '[&U] ((Wallaby,LesserHedgehogTenrec),Hyrax,(Sloth,Armadillos));\n', '[&U] ((Wallaby,Hyrax),Sloth,(Armadillos,LesserHedgehogTenrec));\n', '[&U] ((Wallaby,Hyrax),Armadillos,(Sloth,LesserHedgehogTenrec));\n', '[&U] ((Wallaby,Hyrax),LesserHedgehogTenrec,(Sloth,Armadillos));\n', '[&U] ((Sloth,Armadillos),Wallaby,(LesserHedgehogTenrec,Hyrax));\n', '[&U] ((Sloth,LesserHedgehogTenrec),Wallaby,(Armadillos,Hyrax));\n', '[&U] ((Sloth,Hyrax),Wallaby,(Armadillos,LesserHedgehogTenrec));\n']
>>> B[0]
[[<Tree object at 0x107610dd0>, <Tree object at 0x107608d90>, <Tree object at 0x1076ddd50>, <Tree object at 0x1076e1390>, <Tree object at 0x1076eb6d0>, <Tree object at 0x1076ef7d0>, <Tree object at 0x107610950>, <Tree object at 0x1076a5210>, <Tree object at 0x1076cb310>, <Tree object at 0x107629950>, <Tree object at 0x1076db950>, <Tree object at 0x1076fdb90>, <Tree object at 0x1076fd4d0>, <Tree object at 0x1076fdd90>, <Tree object at 0x1076c44d0>], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
>>> L
['Chicken', 'Platypus', 'Opossum', 'Wallaby', 'Sloth']
>>> M
['Wallaby', 'Sloth', 'Armadillos', 'LesserHedgehogTenrec', 'Hyrax']
Macintosh-0026b0d5f8d0:invariant_rooting ruthdavidson$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dendropy
>>> dendropy.__version__
'3.12.0'
>>> import InvariantScores
>>> treelist = dendropy.TreeList.get_from_path("true-trees-1X.tre", "newick")
>>> S = dendropy.Tree.get_from_path("species-1X.tre", "newick", taxon_set = treelist.taxon_set)
>>> leaves = [n.taxon.label for n in S.leaf_nodes()]
>>> L = [leaves[i] for i in range(5)]
>>> M = [leaves[m] for m in range(4,9)]
>>> A = InvariantScores.get_dist(L,treelist)
['[&U] ((MON,MAC),ORN,(GAL,ECH));\n', '[&U] ((MON,MAC),GAL,(ORN,ECH));\n', '[&U] ((MON,MAC),ECH,(ORN,GAL));\n', '[&U] ((MON,ORN),MAC,(GAL,ECH));\n', '[&U] ((MON,ORN),GAL,(MAC,ECH));\n', '[&U] ((MON,ORN),ECH,(MAC,GAL));\n', '[&U] ((MON,GAL),MAC,(ORN,ECH));\n', '[&U] ((MON,GAL),ORN,(MAC,ECH));\n', '[&U] ((MON,GAL),ECH,(MAC,ORN));\n', '[&U] ((MON,ECH),MAC,(ORN,GAL));\n', '[&U] ((MON,ECH),ORN,(MAC,GAL));\n', '[&U] ((MON,ECH),GAL,(MAC,ORN));\n', '[&U] ((MAC,ORN),MON,(GAL,ECH));\n', '[&U] ((MAC,GAL),MON,(ORN,ECH));\n', '[&U] ((MAC,ECH),MON,(ORN,GAL));\n']
>>> A[0]
[[<Tree object at 0x1172b97d0>, <Tree object at 0x1172b9cd0>, <Tree object at 0x1172bf2d0>, <Tree object at 0x1172bf890>, <Tree object at 0x1172bfe50>, <Tree object at 0x1172c3450>, <Tree object at 0x1172c3a10>, <Tree object at 0x1172bf350>, <Tree object at 0x1172c34d0>, <Tree object at 0x1172c72d0>, <Tree object at 0x1172c7890>, <Tree object at 0x1172c7e50>, <Tree object at 0x1172cb450>, <Tree object at 0x1172cba10>, <Tree object at 0x1172c3950>], [583, 610, 2608, 0, 19, 4, 3, 16, 0, 49, 21, 29, 5, 3, 50]]
>>> B = InvariantScores.get_dist(M,treelist)
['[&U] ((ECH,PRO),LOX,(CHO,DAS));\n', '[&U] ((ECH,PRO),CHO,(LOX,DAS));\n', '[&U] ((ECH,PRO),DAS,(LOX,CHO));\n', '[&U] ((ECH,LOX),PRO,(CHO,DAS));\n', '[&U] ((ECH,LOX),CHO,(PRO,DAS));\n', '[&U] ((ECH,LOX),DAS,(PRO,CHO));\n', '[&U] ((ECH,CHO),PRO,(LOX,DAS));\n', '[&U] ((ECH,CHO),LOX,(PRO,DAS));\n', '[&U] ((ECH,CHO),DAS,(PRO,LOX));\n', '[&U] ((ECH,DAS),PRO,(LOX,CHO));\n', '[&U] ((ECH,DAS),LOX,(PRO,CHO));\n', '[&U] ((ECH,DAS),CHO,(PRO,LOX));\n', '[&U] ((PRO,LOX),ECH,(CHO,DAS));\n', '[&U] ((PRO,CHO),ECH,(LOX,DAS));\n', '[&U] ((PRO,DAS),ECH,(LOX,CHO));\n']
>>> B[0]
[[<Tree object at 0x117ae9690>, <Tree object at 0x117b04550>, <Tree object at 0x117c1be10>, <Tree object at 0x1179ab990>, <Tree object at 0x117bbeb90>, <Tree object at 0x117927f10>, <Tree object at 0x117cb40d0>, <Tree object at 0x117affb10>, <Tree object at 0x117c921d0>, <Tree object at 0x117cafe50>, <Tree object at 0x117c9b0d0>, <Tree object at 0x117cf4050>, <Tree object at 0x117cafb50>, <Tree object at 0x117c1bed0>, <Tree object at 0x117cc1f50>], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
>>>
On Monday, October 6, 2014 12:52:49 PM UTC-5, Ruth Davidson wrote:an email to dendropy-users+unsubscribe@googlegroups.com
<mailto:dendropy-users+unsub...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
--
--------------------------------------
Jeet Sukumaran
--------------------------------------
jeetsu...@gmail.com
--------------------------------------
Blog/Personal Pages:
http://jeetworks.org/
GitHub Repositories:
http://github.com/jeetsukumaran
Photographs (as stream):
http://www.flickr.com/photos/jeetsukumaran/
Photographs (by galleries):
http://www.flickr.com/photos/jeetsukumaran/sets/
--------------------------------------
--
You received this message because you are subscribed to a topic in the Google Groups "DendroPy Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dendropy-users/Lgv7dEBYIJc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dendropy-users+unsubscribe@googlegroups.com.
> <mailto:dendropy-users+unsub...@googlegroups.com>.
import dendropy
import InvariantScores
treelist = dendropy.TreeList.get_from_path("true-trees-1X.tre", "newick")
S = dendropy.Tree.get_from_path("species-1X.tre", "newick", taxon_set = treelist.taxon_set)
print S.taxon_set == treelist.taxon_set
print len(treelist)
leaves = [n.taxon.label for n in S.leaf_nodes()]
L = [leaves[i] for i in range(5)]
M = [leaves[m] for m in range(4,9)]
A = InvariantScores.get_dist(L,treelist)
print A[0]
print sum(A[0][1])
B = InvariantScores.get_dist(M,treelist)
print B[0]
print sum(B[0][1])
~
Here is output:
Macintosh-0026b0d5f8d0:invariant_rooting ruthdavidson$ python 1XTests.py
True
4000
['[&U] ((MON,MAC),ORN,(GAL,ECH));\n', '[&U] ((MON,MAC),GAL,(ORN,ECH));\n', '[&U] ((MON,MAC),ECH,(ORN,GAL));\n', '[&U] ((MON,ORN),MAC,(GAL,ECH));\n', '[&U] ((MON,ORN),GAL,(MAC,ECH));\n', '[&U] ((MON,ORN),ECH,(MAC,GAL));\n', '[&U] ((MON,GAL),MAC,(ORN,ECH));\n', '[&U] ((MON,GAL),ORN,(MAC,ECH));\n', '[&U] ((MON,GAL),ECH,(MAC,ORN));\n', '[&U] ((MON,ECH),MAC,(ORN,GAL));\n', '[&U] ((MON,ECH),ORN,(MAC,GAL));\n', '[&U] ((MON,ECH),GAL,(MAC,ORN));\n', '[&U] ((MAC,ORN),MON,(GAL,ECH));\n', '[&U] ((MAC,GAL),MON,(ORN,ECH));\n', '[&U] ((MAC,ECH),MON,(ORN,GAL));\n']
[[<Tree object at 0x116c65d90>, <Tree object at 0x116c6c390>, <Tree object at 0x116c6c950>, <Tree object at 0x116c6c450>, <Tree object at 0x116c700d0>, <Tree object at 0x116c70690>, <Tree object at 0x116c70c50>, <Tree object at 0x116c74250>, <Tree object at 0x116c74810>, <Tree object at 0x116c6c410>, <Tree object at 0x116c74b50>, <Tree object at 0x116c79150>, <Tree object at 0x116c79710>, <Tree object at 0x116c79cd0>, <Tree object at 0x116c7f2d0>], [583, 610, 2608, 0, 19, 4, 3, 16, 0, 49, 21, 29, 5, 3, 50]]
4000
['[&U] ((ECH,PRO),LOX,(CHO,DAS));\n', '[&U] ((ECH,PRO),CHO,(LOX,DAS));\n', '[&U] ((ECH,PRO),DAS,(LOX,CHO));\n', '[&U] ((ECH,LOX),PRO,(CHO,DAS));\n', '[&U] ((ECH,LOX),CHO,(PRO,DAS));\n', '[&U] ((ECH,LOX),DAS,(PRO,CHO));\n', '[&U] ((ECH,CHO),PRO,(LOX,DAS));\n', '[&U] ((ECH,CHO),LOX,(PRO,DAS));\n', '[&U] ((ECH,CHO),DAS,(PRO,LOX));\n', '[&U] ((ECH,DAS),PRO,(LOX,CHO));\n', '[&U] ((ECH,DAS),LOX,(PRO,CHO));\n', '[&U] ((ECH,DAS),CHO,(PRO,LOX));\n', '[&U] ((PRO,LOX),ECH,(CHO,DAS));\n', '[&U] ((PRO,CHO),ECH,(LOX,DAS));\n', '[&U] ((PRO,DAS),ECH,(LOX,CHO));\n']
[[<Tree object at 0x117346290>, <Tree object at 0x117350d50>, <Tree object at 0x11734b390>, <Tree object at 0x1173b9c90>, <Tree object at 0x1171addd0>, <Tree object at 0x117346c90>, <Tree object at 0x1173551d0>, <Tree object at 0x117350510>, <Tree object at 0x11734b610>, <Tree object at 0x117346dd0>, <Tree object at 0x1171b5310>, <Tree object at 0x11717ab50>, <Tree object at 0x1171be490>, <Tree object at 0x1171908d0>, <Tree object at 0x117346350>], [171, 0, 0, 208, 0, 0, 0, 0, 0, 0, 0, 2, 3619, 0, 0]]
4000
> <mailto:dendropy-users+unsub...@googlegroups.com>.