package uk.ac.leeds.ccg.cluster; /** GAM Parameters class * Description: Parameters methods specific to GAM */ import java.io.*; import java.awt.*; import java.awt.event.*; public class GamParameters extends Parameters { // Version id private static final String version = "$id$"; /**@param radMax maximum circle radius * @param radMin minimum circle radius * @param radInc circle increment * @param overlp overlap in radius between circles */ private double radMax,radMin,radInc,overlp; // Constructors public GamParameters() { setDefaultParameters(); } public GamParameters( File file ) { System.out.println( "Setting GAM parameters from " + file ); StreamTokenizer st = null; // Open file into a StreamTokenised try { st = new StreamTokenizer( new BufferedReader( new InputStreamReader( new FileInputStream(file) ) ) ); } catch ( java.io.FileNotFoundException e ) { System.out.println( e ); } try { 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(); setOverlp(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); } catch (java.io.IOException e) { System.out.println( e ); } } public GamParameters( boolean animate, double radMin, double radMax, double radInc, double overlp, 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); setOverlp(overlp); setSignificanceThreshold(thresh); setMinPopSize(popMin); setMinIncidenceCount(canMin); setMonteCarloRejectionCount(hH); setStatType(meas); setMinPointCount(minPnt); setBootstrapSampleSize(maxSam); setMonteCarloSampleSize(maxMC); setMultipleTestReruns(maxRep); } public String toString() { return "[animate "+getAnimate()+"]\n"+ "[Minimum radius "+getRadMin()+"]\n"+ "[Maximum radius "+getRadMax()+"]\n"+ "[Radius increment "+getRadInc()+"]\n"+ "[Circle overlap "+getOverlp()+"]\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 overlp, 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); setOverlp(overlp); 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); setOverlp(0.5f); 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 getOverlp() { return overlp; } public void setOverlp( double r ) { overlp=r; } public void writeParameters(File file) { PrintWriter pw = null; try { pw = new PrintWriter( new BufferedWriter( new OutputStreamWriter( new FileOutputStream(file)))); } catch (java.io.FileNotFoundException e) { System.out.println( e ); } pw.println(getAnimate()); pw.println(getRadMin()); pw.println(getRadMax()); pw.println(getRadInc()); pw.println(getOverlp()); 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(); } }