/**
   * Prepares loggers, initiates garbage collection thread, parses arguments and initialized
   * variables appropriately/
   */
  private void initialize() {
    fastqWriterFactory.setCreateMd5(CREATE_MD5_FILE);
    switch (READ_NAME_FORMAT) {
      case CASAVA_1_8:
        readNameEncoder = new Casava18ReadNameEncoder(MACHINE_NAME, RUN_BARCODE, FLOWCELL_BARCODE);
        break;
      case ILLUMINA:
        readNameEncoder = new IlluminaReadNameEncoder(RUN_BARCODE);
        break;
    }

    final BclQualityEvaluationStrategy bclQualityEvaluationStrategy =
        new BclQualityEvaluationStrategy(MINIMUM_QUALITY);
    readStructure = new ReadStructure(READ_STRUCTURE);
    if (MULTIPLEX_PARAMS != null) {
      IOUtil.assertFileIsReadable(MULTIPLEX_PARAMS);
    }
    final boolean demultiplex;
    if (OUTPUT_PREFIX != null) {
      sampleBarcodeFastqWriterMap.put(null, buildWriter(OUTPUT_PREFIX));
      demultiplex = false;
    } else {
      populateWritersFromMultiplexParams();
      demultiplex = true;
    }
    final int readsPerCluster =
        readStructure.templates.length() + readStructure.sampleBarcodes.length();
    basecallsConverter =
        new IlluminaBasecallsConverter<FastqRecordsForCluster>(
            BASECALLS_DIR,
            BARCODES_DIR,
            LANE,
            readStructure,
            sampleBarcodeFastqWriterMap,
            demultiplex,
            MAX_READS_IN_RAM_PER_TILE / readsPerCluster,
            TMP_DIR,
            NUM_PROCESSORS,
            FORCE_GC,
            FIRST_TILE,
            TILE_LIMIT,
            queryNameComparator,
            new FastqRecordsForClusterCodec(
                readStructure.templates.length(),
                readStructure.sampleBarcodes.length(),
                readStructure.molecularBarcode.length()),
            FastqRecordsForCluster.class,
            bclQualityEvaluationStrategy,
            this.APPLY_EAMSS_FILTER,
            INCLUDE_NON_PF_READS,
            IGNORE_UNEXPECTED_BARCODES);

    log.info("READ STRUCTURE IS " + readStructure.toString());

    basecallsConverter.setConverter(
        new ClusterToFastqRecordsForClusterConverter(
            basecallsConverter.getFactory().getOutputReadStructure()));
  }
  @Override
  protected int doWork() {
    initialize();

    basecallsConverter.doTileProcessing();

    return 0;
  }