def __str__(self): from SAP.Bio._py3k import StringIO handle = StringIO() save(self, handle) handle.seek(0) return handle.read()
CYS1_DICDI -----MKVIL LFVLAVFTVF VSS------- --------RG IPPEEQ---- ALEU_HORVU MAHARVLLLA LAVLATAAVA VASSSSFADS NPIRPVTDRA ASTLESAVLG CATH_HUMAN ------MWAT LPLLCAGAWL LGV------- -PVCGAAELS VNSLEK---- CYS1_DICDI -----MKVIL LFVLAVFTVF VSS------- --------RG IPPEEQ---X ; end; """) for a in NexusIterator(handle): print(a) for r in a: print("%r %s %s" % (r.seq, r.name, r.id)) print("Done") print("") print("Reading an empty file") assert 0 == len(list(NexusIterator(StringIO()))) print("Done") print("") print("Writing...") handle = StringIO() NexusWriter(handle).write_file([a]) handle.seek(0) print(handle.read()) handle = StringIO() try: NexusWriter(handle).write_file([a, a]) assert False, "Should have rejected more than one alignment!" except ValueError: pass