Commit 934c2bff authored by Mikael Boden's avatar Mikael Boden

L3

parent d56ac8d9
......@@ -643,13 +643,15 @@ class Alignment():
distmat[i, j] = distmat[j, i] = dist
return distmat
def writeHTML(self, filename):
def writeHTML(self, filename=None):
""" Generate HTML that displays the alignment in color.
Requires that the alphabet is annotated with the label 'html-color' (see Sequence.annotateSym)
and that each symbol maps to a text string naming the color, e.g. 'blue'
"""
fh = open(filename, 'w')
fh.write('<html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">\n<title>Sequence Alignment</title>\n</head><body><pre>\n')
if filename == None:
htmlstr = '<pre>\n'
else:
htmlstr = '<html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">\n<title>Sequence Alignment</title>\n</head><body><pre>\n'
maxNameLength = self.getnamelen()
html = ''.ljust(maxNameLength) + ' '
for i in range(self.alignlen - 1):
......@@ -658,7 +660,7 @@ class Alignment():
else:
html += ' '
html += '%s\n' % (self.alignlen)
fh.write(html)
htmlstr += html
if self.alignlen > 10:
html = ''.ljust(maxNameLength) + ' '
for i in range(self.alignlen - 1):
......@@ -667,7 +669,7 @@ class Alignment():
else:
html += ' '
html += '\n'
fh.write(html)
htmlstr += html
for seq in self.seqs:
html = seq.name.ljust(maxNameLength) + ' '
for sym in seq:
......@@ -676,9 +678,15 @@ class Alignment():
color = 'white'
html += '<font style="BACKGROUND-COLOR: %s">%s</font>' % (color, sym)
html += '\n'
fh.write(html)
fh.write('</pre></body></html>\n')
fh.close()
htmlstr += html
htmlstr += '<pre>'
if filename:
fh = open(filename, 'w')
fh.write(htmlstr)
fh.write('</body></html>\n')
fh.close()
else:
return htmlstr
def saveConsensus(aln, theta1 = 0.99, theta2 = 0.01, countgaps = False, consensus = True, filename = None):
""" Display a table with rows for each alignment column, showing
......
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