package uk.ac.leeds.ccg.cluster; /** SpatScan Parameters class * Description: Parameters methods specific to SpatScan */ import java.io.*; import java.awt.*; import java.awt.event.*; public class SpattimescanParameters extends Parameters { // Version id private static final String version = "$id$"; // Members /**@param radMax maximum circle radius * @param radMin minimum circle radius * @param radInc circle increment * @param timeMax latest time * @param timeMin earliest time * @param timeInc earliest time * @param numRuns number of runs */ private double radMax,radMin,radInc, timeMin,timeMax,timeInc; private int numRuns; // Constructors public SpattimescanParameters(){ setDefaultParameters(); } public SpattimescanParameters(File file) throws IOException,FileNotFoundException{ // Read into a stream tokenised buffered input stream StreamTokenizer st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( new FileInputStream (file)))); System.out.println ("Setting SpatScan parameters from "+file); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setAnimate(true);} else {setAnimate(false);} st.nextToken(); setRadMin(st.nval); st.nextToken(); setRadMax(st.nval); st.nextToken(); setRadInc(st.nval); st.nextToken(); setTimeMin(st.nval); st.nextToken(); setTimeMax(st.nval); st.nextToken(); setTimeInc(st.nval); st.nextToken(); setNumRuns((int)st.nval); st.nextToken(); setSignificanceThreshold(st.nval); st.nextToken(); setMinPopSize(st.nval); st.nextToken(); setMinIncidenceCount(st.nval); st.nextToken(); setMonteCarloRejectionCount(st.nval); st.nextToken(); setStatType((int)st.nval); st.nextToken(); setMinPointCount((int)st.nval); st.nextToken(); setBootstrapSampleSize((int)st.nval); st.nextToken(); setMonteCarloSampleSize((int)st.nval); st.nextToken(); setMultipleTestReruns((int)st.nval); } public SpattimescanParameters(boolean animate, double radMin, double radMax, double radInc, double timeMin, double timeMax, double timeInc, int numRuns, double thresh, double popMin, double canMin, double hH, int meas, int minPnt, int maxSam, int maxMC, int maxRep){ setAnimate(animate); setRadMin(radMin); setRadMax(radMax); setRadInc(radInc); setTimeMin(timeMin); setTimeMax(timeMax); setTimeInc(timeInc); setNumRuns(numRuns); setSignificanceThreshold(thresh); setMinPopSize(popMin); setMinIncidenceCount(canMin); setMonteCarloRejectionCount(hH); setStatType(meas); setMinPointCount(minPnt); setBootstrapSampleSize(maxSam); setMonteCarloSampleSize(maxMC); setMultipleTestReruns(maxRep); } // Methods public String toString(){ return "[animate "+getAnimate()+"]\n"+ "[Minimum radius "+getRadMin()+"]\n"+ "[Maximum radius "+getRadMax()+"]\n"+ "[Radius increment "+getRadInc()+"]\n"+ "[Earliest time "+getTimeMin()+"]\n"+ "[Latest time "+getTimeMax()+"]\n"+ "[Time increment "+getTimeInc()+"]\n"+ "[number of runs "+getNumRuns()+"]\n"+ "[significance threshold "+getSignificanceThreshold()+"]\n"+ "[minimum population size "+getMinPopSize()+"]\n"+ "[minimum incidence count "+getMinIncidenceCount()+"]\n"+ "[rejection count for Monte Carlo test "+getMonteCarloRejectionCount()+"]\n"+ "[type of statistic "+ getStatType()+"]\n"+ "[minimum point count "+getMinPointCount()+"]\n"+ "[sample size for bootstrap "+getBootstrapSampleSize()+"]\n"+ "[integer Monte Carlo sample size "+getMonteCarloSampleSize()+"]\n"+ "[number of multiple testing re-runs "+getMultipleTestReruns()+"]\n"; } public Parameters getParameters() {return this;} public void setParameters(boolean animate, double radMin, double radMax, double radInc, double timeMin, double timeMax, double timeInc, int numRuns, double thresh, double popMin, double canMin, double hH, int meas, int minPnt, int maxSam, int maxMC, int maxRep){ setAnimate(animate); setRadMin(radMin); setRadMax(radMax); setRadInc(radInc); setTimeMin(timeMin); setTimeMax(timeMax); setTimeInc(timeInc); setNumRuns(numRuns); setSignificanceThreshold(thresh); setMinPopSize(popMin); setMinIncidenceCount(canMin); setMonteCarloRejectionCount(hH); setStatType(meas); setMinPointCount(minPnt); setBootstrapSampleSize(maxSam); setMonteCarloSampleSize(maxMC); setMultipleTestReruns(maxRep); } public void setDefaultParameters(){ setRadMin(500.0f); setRadMax(5000.0f); setRadInc(500.0f); setTimeMin(0.0f); setTimeMax(50.0f); setTimeInc(10.0f); setNumRuns(249); super.setDefaultParameters(); } public double getRadMin() {return radMin;} public void setRadMin(double r){radMin=r;} public double getRadMax() {return radMax;} public void setRadMax(double r) {radMax=r;} public double getRadInc() {return radInc;} public void setRadInc(double r) {radInc=r;} public double getTimeMin() {return timeMin;} public void setTimeMin(double r){timeMin=r;} public double getTimeMax() {return timeMax;} public void setTimeMax(double r) {timeMax=r;} public double getTimeInc() {return timeInc;} public void setTimeInc(double r) {timeInc=r;} public int getNumRuns() {return numRuns;} public void setNumRuns(int d) {numRuns=d;} public void writeParameters(File file) throws IOException,FileNotFoundException{ PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream (file)))); pw.println(getAnimate()); pw.println(getRadMin()); pw.println(getRadMax()); pw.println(getRadInc()); pw.println(getTimeMin()); pw.println(getTimeMax()); pw.println(getTimeInc()); pw.println(getNumRuns()); pw.println(getSignificanceThreshold()); pw.println(getMinPopSize()); pw.println(getMinIncidenceCount()); pw.println(getMonteCarloRejectionCount()); pw.println(getStatType()); pw.println(getMinPointCount()); pw.println(getBootstrapSampleSize()); pw.println(getMonteCarloSampleSize()); pw.println(getMultipleTestReruns()); System.out.println ("Parameters saved to "+file); pw.flush(); pw.close(); } }