Ejemplo n.º 1
0
  public static void main(String[] args) {
    File toParse = new File("/Users/nix/Desktop/repeatMasker.bed");
    String line;
    String[] tokens;

    try {
      BufferedReader in = new BufferedReader(new FileReader(toParse));
      int counter = 0;
      while ((line = in.readLine()) != null) {
        tokens = line.split("\\t+");
        StringBuilder sb = new StringBuilder(tokens[4]);

        for (int i = 5; i < tokens.length; i++) {
          sb.append("_");
          sb.append(tokens[i]);
        }
        counter++;
        // 0	     1          2   3    4
        // chr1	8388322	8388809	+	Dr000331
        System.out.println(
            tokens[0]
                + "\tRepeatMasker\tRepeatMasker\t"
                + tokens[1]
                + "\t"
                + tokens[2]
                + "\t.\t"
                + tokens[3]
                + "\t.\t"
                + sb
                + "_"
                + counter);
      }

      in.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  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);
  }
  private void buildXmlTemplate() {

    StringBuilder sb = new StringBuilder();
    sb.append("<Pipeline>\n\n");
    sb.append(fetchFieldXml());
    sb.append(fetchQCXml());
    sb.append(fetchVariantPoolsXml());
    sb.append(fetchAnnotatorXml());
    if (uploadVarsToNGSWeb) sb.append(fetchVariantUploadXml());
    sb.append(fetchVariantOutputXml());
    sb.append(fetchCleanupReviewDirLinkGenXml());
    if (webRootForLinks != null) fetchWebRootLinksXml();
    sb.append("\n</Pipeline>\n");
    xmlTemplate = sb.toString();
  }