% this version is only specific for Syngenta
% mainly for hypothesis selection based on trees
% settings and cross validation are more modules

% in terms of tomato input files
% use Ondex ID directly -- rather than ex0
% new constraint -- direction of same reaction
% mutant and time constraint
% score function is specific for the data 


% For cancer project -- genEIs_T_constraintIncorporated.pl need to be replaced -- 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load in build-in libraries
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

:-use_module(library(lists)).
:-use_module(library(terms)).
:-use_module(library(ordsets)).
:-use_module(library(rbtrees)).
:-use_module(library(random)).
:-use_module(library(apply_macros)).


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  mc-TopLog
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:-['source/settings.pl'].

:-['source/genEIs_T_constraintIncorporated.pl']. %_multiE
:-['source/topTheory_varConnection.pl'].

%:-['source/genTmE.pl'].
%:-['source/crossProduct_allEx.pl'].

:-['source/nonGroundHBuilder.pl'].

:-['source/covering.pl']. 
%:-['source/covering_syngenta_1.pl']. % used before for ex0
%:-['source/multiECovering.pl'].

%:-['source/countingChoosing_temp.pl']. %countingChoosing_onlyCounting
%:-['source/allEITs_BayesianCounting.pl'].
%:-['source/bayes_syngenta.pl'].
%:-['source/countTheory.pl']. %
:-['source/insertTheories/decomposed_intoCla_outputed.pl']. 
%:-['source/insertTheories/decomposed_positionID.pl']. %decomposed_intoCla.pl
%:-['source/likelihood_posterial.pl'].

%:-['source/score/scoreCla_GE_BOTHTimeMutant_constrainted.pl']. %
%:-['source/score/scoreCla_GE_Time_Mutant_constrainted.pl'].  %scoreCla_GE %shared_NoLength %scoreTheory_GE_multivariate
%:-['source/score/shared_NoLength.pl'].
%:-['source/score/scoreTheory_GE_multivariate.pl'].

:-['source/cross_validation_sepTrain_and_Test.pl']. % _temp
:-['source/exProcess.pl'].
:-['source/utilities.pl'].
:-['source/programTransform.pl']. % this one haven't been 


%:-['source/cross_product_thretholdPruning.pl'].
%:-['source/hypothesisSelection_preprocssing_smallestShared.pl'].
%:-['source/hypothesisSelection_smallestShared.pl'].
%:-['source/hypothesisSelection_domainSpecific.pl'].
%:-['source/treeConstruction/hypothesisSelection.pl'].

:-['source/treeConstruction/coverageNonSorted_fluxRecord.pl']. % coverageSorted_fluxRecord %_beamSearch
%:-['source/treeConstruction/differentDescriptionLength/hypothesisSelection_groupingChoosing_keepPreSelection_FluxPassing.pl']. 	%hypothesisSelection_noEIs_combineCheck	
%hypothesisSelection_groupingChoosing_noRecordForCombineAndCompeting
%:-['source/treeConstruction/differentDescriptionLength/hypothesisSelection_group_ScoreBased.pl']. %hypothesisSelection_groupingChoosing_keepPreSelection_FluxPassing_beamSearch_EIsubsetIgnored %hypothesisSelection_groupingChoosing_keepPreSelection_FluxPassing_beamSearch_fewRecord
%:-['source/treeConstruction/differentDescriptionLength/hypothesisSelection1.pl'].
:-['source/treeConstruction/differentDescriptionLength/hypothesisSelection_groupingChoosing_keepPreSelection_FluxPassing_beamSearch_EIsubsetIgnored2.pl']. % _newCombinable_2011_9_26

%:-['source/treeConstruction/draw.pl']. 
%:-['source/claIndex.pl']. 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Data 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% !!!!! remember to change the retract in 'covering.pl'
%:-['artificialData/bioNetwork/inoue/ex'].
%:-['artificialData/bioNetwork/metalog/hyEx'].
%:-['artificialData/bioNetwork/ecRule/ecClass1Ex'].
%:-['artificialData/animal/ex'].
%:-['artificialData/grammar/grammar'].
%:-['artificialData/bioNetwork/reactionReconstruction/ex'].
%:-['artificialData/odd_even/ex'].
%:-['artificialData/tomato/tomato_learningData/ex'].
%:-['artificialData/metalog/hyEx'].
%:-['artificialData/tomato/tomato_data.pl']. 
%:-['artificialData/tomato/archive/11_30/tomato_data.pl']. 
:-['artificialData/cancer/cancer_data.pl']. 
%:-['artificialData/hexose/hexose_data.pl']. 
%:-['artificialData/rsToy/candidateH0.pl'].
%:-['artificialData/toy_example.pl'].

