package uk.ac.leeds.ccg.cluster; /**Parameters class * Description: Parameter methods used by all clustering methods */ import java.io.*; import java.awt.*; import java.awt.event.*; public class Parameters{ // Version id private static final String version = "$id$"; // Members /**@param animate control for visualising search * @param thresh significance threshold for the test * @param popMin minimum population size * @param canMin minimum incidence count * @param hH rejection count for Monte Carlo test * @param meas type of statistic * @param minPnt minimum point count * @param maxSam sample size for bootstrap * @param maxMC integer Monte Carlo sample size * @param maxRep number of multiple testing re-runs */ private boolean animate; private double thresh,popMin,canMin,hH; private int meas,minPnt,maxSam,maxMC,maxRep; private boolean excess; // Constructors public Parameters(){ setDefaultParameters(); } public Parameters( File file ) { try { StreamTokenizer st = new StreamTokenizer( new BufferedReader( new InputStreamReader( new FileInputStream( file ) ) ) ); //System.out.println( "Setting parameters from " + file ); st.nextToken(); if ( st.sval.equalsIgnoreCase( "true" ) ) { setAnimate( true ); } else { setAnimate( false ); } 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 ); if ( st.sval.equalsIgnoreCase( "true" ) ) { setExcess( true ); } else { setExcess( false ); } } catch ( java.io.IOException e) { System.out.println( e + " in Parameters( File( " + file.toString() + " ) )" ); } } public Parameters( boolean animate, double thresh, double popMin, double canMin, double hH, int meas, int minPnt, int maxSam, int maxMC, int maxRep, boolean excess ){ setAnimate( animate ); setSignificanceThreshold( thresh ); setMinPopSize( popMin ); setMinIncidenceCount( canMin ); setMonteCarloRejectionCount( hH ); setStatType( meas ); setMinPointCount( minPnt ); setBootstrapSampleSize( maxSam ); setMonteCarloSampleSize( maxMC ); setMultipleTestReruns( maxRep ); setExcess( excess ); } // Methods public String tostring(){ return "[excess " + getExcess() + "]\n"+ "[animate " + getAnimate() + "]\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 thresh, double popMin, double canMin, double hH, int meas, int minPnt, int maxSam, int maxMC, int maxRep, boolean excess ) { setAnimate( animate ); setSignificanceThreshold( thresh ); setMinPopSize( popMin ); setMinIncidenceCount( canMin ); setMonteCarloRejectionCount( hH ); setStatType( meas ); setMinPointCount( minPnt ); setBootstrapSampleSize( maxSam ); setMonteCarloSampleSize( maxMC ); setMultipleTestReruns( maxRep ); setExcess( excess ); } public void setDefaultParameters(){ setParameters( false, 0.01d, 1.0d, 1.0d, 20.0d, 1, 1, 400, 200, 0, true ); } public boolean getAnimate() { return this.animate; } public void setAnimate( boolean animate ) { this.animate = animate; } public double getSignificanceThreshold() { return this.thresh; } public void setSignificanceThreshold( double thresh ) { this.thresh = thresh; } public double getMinPopSize() { return this.popMin; } public void setMinPopSize( double popMin ) { this.popMin = popMin; } public double getMinIncidenceCount() { return this.canMin; } public void setMinIncidenceCount( double canMin ) { this.canMin = canMin; } public double getMonteCarloRejectionCount() { return this.hH; } public void setMonteCarloRejectionCount( double hH ) { this.hH = hH; } public int getStatType() { return this.meas; } public void setStatType( int meas ) { this.meas = meas; } public int getMinPointCount() { return this.minPnt; } public void setMinPointCount( int minPnt ) { this.minPnt = minPnt; } public int getBootstrapSampleSize() {return maxSam;} public void setBootstrapSampleSize(int i) {maxSam=i;} public int getMonteCarloSampleSize() {return maxMC;} public void setMonteCarloSampleSize(int i) {maxMC=i;} public int getMultipleTestReruns() {return maxRep;} public void setMultipleTestReruns(int i) {maxRep=i;} public boolean getExcess() { return excess; } public void setExcess(boolean excess) { this.excess = excess;} public void writeParameters(File file) throws IOException,FileNotFoundException{ PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream(file)))); pw.println(getAnimate()); 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()); if ( getExcess() ) { pw.println(); } else { pw.println(); } System.out.println("Parameters saved to "+file); pw.flush(); pw.close(); } }