public int simMutate(File aFile, mutList aMutList, hap aHap) throws IOException{
			int i,summut = 0;
			double mutrate, probSum = 0;
			double loc;
			int numRegions,reg,numMuts = 0;
			double randMark,begin;
			double[] reglen,probRegion,treeTime;
			int[] nMutByRegion = null;
			numRegions = dem.getNumRegs();
			reglen = new double[numRegions];
			treeTime = new double[numRegions];
			for(reg= 0;reg<numRegions;reg++){//parallel process would make it faster
				treeTime[reg] = dem.totalTreeTime(reg);
				reglen[reg] = dem.getRegLength(reg);
				probSum += treeTime[reg] + reglen[reg];
			}
			if(fixedNumMut>0){
				probRegion = new double[numRegions];
				nMutByRegion = new int[numRegions];
				for(reg = 0;reg<numRegions;reg++){
					probRegion[reg] = treeTime[reg]*reglen[reg] /probSum;
				}
				cosiRand.multiNom.multinom(numRegions, fixedNumMut, probRegion, nMutByRegion);
			}
			for(reg=0;reg<numRegions;reg++){
				FileWriter fileOut = new FileWriter(aFile.getName(),true);
				BufferedWriter out = new BufferedWriter(fileOut);
				begin = dem.regBegin(reg);
				
				if(fixedNumMut==-1){
					mutrate = theta * treeTime[reg] * reglen[reg];
					numMuts = poissoner.poission(mutrate);
						out.write(String.format("> [%f,  %f]  time %d E[muts] = %f (%d)\n",
								begin,reglen[reg],(int)treeTime[reg],mutrate,numMuts));
				
				}
					
				else{ 
					numMuts = nMutByRegion[reg];
					if(aFile.canWrite()){
						out.write(String.format("> [%f, %f]  time %d E[muts] = %f (%d)\n",
									begin,reglen[reg],(int) treeTime[reg],0,numMuts));
					}
					
					
				}
				out.close();
				summut += numMuts;
				for(i=0;i<numMuts;i++){
					loc = begin + random.randomDouble()*reglen[reg];
					randMark = random.randomDouble();
					mutate.mutateFindAndPrint(aFile, reg, loc, randMark, treeTime[reg], aMutList, aHap);
				}
			}
			return numMuts;
			
		}