:- use_module(library(plunit)). :- begin_tests(pattern). has_start(Start, String) :- atom_concat(Start, _, String). count_start(Atom, List, Count) :- include(has_start(Atom), List, L), length(L, Count). test('pattern_fail') :- command('pattern_reduction("library/examples/sepi/MM5.bc").'), read_file_to_string("library/examples/sepi/MM5_reduced.bc", String, []), String = "S+E=>ES.\nES=>S+E.\nES=>P+E.\nES=>_.\n". test('pattern_success') :- command('pattern_reduction("library/examples/sepi/MM1.bc").'), read_file_to_string("library/examples/sepi/MM1_reduced.bc", String, []), String = "S+E=>P+E.\n". test('pattern_intermediary_success') :- with_option([r_1: no], pattern_reduction("library/examples/sepi/MM6.bc")), read_file_to_string("library/examples/sepi/MM6_reduced.bc", String, []), String = "S+E=>P+E.\n". test('pattern_mapk1_to_mapk3') :- command('pattern_reduction("library/examples/sepi/mapk1.bc").'), with_output_to( atom(Result), command('search_reduction("library:examples/sepi/mapk1_reduced.bc", "library:examples/sepi/mapk3.bc").') ), atomic_list_concat(Split, '\n', Result), count_start('sepi', Split, 1), with_output_to( atom(Result2), command('search_reduction("library:examples/sepi/mapk3.bc", "library:examples/sepi/mapk1_reduced.bc").') ), atomic_list_concat(Split2, '\n', Result2), count_start('sepi', Split2, 1). test('pattern_mapk2_to_mapk3') :- with_option([r_1: no], pattern_reduction("library/examples/sepi/mapk2.bc")), with_output_to( atom(Result), command('search_reduction("library:examples/sepi/mapk2_reduced.bc", "library:examples/sepi/mapk3.bc").') ), atomic_list_concat(Split, '\n', Result), count_start('sepi', Split, 1), with_output_to( atom(Result2), command('search_reduction("library:examples/sepi/mapk3.bc", "library:examples/sepi/mapk2_reduced.bc").') ), atomic_list_concat(Split2, '\n', Result2), count_start('sepi', Split2, 1). test('pattern_R-2_EP') :- with_output_to( atom(Output), command('pattern_reduction("library/examples/sepi/mapk26.bc").') ), Output = 'Number of Michaelis Menten motifs: 2\nNumber of variant of Michaelis Menten motifs: 0\n'. :- end_tests(pattern).