import prompt.engine.EngineResults;
import prompt.engine.IEngineResults;
import prompt.gui.cfg.GuiCfg;
import prompt.statistic.*;
import prompt.ui.DataTable;


public class DemoEnrichmentTest2 {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		//read default configuration e.g. where is the R-Path,
		//see the online help for further information
		GuiCfg.readCfgStudio();
		
		//load the data
		EngineResults result0 = new EngineResults();
		
		String data = "CAT1\tCAT2\n"+
		"DE\t500\t125000\n"+
		"not_DE\t3500\t500000\n";
		
		String desc1= "description 1";
		String desc2= "description 2";
		boolean rownames = true;
		String resultType = "nur_wichtig fuer_default_visualisations";
		result0.setResult( data,  desc1,  desc2,
		             rownames, resultType);	  
		 
		//result0.loadDataFromFile("data.txt");
		DataTable dataTable = new DataTable(result0, "Title");
		dataTable.showTable();
		
		
		//Here the test is performed
//		Note the absolute path to the data filename
		ChiSq test0 = new prompt.statistic.ChiSq();
		
		test0.init(result0, "testm");
		test0.run();
		IEngineResults result1 = test0.getResults();

		String title = "Test results: p-val="+test0.getPValue();
		dataTable = new DataTable(result1, title);
		dataTable.showTable();
//		the test result is an IEngineResult that contains the p-value and test statistics in a key-value manner

		System.out.println(result1);
//		or alternatively
		System.out.println(test0.getPValue());


	}

}