%:-['artificialData/familyTree/family.pl']. 
%:-['artificialData/eventCalculus/data.pl']. 

/*
:-['artificialData/odd_even/odd_evenEx'].
%:-['artificialData/odd_even/odd_evenTopCla'].
:-['artificialData/odd_even/odd_evenTopCla_nonFixLength'].
%:-['artificialData/odd_even/singleCla/t'].
%:-['artificialData/odd_even/singleCla/t_nonFixLength'].
%:-['artificialData/odd_even/singleCla/b'].
%:-['artificialData/odd_even/singleCla/odd_even_automa'].
%:-['artificialData/odd_even/singleCla/evInputOddEven'].
%:-['artificialData/odd_even/theory/t'].
:-['artificialData/odd_even/theory/t_nonFixLength'].
%:-['artificialData/odd_even/theory/t_nonFixLength_special'].
:-['artificialData/odd_even/theory/b'].
%:-['artificialData/odd_even/theory/mE/test'].
%:-['artificialData/odd_even/theory/mE/t'].
%:-['artificialData/odd_even/theory/mE/b'].
*/

%:-['artificialData/path_edge/path_edgeEx'].
%:-['artificialData/path_edge/path_edgeTopCla'].
%:-['artificialData/path_edge/experiment/0/t'].
%:-['artificialData/path_edge/experiment/0/b'].
%:-['artificialData/path_edge/experiment/abduction/t'].
%:-['artificialData/path_edge/experiment/abduction/b'].
/*
%:-['artificialData/path_edge/AILP/path_edge'].
%:-['artificialData/path_edge/AILP/evInputPath_edge'].
%:-['artificialData/path_edge/abduction/path_edge'].
%:-['artificialData/path_edge/abduction/evInputPath_edge'].
%:-['artificialData/path_edge/induction/path_edge'].
%:-['artificialData/path_edge/induction/path_edge_automa'].
%:-['artificialData/path_edge/induction/evInputPath_edge'].
*/


/*
%:-['artificialData/grammar/grammar'].
%:-['artificialData/grammar/evInput_grammar'].
%:-['artificialData/grammar/AILP/12/grammarLengthLimit'].
%:-['artificialData/grammar/AILP/12/grammar'].
%:-['artificialData/grammar/AILP/12/evInput_grammar'].
*/



:- dynamic claID_mapping/2.




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output Version Information
mcTopLog_version(1).
mcTopLog_manual('http://www.doc.ic.ac.uk/~dl308/MC-Toplog/user_manual.html').

versionInfo:-
	nl, nl,
	write('MC-TopLog Version '), 
	mcTopLog_version(Version), write(Version), nl,
	mcTopLog_manual(Man),
	write('Manual: '),
	write(Man), nl, nl.

%training_examples([90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110]).

run:-	yap_flag(argv,[InputFile1,InputFile2]),
 	consult(InputFile2),
	training_examples(TrainEIs),%write(TrainEIs),
	test_examples(TestEIs),

	(set(etoB,yes)->
		maplist(removeTestEI,TestEIs,RemovedEIsDetail); 
		Foo=0 	% do nothing
	),
	gen_output_readIn_candiateH(TrainEIs),
	indentifySharedHs(TrainEIs,T_EITIs),
	outputToC(TrainEIs,T_EITIs).

% ideally, you need to remove training data when learning, but since you 


:- 	yap_flag(argv,[TimePoint,Fold_Index0]),	%[InputFile1,TimePoint,Fold_Index0]),
	%[TimePoint,Fold_Index0]=['Day1','10'],
	getAllEx_oneTimePoint(TimePoint,AllEIs),
	%atom_number(Fold_Index0,Fold_Index_original),	Fold_Index is Fold_Index_original+1,
	atom_number(Fold_Index0,Fold_Index),
	get_folds(Fold_Index,AllEIs,OneFoldEIs),
	%atom_concat(['./artificialData/cancer/experiments/progolH/',TimePoint,'/','hypoonly_',Fold_Index0,'.txt'],FileName), 
	atom_concat(['./artificialData/cancer/experiments/mcTopLogH_GE_gen3-8/',TimePoint,'_',Fold_Index0,'.pl'],FileName), %mcTopLogH_gen3_GE
	consult(FileName),
	test_only(OneFoldEIs,Result),
	tell('oneFoldPrediction.txt'),
	write(Result),write(' '),
	told.

compression:- yap_flag(argv,[TimePoint,Fold_Index0]),	
	%[TimePoint,Fold_Index0]=['rin_late','20'],
	atom_concat([TimePoint,'_',Fold_Index0,'.pl'],FileName),
	consult(FileName),
	computeCompression(Compression),

	tell('oneFoldPrediction.txt'),
	write(Compression),write(' '),
	told.