迭代适用于14次运行,但随后决定陷入循环并且不再产生值。不知道为什么,对我来说很好看。我已经检查了while循环,当我把它写出来时它们对我有意义。不确定第十三次或第十四次迭代是否对其停止的原因很重要。我也不知道是否只是我的电脑需要一段时间来编译所有这些数据。这只是我正在为项目工作的代码的一部分。请帮忙!
for (int c = 0; c < 50; c++) {
//for loop here(for the 1000 times it occurs
//create a temp array for gene expression and the subfamily
String[] tempArray1 = OlfrOP6; //array used to select genes from
String[] tempArray2 = subOP6; //corresponding array to get subfamily
Random randomizer = new Random();
int random = 0;
String[] fictCellOlfr = new String[OP6counter];
String[] fictCellSub = new String[OP6counter];
for (int a = 0; a < OP6counter; a++) {
boolean neg = true;
int count = 0;
random = randomizer.nextInt(1113);
while (neg == true) {
if (tempArray1[random].equals("-1")) {
random = randomizer.nextInt(1113);
} else {
fictCellOlfr[a] = tempArray1[random];
fictCellSub[a] = tempArray2[random];
tempArray1[random] = "-1";
neg = false;
}
}
}
tempArray1 = OlfrOP6;
tempArray2 = subOP6;
System.out.println(Arrays.toString(fictCellOlfr));
System.out.println(Arrays.toString(fictCellSub));
ArrayList < String > freqTempSub = new ArrayList < String > ();
ArrayList < Integer > freqTempSubCounter = new ArrayList < Integer > ();
freqTempSub.add(0, fictCellSub[0]);
freqTempSubCounter.add(0, 1);
for (int i = 1; i < 79; i++) {
String temp = fictCellSub[i];
boolean button = true;
for (int h = 0; h < freqTempSub.size(); h++) {
if (freqTempSub.get(h).equals(temp)) {
int temp2 = freqTempSubCounter.get(h);
freqTempSubCounter.set(h, temp2 + 1);
button = false;
}
}
if (button == true) {
freqTempSub.add(temp);
freqTempSubCounter.add(1);
}
}
//add this to excel
//Need to change this code so that it extends two columnns not chop it up
int d = 3 * (c + 1);
for (int a = 1; a <= freqTempSub.size(); a++) {
Cell name = outputSheet.getRow(0).createCell(d);
name.setCellValue("Subfamily");
Cell name1 = outputSheet.getRow(0).createCell(d + 1);
name1.setCellValue("Frequency");
String x = freqTempSub.get(a - 1);
String y = Integer.toString(freqTempSubCounter.get(a - 1));
String z = Integer.toString(freqTempSubCounter.size());
Cell cell = outputSheet.getRow(a).createCell(d); //null because freqTemp may be bigger than original
cell.setCellValue(x);
Cell cell1 = outputSheet.getRow(a).createCell(d + 1);
cell1.setCellValue(y + "/" + z);
}
uniqueSub.add(freqTempSubCounter.size());
//now add uniqueSub to Sheet 2 so that it can be used to make graph
System.out.println(uniqueSub);
}
for (int i = 1; i <= uniqueSub.size(); i++) {
Cell name = outputSheet1.createRow(0).createCell(0);
Cell cell = outputSheet1.createRow(i).createCell(0);
name.setCellValue("Unique Subfamily");
cell.setCellValue(uniqueSub.get(i - 1));
}