def test_func_write_FASTA(self): test_array = convert_to_obj_array( ["> alirocumab", "AAAAAAKKKKK", "> secondone", "TTTTTTTT"]) if not os.path.exists((get_test_dir() + "/outputs")): os.mkdir(get_test_dir() + "/outputs") write_fasta(get_test_dir() + "/outputs/test-write.txt", test_array) output_file = get_test_dir() + "/outputs/tidied-test-write.txt" try: path_exists = os.path.exists(output_file) self.assertEqual(1, path_exists) finally: os.remove(output_file)
def test_class_method_ProcessFASTA_get_fasta_gold_standard(self): test_processfasta = ProcessFasta( get_test_dir() + "/inputs/test_gold_standard.txt", False, False) test_processfasta.get_fasta() valid_array = test_processfasta.validate_fasta() self.assertEqual("> alirocumab", valid_array[0].id) self.assertEqual("MVKVYAPASSANMSVGFDVLGAAVTPVDGALLGDVVTVEAAETF", valid_array[0].sequence)
def test_func_read_fasta_excess_whitespace_multi(self): input_array = read_fasta(get_test_dir() + "/inputs/test_excess_whitespace_multi.txt") test_array = remove_whitespace(input_array) ref_array = [ "> alirocumab1", "MVKVYAPASSANMSVGFDVLGAA", "> alirocumab2", "MVKVYAPASSANMSVGFDVLGAA", "> alirocumab3", "MVKVYAPASSANMSVGFDVLGAA" ] self.assertEqual(ref_array, test_array)
def test_class_method_ProcessFASTA_get_fasta_excess_whitespace_multi(self): test_processfasta = ProcessFasta( get_test_dir() + "/inputs/test_excess_whitespace_multi.txt", False, False) test_processfasta.get_fasta() valid_array = test_processfasta.validate_fasta() self.assertEqual("> alirocumab1", valid_array[0].id) self.assertEqual("MVKVYAPASSANMSVGFDVLGAA", valid_array[0].sequence) self.assertEqual("> alirocumab2", valid_array[1].id) self.assertEqual("MVKVYAPASSANMSVGFDVLGAA", valid_array[1].sequence) self.assertEqual("> alirocumab3", valid_array[2].id) self.assertEqual("MVKVYAPASSANMSVGFDVLGAA", valid_array[2].sequence)
def test_func_read_fasta(self): test_array = read_fasta(get_test_dir() + "/inputs/test_gold_short.txt") ref_array = ["> alirocumab", "MVKVYAPASSANMSVGFDVL", "GAAVTPVDG"] self.assertEqual(ref_array, test_array)
def test_class_method_ProcessFASTA_get_fasta_ID_only_single(self): fasta_array = read_fasta(get_test_dir() + "/inputs/test_ID_only_single.txt") with self.assertRaisesRegex(Exception, "Unpaired ID and sequence"): convert_to_obj_array(fasta_array)
def test_func_read_fasta_empty(self): with self.assertRaisesRegex(Exception, "No data in file"): read_fasta(get_test_dir() + "/inputs/test_empty.txt")