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();
   }
 }
Beispiel #2
1
  /// <summary>
  /// FileStreamから読み込みながらコンストラクト
  /// </summary>
  /// <param name="sr">読み込み対象</param>
  public VsqHandle(TextMemoryStream sr, int value, StringBuilder last_line) {
    try {
      this.index = value;
      String[] spl;
      String[] spl2;

      // default値で梅
      m_type = VsqHandleType.Vibrato;
      iconID = "";
      IDS = "normal";
      L0 = new Lyric("");
      original = 0;
      caption = "";
      length = 0;
      startDepth = 0;
      depthBP = null;
      int depth_bp_num = 0;
      startRate = 0;
      rateBP = null;
      int rate_bp_num = 0;
      language = 0;
      program = 0;
      duration = 0;
      depth = 64;

      String tmpDepthBPX = "";
      String tmpDepthBPY = "";
      String tmpRateBPX = "";
      String tmpRateBPY = "";

      // "["にぶち当たるまで読込む
      last_line.setLength(0);
      last_line.append(sr.readLine());
      while (!last_line.toString().startsWith("[")) {
        spl = Misc.splitString(last_line.toString(), "=");
        if (spl[0].equals("Language")) {
          m_type = VsqHandleType.Singer;
          language = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("Program")) {
          program = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("IconID")) {
          iconID = spl[1];
        } else if (spl[0].equals("IDS")) {
          IDS = spl[1];
        } else if (spl[0].equals("Original")) {
          original = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("Caption")) {
          caption = spl[1];
          for (int i = 2; i < spl.length; i++) {
            caption += "=" + spl[i];
          }
        } else if (spl[0].equals("Length")) {
          length = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("StartDepth")) {
          startDepth = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("DepthBPNum")) {
          depth_bp_num = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("DepthBPX")) {
          tmpDepthBPX = spl[1];
        } else if (spl[0].equals("DepthBPY")) {
          tmpDepthBPY = spl[1];
        } else if (spl[0].equals("StartRate")) {
          m_type = VsqHandleType.Vibrato;
          startRate = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("RateBPNum")) {
          rate_bp_num = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("RateBPX")) {
          tmpRateBPX = spl[1];
        } else if (spl[0].equals("RateBPY")) {
          tmpRateBPY = spl[1];
        } else if (spl[0].equals("L0")) {
          m_type = VsqHandleType.Lyric;
          L0 = new Lyric(spl[1]);
        } else if (spl[0].equals("Duration")) {
          m_type = VsqHandleType.NoteHeadHandle;
          duration = Integer.parseInt(spl[1]);
        } else if (spl[0].equals("Depth")) {
          duration = Integer.parseInt(spl[1]);
        }
        if (sr.peek() < 0) {
          break;
        }
        last_line.setLength(0);
        last_line.append(sr.readLine());
      }
      /*if ( IDS != "normal" ) {
          m_type = VsqHandleType.Singer;
      } else if ( IconID != "" ) {
          m_type = VsqHandleType.Vibrato;
      } else {
          m_type = VsqHandleType.Lyric;
      }*/

      // RateBPX, RateBPYの設定
      if (m_type == VsqHandleType.Vibrato) {
        if (rate_bp_num > 0) {
          float[] rate_bp_x = new float[rate_bp_num];
          spl2 = tmpRateBPX.split(",");
          for (int i = 0; i < rate_bp_num; i++) {
            rate_bp_x[i] = Float.parseFloat(spl2[i]);
          }

          int[] rate_bp_y = new int[rate_bp_num];
          spl2 = tmpRateBPY.split(",");
          for (int i = 0; i < rate_bp_num; i++) {
            rate_bp_y[i] = Integer.parseInt(spl2[i]);
          }
          rateBP = new VibratoBPList(rate_bp_x, rate_bp_y);
        } else {
          // m_rate_bp_x = null;
          // m_rate_bp_y = null;
          rateBP = new VibratoBPList();
        }

        // DepthBPX, DepthBPYの設定
        if (depth_bp_num > 0) {
          float[] depth_bp_x = new float[depth_bp_num];
          spl2 = tmpDepthBPX.split(",");
          for (int i = 0; i < depth_bp_num; i++) {
            depth_bp_x[i] = Float.parseFloat(spl2[i]);
          }

          int[] depth_bp_y = new int[depth_bp_num];
          spl2 = tmpDepthBPY.split(",");
          for (int i = 0; i < depth_bp_num; i++) {
            depth_bp_y[i] = Integer.parseInt(spl2[i]);
          }
          depthBP = new VibratoBPList(depth_bp_x, depth_bp_y);
        } else {
          depthBP = new VibratoBPList();
          // m_depth_bp_x = null;
          // m_depth_bp_y = null;
        }
      } else {
        depthBP = new VibratoBPList();
        rateBP = new VibratoBPList();
      }
    } catch (Exception ex) {
      System.out.println("VsqHandle(TextMemoryStream,int,StringBuilder); ex=" + ex);
    }
  }
