private static void writeDereplicateFiles( File dir) throws Exception
	{
		String[] files = dir.list();
		
		for( String s : files)
			if( s.startsWith(REP_PREFIX))
			{
				File file = new File(dir.getPath() + File.separator + s);
				
				HashMap<String, Integer> map = new HashMap<String, Integer>();
				
				FastaSequenceOneAtATime fsoat = new FastaSequenceOneAtATime(file);
				
				for( FastaSequence fs = fsoat.getNextSequence(); fs != null; fs = fsoat.getNextSequence())
				{
					Integer val = map.get(fs.getSequence());
					if( val == null)
						val =0;
					val++;
					map.put(fs.getSequence(), val);
				}

				List<Holder> list = new ArrayList<Holder>();
				
				for( String seq : map.keySet())
					list.add(new Holder(seq,map.get(seq)));
				
				Collections.sort(list);
				int numWritten=1;
				int totalSequences =0;
				int numSingletons =0;
				
				BufferedWriter writer = new BufferedWriter(new FileWriter(new File(dir.getPath() + File.separator + DEREP_PREFIX +  s.replace(REP_PREFIX, ""))));
				
				for( Holder h : list)
				{
					//if( h.num > 1)
					{
						writer.write(">" + s.replace(REP_PREFIX, "") + "_" + numWritten + "_" + h.num + "\n" );
						writer.write(h.sequence + "\n");
						totalSequences += h.num;
						numWritten++;
					}
					//else
					{
						numSingletons++;
					}
				}
				
				writer.flush();  writer.close();
				System.out.println(s.replace(REP_PREFIX, "") + " " + totalSequences + " " + numWritten + " " + numSingletons);
			}
	}