/** This method will process each argument and assign new variables */
  public void processArgs(String[] args) {
    Pattern pat = Pattern.compile("-[a-z]");
    System.out.println(
        "\n" + IO.fetchUSeqVersion() + " Arguments: " + Misc.stringArrayToString(args, " ") + "\n");
    for (int i = 0; i < args.length; i++) {
      String lcArg = args[i].toLowerCase();
      Matcher mat = pat.matcher(lcArg);
      if (mat.matches()) {
        char test = args[i].charAt(1);
        try {
          switch (test) {
            case 'o':
              jobId = args[++i];
              break;
            case 's':
              sampleId = args[++i];
              break;
            case 'm':
              submitter = args[++i];
              break;
            case 'y':
              analysisType = args[++i];
              break;
            case 'w':
              webRootForLinks = new File(args[++i]);
              break;
            case 'e':
              snpEffGenome = args[++i];
              break;
            case 'i':
              minimumReadDepth = args[++i];
              break;
            case 't':
              threads = args[++i];
              break;
            case 'l':
              uploadVarsToNGSWeb = true;
              break;
            case 'j':
              pJar = new File(args[++i]);
              break;
            case 'p':
              truncPipePropFile = new File(args[++i]);
              break;
            case 'q':
              bedForCoverageQC = new File(args[++i]);
              break;
            case 'b':
              bedForVarCalling = new File(args[++i]);
              break;
            case 'r':
              fastaReference = new File(args[++i]);
              break;
            case 'u':
              unfilteredBam = new File(args[++i]);
              break;
            case 'f':
              finalBam = new File(args[++i]);
              break;
            case 'v':
              finalVcf = new File(args[++i]);
              break;
            case 'd':
              outputDirectory = new File(args[++i]);
              break;
            case 'c':
              referenceDir = new File(args[++i]);
              break;
            case 'h':
              printDocs();
              System.exit(0);
            default:
              Misc.printErrAndExit("\nProblem, unknown option! " + mat.group());
          }
        } catch (Exception e) {
          Misc.printErrAndExit(
              "\nSorry, something doesn't look right with this parameter: -" + test + "\n");
        }
      }
    }

    // check output dir and if needed set sampleId
    if (outputDirectory != null) {
      outputDirectory.mkdirs();
      if (sampleId.length() == 0) sampleId = outputDirectory.getName();
    }
    // check root directory if needed
    if (webRootForLinks != null) {
      if (webRootForLinks.exists() == false) webRootForLinks.mkdirs();
      // links dir?
      File links = new File(webRootForLinks, "links");
      if (links.exists() == false) links.mkdirs();
    }

    // look for required fields and files
    checkPrintFields();
    checkPrintFiles();
    checkForGzippedVcf();
  }