Example #1
0
 def test_unknown_index(self):
     # TODO - Add SFF file with no index,
     # self.assertEqual(str(err), "No index present in this SFF file")
     with open("Roche/E3MFGYR02_alt_index_in_middle.sff", "rb") as handle:
         try:
             values = _sff_find_roche_index(handle)
         except ValueError as err:
             self.assertTrue(str(err) in ("Unknown magic number '.diy' in SFF index header:\n'.diy1.00'",
                                          "Unknown magic number b'.diy' in SFF index header:\nb'.diy1.00'"))
         else:
             self.assertTrue(False, "Test _sff_find_roche_index did not raise exception")
Example #2
0
 def test_unknown_index(self):
     # TODO - Add SFF file with no index,
     # self.assertEqual(str(err), "No index present in this SFF file")
     with open("Roche/E3MFGYR02_alt_index_in_middle.sff", "rb") as handle:
         try:
             values = _sff_find_roche_index(handle)
         except ValueError as err:
             self.assertTrue(str(err) in ("Unknown magic number '.diy' in SFF index header:\n'.diy1.00'",
                                          "Unknown magic number b'.diy' in SFF index header:\nb'.diy1.00'"))
         else:
             self.assertTrue(False, "Test _sff_find_roche_index did not raise exception")
Example #3
0
 def test_unknown_index(self):
     # TODO - Add SFF file with no index,
     # self.assertEqual(str(err), "No index present in this SFF file")
     with open("Roche/E3MFGYR02_alt_index_in_middle.sff", "rb") as handle:
         with self.assertRaises(ValueError) as cm:
             values = _sff_find_roche_index(handle)
     self.assertIn(
         str(cm.exception),
         (
             "Unknown magic number '.diy' in SFF index header:\n'.diy1.00'",
             "Unknown magic number b'.diy' in SFF index header:\nb'.diy1.00'",
         ),
     )
Example #4
0
 def test_no_index(self):
     # Does a lot of work to create a no-index SFF file
     # (in the process checking this bit of SffWriter works)
     records = list(SeqIO.parse(BytesIO(self.good), "sff"))
     with BytesIO() as handle:
         writer = SffWriter(handle, index=False)
         count = writer.write_file(records)
         self.assertEqual(count, len(records))
         handle.seek(0)
         new = list(SeqIO.parse(handle, "sff"))
         self.assertEqual(len(records), len(new))
         for a, b in zip(records, new):
             self.assertEqual(a.id, b.id)
         handle.seek(0)
         with self.assertRaises(ValueError) as cm:
             values = _sff_find_roche_index(handle)
         err = str(cm.exception)
         self.assertEqual(err, "No index present in this SFF file")
Example #5
0
 def test_no_index(self):
     # Does a lot of work to create a no-index SFF file
     # (in the process checking this bit of SffWriter works)
     records = list(SeqIO.parse(BytesIO(self.good), "sff"))
     with BytesIO() as handle:
         writer = SffWriter(handle, index=False)
         count = writer.write_file(records)
         self.assertEqual(count, len(records))
         handle.seek(0)
         new = list(SeqIO.parse(handle, "sff"))
         self.assertEqual(len(records), len(new))
         for a, b in zip(records, new):
             self.assertEqual(a.id, b.id)
         handle.seek(0)
         try:
             values = _sff_find_roche_index(handle)
         except ValueError as err:
             self.assertEqual(str(err), "No index present in this SFF file")
         else:
             self.assertTrue(False, "Test _sff_find_roche_index did not raise exception")