Commit 85897a23 authored by Mikael Boden's avatar Mikael Boden

guide.py

parent 8625943a
...@@ -169,7 +169,7 @@ class Alignment(): ...@@ -169,7 +169,7 @@ class Alignment():
return len(self.seqs) return len(self.seqs)
def __getitem__(self, ndx): def __getitem__(self, ndx):
return self.seqs[ndx] return self.seqs[ndx]
def calcDistances(self, measure, a=1.0): def calcDistances(self, measure = 'fractional', a=1.0):
""" Calculate the evolutionary distance between all pairs of sequences """ Calculate the evolutionary distance between all pairs of sequences
in this alignment, using the given measure. Measure can be one of in this alignment, using the given measure. Measure can be one of
'fractional', 'poisson', 'gamma', 'jc' or 'k2p'. If 'gamma' or 'k2p' is 'fractional', 'poisson', 'gamma', 'jc' or 'k2p'. If 'gamma' or 'k2p' is
...@@ -201,7 +201,7 @@ class Alignment(): ...@@ -201,7 +201,7 @@ class Alignment():
L += 1 L += 1
if seqA[k] != seqB[k]: if seqA[k] != seqB[k]:
D += 1 D += 1
p = float(D)/L p = D / L
# Now calculate the specified measure based on p # Now calculate the specified measure based on p
if measure == 'fractional': if measure == 'fractional':
dist = p dist = p
...@@ -214,7 +214,7 @@ class Alignment(): ...@@ -214,7 +214,7 @@ class Alignment():
symbolsPerLine = 60 symbolsPerLine = 60
maxNameLength = self.namelen + 1 maxNameLength = self.namelen + 1
mystring = u'' mystring = u''
wholeRows = self.alignlen / symbolsPerLine wholeRows = self.alignlen // symbolsPerLine
for i in range(wholeRows): for i in range(wholeRows):
for j in range(len(self.seqs)): for j in range(len(self.seqs)):
mystring += self.seqs[j].name.ljust(maxNameLength) + u' ' mystring += self.seqs[j].name.ljust(maxNameLength) + u' '
...@@ -235,7 +235,7 @@ class Alignment(): ...@@ -235,7 +235,7 @@ class Alignment():
html = u''.ljust(self.namelen) + u' ' html = u''.ljust(self.namelen) + u' '
for i in range(self.alignlen - 1): for i in range(self.alignlen - 1):
if (i+1) % 10 == 0: if (i+1) % 10 == 0:
html += str(i/10+1)[-1] html += str(i//10+1)[-1]
else: else:
html += ' ' html += ' '
html += u'%s\n' % (self.alignlen) html += u'%s\n' % (self.alignlen)
...@@ -504,7 +504,7 @@ def readClustalString(string, alphabet): ...@@ -504,7 +504,7 @@ def readClustalString(string, alphabet):
continue continue
sections = line.split() sections = line.split()
name, seq = sections[0:2] name, seq = sections[0:2]
if seqs.has_key(name): if name in seqs:
seqs[name] += seq seqs[name] += seq
else: else:
seqs[name] = seq seqs[name] = seq
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment