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_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(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_autodetect_fastq_format(self): path = os.path.join(self._tmpdir, 'tmp.fastq') fmt = get_format(path) with open_output(path, "w") as f: for seq in simple_fastq: f.write(fmt.format(seq)) assert list(openseq(path)) == simple_fastq
def test_write_qualities_to_fasta(self): path = os.path.join(self._tmpdir, 'tmp.fasta') fmt = get_format(path, qualities=True) assert isinstance(fmt, FastaFormat) with open_output(path, "w") as f: for seq in simple_fastq: f.write(fmt.format(seq)) assert list(openseq(path)) == simple_fasta
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'