def testIsValid(self): # Valid self.assertTrue(FastqIO.isValid(self.tmp_seq)) self.assertTrue(FastqIO.isValid(self.tmp_seq_gz)) # Valid long file content = "@seq1\nATGC\n+\n####\n@seq2\nATGC\n+\n####\n@seq3\nATGC\n+\n####\n@seq4\nATGC\n+\n####\n@seq5\nATGC\n+\n####\n@seq6\nATGC\n+\n####\n@seq7\nATGC\n+\n####\n@seq8\nATGC\n+\n####\n@seq9\nATGC\n+\n####\n@seq10\nATGC\n+\n####\n@seq11\nATGC\n+\n####\n" with open(self.tmp_out, "w") as FH_out: FH_out.write(content) self.assertTrue(FastqIO.isValid(self.tmp_out)) # Valid empty file content = "" with open(self.tmp_out, "w") as FH_out: FH_out.write(content) self.assertTrue(FastqIO.isValid(self.tmp_out)) # Valid empty sequence content = "@seq1\n\n+\n\n" with open(self.tmp_out, "w") as FH_out: FH_out.write(content) self.assertTrue(FastqIO.isValid(self.tmp_out)) # Invalid file (fasta) content = ">seq1\nATGC\n>seq2\nATGC" with open(self.tmp_out, "w") as FH_out: FH_out.write(content) self.assertTrue(not FastqIO.isValid(self.tmp_out)) # Invalid file (not a sequence) content = "@seq1\nAT1GC2\n+\n######" with open(self.tmp_out, "w") as FH_out: FH_out.write(content) self.assertTrue(not FastqIO.isValid(self.tmp_out))
def testWrite(self): with FastqIO(self.tmp_out, "w") as FH_out: for curr_rec in self.expected_rec: FH_out.write(curr_rec) self.assertTrue(FastqIO.isValid(self.tmp_out)) self.assertTrue(filecmp.cmp(self.tmp_out, self.tmp_seq))