private static void buildIndex(String dataFile) {
		System.out.println("Building Index ... ");
		String indexFile = dataFile + ".idx";
		try {
			StringBuilder sb = new StringBuilder();
			BufferedReader br = new BufferedReader(new FileReader(dataFile));
			String line = null;
			String tmp = null;
			long offset = 0;
			long chrSize = 0;
			long chrOffset = 0;
			int lineLength = 0;

			boolean isFirst = true;
			while ((line = br.readLine()) != null) {
				offset += (line.length() + EXTRA);
				if (line.length() <= 0)
					continue;
				if (line.charAt(0) == ';')
					continue;
				if (line.charAt(0) == '>') {
					if (!isFirst) {
						// if (tmp.compareTo(chr) == 0) {
						// globalOffset = chrOffset;
						// charPerLine = lineLength;
						// }
						sb.append(tmp);
						sb.append("\t");
						sb.append(Long.toString(chrSize));
						sb.append("\t");
						sb.append(Long.toString(chrOffset));
						sb.append("\t");
						sb.append(Long.toString(lineLength));
						sb.append("\t");
						sb.append(Long.toString(lineLength + EXTRA));
						sb.append("\t");
						sb.append(ENDOFLINE);

						indexMap.put(
								tmp,
								new String[] { Long.toString(chrOffset),
										Long.toString(lineLength) });

						chrSize = 0;
						chrOffset = 0;
						lineLength = 0;
					}
					isFirst = false;
					lineLength = 0;
					int pos = line.indexOf(' ');
					if (pos == -1)
						pos = line.length();
					tmp = line.substring(1, pos);
					chrOffset = offset;
				} else {
					chrSize += line.length();
					if (lineLength < line.length())
						lineLength = line.length();
				}
			}
			// if (tmp.compareTo(chr) == 0) {
			// globalOffset = chrOffset;
			// charPerLine = lineLength;
			// }
			sb.append(tmp);
			sb.append("\t");
			sb.append(Long.toString(chrSize));
			sb.append("\t");
			sb.append(Long.toString(chrOffset));
			sb.append("\t");
			sb.append(Long.toString(lineLength));
			sb.append("\t");
			sb.append(Long.toString(lineLength + EXTRA));
			sb.append("\t");
			sb.append(ENDOFLINE);

			br.close();
			BufferedWriter bw = new BufferedWriter(new FileWriter(indexFile));
			// bw.append(Integer.toString(charPerLine));
			// bw.append("\n");
			bw.append(sb.toString());
			bw.close();
		} catch (FileNotFoundException e) {
			System.err.println("Data file not found.");
			System.err.println("Abort!");
			System.exit(1);
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}