public static ChromosomeArray regenNBlocks( ChromosomeArray cha, int blocksize, int trigger, int endsize) { ChromosomeArray chb = new ChromosomeArray(cha.chromosome, cha.strand, cha.minIndex, cha.maxIndex); chb.maxIndex = -1; int aloc = 0; int bloc = 0; int ns = 0; // Process start while (cha.get(aloc) == 'N') { chb.set(bloc, 'N'); ns++; aloc++; bloc++; } while (ns < endsize) { chb.set(bloc, 'N'); ns++; bloc++; } ns = 0; // Process middle while (aloc <= cha.maxIndex) { byte b = cha.get(aloc); if (b == 'N') { ns++; } else { if (ns >= trigger) { while (ns < blocksize) { chb.set(bloc, 'N'); bloc++; ns++; } } ns = 0; } chb.set(bloc, b); aloc++; bloc++; } // Process end ns = 0; for (int i = chb.maxIndex; i >= 0; i--) { if (chb.get(i) != 'N') { break; } } while (ns < endsize) { chb.set(chb.maxIndex + 1, 'N'); ns++; } return chb; }