Beispiel #3
0
 public static String toHTML(String s) {
   s = Misc.string_replace("&gt;", ">", s);
   s = Misc.string_replace("&lt;", "<", s);
   s = Misc.string_replace("&nbsp;", " ", s);
   s = Misc.string_replace("&nbsp;&nbsp;&nbsp;&nbsp;", "\t", s);
   s = Misc.string_replace("<br>", "\n", s);
   return s;
 }
  /** This method will process each argument and assign new varibles */
  public void processArgs(String[] args) {
    File file = null;
    Pattern pat = Pattern.compile("-[a-z]");
    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 'f':
              file = new File(args[i + 1]);
              i++;
              break;
            case 'v':
              genomeVersion = args[i + 1];
              i++;
              break;
            case 's':
              sumScores = true;
              break;
            case 't':
              threshold = Float.parseFloat(args[++i]);
              break;
            case 'h':
              printDocs();
              System.exit(0);
            default:
              Misc.printExit("\nError, unknown option! " + mat.group());
          }
        } catch (Exception e) {
          System.out.print("\nSorry, something doesn't look right with this parameter: -" + test);
          System.out.println();
          System.exit(0);
        }
      }
    }
    if (file == null || file.exists() == false)
      Misc.printErrAndExit("Problem finding your bed files!\n");
    // pull files
    File[][] tot = new File[3][];
    tot[0] = IO.extractFiles(file, ".bed");
    tot[1] = IO.extractFiles(file, ".bed.zip");
    tot[2] = IO.extractFiles(file, ".bed.gz");
    bedFiles = IO.collapseFileArray(tot);
    if (bedFiles == null || bedFiles.length == 0)
      Misc.printErrAndExit("Problem finding your xxx.bed(.zip/.gz OK) files!\n");

    // genome version
    if (genomeVersion == null)
      Misc.printErrAndExit(
          "Please enter a genome version (e.g. H_sapiens_Mar_2006, see http://genome.ucsc.edu/FAQ/FAQreleases\n");
  }
  /** This method will process each argument and assign new varibles */
  public void processArgs(String[] args) {
    Pattern pat = Pattern.compile("-[a-z]");
    File dir = null;
    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 'f':
              dir = new File(args[i + 1]);
              i++;
              break;
            case 'v':
              genomeVersion = args[i + 1];
              i++;
              break;
            case 's':
              strand = args[++i];
              break;
            case 't':
              stairStep = true;
              break;
            case 'h':
              printDocs();
              System.exit(0);
            default:
              Misc.printExit("\nError: unknown option! " + mat.group());
          }
        } catch (Exception e) {
          Misc.printExit(
              "\nSorry, something doesn't look right with this parameter: -" + test + "\n");
        }
      }
    }
    if (dir == null || dir.canRead() == false)
      Misc.printExit("\nError: cannot find or read your sgr file/ directory.\n");
    File[][] tot = new File[3][];
    tot[0] = IO.extractFiles(dir, ".sgr");
    tot[1] = IO.extractFiles(dir, ".sgr.zip");
    tot[2] = IO.extractFiles(dir, ".sgr.gz");
    sgrFiles = IO.collapseFileArray(tot);

    if (sgrFiles == null || sgrFiles.length == 0)
      Misc.printExit("\nError: cannot find your xxx.sgr.zip file(s)");
    if (genomeVersion == null)
      Misc.printExit(
          "\nError: you must supply a genome version. Goto http://genome.ucsc.edu/cgi-"
              + "bin/hgGateway load your organism to find the associated genome version.\n");
  }
  public void checkPrintFiles() {
    LinkedHashMap<String, File> nameFile = new LinkedHashMap<String, File>();
    nameFile.put("Reference directory", referenceDir);
    nameFile.put("Pipeline.jar", pJar);
    nameFile.put("Pipeline properties", truncPipePropFile);
    nameFile.put("Coverage QC bed", bedForCoverageQC);
    nameFile.put("Variant calling bed", bedForVarCalling);
    nameFile.put("Fasta genome reference", fastaReference);
    nameFile.put("Unfiltered bam", unfilteredBam);
    nameFile.put("Final bam", finalBam);
    nameFile.put("Final vcf", finalVcf);
    if (webRootForLinks != null) nameFile.put("Web links dir", webRootForLinks);
    nameFile.put("Final output dir", outputDirectory);

    boolean missingFile = false;
    System.out.println("\nResources (name exists path):");
    for (String name : nameFile.keySet()) {
      File f = nameFile.get(name);
      boolean fExists = true;
      if (f == null) {
        fExists = false;
        missingFile = true;
      } else {
        fExists = f.exists();
        if (fExists == false) missingFile = true;
      }
      System.out.println(name + "\t" + fExists + "\t" + f);
    }
    if (missingFile) Misc.printErrAndExit("\nMissing resources! See above.");
  }
 public String fetchCleanupReviewDirLinkGenXml() {
   String s = null;
   try {
     s = // Organize and Clean Up Section
         "<ReviewDirGenerator class='operator.ReviewDirGenerator' destination.dir='"
             + outputDirectory.getCanonicalPath()
             + "' sample='"
             + outputDirectory.getName()
             + "' submitter='"
             + submitter
             + "' analysis.type='"
             + analysisType
             + "'> \n"
             + "    <finalVariants /> \n"
             + "    <ViewerCSV /> \n"
             + "    <InstanceLog class='buffer.InstanceLogFile' /> \n"
             + "    <finalBAM /> \n"
             + "    <QCOutputFile /> \n"
             + "    <bedForVars /> \n"
             + "</ReviewDirGenerator> \n\n";
   } catch (IOException e) {
     e.printStackTrace();
     Misc.printErrAndExit("\nError fetching clean up and review dir links.\n");
   }
   return s;
 }
