-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
144 lines (135 loc) · 9.6 KB
/
test.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from Evolutionary_trees import Alignment, Leaf, BinNode, BinTree, Reconstruct_History
sequences=['MEVKKTSWTEEEDRILYQAHKRLGNRWAEIAKLLPGRTDNAIKNHWNSTMRRKV',
'ADVKRGNISKEEEDIIIKLHATLGNRWSLIASHLPGRTDNEIKNYWNSHLSRQ',
'DLKRGNFTADEDDLIVKLHSLLGNKWSLIAARLPGRTDNEIKNYWNTHVRRK',
'NVNKGNFTEQEEDLIIRLHKLLGNRWSLIAKRVPGRTDNQVKNYWNTHLSKK',
'DLKRGCFSQQEEDHIVALHQILGNRWSQIASHLPGRTDNEIKNFWNSCIKKK',
'DLKRGIFSEAEENLILDLHATLGNRWSRIAAQLPGRTDNEIKNYWNTRLKKR',
'SHPTYSEMIAAAIRAEKSRGGSSRQSIQKYIKSHYKVGHNADLQIKLSIRRLLAAGV',
'SHPKYSDMIASALESLKEKKGSSRQAILKYVKANFTVGDNANVHIKQALKRGVTSGQ',
'AHPSSSEMVLAAITALKERGGSSAQAIRKYIEKNYTVDIKKQAIFIKRALITGVEKGT',
'THPPTSVMVMAAIKALKERNGSSLPAIKKYIAANYKVDVVKNAHFIKKALKSLVEKKK',
'KPSTLSMIVAAITAMKNRKGSSVQAIRKYILANNKGINTSHLGSAMKLAFAKGLKSGV',
'AHPPVIDMITAAIAAQKERRGSSVAKIQSYIAAKYRCDINALNPHIRRALKNQVKSGA',
'AHPPYINTIKEAIKQLKDRKGASKQAILKFISQNYKLGDNVIQINAHHRQALKRGV',
'AHPPVATMVVTAILGLKERKGSSMVAIKKYIAANYRVDVARLAPFIRKFIRKA',
'SHPTYEEMIKDAIVTLKERTGSSQYAIQKFIEEKRKELPPTFRKLLLLNLKRLVASGK',
'NHPTYQVMISTAIAHYKDRTGSSQPAIIKYIEANYNVAPDTFKTQLKLALKRLVAKGT',
'MRSSAKQEELVKAFKALLKEEKFSSQGEIVAALQEQGFDNINQSKVSRMLTKFGAVRT',
'MARHRRIVDILNRQPVRSQSQLAKLLADNGLSVTQATLSRDLDELGAVKI',
'ENLNPVTRTARQALILQILDKQKVTSQVQLSELLLDEGIDITQATLSRDLDELGARKV',
'MNKGQRHIKIREIITSNEIETQDELVDMLKQDGYKVTQATVSRDIKELHLVKV',
'MNKGQRHIKIREIIMSNDIETQDELVDRLREAGFNVTQATVSRDIKEMQLVKV',
'MRKRDRHQLIKKMITEEKLSTQKEIQDRLEAHNVCVTQTTLSRDLREIGLTKV',
'GPEVAANRAGRQARIVAILSSAQVRSQNELAALLAAEGIEVTQATLSRDLEELGAVKL',
'TPDEREALGTRVRIIEELLRGEMSQRELKNELGAGIATITRGSNSLKAAPV',
'TADERDAVGLRLQIVSQLIDKNMPQREIQQNLNTSAATITRGSNMIKTMDP',
'SFSERKDVASRYHIIRALLEGELTQREIAEKYGVSIAQITRGSNALKGLDP',
'RGSALSDTERAQLDVMKLLNVSLHEMSRKISRSRHCIRVYLKDPVSYGT']
print 'Making alignment for:', sequences[:2]
score,(aligned_sequence1, aligned_sequence2)= Alignment(sequences[0],sequences[1])
print 'Alignment score:', score
print 'Alignment:'
print aligned_sequence1
print aligned_sequence2
print
t= BinTree(BinNode(BinNode(Leaf(sequences[0]),Leaf(sequences[1])),BinNode(Leaf(sequences[2]),BinNode(Leaf(sequences[3]),Leaf(sequences[4])))))
print 'Tree t:'
print t
print 'The evolutionary cost for a tree without designated ancestor sequences is', t.history_cost()
print
t.reconstruct_ancestors()
print 'Tree t with designated ancestor sequences:'
print t
print 'The evolutionary cost of a tree t:', t.history_cost()
print
print 'Reconstructing the tree for the sequences', sequences
t= Reconstruct_History(sequences)
print t
print 'The evolutionary cost of the reconstructed tree:', t.history_cost()
#ANSWER:
# Making alignment for: ['MEVKKTSWTEEEDRILYQAHKRLGNRWAEIAKLLPGRTDNAIKNHWNSTMRRKV', 'ADVKRGNISKEEEDIIIKLHATLGNRWSLIASHLPGRTDNEIKNYWNSHLSRQ']
# Alignment score: 26
# Alignment:
# MEVK_KTSWTEEEDRILYQAHKRLGNRWAEIAKLLPGRTDNAIKNHWNSTMRRKV
# ADVKRGNISKEEED_IIIKLHATLGNRWSLIASHLPGRTDNEIKNYWNSHLSR_Q
#
# Tree t:
# █>
# ├-█>
# │ ├-MEVKKTSWTEEEDRILYQAHKRLGNRWAEIAKLLPGRTDNAIKNHWNSTMRRKV
# │ └-ADVKRGNISKEEEDIIIKLHATLGNRWSLIASHLPGRTDNEIKNYWNSHLSRQ
# └-█>
# ├-DLKRGNFTADEDDLIVKLHSLLGNKWSLIAARLPGRTDNEIKNYWNTHVRRK
# └-█>
# ├-NVNKGNFTEQEEDLIIRLHKLLGNRWSLIAKRVPGRTDNQVKNYWNTHLSKK
# └-DLKRGCFSQQEEDHIVALHQILGNRWSQIASHLPGRTDNEIKNFWNSCIKKK
# The evolutionary cost for a tree without designated ancestor sequences is None
#
# Tree t with designated ancestor sequences:
# █>DVKRGNFSKEEDDRIIYKLHALLGNRWSQIASRLPGRTDNQIKNHWNSHMIRKQ
# ├-█>ADVKRKNSSKEEEDRIIYKAHARLGNRWSLIAKLLPGRTDNEIKNHWNSHMRRKQ
# │ ├-MEVKKTSWTEEEDRILYQAHKRLGNRWAEIAKLLPGRTDNAIKNHWNSTMRRKV
# │ └-ADVKRGNISKEEEDIIIKLHATLGNRWSLIASHLPGRTDNEIKNYWNSHLSRQ
# └-█>DLKKGNFSADEDDHIIKLHSLLGNKWSQIASRLPGRTDNQIKNYWNSHIRKK
# ├-DLKRGNFTADEDDLIVKLHSLLGNKWSLIAARLPGRTDNEIKNYWNTHVRRK
# └-█>DLKKGCFSQQEEDHIIRLHKILGNRWSQIASRLPGRTDNQIKNYWNSHIKKK
# ├-NVNKGNFTEQEEDLIIRLHKLLGNRWSLIAKRVPGRTDNQVKNYWNTHLSKK
# └-DLKRGCFSQQEEDHIVALHQILGNRWSQIASHLPGRTDNEIKNFWNSCIKKK
# The evolutionary cost of a tree t: 90
#
# Reconstructing the tree for the sequences ['MEVKKTSWTEEEDRILYQAHKRLGNRWAEIAKLLPGRTDNAIKNHWNSTMRRKV', 'ADVKRGNISKEEEDIIIKLHATLGNRWSLIASHLPGRTDNEIKNYWNSHLSRQ', 'DLKRGNFTADEDDLIVKLHSLLGNKWSLIAARLPGRTDNEIKNYWNTHVRRK', 'NVNKGNFTEQEEDLIIRLHKLLGNRWSLIAKRVPGRTDNQVKNYWNTHLSKK', 'DLKRGCFSQQEEDHIVALHQILGNRWSQIASHLPGRTDNEIKNFWNSCIKKK', 'DLKRGIFSEAEENLILDLHATLGNRWSRIAAQLPGRTDNEIKNYWNTRLKKR', 'SHPTYSEMIAAAIRAEKSRGGSSRQSIQKYIKSHYKVGHNADLQIKLSIRRLLAAGV', 'SHPKYSDMIASALESLKEKKGSSRQAILKYVKANFTVGDNANVHIKQALKRGVTSGQ', 'AHPSSSEMVLAAITALKERGGSSAQAIRKYIEKNYTVDIKKQAIFIKRALITGVEKGT', 'THPPTSVMVMAAIKALKERNGSSLPAIKKYIAANYKVDVVKNAHFIKKALKSLVEKKK', 'KPSTLSMIVAAITAMKNRKGSSVQAIRKYILANNKGINTSHLGSAMKLAFAKGLKSGV', 'AHPPVIDMITAAIAAQKERRGSSVAKIQSYIAAKYRCDINALNPHIRRALKNQVKSGA', 'AHPPYINTIKEAIKQLKDRKGASKQAILKFISQNYKLGDNVIQINAHHRQALKRGV', 'AHPPVATMVVTAILGLKERKGSSMVAIKKYIAANYRVDVARLAPFIRKFIRKA', 'SHPTYEEMIKDAIVTLKERTGSSQYAIQKFIEEKRKELPPTFRKLLLLNLKRLVASGK', 'NHPTYQVMISTAIAHYKDRTGSSQPAIIKYIEANYNVAPDTFKTQLKLALKRLVAKGT', 'MRSSAKQEELVKAFKALLKEEKFSSQGEIVAALQEQGFDNINQSKVSRMLTKFGAVRT', 'MARHRRIVDILNRQPVRSQSQLAKLLADNGLSVTQATLSRDLDELGAVKI', 'ENLNPVTRTARQALILQILDKQKVTSQVQLSELLLDEGIDITQATLSRDLDELGARKV', 'MNKGQRHIKIREIITSNEIETQDELVDMLKQDGYKVTQATVSRDIKELHLVKV', 'MNKGQRHIKIREIIMSNDIETQDELVDRLREAGFNVTQATVSRDIKEMQLVKV', 'MRKRDRHQLIKKMITEEKLSTQKEIQDRLEAHNVCVTQTTLSRDLREIGLTKV', 'GPEVAANRAGRQARIVAILSSAQVRSQNELAALLAAEGIEVTQATLSRDLEELGAVKL', 'TPDEREALGTRVRIIEELLRGEMSQRELKNELGAGIATITRGSNSLKAAPV', 'TADERDAVGLRLQIVSQLIDKNMPQREIQQNLNTSAATITRGSNMIKTMDP', 'SFSERKDVASRYHIIRALLEGELTQREIAEKYGVSIAQITRGSNALKGLDP', 'RGSALSDTERAQLDVMKLLNVSLHEMSRKISRSRHCIRVYLKDPVSYGT']
# █>EMNRSDAKQEDLKVRKALIEESVTSRREYAEKKNAPGVIIVQVKNMLEEFGTVK
# ├-█>SYSMEKADLTVRKNLILESVEKRRKYIEKKNRPGAIIVQLKNNLVSIGTDK
# │ ├-█>RPSYISMEAAALTVMKNLKGSSVEMIRKYIEKKNRVGIIVHLKKNLVSGT
# │ │ ├-█>AKPSYISMIAAAITTMKNRKGSSVQAIQKYIEKKNNVGINIQHLMKHRRAKNLVSGT
# │ │ │ ├-█>AHPSYIDMIAEAITTQKERKGSSMPAIQKYIEKKYRVDINIQNLFHRRANLVSGT
# │ │ │ │ ├-█>AHPTYINMIAEAIATLKDRTGSSKQAIQKYIKSHYKLPHNNIQLKLNHRRALASGT
# │ │ │ │ │ ├-█>SHPTYEVMIATAIATLKDRTGSSRQAIQKYIKSHYKELPHNFNKQLKLNLRRGVASGT
# │ │ │ │ │ │ ├-█>SHPTYSDMIASALRSLKSKKGSSRQAIQKYIKSHFKVGHNANVQIKLSLRRGVASGQ
# │ │ │ │ │ │ │ ├-SHPKYSDMIASALESLKEKKGSSRQAILKYVKANFTVGDNANVHIKQALKRGVTSGQ
# │ │ │ │ │ │ │ └-SHPTYSEMIAAAIRAEKSRGGSSRQSIQKYIKSHYKVGHNADLQIKLSIRRLLAAGV
# │ │ │ │ │ │ └-█>NHPTYEVMIKTAIATYKDRTGSSQPAIQKFIEANYKELPPTFKKLLLLNLKRLVASGT
# │ │ │ │ │ │ ├-NHPTYQVMISTAIAHYKDRTGSSQPAIIKYIEANYNVAPDTFKTQLKLALKRLVAKGT
# │ │ │ │ │ │ └-SHPTYEEMIKDAIVTLKERTGSSQYAIQKFIEEKRKELPPTFRKLLLLNLKRLVASGK
# │ │ │ │ │ └-AHPPYINTIKEAIKQLKDRKGASKQAILKFISQNYKLGDNVIQINAHHRQALKRGV
# │ │ │ │ └-█>AHPSVIDMILAAITAQKERKGSSMPKIQSYIEKKYRVDINRQNPFIRRANIVSGK
# │ │ │ │ ├-█>AHPSTAEMVLAAITALKERKGSSMPAIKKYIEKNYRVDVARQAPFIKRAFIVRKK
# │ │ │ │ │ ├-█>AHPSTSEMVLAAITALKERNGSSAPAIKKYIEKNYTVDVVKQAHFIKRALISLVEKGK
# │ │ │ │ │ │ ├-THPPTSVMVMAAIKALKERNGSSLPAIKKYIAANYKVDVVKNAHFIKKALKSLVEKKK
# │ │ │ │ │ │ └-AHPSSSEMVLAAITALKERGGSSAQAIRKYIEKNYTVDIKKQAIFIKRALITGVEKGT
# │ │ │ │ │ └-AHPPVATMVVTAILGLKERKGSSMVAIKKYIAANYRVDVARLAPFIRKFIRKA
# │ │ │ │ └-AHPPVIDMITAAIAAQKERRGSSVAKIQSYIAAKYRCDINALNPHIRRALKNQVKSGA
# │ │ │ └-KPSTLSMIVAAITAMKNRKGSSVQAIRKYILANNKGINTSHLGSAMKLAFAKGLKSGV
# │ │ └-RGSALSDTERAQLDVMKLLNVSLHEMSRKISRSRHCIRVYLKDPVSYGT
# │ └-█>SEVNKGDFTSREDIILEQLEKRLGNRELAKNLPGAGIAQIKNGWNSIHTRDK
# │ ├-█>SPDERDDVGSRYHIIEELLEKELTQRELAENLGAGIAQITRGSNMIKTLDP
# │ │ ├-█>TPDERDAVGLRLRIVEELLDKNMPQRELKQNLNAGIATITRGSNMIKTMPP
# │ │ │ ├-TADERDAVGLRLQIVSQLIDKNMPQREIQQNLNTSAATITRGSNMIKTMDP
# │ │ │ └-TPDEREALGTRVRIIEELLRGEMSQRELKNELGAGIATITRGSNSLKAAPV
# │ │ └-SFSERKDVASRYHIIRALLEGELTQREIAEKYGVSIAQITRGSNALKGLDP
# │ └-█>MEVNKGSFTEEEDLILYQLHKRLGNRWSEIAKRLPGRTDNAIKNHWNSTHRRKK
# │ ├-█>DVNKGNFSEAEEDLIIKLHALLGNRWSRIAKRLPGRTDNEIKNYWNTHLSKK
# │ │ ├-█>DLKRGNFSEAEEDNLIIKLHATLGNKWSRIASRLPGRTDNEIKNYWNTHISKR
# │ │ │ ├-█>ADLKRGNISAEEDDLIIKLHATLGNKWSLIASRLPGRTDNEIKNYWNSHVSRK
# │ │ │ │ ├-DLKRGNFTADEDDLIVKLHSLLGNKWSLIAARLPGRTDNEIKNYWNTHVRRK
# │ │ │ │ └-ADVKRGNISKEEEDIIIKLHATLGNRWSLIASHLPGRTDNEIKNYWNSHLSRQ
# │ │ │ └-█>DLKRGIFSEAEENLIVDLHQILGNRWSRIASHLPGRTDNEIKNYWNTCIKKR
# │ │ │ ├-DLKRGIFSEAEENLILDLHATLGNRWSRIAAQLPGRTDNEIKNYWNTRLKKR
# │ │ │ └-DLKRGCFSQQEEDHIVALHQILGNRWSQIASHLPGRTDNEIKNFWNSCIKKK
# │ │ └-NVNKGNFTEQEEDLIIRLHKLLGNRWSLIAKRVPGRTDNQVKNYWNTHLSKK
# │ └-MEVKKTSWTEEEDRILYQAHKRLGNRWAEIAKLLPGRTDNAIKNHWNSTMRRKV
# └-█>EMNRSDAKQEELVKAFKALTKEEKVTSQGEIADLQAAEGVNINQATVSRMLEEFGAVKV
# ├-█>EMANKGDAHQALIRKQITSKELVTSQNEIADLLAAEGVNVTQATLSRDIEELGAVKV
# │ ├-█>EMANPRTAHQALIVQILSKAQVTSQNQLAKLLAAEGLSITQATLSRDLEELGAVKV
# │ │ ├-█>PMANRAHRARIVDILSRAQVRSQNELAKLLAAEGLSVTQATLSRDLEELGAVKI
# │ │ │ ├-GPEVAANRAGRQARIVAILSSAQVRSQNELAALLAAEGIEVTQATLSRDLEELGAVKL
# │ │ │ └-MARHRRIVDILNRQPVRSQSQLAKLLADNGLSVTQATLSRDLDELGAVKI
# │ │ └-ENLNPVTRTARQALILQILDKQKVTSQVQLSELLLDEGIDITQATLSRDLDELGARKV
# │ └-█>MRKGDRHQLIRKMITSEELETQKEIVDRLEQHGVNVTQATLSRDIREMGLTKV
# │ ├-█>MNKGQRHIKIREIITSNEIETQDELVDRLRQAGYNVTQATVSRDIKEMHLVKV
# │ │ ├-MNKGQRHIKIREIIMSNDIETQDELVDRLREAGFNVTQATVSRDIKEMQLVKV
# │ │ └-MNKGQRHIKIREIITSNEIETQDELVDMLKQDGYKVTQATVSRDIKELHLVKV
# │ └-MRKRDRHQLIKKMITEEKLSTQKEIQDRLEAHNVCVTQTTLSRDLREIGLTKV
# └-MRSSAKQEELVKAFKALLKEEKFSSQGEIVAALQEQGFDNINQSKVSRMLTKFGAVRT
# The evolutionary cost of the reconstructed tree: 776