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 SpatscanParameters 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 numRuns number of runs */ private double radMax,radMin,radInc; private int numRuns; // Constructors public SpatscanParameters(){ setDefaultParameters(); } public SpatscanParameters(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(); 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 SpatscanParameters(boolean animate, double radMin, double radMax, double radInc, 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); 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"+ "[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, 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); 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); 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 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(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(); } }