Beispiel #8
0
	public void sendXHeader() throws IOException
	{
		StringBuffer header1 = new StringBuffer();
		StringBuffer header2 = new StringBuffer();
		int lengthOfXA = param.getRandomLengthOfXA();
		int lengthOfXB = param.getRandomLengthOfXB();
		for (int i=0 ; i<lengthOfXA ; i++) 
		{
			header1.append(Misc.getRandomByte());
		}
		for (int i=0 ; i<lengthOfXB ; i++) 
		{
			header2.append(Misc.getRandomByte());
		}
		socket.getOutputStream().write(("X-" + header1.toString() + ": " + header2.toString() + "\r\n").getBytes());
		socket.getOutputStream().flush();
	}
  // constructor
  public Sgr2Bar(String[] args) {
    try {
      // check for args
      processArgs(args);

      System.out.println("Genome version -> " + genomeVersion);
      System.out.println("Strand -> " + strand);
      System.out.println("Stair Step? -> " + stairStep);
      System.out.println();

      // load tagValues
      if (stairStep) tagValues.put(BarParser.GRAPH_TYPE_TAG, BarParser.GRAPH_TYPE_STAIRSTEP);
      else tagValues.put(BarParser.GRAPH_TYPE_TAG, BarParser.GRAPH_TYPE_BAR);

      for (int x = 0; x < sgrFiles.length; x++) {
        System.out.println("\tLoading -> " + sgrFiles[x]);
        GrGraph[] grs = GrGraph.loadSgrFile(sgrFiles[x]);

        // make save directory
        String dirName;

        dirName = Misc.removeExtension(sgrFiles[x].getCanonicalPath());

        File dir = new File(dirName);
        dir.mkdir();
        // print bar files
        System.out.println("\tSaving...");
        for (int i = 0; i < grs.length; i++) {
          File barFile = new File(dir, grs[i].getChromosome() + ".bar");
          barParser.writeBarFile(
              barFile,
              grs[i].getChromosome(),
              genomeVersion,
              strand.charAt(0),
              grs[i].getBasePositions(),
              grs[i].getValues(),
              tagValues);
        }
      }
      System.out.println("\nDone!\n");
    } catch (IOException e) {
      e.printStackTrace();
      Misc.printErrAndExit("\nFailed to parse file!");
    }
  }
  private void buildXmlPropertiesFile() {
    System.out.println(
        "\nBuilding and checking your pipeline properties file -> " + truncPipePropFile);
    StringBuilder toPrint = new StringBuilder();

    // walk through the prop file
    String[] prop = IO.loadFileIntoStringArray(truncPipePropFile);
    Pattern val = Pattern.compile("(<entry key.+>)([D|A|B].*)</entry>");
    boolean missingFile = false;
    for (String s : prop) {
      // does it match a file needing prepending? Data/, Apps/, Bed/
      Matcher mat = val.matcher(s);
      if (mat.matches()) {
        File test = new File(referenceDir, mat.group(2));
        if (test.exists()) {
          System.out.println("Found\t" + test);
          toPrint.append(mat.group(1));
          toPrint.append(test.toString());
          toPrint.append("</entry>");
        } else {
          System.out.println("Misssing\t" + test);
          missingFile = true;
        }
      }
      // threads?
      else if (s.contains("threads"))
        toPrint.append("<entry key=\"threads\">" + threads + "</entry>");

      // nope just save it and add a line return
      else toPrint.append(s);
      toPrint.append("\n");
    }
    // anything missing? if so exit
    if (missingFile)
      Misc.printErrAndExit(
          "\nFailed to find all of the files in your properties file, see above.\n");

    // OK, write it out
    completePipelinePropFile = new File(outputDirectory, "pipelineProperties.xml");
    if (IO.writeString(toPrint.toString(), completePipelinePropFile) == false)
      Misc.printErrAndExit("Problem writing -> " + truncPipePropFile);
  }
  public static void main(String[] args) {
    File column = new File(args[0]);
    try {
      // how many different dbs are present
      LinkedHashMap dbs = new LinkedHashMap();
      BufferedReader in = new BufferedReader(new FileReader(column));
      String line;
      int index = 0;
      while ((line = in.readLine()) != null) {
        if (line.trim().length() == 0) continue;
        String[] tokens = line.split("\\|");
        for (int i = 0; i < tokens.length; i += 2) {
          if (dbs.containsKey(tokens[i]) == false) {
            dbs.put(tokens[i], new Integer(index++));
          }
        }
      }
      in.close();
      // print header
      Iterator it = dbs.keySet().iterator();
      while (it.hasNext()) {
        String c = (String) it.next();
        System.out.print("Reporter BioSequence DatabaseEntry [" + c + "]\t");
      }
      System.out.println();
      // print lines
      in = new BufferedReader(new FileReader(column));
      int numColumns = dbs.size();
      while ((line = in.readLine()) != null) {
        if (line.trim().length() == 0) {
          System.out.println();
        } else {
          String[] columns = new String[numColumns];
          String[] tokens = line.split("\\|");
          for (int i = 0; i < tokens.length; i += 2) {
            // System.out.println(line+"Tok"+tokens[i]);
            int columnIndex = ((Integer) dbs.get(tokens[i])).intValue();
            if (columns[columnIndex] == null) columns[columnIndex] = tokens[i + 1];
            else columns[columnIndex] = columns[columnIndex] + ";" + tokens[i + 1];
          }
          // print it
          for (int i = 0; i < numColumns; i++) {
            if (columns[i] == null) columns[i] = "";
          }
          System.out.println(Misc.stringArrayToString(columns, "\t"));
        }
      }
      in.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 private void checkForGzippedVcf() {
   String vcfName = finalVcf.getName();
   if (vcfName.endsWith(".gz")) {
     File uncomp = new File(finalVcf.getParentFile(), vcfName.substring(0, vcfName.length() - 3));
     if (uncomp.exists() == false) {
       deleteTempVcf = true;
       if (IO.uncompress(finalVcf, uncomp) == null)
         Misc.printErrAndExit("ERROR: failed to uncompress -> " + finalVcf);
     }
     finalVcf = uncomp;
   }
 }
 /** This method will process each argument and assign new varibles */
 public void processArgs(String[] args) {
   Pattern pat = Pattern.compile("-[a-z]");
   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 'f':
             fastas = IO.extractFiles(args[i + 1], "fasta");
             i++;
             break;
           case 'n':
             numberOfBases = Integer.parseInt(args[i + 1]);
             i++;
             break;
           case 'i':
             indexDirectory = new File(args[i + 1]);
             i++;
             break;
           case 'h':
             printDocs();
             System.exit(0);
           default:
             Misc.printExit("\nError: unknown option! " + mat.group());
         }
       } catch (Exception e) {
         Misc.printExit(
             "\nSorry, something doesn't look right with this parameter: -" + test + "\n");
       }
     }
   }
   // make index directory?
   if (indexDirectory == null) {
     indexDirectory = new File(fastas[0].getParentFile(), "IndexedSequences");
     indexDirectory.mkdir();
   }
 }
  private void executePipelineJob() {
    String[] cmd = null;
    try {
      // write out tempTemplate
      File template = new File(outputDirectory, "pipelineTemplate.xml");
      if (IO.writeString(xmlTemplate, template) == false)
        Misc.printErrAndExit("Problem writing -> " + template);

      // build and execute cmd
      cmd =
          new String[] {
            "java",
            "-jar",
            "-Xmx2G",
            pJar.getCanonicalPath(),
            "-props",
            completePipelinePropFile.getCanonicalPath(),
            template.getCanonicalPath()
          };

      String stringCmd = Misc.stringArrayToString(cmd, " ");
      System.out.println("\nExecuting:\n" + stringCmd);
      System.out.println("\nPipelineOutput:");
      String[] out = IO.executeViaProcessBuilder(cmd, true);

      // check output for possible errors
      for (String line : out) {
        String lcLine = line.toLowerCase();
        // watch out for cases where error is mentioned in a warning output line.
        if (lcLine.contains("error") && lcLine.startsWith("warning") == false)
          Misc.printErrAndExit(
              "\n\nERROR found in Pipeline.jar output, see above. Aborting!\n" + line);
      }

    } catch (Exception e) {
      e.printStackTrace();
      Misc.printErrAndExit("ERROR: executing " + Misc.stringArrayToString(cmd, " "));
    }
  }
  public void checkPrintFields() {
    LinkedHashMap<String, String> nameField = new LinkedHashMap<String, String>();
    nameField.put("Job ID", jobId);
    nameField.put("Sample ID", sampleId);
    nameField.put("Submitter", submitter);
    nameField.put("Analysis Type", analysisType);
    nameField.put("Minimum Align Depth", minimumReadDepth);
    nameField.put("Threads", threads);
    nameField.put("SnpEff Genome", snpEffGenome);
    // set output of booleans
    nameField.put("Upload Vars to NGSWeb", uploadVarsToNGSWeb + "");

    boolean missingField = false;
    System.out.println("Fields:");
    for (String name : nameField.keySet()) {
      String f = nameField.get(name);
      if (f == null || f.length() == 0) missingField = true;
      System.out.println(name + "\t" + f);
    }
    if (missingField) Misc.printErrAndExit("\nMissing Fields! See above.");
  }
