/*
 * Author: tdanford
 * Date: May 8, 2009
 */
package edu.mit.csail.cgs.sigma.expression.rma;

import java.util.*;
import java.io.*;

import edu.mit.csail.cgs.cgstools.singlevarcalculus.FunctionModel;
import edu.mit.csail.cgs.cgstools.slicer.*;
import edu.mit.csail.cgs.ewok.verbs.Filter;
import edu.mit.csail.cgs.ewok.verbs.FilterIterator;
import edu.mit.csail.cgs.sigma.expression.segmentation.Segment;
import edu.mit.csail.cgs.sigma.expression.workflow.WholeGenome;
import edu.mit.csail.cgs.sigma.expression.workflow.WorkflowProperties;
import edu.mit.csail.cgs.sigma.expression.workflow.models.DataSegment;
import edu.mit.csail.cgs.utils.iterators.SerialIterator;
import edu.mit.csail.cgs.utils.models.*;
import edu.mit.csail.cgs.utils.models.data.*;

public class HRMA extends Model {
	
	public static void main(String[] args) { 
		WorkflowProperties props = new WorkflowProperties();
		try {
			//String key = "s288c";
			String key = "txns288c";
			
			if(args.length > 0) { key = args[0]; }
			WholeGenome genome = WholeGenome.loadWholeGenome(props, key);
			
			genome.loadIterators();
			Iterator<DataSegment> segs = new SerialIterator<DataSegment>(
					genome.getWatsonSegments(), genome.getCrickSegments());
			
			segs = new FilterIterator<DataSegment,DataSegment>(new Filter<DataSegment,DataSegment>() { 
				public DataSegment execute(DataSegment s) { 
					return s.hasConsistentType(Segment.LINE, new Integer[] { 0, 2 }) ? s : null;
				}
			}, segs);
			
			HRMA hrma = new HRMA(segs, 500);
			
			int n = 50;
			
			for(int i = 0; i < n; i++) { 
				hrma.sample();
			}
			
			Integer[] fg = new Integer[] { 0, 2 };
			Integer[] bg = new Integer[] { 1, 3 };
			hrma.printDiffProbs(100, fg, bg);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
