}
public void createPlot(String plotTitle, File outdir) throws IOException{
XYSeriesCollection dataset = new XYSeriesCollection();
DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset();
PrintStream boxchart_dataStream = new PrintStream(new File(outdir, plotTitle + ".boxchart.txt"));
boxchart_dataStream.println("#\tkmer" + "\trank" + "\t" + "max" + "\t" + "avg" + "\t" + "min" +
"\t" + "Q1" + "\t" + "median" + "\t" + "Q3" + "\t" + "98Pct" + "\t" + "2Pct" + "\t" + "comparisons" + "\t" + "sum");
for ( int i = 0; i < ranks.size(); i++){
long[] countArray = sabCoutMap.get(ranks.get(i));
if ( countArray == null) continue;
double sum = 0.0;
int max = 0;
int min = 100;
double mean = 0;
int Q1 = -1;
int median = -1;
int Q3 = -1;
int pct_98 =-1;
int pct_2 = -1;
long comparisons = 0;
int minOutlier = 0; // we don't care about the outliers
int maxOutlier = 0; //
XYSeries series = new XYSeries(ranks.get(i));
for ( int c = 0; c< countArray.length; c++){
if ( countArray[c] == 0 ) continue;
comparisons += countArray[c];
sum += countArray[c] * c;
if ( c < min){
min = c;
}
if ( c > max){
max = c;
}
}
// create series
double cum = 0;
for ( int c = 0; c< countArray.length; c++){
if ( countArray[c] == 0 ) continue;
cum += countArray[c];
int pct = (int) Math.floor(100*cum/comparisons);
series.add(c, pct);
if ( pct_2 == -1 && pct >=5){
pct_2 = c;
}
if ( Q3 == -1 && pct >=25){
Q3 = c;
}
if ( median == -1 && pct >=50){
median = c;
}
if ( Q1 == -1 && pct >=75){
Q1 = c;
}
if ( pct_98 == -1 && pct >=98){
pct_98 = c;
}
}
if ( !series.isEmpty()) {
dataset.addSeries(series);
BoxAndWhiskerItem item = new BoxAndWhiskerItem(sum/comparisons, median, Q1, Q3, pct_2, pct_98, minOutlier, maxOutlier, new ArrayList());
scatterDataset.add(item, ranks.get(i), "");
boxchart_dataStream.println("#\t" + GoodWordIterator.getWordsize() + "\t" + ranks.get(i) + "\t" + max + "\t" + format.format(sum/comparisons) + "\t" + min +
"\t" + Q1 + "\t" + median + "\t" + Q3 + "\t" + pct_98 + "\t" + pct_2 + "\t" + comparisons + "\t" + sum);
}
}