def test_twoheaders(self): fmt = FastqFormat() with open_output(self.path, "w") as fw: fw.write(fmt.format(Sequence("name", "CCATA", "!#!#!", name2="name"))) fw.write(fmt.format(Sequence("name2", "HELLO", "&&&!&", name2="name2"))) with open(self.path) as t: assert t.read() == '@name\nCCATA\n+name\n!#!#!\n@name2\nHELLO\n+name2\n&&&!&\n'
def test(self): fmt = FastqFormat() with open_output(self.path, "w") as fw: fw.write(fmt.format_entry("name", "CCATA", "!#!#!")) fw.write(fmt.format_entry("name2", "HELLO", "&&&!&&")) with open(self.path) as t: assert t.read() == '@name\nCCATA\n+\n!#!#!\n@name2\nHELLO\n+\n&&&!&&\n'
def test(self): reads = [ (Sequence('A/1 comment', 'TTA', '##H'), Sequence('A/2 comment', 'GCT', 'HH#')), (Sequence('B/1', 'CC', 'HH'), Sequence('B/2', 'TG', '#H')) ] fmt = InterleavedFormatter(FastqFormat(), "foo") result = defaultdict(lambda: []) for read1, read2 in reads: fmt.format(result, read1, read2) assert fmt.written == 2 assert fmt.read1_bp == 5 assert fmt.read2_bp == 5 assert "foo" in result assert "".join(result["foo"]) == '@A/1 comment\nTTA\n+\n##H\n@A/2 comment\nGCT\n+\nHH#\n@B/1\nCC\n+\nHH\n@B/2\nTG\n+\n#H\n'