-
Notifications
You must be signed in to change notification settings - Fork 0
/
complete tree.py
45 lines (41 loc) · 1.03 KB
/
complete tree.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
(n-1) - number of edges
# ~ l=[]
# ~ with open("rosalind_tree.txt") as f1:
# ~ for line in f1:
# ~ l.append(line.strip())
# ~ n = int(l.pop(0))
# ~ #count isolated nodes
# ~ t=0
# ~ nodes=[]
# ~ for i in l:
# ~ nodes.append(i.split()[0])
# ~ nodes.append(i.split()[1])
# ~ node = list(set(nodes))
# ~ if len(node) != n:
# ~ for j in range(1, n+1):
# ~ if str(j) not in node:
# ~ t+=1
# ~ #count other taxa
# ~ taxa=[]
# ~ for k in l:
# ~ a = k.split()[0]
# ~ b = k.split()[1]
# ~ flag=0
# ~ for taxon in taxa:
# ~ if (a in taxon) and (b not in taxon):
# ~ flag=1
# ~ taxon.append(b)
# ~ break
# ~ elif (a not in taxon) and (b in taxon):
# ~ flag=1
# ~ taxon.append(a)
# ~ break
# ~ if flag == 0:
# ~ taxa.append([a, b])
# ~ print(taxa)
# ~ t += len(taxa)
# ~ print(t-1)
# ~ su=0
# ~ for d in taxa:
# ~ su += len(d)
# ~ print(su)