Exemple #1
0
 def testIsValid(self):
     # Valid
     self.assertTrue(FastaIO.isValid(self.tmp_mono_line))
     self.assertTrue(FastaIO.isValid(self.tmp_multi_line))
     self.assertTrue(FastaIO.isValid(self.tmp_multi_line_gz))
     # Valid long file
     content = ">seq1\nATGC\n>seq2\nATGC\n>seq3\nATGC\n>seq4\nATGC\n>seq5\nATGC\n>seq6\nATGC\n>seq7\nATGC\n>seq8\nATGC\n>seq9\nATGC\n>seq10\nATGC\n>seq11\nATGC\n>seq12\nATGC"
     with open(self.tmp_out, "w") as FH_out:
         FH_out.write(content)
     self.assertTrue(FastaIO.isValid(self.tmp_out))
     # Valid empty file
     content = ""
     with open(self.tmp_out, "w") as FH_out:
         FH_out.write(content)
     self.assertTrue(FastaIO.isValid(self.tmp_out))
     # Valid empty sequence
     content = ">seq1\n"
     with open(self.tmp_out, "w") as FH_out:
         FH_out.write(content)
     self.assertTrue(FastaIO.isValid(self.tmp_out))
     # Invalid file (two headers)
     content = ">seq1\nATGC\n>seq2\n>seq3\nATGC"
     with open(self.tmp_out, "w") as FH_out:
         FH_out.write(content)
     self.assertTrue(not FastaIO.isValid(self.tmp_out))
     # Invalid file (no header at the first line)
     content = "seq1\nATGC\n>seq2\nATGC"
     with open(self.tmp_out, "w") as FH_out:
         FH_out.write(content)
     self.assertTrue(not FastaIO.isValid(self.tmp_out))
     # Invalid file (fastq)
     content = "@seq1\nATGC\n+\n####"
     with open(self.tmp_out, "w") as FH_out:
         FH_out.write(content)
     self.assertTrue(not FastaIO.isValid(self.tmp_out))
Exemple #2
0
 def testWrite(self):
     with FastaIO(self.tmp_out, "w") as FH_out:
         for curr_rec in self.expected_rec:
             FH_out.write(curr_rec)
     self.assertTrue(FastaIO.isValid(self.tmp_out))
     self.assertTrue(filecmp.cmp(self.tmp_out, self.tmp_mono_line))