示例#1
0
  public static void main(String args[]) throws IOException, ParseException {
    Options options = new Options();
    options.addOption("u", "uniquehits", false, "only output hits with a single mapping");
    options.addOption(
        "s",
        "nosuboptimal",
        false,
        "do not include hits whose score is not equal to the best score for the read");
    CommandLineParser parser = new GnuParser();
    CommandLine cl = parser.parse(options, args, false);
    boolean uniqueOnly = cl.hasOption("uniquehits");
    boolean filterSubOpt = cl.hasOption("nosuboptimal");

    ArrayList<String[]> lines = new ArrayList<String[]>();

    String line;
    String lastRead = "";
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while ((line = reader.readLine()) != null) {
      String pieces[] = line.split("\t");
      if (!pieces[0].equals(lastRead)) {
        printLines(lines, uniqueOnly, filterSubOpt);
        lines.clear();
      }
      lines.add(pieces);
      lastRead = pieces[0];
    }
    printLines(lines, uniqueOnly, filterSubOpt);
  }
示例#2
0
文件: Installer.java 项目: suever/CTP
 private boolean startLauncher(File dir) {
   try {
     Runtime rt = Runtime.getRuntime();
     ArrayList<String> command = new ArrayList<String>();
     command.add("java");
     command.add("-jar");
     command.add("Launcher.jar");
     String[] cmdarray = command.toArray(new String[command.size()]);
     Process proc = rt.exec(cmdarray, null, dir);
     return true;
   } catch (Exception ex) {
     System.err.println("Unable to start the Launcher program.\n" + ex.getMessage());
     return false;
   }
 }
示例#3
0
  public static void printLines(
      ArrayList<String[]> lines, boolean uniqueOnly, boolean filterSubOpt) {
    double numHits = 0;
    ArrayList<String[]> linesToPrint;
    // First count the number of (valid) hits
    if (filterSubOpt && lines.size() > 1) {
      linesToPrint = new ArrayList<String[]>();
      int minMis = Integer.MAX_VALUE;
      // Find minimum number of mismatchs
      int[] mismatches = new int[lines.size()];
      int i = 0;
      for (String[] pieces : lines) {
        int mis = 0;
        if (pieces.length > 7 && pieces[7].length() > 1) mis = pieces[7].split(",").length;
        mismatches[i] = mis;
        if (mis < minMis) minMis = mis;
        i++;
      }
      // Only add minimum mismatch hits
      i = 0;
      for (String[] pieces : lines) {
        if (mismatches[i] == minMis) linesToPrint.add(pieces);
        i++;
      }
      numHits = linesToPrint.size();
    } else {
      linesToPrint = lines;
      numHits = lines.size();
    }

    // Now add the hits!
    if (!uniqueOnly || linesToPrint.size() == 1) {
      double weight = 1.0 / numHits;
      for (String[] pieces : linesToPrint) {
        if (readLength == -1) readLength = pieces[4].length();

        Integer coord =
            pieces[1].equals("+")
                ? Integer.valueOf(pieces[3])
                : Integer.valueOf(pieces[3]) + readLength - 1;
        coord += 1; // Bowtie default output is 0-based - we want 1-based.
        System.out.println(
            String.format(
                "%s\t%s\t%s\t%d\t%f", pieces[2], coord, pieces[1], pieces[4].length(), weight));
      }
    }
  }
示例#4
0
文件: Q2.java 项目: rlishtaba/jPOS
 public void run() {
   started = true;
   Thread.currentThread().setName("Q2-" + getInstanceId().toString());
   try {
     /*
      * The following code determines whether a MBeanServer exists
      * already. If so then the first one in the list is used.
      * I have not yet find a way to interrogate the server for
      * information other than MBeans so to pick a specific one
      * would be difficult.
      */
     ArrayList mbeanServerList = MBeanServerFactory.findMBeanServer(null);
     if (mbeanServerList.isEmpty()) {
       server = MBeanServerFactory.createMBeanServer(JMX_NAME);
     } else {
       server = (MBeanServer) mbeanServerList.get(0);
     }
     final ObjectName loaderName = new ObjectName(Q2_CLASS_LOADER);
     try {
       loader =
           (QClassLoader)
               java.security.AccessController.doPrivileged(
                   new java.security.PrivilegedAction() {
                     public Object run() {
                       return new QClassLoader(server, libDir, loaderName, mainClassLoader);
                     }
                   });
       server.registerMBean(loader, loaderName);
       loader = loader.scan(false);
     } catch (Throwable t) {
       if (log != null) log.error("initial-scan", t);
       else t.printStackTrace();
     }
     factory = new QFactory(loaderName, this);
     initSystemLogger();
     addShutdownHook();
     q2Thread = Thread.currentThread();
     q2Thread.setContextClassLoader(loader);
     if (cli != null) cli.start();
     initConfigDecorator();
     for (int i = 1; !shutdown; i++) {
       try {
         boolean forceNewClassLoader = scan();
         QClassLoader oldClassLoader = loader;
         loader = loader.scan(forceNewClassLoader);
         if (loader != oldClassLoader) {
           oldClassLoader = null; // We want't this to be null so it gets GCed.
           System.gc(); // force a GC
           log.info(
               "new classloader ["
                   + Integer.toString(loader.hashCode(), 16)
                   + "] has been created");
         }
         deploy();
         checkModified();
         relax(SCAN_INTERVAL);
         if (i % (3600000 / SCAN_INTERVAL) == 0) logVersion();
       } catch (Throwable t) {
         log.error("start", t);
         relax();
       }
     }
     undeploy();
     try {
       server.unregisterMBean(loaderName);
     } catch (InstanceNotFoundException e) {
       log.error(e);
     }
     if (decorator != null) {
       decorator.uninitialize();
     }
     if (exit && !shuttingDown) System.exit(0);
   } catch (Exception e) {
     if (log != null) log.error(e);
     else e.printStackTrace();
     System.exit(1);
   }
 }