Beispiel #16
0
 public static void saveTextFile(File file, String content)
     throws UnsupportedEncodingException, FileNotFoundException, IOException {
   Misc.saveTextFile(file, content, "UTF-8");
 }
Beispiel #17
0
  @Override
  public void run() {
    try {
      Thread.currentThread().setName("ServerEngine");
      System.setOut(new Misc.TimestampLogger(System.out));
      System.setErr(new Misc.TimestampLogger(System.err, "./data/err.log"));

      address = new InetSocketAddress(host, port);
      System.out.println("Starting " + Constants.SERVER_NAME + " on " + address + "...");

      // load shutdown hook
      Thread shutdownhook = new ShutDownHook();
      Runtime.getRuntime().addShutdownHook(shutdownhook);

      PacketManager.loadPackets();

      Cache.load();

      // load scripts
      Misc.loadScripts(new File("./data/ruby/"));

      GlobalVariables.patchNotes = Misc.loadPatchNotes();
      GlobalVariables.info = Misc.loadInfo();
      GlobalVariables.npcDump = Misc.getNpcDump();
      GlobalVariables.itemDump = Misc.getItemDump();

      // load all xstream related files.
      XStreamUtil.loadAllFiles();

      // item weights
      ItemDefinition.loadWeight();

      // interfaces
      RSInterface.load();

      // Load plugins
      PluginManager.loadPlugins();

      // Load regions
      ObjectDef.loadConfig();
      Region.load();
      Rangable.load();

      // Load objects
      ObjectLoader objectLoader = new ObjectLoader();
      objectLoader.load();

      GameObjectData.init();

      // load combat manager
      CombatManager.init();

      // Load minute timer
      startMinutesCounter();

      // global drops
      GlobalGroundItem.initialize();

      // load npc ls
      Npc.loadNpcDrops();

      // mage arena timers
      AlchemistPlayground.loadAlchemistPlayGround();
      EnchantingChamber.loadEnchantingChamber();
      CreatureGraveyard.loadCreatureGraveyard();

      // spawning world fishing spots
      FishingSpots.spawnFishingSpots();

      QuestHandler.init();

      NpcLoader.loadAutoSpawn("./data/npcs/spawn-config.cfg");

      HighscoresManager.load();

      // Start up and get a'rollin!
      startup();
      System.out.println("Online!");
      while (!Thread.interrupted()) {
        try {
          cycle();
          sleep();
        } catch (Exception ex) {
          PlayerSave.saveAllPlayers();
          ex.printStackTrace();
        }
      }
      scheduler.schedule(
          new Task() {
            @Override
            protected void execute() {
              if (Thread.interrupted()) {
                PlayerSave.saveAllPlayers();
                stop();
                return;
              }
              try {
                cycle();
              } catch (Exception ex) {
                PlayerSave.saveAllPlayers();
                ex.printStackTrace();
                stop();
              }
            }
          });
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    PluginManager.close();
  }
Beispiel #18
0
	public void sendPOSTBodyRandomByte() throws IOException
	{
		socket.getOutputStream().write(Misc.getRandomByte());
		socket.getOutputStream().flush();
	}
  /** 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();
  }