/* 
0. Each version's scoring is based on agreement with GE data
	agree: 0.1
	no GE data while known EC
	no GE data while unknown EC (enzyme not assigned EC; no assigned enzymes)
	
	
1. the number of examples that sharing each of its facts
	*** while this is not considering the length of each facts.
*/


% Input is [1-[], 2-[] ...]

scoreAll(EIsTs,Tree,ScoredEIsTs):-
	maplist(scoreEITs(Tree),EIsTs,ScoredEIsTs).

% for each example, score all its candidates and sorted

scoreEITs(Tree,EI-Ts,EI-SortedScoredTs):-
	maplist(scoreEachT(Tree),Ts,ScoredTs),
	sort(ScoredTs,SortedScoredTs),
	write('Here are candidates for '), write(EI),nl,print_list(SortedScoredTs).



scoreEachT(Tree,T,TotalScore-T):-
	maplist(scoreEachHypothesizedRS(Tree),T,Scores),
	%nl,write(Scores-T),nl,
	multiplyList(Scores,TotalScore).


scoreEachHypothesizedRS(Tree,HypothesizedRS,Score):-
	rb_lookup(HypothesizedRS,EI_List,Tree),
	length(EI_List,SharedNum),
/*	((SharedNum=1;SharedNum=2)->
		Foo=1;
		write('One shared by more than one example '),write(SharedNum-HypothesizedRS),nl
	),*/

	HypothesizedRS=[rs-{ReactionID,LimitingType,HypothesizedState,Time}],%UsedRule,
	scoreByGEData(ReactionID,HypothesizedState,Time,Score_GE),
	Score is SharedNum*Score_GE.

	
scoreByGEData(ReactionID,HypothesizedState,Time,Score_GE):-
	catalyzed_by_ECclass(ReactionID,EC_Number),!,	
	(concentration_enzClass(EC_Number,GEChange,Time)->
		(propotional(HypothesizedState,GEChange)->
				Score_GE=0.1;%write('Yes, agreed'),nl;  % whatever up/down/no_change, as long as they agree with each other
				Score_GE=0.001 %,write('No, disagreed'),nl
			);
		Score_GE=0.01
		).


scoreByGEData(ReactionID,HypothesizedState,Time,0.01). %:-write('Here is one that not annotated ').
	% what score to unannotated reaction? mid point, as unmeasured EC


propotional(cataIncreased,up).
propotional(cataDecreased,down).
propotional(cataNoChange,noChange).




