public Bed2Bar(String[] args) {
   try {
     processArgs(args);
     // load Window[]
     for (int i = 0; i < bedFiles.length; i++) {
       bedFile = bedFiles[i];
       System.out.println("Parsing " + bedFile.getName());
       bedLinesHash = Bed.parseBedFile(bedFile, true, false);
       if (bedLinesHash == null || bedLinesHash.size() == 0) {
         System.out.println("Problem parsing bed file, skipping!");
         continue;
       }
       barDirectory = IO.makeDirectory(bedFile, "");
       File bedOutFile =
           new File(Misc.removeExtension(bedFile.toString()) + "_" + threshold + "_Filt.bed");
       bedOut = new PrintWriter(new FileWriter(bedOutFile));
       makeStairStepBarFiles();
     }
     bedOut.close();
     System.out.println("\nDone!\n");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  /** Make a heatmap blocks from given window indexes, stop not included. */
  public void sumHeatMapBlocks(int startIndex, int stopIndex) {
    // create arrays of float, one per base to hold sums
    // windows are sorted by start and length
    int startBase = windows[startIndex].getStart();
    int stopBase = findMaxStop(startIndex, stopIndex);

    int numBases = 1 + stopBase - startBase;
    float[] sums = new float[numBases];

    // load max arrays with max scores
    // for each window
    for (int i = startIndex; i < stopIndex; i++) {
      float score = windows[i].getScore();
      int baseIndex = windows[i].getStart() - startBase;
      int length = windows[i].getStop() - windows[i].getStart() + baseIndex + 1;
      for (int j = baseIndex; j < length; j++) sums[j] += score;
    }

    // build blocks
    // open first block
    // set zero mark
    int previousBase = startBase - 1;
    if (previousBase < 0) previousBase = 0;
    add(previousBase, 0);
    // set block value
    float blockValue = sums[0];
    add(startBase, blockValue);

    // advance each base opening and closing blocks
    for (int i = 1; i < numBases; i++) {
      float testValue = sums[i];
      if (testValue != blockValue) {
        // close old
        add(i - 1 + startBase, blockValue);
        // open new
        blockValue = testValue;
        add(i + startBase, blockValue);
      }
    }
    // close last block
    add(numBases - 2 + startBase, blockValue);
    add(numBases - 1 + startBase, 0);

    // make merged filtered bed file?
    if (bedOut != null) {
      boolean[] falseMask = new boolean[sums.length];
      Arrays.fill(falseMask, true);
      for (int i = 0; i < sums.length; i++) if (sums[i] >= threshold) falseMask[i] = false;
      int[][] blocks = ExportIntergenicRegions.fetchFalseBlocks(falseMask, 0, 0);
      // print bed file
      for (int i = 0; i < blocks.length; i++) {
        bedOut.println(
            chromosome + "\t" + (startBase + blocks[i][0]) + "\t" + (startBase + blocks[i][1]));
      }
    }
  }