Skip to content

Commit b4f459b

Browse files
committed
udpate
1 parent 06b98ce commit b4f459b

26 files changed

+17682
-309
lines changed
0 Bytes
Binary file not shown.

SCIE2100_Practical5/try_prac5.ipynb

Lines changed: 159 additions & 133 deletions
Large diffs are not rendered by default.

SCIE2100_Practical6/sstruct.py

Lines changed: 0 additions & 176 deletions
This file was deleted.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"from sequence import *\n",
10+
"from phylo import *"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 3,
16+
"metadata": {},
17+
"outputs": [
18+
{
19+
"data": {
20+
"text/plain": [
21+
"array([[0. , 1.50692857],\n",
22+
" [1.50692857, 0. ]])"
23+
]
24+
},
25+
"execution_count": 3,
26+
"metadata": {},
27+
"output_type": "execute_result"
28+
}
29+
],
30+
"source": [
31+
"eh_aln = readClustalFile('eh.aln', Protein_Alphabet)\n",
32+
"d = eh_aln.calcDistances('gamma', 3.25)\n",
33+
"d"
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": 11,
39+
"metadata": {},
40+
"outputs": [
41+
{
42+
"name": "stdout",
43+
"output_type": "stream",
44+
"text": [
45+
"A0A1A8AU08:0.00261\n",
46+
"G3PS36:0.15853\n"
47+
]
48+
}
49+
],
50+
"source": [
51+
"my_tree = readNewick('tyrosine_protein_kinase_fer.newick') # Read the newick file\n",
52+
"mynode1 = my_tree.findLabel(\"A0A1A8AU08\")\n",
53+
"print(mynode1) # Look at selected node after loading the tree\n",
54+
"mynode2 = my_tree.findLabel(\"G3PS36\")\n",
55+
"print(mynode2)"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": 25,
61+
"metadata": {
62+
"scrolled": true
63+
},
64+
"outputs": [
65+
{
66+
"name": "stdout",
67+
"output_type": "stream",
68+
"text": [
69+
"has-distance 0.0 from ancestor N_1O72YI\n",
70+
"has-distance 0.07799 from ancestor N_P3SJE1\n",
71+
"has-distance 0.02885 from ancestor N_6X5OCZ\n",
72+
"has-distance 0.13452 from ancestor N_LZTO3K\n",
73+
"has-distance 0.03481 from ancestor N_NN3PPW\n",
74+
"has-distance 0.18156 from ancestor N_73PQ48\n",
75+
"has-distance 0.08849 from ancestor N_IY4J2R\n",
76+
"has-distance 0.12177 from ancestor N_G5HCJJ\n",
77+
"has-distance 0.21528 from ancestor N_4RGOI5\n",
78+
"has-distance 0.01235 from ancestor N_HS73OU\n",
79+
"has-distance 0.01859 from ancestor N_KHKD4J\n",
80+
"has-distance 0.12479 from ancestor N_NP656I\n",
81+
"has-distance 0.01038 from ancestor N_A7C7F3\n",
82+
"has-distance 0.00261 from ancestor N_01RRZV\n"
83+
]
84+
}
85+
],
86+
"source": [
87+
"# print all the ancestor of the node A0A1A8AU08 with distance\n",
88+
"mynode1 = my_tree.findLabel(\"A0A1A8AU08\") # Get the node with the same name as the sequence\n",
89+
"a_node1 = my_tree.getAncestorsOf(mynode1, transitive = True) # Get the direct ancestor for the node\n",
90+
"for i in a_node1:\n",
91+
" print('has-distance', i.dist, 'from ancestor', i.label) # Print the evolutionary distance"
92+
]
93+
},
94+
{
95+
"cell_type": "code",
96+
"execution_count": 26,
97+
"metadata": {},
98+
"outputs": [
99+
{
100+
"name": "stdout",
101+
"output_type": "stream",
102+
"text": [
103+
"has-distance 0.0 from ancestor N_1O72YI\n",
104+
"has-distance 0.07799 from ancestor N_P3SJE1\n",
105+
"has-distance 0.02885 from ancestor N_6X5OCZ\n",
106+
"has-distance 0.02773 from ancestor N_9M57YW\n",
107+
"has-distance 0.02666 from ancestor N_4VRM75\n",
108+
"has-distance 0.09947 from ancestor N_4VYY4L\n",
109+
"has-distance 0.0897 from ancestor N_0NESZ0\n",
110+
"has-distance 0.12596 from ancestor N_NMAIEZ\n",
111+
"has-distance 0.17501 from ancestor N_M5VDPE\n",
112+
"has-distance 0.03378 from ancestor N_8H3LJ6\n",
113+
"has-distance 0.09747 from ancestor N_5W280K\n",
114+
"has-distance 0.02613 from ancestor N_MY3XJW\n",
115+
"has-distance 0.08731 from ancestor N_6VA4CW\n"
116+
]
117+
}
118+
],
119+
"source": [
120+
"# print all the ancestor of the node G3PS36 with distance\n",
121+
"mynode2 = my_tree.findLabel(\"G3PS36\") # Get the node with the same name as the sequence\n",
122+
"a_node2 = my_tree.getAncestorsOf(mynode2, transitive = True) # Get the direct ancestor for the node\n",
123+
"for i in a_node2:\n",
124+
" print('has-distance', i.dist, 'from ancestor', i.label) # Print the evolutionary distance"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": 35,
130+
"metadata": {},
131+
"outputs": [
132+
{
133+
"name": "stdout",
134+
"output_type": "stream",
135+
"text": [
136+
"[<phylo.PhyloNode object at 0x0000025EC4BD9C10>, <phylo.PhyloNode object at 0x0000025EC4BA5BB0>, <phylo.PhyloNode object at 0x0000025EC4BA5FD0>]\n",
137+
"nearest: N_6X5OCZ\n"
138+
]
139+
}
140+
],
141+
"source": [
142+
"# find all common ancestors\n",
143+
"common_ancestors = []\n",
144+
"for x in a_node1:\n",
145+
" for y in a_node2:\n",
146+
" if x.label == y.label:\n",
147+
" common_ancestors.append(x)\n",
148+
"print(common_ancestors)\n",
149+
"# find the nearest one\n",
150+
"nearest_dis = 100\n",
151+
"nearest = ''\n",
152+
"for i in common_ancestors:\n",
153+
" if i.dist < nearest_dis:\n",
154+
" nearest = i\n",
155+
"print(\"nearest: \", nearest.label)"
156+
]
157+
},
158+
{
159+
"cell_type": "code",
160+
"execution_count": null,
161+
"metadata": {},
162+
"outputs": [],
163+
"source": []
164+
}
165+
],
166+
"metadata": {
167+
"kernelspec": {
168+
"display_name": "Python 3",
169+
"language": "python",
170+
"name": "python3"
171+
},
172+
"language_info": {
173+
"codemirror_mode": {
174+
"name": "ipython",
175+
"version": 3
176+
},
177+
"file_extension": ".py",
178+
"mimetype": "text/x-python",
179+
"name": "python",
180+
"nbconvert_exporter": "python",
181+
"pygments_lexer": "ipython3",
182+
"version": "3.8.3"
183+
}
184+
},
185+
"nbformat": 4,
186+
"nbformat_minor": 4
187+
}

0 commit comments

Comments
 (0)