// Path: src/main/java/ch/ethz/bsse/indelfixer/utils/StatusUpdate.java
// public class StatusUpdate {
// 
//     private static final long start = System.currentTimeMillis();
//     private static final DateFormat df;
//     public static int readCount = 0;
//     public static int unmappedCount = 0;
//     public static int tooSmallCount = 0;
//     public static int alignCount1 = 0;
//     public static int alignCount2 = 0;
//     public static int alignCount3 = 0;
//     private static String oldOut = "";
// 
//     static {
//         df = new SimpleDateFormat("HH:mm:ss");
//         df.setTimeZone(TimeZone.getTimeZone("GMT"));
//     }
// 
//     public static void print(String text, double percentage) {
//         System.out.print("\r" + time() + "  " + text + Math.round(percentage * 100) / 100 + "%");
//     }
// 
//     public static void print(String text) {
//         System.out.print("\r" + time() + "  " + text);
//     }
// 
//     public synchronized static void processReads() {
//         readCount++;
//         if (!oldOut.equals(time())) {
//             oldOut = time();
//             System.out.print("\r                                                                                                                      ");
//             System.out.print("\r" + time() + " Mapped: " + readCount + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
//         }
//     }
// 
//     public synchronized static void processUnmapped() {
//         ++unmappedCount;
//         if (!oldOut.equals(time())) {
//             oldOut = time();
//             System.out.print("\r                                                                                                                     ");
//             System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
//         }
//     }
// 
//     public synchronized static void processLength() {
//         ++tooSmallCount;
//         if (!oldOut.equals(time())) {
//             oldOut = time();
//             System.out.print("\r                                                                                                                     ");
//             System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
//         }
//     }
// 
//     public static void println(String text) {
//         System.out.println("\r" + time() + "  " + text);
//     }
// 
//     private static String time() {
//         return df.format(new Date(System.currentTimeMillis() - start));
//     }
// }


import ch.ethz.bsse.indelfixer.utils.StatusUpdate;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
        while (offset < indexOffset) {
            StatusUpdate.print("Indexing SFF:\t\t" + indexing++);
            raf.seek(offset);
            // readHeaderLength
            byte[] readHeaderLength = new byte[2];
            raf.read(readHeaderLength);
//            BigInteger readHeaderLengthBig = new BigInteger(readHeaderLength);
            // nameLength
            byte[] nameLength = new byte[2];
            raf.read(nameLength);
            BigInteger nameLengthBig = new BigInteger(nameLength);
            // numberOfBasesBig
            byte[] numberOfBases = new byte[4];
            raf.read(numberOfBases);
            BigInteger numberOfBasesBig = new BigInteger(numberOfBases);
            // skip to name of read
            raf.seek(raf.getFilePointer() + 8);
            // name
            byte[] name = new byte[nameLengthBig.intValue()];
            raf.read(name);
            // add read to hashtable
            reads.put(new String(name), offset);
            // calculate readDataLength
            long readDataLength = numberOfFlowsPerRead * 2 + 3 * numberOfBasesBig.longValue();
            // calculate offset for next read
            offset = eightBytePadding(eightBytePadding(raf.getFilePointer()) + readDataLength);
//            if (indexing > 100) {
//                break;
//            }
        }
// Path: src/main/java/ch/ethz/bsse/indelfixer/utils/StatusUpdate.java
// public class StatusUpdate {
// 
//     private static final long start = System.currentTimeMillis();
//     private static final DateFormat df;
//     public static int readCount = 0;
//     public static int unmappedCount = 0;
//     public static int tooSmallCount = 0;
//     public static int alignCount1 = 0;
//     public static int alignCount2 = 0;
//     public static int alignCount3 = 0;
//     private static String oldOut = "";
// 
//     static {
//         df = new SimpleDateFormat("HH:mm:ss");
//         df.setTimeZone(TimeZone.getTimeZone("GMT"));
//     }
// 
//     public static void print(String text, double percentage) {
//         System.out.print("\r" + time() + "  " + text + Math.round(percentage * 100) / 100 + "%");
//     }
// 
//     public static void print(String text) {
//         System.out.print("\r" + time() + "  " + text);
//     }
// 
//     public synchronized static void processReads() {
//         readCount++;
//         if (!oldOut.equals(time())) {
//             oldOut = time();
//             System.out.print("\r                                                                                                                      ");
//             System.out.print("\r" + time() + " Mapped: " + readCount + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
//         }
//     }
// 
//     public synchronized static void processUnmapped() {
//         ++unmappedCount;
//         if (!oldOut.equals(time())) {
//             oldOut = time();
//             System.out.print("\r                                                                                                                     ");
//             System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
//         }
//     }
// 
//     public synchronized static void processLength() {
//         ++tooSmallCount;
//         if (!oldOut.equals(time())) {
//             oldOut = time();
//             System.out.print("\r                                                                                                                     ");
//             System.out.print("\r" + time() + " Mapped: " + (readCount) + "\t\tUnmapped: " + unmappedCount + "\t\tToo small: " + tooSmallCount);
//         }
//     }
// 
//     public static void println(String text) {
//         System.out.println("\r" + time() + "  " + text);
//     }
// 
//     private static String time() {
//         return df.format(new Date(System.currentTimeMillis() - start));
//     }
// }


// Path: src/main/java/ch/ethz/bsse/indelfixer/sffParser/SFFFile.java
import ch.ethz.bsse.indelfixer.utils.StatusUpdate;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

        while (offset < indexOffset) {
            StatusUpdate.print("Indexing SFF:\t\t" + indexing++);
            raf.seek(offset);
            // readHeaderLength
            byte[] readHeaderLength = new byte[2];
            raf.read(readHeaderLength);
//            BigInteger readHeaderLengthBig = new BigInteger(readHeaderLength);
            // nameLength
            byte[] nameLength = new byte[2];
            raf.read(nameLength);
            BigInteger nameLengthBig = new BigInteger(nameLength);
            // numberOfBasesBig
            byte[] numberOfBases = new byte[4];
            raf.read(numberOfBases);
            BigInteger numberOfBasesBig = new BigInteger(numberOfBases);
            // skip to name of read
            raf.seek(raf.getFilePointer() + 8);
            // name
            byte[] name = new byte[nameLengthBig.intValue()];
            raf.read(name);
            // add read to hashtable
            reads.put(new String(name), offset);
            // calculate readDataLength
            long readDataLength = numberOfFlowsPerRead * 2 + 3 * numberOfBasesBig.longValue();
            // calculate offset for next read
            offset = eightBytePadding(eightBytePadding(raf.getFilePointer()) + readDataLength);
//            if (indexing > 100) {
//                break;
//            }
        }
        StatusUpdate.println("Indexing SFF:\t\t" + indexing);