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 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, " "));
    }
  }
Ejemplo n.º 3
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();
    }
  }