__author__ Lenovo from ete2 import Tree open Users Lenovo PycharmProje

 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
__author__ = 'Lenovo'
#from ete2 import Tree
f = open("C:\Users\Lenovo\PycharmProjects\PhylogeneticTree\data")
fd = f.read().split("Aligning...")
proteinList = fd[0].split(": ")
scoreList = fd[1].split("Sequences")
nProteins = len(proteinList)
print len(scoreList)
#building score's matrix
matrix = [[0 for i in range(len(proteinList) - 1)] for j in range(len(proteinList) - 1)]
pointInScoreList = 0
for i in range(nProteins - 1):
for j in range(i, nProteins - 1):
if j != i:
pointInScoreList += 1
if len(scoreList[pointInScoreList].split("Score: ")) >= 2:
score = float(scoreList[pointInScoreList].split("Score: ")[1].split("\n")[0])
#print score
matrix[i][j] = score
matrix[j][i] = score
#print(matrix)
#finding max total score (general ancestor)
#totalScores = [0 for i in range(len(proteinList) - 1)]
ancestorIndex = 0
maxSum = 0
for i in range(nProteins - 1):
sum = 0
for j in range(nProteins - 1):
sum += matrix[i][j]
#totalScores[i] = sum
if sum > maxSum:
maxSum = sum
ancestorIndex = i
#print ancestorIndex
#building the string representig tree
tree = Tree()
#for i in range(nProteins - 1):
#builtTreeString(i, treeString, matrix, structure)
print "Hello!"