def __str__(self) : out = StringIO() print('## LogoData', file=out) print('# First column is position number, counting from zero', file=out) print('# Subsequent columns are raw symbol counts', file=out) print('# Entropy is mean entropy measured in nats.' , file=out) print('# Low and High are the 95% confidence limits.', file=out) print('# Weight is the fraction of non-gap symbols in the column.', file=out) print('#\t', file=out) # Show column names print('#', end='\t', file=out) for a in self.alphabet : print(a, end=' \t', file=out) print('Entropy\tLow\tHigh\tWeight', file=out) # Write the data table for i in range(self.length) : print(i + 1, end=' \t', file=out) for c in self.counts[i]: print(c, end=' \t', file=out) print("%6.4f" % self.entropy[i], end=' \t', file=out) if self.entropy_interval is not None: print("%6.4f" % self.entropy_interval[i][0], end=' \t', file=out) print("%6.4f" % self.entropy_interval[i][1], end=' \t', file=out) else : print('\t', '\t', end='', file=out) if self.weight is not None : print("%6.4f" % self.weight[i], end='', file=out) print('', file=out) print('# End LogoData', file=out) return out.getvalue()
def testParse(self): f = testdata_stream('scop/dir.cla.scop.txt_test') try: cla = f.read() f.close() f = testdata_stream('scop/dir.des.scop.txt_test') des = f.read() f.close() f = testdata_stream('scop/dir.hie.scop.txt_test') hie = f.read() finally: f.close() scop = Scop.parse_files(StringIO(cla), StringIO(des), StringIO(hie)) cla_out = StringIO() scop.write_cla(cla_out) assert cla_out.getvalue() == cla, cla_out.getvalue() des_out = StringIO() scop.write_des(des_out) assert des_out.getvalue() == des, des_out.getvalue() hie_out = StringIO() scop.write_hie(hie_out) assert hie_out.getvalue() == hie, hie_out.getvalue() domain = scop.domains_by_sid["d1hbia_"] self.assertEqual(domain.sunid, 14996) domains = scop.domains self.assertEqual(len(domains), 14) self.assertEqual(domains[4].sunid, 14988) self.assertFalse(-111 in scop.nodes_by_sunid) self.assertFalse("no such domain" in scop.domains_by_sid)
def testParse(self): f = testdata_stream('scop/dir.cla.scop.txt_test') try: cla = f.read() f.close() f = testdata_stream('scop/dir.des.scop.txt_test') des = f.read() f.close() f = testdata_stream('scop/dir.hie.scop.txt_test') hie = f.read() finally: f.close() scop = Scop.parse_files(StringIO(cla), StringIO(des), StringIO(hie)) cla_out = StringIO() scop.write_cla(cla_out) assert cla_out.getvalue() == cla, cla_out.getvalue() des_out = StringIO() scop.write_des(des_out) assert des_out.getvalue() == des, des_out.getvalue() hie_out = StringIO() scop.write_hie(hie_out) assert hie_out.getvalue() == hie, hie_out.getvalue() domain = scop.domains_by_sid["d1hbia_"] self.assertEqual(domain.sunid, 14996) domains = scop.domains self.assertEqual(len(domains), 14) self.assertEqual(domains[4].sunid, 14988) self.assertFalse(-111 in scop.nodes_by_sunid) self.assertFalse("no such domain" in scop.domains_by_sid )