def test_write_sequence_object(self): fmt = FastaFormat() with open_output(self.path, "w") as fw: fw.write(fmt.format(Sequence("name", "CCATA"))) fw.write(fmt.format(Sequence("name2", "HELLO"))) with open(self.path) as t: assert t.read() == '>name\nCCATA\n>name2\nHELLO\n'
def test_linelength(self): fmt = FastaFormat(line_length=3) with open_output(self.path, "w") as fw: fw.write(fmt.format_entry("r1", "ACG")) fw.write(fmt.format_entry("r2", "CCAT")) fw.write(fmt.format_entry("r3", "TACCAG")) with open(self.path) as t: x=t.read() print(x) assert x == '>r1\nACG\n>r2\nCCA\nT\n>r3\nTAC\nCAG\n'
def test_write_zero_length_sequence(self): fmt = FastaFormat() s = fmt.format_entry("name", "") assert s == '>name\n\n', '{0!r}'.format(s)