private boolean parseArgs(String[] args) {
    if (args.length < 1) {
      System.out.println(
          "Usage: java hclustering (<filename>:<16s-23s|23s-5s>:[<lowerThreshold>]:"
              + "[<upperThreshold>]:[<single|average|complete|ward>])+");
      System.exit(1);
    }

    try {
      for (String arg : args) {
        System.out.println("arg: " + arg);

        File dataFile;
        FileSettings currFileSettings = new FileSettings();

        String[] subArgs = arg.split(ARG_SEPARATOR);

        /*
         * subArg indices:
         *    0 - filename
         *    1 - region
         *    3 - lowerthreshold
         *    4 - upperthreshold
         *    5 - distanceType
         */

        dataFile = new File(subArgs[0]);
        currFileSettings.setRegion(IsolateRegion.getRegion(subArgs[1]));

        currFileSettings.setLowerThreshold(
            subArgs.length >= 3 ? Double.parseDouble(subArgs[2]) : mLowerThreshold);

        currFileSettings.setUpperThreshold(
            subArgs.length >= 4 ? Double.parseDouble(subArgs[3]) : mUpperThreshold);

        // use reflection for distance measure
        /*
        distanceMode = args.length >= 3 ?
         (DistanceMeasure) Class.forName(args[2]).newInstance() :
         new EuclideanDistanceMeasure();
         */

        currFileSettings.setDistanceType(
            subArgs.length >= 5
                ? Cluster.distType.valueOf(subArgs[4].toUpperCase())
                : Cluster.distType.AVERAGE);

        dataFileMap.put(dataFile, currFileSettings);
      }
    } catch (NumberFormatException formatErr) {
      System.out.printf("Invalid threshold values: %d or %d\n", args[2], args[3]);
      System.exit(1);
    }

    return true;
  }
  public boolean cluster(String[] args) {
    boolean success = false;
    // handle command line arguments; sets dataFile and threshold
    success = parseArgs(args);

    Map<String, Map<Integer, List<Isolate>>> dataMap =
        new HashMap<String, Map<Integer, List<Isolate>>>();

    /*
     * Each isolate similarity matrix holds a correlation for both regions
     */
    IsolateSimilarityMatrix partialCorrelations = new IsolateSimilarityMatrix();
    Map<Connectivity, IsolateSimilarityMatrix> isolateNetworks =
        new HashMap<Connectivity, IsolateSimilarityMatrix>();

    isolateNetworks.put(Connectivity.STRONG, new IsolateSimilarityMatrix());
    isolateNetworks.put(Connectivity.WEAK, new IsolateSimilarityMatrix());

    Cluster.distType type = null;
    String dataFileName = null;
    double lowerThreshold = -1, upperThreshold = -1;

    for (File dataFile : dataFileMap.keySet()) {
      FileSettings settings = dataFileMap.get(dataFile);

      dataFileName = dataFile.getName();
      IsolateRegion region = settings.getRegion();
      type = settings.getDistanceType();
      lowerThreshold = settings.getLowerThreshold();
      upperThreshold = settings.getUpperThreshold();

      if (dataFile != null) {
        IsolateFileParser parser = new IsolateFileParser(dataFile, settings);

        // MARKER old code
        // isolateMap = parser.extractData(similarityMatrix);
        // mIsolateNetworks = parser.extractData();
        parser.extractData(isolateNetworks, partialCorrelations);
      }

      System.out.println("strong Network size: " + isolateNetworks.get(Connectivity.STRONG).size());
    }

    // each point is a cluster, and we will combine two clusters in each iteration
    List<ClusterDendogram> clustDends = clusterIsolates(type, isolateNetworks);
    // System.err.println("clustDends length: " + clustDends.size());

    // if the isolates yielded NO clusters (wtf data disappear?) or
    // if clusterIsolates returned null, then this was *NOT* a success
    success = clustDends != null && !clustDends.isEmpty();

    String outputFileDir =
        String.format("ClusterResults/%s_%.02f_%.02f", type, lowerThreshold, upperThreshold);

    /*
    String outputFileName = String.format("%s/%s", outputFileDir,
     dataFile.getName().substring(0,
     dataFile.getName().indexOf(".csv")));
    */

    String origFileName =
        HClustering.mOutputFileName.equals("")
            ? dataFileName.substring(0, dataFileName.indexOf(".csv"))
            : HClustering.mOutputFileName;
    System.out.println(
        "Writing to file "
            + origFileName
            + " even though outputFilename should be "
            + HClustering.mOutputFileName);
    String outputFileName = String.format("%s/%s", outputFileDir, origFileName);

    IsolateOutputWriter.outputClusters(clustDends, outputFileDir, outputFileName + ".xml");
    IsolateOutputWriter.outputCytoscapeFormat(clustDends, outputFileName);
    IsolateOutputWriter.outputTemporalClusters(clustDends, outputFileName);
    IsolateOutputWriter.outputTemporalCharts(clustDends, outputFileName);

    return success;
  }