Ejemplo n.º 1
0
class tXmapFile_iter(unittest.TestCase):
	input_file="test.xmap"
	def setUp(self):
		with open(self.input_file, "w"):
			self.obj=XmapFile_iter(self.input_file)

	def tearDown(self):
		os.remove(self.input_file)

	def test_next_emptyFile(self):
		with self.assertRaises(StopIteration):
			self.obj.next()
		
	def test_next_badFileFormat(self):
		with open(self.input_file, "w") as i_file:
			i_file.write("1	2	3	4	5\n")

		with self.assertRaises(Exception):
			self.obj.next()

	def test_next_skipsHeaders(self):
		with open(self.input_file, "w") as o_file:
			o_file.write("# this is a comment")
		with self.assertRaises(StopIteration):
			self.obj.next()
		
	def test_next_goodFormat(self):
		expected=Mock(alignment_id=0, query_id=1, anchor_id=2, query_start=3.0, query_end=4.0, query_len=10.0, anchor_start=5.0, anchor_end=6.0, anchor_len=11.0, orientation="+", confidence=8.0, hit_enum="9D", label_channel="channel12", alignment="(1,3)")
		with open(self.input_file, "w") as i_file:
			i_file.write("#1	2	3	4	5\n0	1	2	3.0	4.0	5.0	6.0	+	8.0	9D	10.0	11.0	channel12	(1,3)")

		actual=self.obj.next()

		self.assertEqual(expected, actual)
Ejemplo n.º 2
0
	def setUp(self):
		with open(self.input_file, "w"):
			self.obj=XmapFile_iter(self.input_file)