public static void main(String[] args) throws Exception
	{	
		
		BufferedWriter writer = new BufferedWriter(new FileWriter(new File( 
				ConfigReader.getBurkholderiaDir() + File.separator +  "summary" + File.separator +
				"summary.txt")));
		writer.write("fileA\tfileB\tnumInCommon\tkey\ttime\n");
		
		BufferedWriter detailedWriter = new BufferedWriter(new FileWriter(new File( 
				ConfigReader.getBurkholderiaDir() + File.separator + "summary" + File.separator + 
				"details.txt"	)));
		
		detailedWriter.write("fileA\tfileB\tnumInCommon\tkey\ttime\tlongID\taCounts1\taCounts2\taCounts3\taCounts4\tbCounts1\tbCounts2\tbCounts3\tbCounts4\tconsensusA\tconsensusB\n");
		
		List<PairedReads> pairedList = DoAllBurkComparisons.getAllBurkholderiaPairs();
		for(int x=0; x < pairedList.size()-1; x++)
		{
			PairedReads prx = pairedList.get(x);
			
			if( FileUtils.getCountsFile(prx.getFirstFileName()).exists() && 
					FileUtils.getCountsFile(prx.getSecondFileName()).exists())
			{
				for( int y=x+1; y < pairedList.size(); y++)
				{
					PairedReads pry = pairedList.get(y);
					
					if( FileUtils.getCountsFile(pry.getFirstFileName()).exists() 
							&& FileUtils.getCountsFile(pry.getSecondFileName()).exists())
					{
						HashMap<Long, SnpResultFileLine> map1 = SnpResultFileLine.parseFile(
								FileUtils.getSNPResultsFile(  FileUtils.getCountsFile(prx.getFirstFileName())
														, FileUtils.getCountsFile(pry.getFirstFileName()))	);
						map1 = SnpResultFileLine.filter(map1, MIN_PVALUE);
							

						HashMap<Long, SnpResultFileLine> map2 = SnpResultFileLine.parseFile(
									FileUtils.getSNPResultsFile(  FileUtils.getCountsFile(prx.getFirstFileName())
															, FileUtils.getCountsFile(pry.getSecondFileName()))	);
						map2 = SnpResultFileLine.filter(map2, MIN_PVALUE);
							

						HashMap<Long, SnpResultFileLine> map3 = SnpResultFileLine.parseFile(
										FileUtils.getSNPResultsFile(  FileUtils.getCountsFile(prx.getSecondFileName())
																, FileUtils.getCountsFile(pry.getFirstFileName()))	);
						map3 = SnpResultFileLine.filter(map3, MIN_PVALUE);
						

						HashMap<Long, SnpResultFileLine> map4 = SnpResultFileLine.parseFile(
										FileUtils.getSNPResultsFile(  FileUtils.getCountsFile(prx.getSecondFileName())
																, FileUtils.getCountsFile(pry.getSecondFileName()))	);
						map4 = SnpResultFileLine.filter(map4, MIN_PVALUE);
						
						HashSet<Long> commonLongs = new HashSet<Long>();
						commonLongs.addAll(map1.keySet());
						
						commonLongs.retainAll(map2.keySet());
						commonLongs.retainAll(map3.keySet());
						commonLongs.retainAll(map4.keySet());

						System.out.println(map1.size() +  " " + map2.size() + " " + map3.size() + " " 
								+ map4.size() + " " + commonLongs.size());
						
						writer.write(prx.getFirstFileName().getName() + "\t" + 
										pry.getSecondFileName().getName() + "\t" + 
											commonLongs.size() + "\t" + 
												getCode(prx.getFirstFileName().getName(), pry.getSecondFileName().getName()) + "\t"	
												 + getYears(prx.getFirstFileName().getName(), pry.getSecondFileName().getName()) +  "\n");
						
						for(Long longID : commonLongs)
						{
							detailedWriter.write(prx.getFirstFileName().getName() + "\t" + 
									pry.getSecondFileName().getName() + "\t" + 
										commonLongs.size() + "\t" + 
											getCode(prx.getFirstFileName().getName(), pry.getSecondFileName().getName()) + "\t"	
											 + getYears(prx.getFirstFileName().getName(), pry.getSecondFileName().getName()) + "\t");
							
							detailedWriter.write(longID +"\t" );
							detailedWriter.write(map1.get(	longID).getCounts1() + "\t");
							detailedWriter.write(map2.get(	longID).getCounts1() + "\t");
							detailedWriter.write(map3.get(	longID).getCounts1() + "\t");
							detailedWriter.write(map4.get(	longID).getCounts1() + "\t");
							
							detailedWriter.write(map1.get(	longID).getCounts2() + "\t");
							detailedWriter.write(map2.get(	longID).getCounts2() + "\t");
							detailedWriter.write(map3.get(	longID).getCounts2() + "\t");
							detailedWriter.write(map4.get(	longID).getCounts2() + "\t");
							detailedWriter.write(getConsensus(longID, map1, map2, map3, map4, true) + "\t");
							detailedWriter.write(getConsensus(longID, map1, map2, map3, map4, false) + "\n");
							detailedWriter.flush();
					
						}
						
						writer.flush();
						

					}										
				}
			}
		}
		
		detailedWriter.flush();  detailedWriter.close();
		writer.flush(); writer.close();
	}