def test_fragment_with_duplicate_in_pair_2(self): # Ensure the reducer catches a fragment duplicate of pair[1]. p = list(test_utils.pair1()) # Insert the pair into the context self.__ctx.add_value(test_utils.make_key(p[1]), PAIR_STRING) # Remove the first read from the pair, reorder so that the None is at index 1, # the serialize and insert into the context. test_utils.erase_read1(p) self.__ctx.add_value(test_utils.make_key(p[1]), proto.serialize_pair( (p[1], None) )) self.__reducer.reduce(self.__ctx) # now ensure that nothing was emitted. The pair isn't emitted because # the key refers to read2, and the fragment isn't emitted because it's a duplicate of # the one in the pair. self.assertEqual(0, len(self.__ctx.emitted.keys())) # check counter self.assertFalse(self.__ctx.counters.has_key(self.__pair_counter_name())) self.assertTrue(self.__ctx.counters.has_key(self.__frag_counter_name())) self.assertEqual(1, self.__ctx.counters[self.__frag_counter_name()])
def test_fragment_with_duplicate_in_pair_2(self): # Ensure the reducer catches a fragment duplicate of pair[1]. p = list(test_utils.pair1()) # Insert the pair into the context self.__ctx.add_value(test_utils.make_key(p[1]), PAIR_STRING) # Remove the first read from the pair, reorder so that the None is at index 1, # the serialize and insert into the context. test_utils.erase_read1(p) self.__ctx.add_value(test_utils.make_key(p[1]), proto.serialize_pair((p[1], None))) self.__reducer.reduce(self.__ctx) # now ensure that nothing was emitted. The pair isn't emitted because # the key refers to read2, and the fragment isn't emitted because it's a duplicate of # the one in the pair. self.assertEqual(0, len(self.__ctx.emitted.keys())) # check counter self.assertFalse( self.__ctx.counters.has_key(self.__pair_counter_name())) self.assertTrue(self.__ctx.counters.has_key( self.__frag_counter_name())) self.assertEqual(1, self.__ctx.counters[self.__frag_counter_name()])
def test_emit_reverse_fragment1(self): # None in pair[0]. Fragment in pair[1]. self.pair1 = test_utils.erase_read1(list(self.pair1)) self.pair1[1].set_on_reverse(True) self.link.process(self.pair1) self.assertEqual(1, len(self.ctx.emitted.keys())) expected_key = test_utils.make_key(self.pair1[1]) self.assertEqual(1, len(self.ctx.emitted[expected_key])) unserialized = proto.unserialize_pair(self.ctx.emitted[expected_key][0]) self.assertTrue(unserialized[1] is None) self.assertEqual(self.pair1[1].tid, unserialized[0].tid) self.assertEqual(self.pair1[1].pos, unserialized[0].pos) self.assertTrue(unserialized[0].is_on_reverse())
def test_emit_forward_fragment1(self): # None in pair[0]. Fragment in pair[1]. self.pair1 = test_utils.erase_read1(list(self.pair1)) self.link.process(self.pair1) self.assertEqual(1, len(self.ctx.emitted.keys())) expected_key = test_utils.make_key(self.pair1[1]) self.assertEqual(1, len(self.ctx.emitted[expected_key])) unserialized = proto.unserialize_pair(self.ctx.emitted[expected_key][0]) self.assertTrue(unserialized[1] is None) self.assertEqual(self.pair1[1].tid, unserialized[0].tid) self.assertEqual(self.pair1[1].pos, unserialized[0].pos) self.assertTrue(self.ctx.counters.has_key("Test:MAPPED COORDINATES")) self.assertEqual(1, self.ctx.counters["Test:MAPPED COORDINATES"])
def test_emit_reverse_fragment1(self): # None in pair[0]. Fragment in pair[1]. self.pair1 = test_utils.erase_read1(list(self.pair1)) self.pair1[1].set_on_reverse(True) self.link.process(self.pair1) self.assertEqual(1, len(self.ctx.emitted.keys())) expected_key = test_utils.make_key(self.pair1[1]) self.assertEqual(1, len(self.ctx.emitted[expected_key])) unserialized = proto.unserialize_pair( self.ctx.emitted[expected_key][0]) self.assertTrue(unserialized[1] is None) self.assertEqual(self.pair1[1].tid, unserialized[0].tid) self.assertEqual(self.pair1[1].pos, unserialized[0].pos) self.assertTrue(unserialized[0].is_on_reverse())
def test_emit_forward_fragment1(self): # None in pair[0]. Fragment in pair[1]. self.pair1 = test_utils.erase_read1(list(self.pair1)) self.link.process(self.pair1) self.assertEqual(1, len(self.ctx.emitted.keys())) expected_key = test_utils.make_key(self.pair1[1]) self.assertEqual(1, len(self.ctx.emitted[expected_key])) unserialized = proto.unserialize_pair( self.ctx.emitted[expected_key][0]) self.assertTrue(unserialized[1] is None) self.assertEqual(self.pair1[1].tid, unserialized[0].tid) self.assertEqual(self.pair1[1].pos, unserialized[0].pos) self.assertTrue(self.ctx.counters.has_key("Test:MAPPED COORDINATES")) self.assertEqual(1, self.ctx.counters["Test:MAPPED COORDINATES"])
def test_empty_read1(self): # Ensure the reducer raises an exception if the pair[0] is None p = test_utils.erase_read1(list(test_utils.pair1())) self.__ctx.add_value(test_utils.make_key(p[1]), proto.serialize_pair(p)) self.assertRaises(ValueError, self.__reducer.reduce, self.__ctx)