class GameTestInputType2(unittest.TestCase): """ class for testing alignment game """ def setUp(self): self.algo = AlignmentGame('C--TA', 'CACTU', 2, -1, -1) def tearDown(self): del self.algo def test_get_score2(self): """ Ensure that game score get correctly for diferent type of inputs 1 """ self.algo.calculate_score() score = self.algo.get_score() self.assertEqual(score, 1) def test_alignment_result(self): """ Ensure that game alignment result get correctly """ self.algo.calculate_score() alignment_result = self.algo.get_align_result() self.assertEqual(alignment_result, ['match', 'gap', 'gap', 'match', 'mismatch']) def test_validation(self): """ Testing for validation """ input_validation = self.algo.validate_input() self.assertEqual(input_validation, {'error': 'None'})
class GameTest(unittest.TestCase): """ class for testing alignment game """ def setUp(self): self.algo = AlignmentGame('AAAC', 'AAC-', 2, -1, -1) def tearDown(self): del self.algo def test_input_sequence(self): """ Ensure that user inputs sequence get correctly """ input_seq = self.algo.get_input_alignments() self.assertEqual(input_seq[0], 'AAAC') self.assertEqual(input_seq[1], 'AAC-') def test_input_panalties(self): """ Ensure that user panalties get correcly """ input_panalties = self.algo.get_input_panalty() self.assertEqual(input_panalties[0], 2) self.assertEqual(input_panalties[1], -1) self.assertEqual(input_panalties[2], -1) def test_calculate_score(self): """ Ensure that game score get correctly """ input_validation = self.algo.validate_input() self.assertEqual(input_validation, {'error': 'None'}) self.algo.calculate_score() score = self.algo.get_score() self.assertEqual(score, 2) def test_alignment_result(self): """ Ensure that game alignment result get correctly """ self.algo.calculate_score() alignment_result = self.algo.get_align_result() self.assertEqual(alignment_result, ['match', 'match', 'mismatch', 'gap'])
class GameTestInputTypeNullInput2(unittest.TestCase): """ class for testing alignment game """ def setUp(self): self.algo = AlignmentGame('AA-TU', '', 2, -1, -1) def tearDown(self): del self.algo def test_null_input2(self): """ Testing for one null input """ input_validation = self.algo.validate_input() self.assertEqual(input_validation, {'error': 'inputs are not entered'})
class GameTestInputTypeInvalidInput2(unittest.TestCase): """ class for testing alignment game """ def setUp(self): self.algo = AlignmentGame('ACCC', 'AB-C', 2, -1, "a") def tearDown(self): del self.algo def test_invalid_input_panalty(self): """ Testing for invalid input panalty """ input_validation = self.algo.validate_input() self.assertEqual(input_validation, {'error': 'Invalid input sequence'})
def game_score(): request_data = request.get_json() seq_a = str(request_data['seq_a']) seq_b = str(request_data['seq_b']) match = int(request_data['match']) mismatch = int(request_data['mismatch']) gap = int(request_data['gap']) # alignment_game = AlignmentGame(seq_a,seq_b,match,mismatch,gap) # alignment_game.calculate_score() # resp = {'result':{}} # resp['result']['game_score'] = alignment_game.get_score() # resp['result']['alignment_result'] = alignment_game.get_align_result() game_algorithm = AlignmentGame(seq_a, seq_b, match, mismatch, gap) game_executer = GameExecuter(game_algorithm) result = game_executer.get_results() resp = {'result': result} return jsonify(resp)
def setUp(self): self.algo = AlignmentGame('C--TA', 'CACTU', 2, -1, -1)
def setUp(self): self.algo = AlignmentGame('AACTU', 'AC', 4, -1, -1)
def setUp(self): self.algo = AlignmentGame('ACCC', 'AB-C', 2, -1, "a")
def setUp(self): self.algo = AlignmentGame('AB++', 'AB-C', 2, -1, -1)
def setUp(self): self.algo = AlignmentGame('AA-TU', '', 2, -1, -1)
def setUp(self): self.algo = AlignmentGame('CUTTAC', '-', 2, -1, -1)
def setUp(self): self.algo = AlignmentGame('AAAC', 'AAC-', 2, -1, -1)