コード例 #1
0
  private List<String> constructArguments()
      throws IOException, XMLStreamException, URISyntaxException, UnspecifiedPladipusException {
    File peptideShakerJar = getJar();
    ArrayList<String> cmdArgs = new ArrayList<>();
    cmdArgs.add("java");
    cmdArgs.add("-Xmx" + MemoryWarningSystem.getAllowedRam() + "M");
    cmdArgs.add("-cp");
    cmdArgs.add(peptideShakerJar.getAbsolutePath());
    cmdArgs.add("eu.isas.peptideshaker.cmd.PeptideShakerCLI");
    // check if folder exists
    File outputFolder = new File(parameters.get("output_folder"));
    outputFolder.mkdirs();
    // check if reports are requested
    if (parameters.containsKey("reports")) {
      File outputReportFolder = new File(outputFolder, "reports");
      if (outputReportFolder.mkdirs()) {
        parameters.put("out_reports", outputReportFolder.getAbsolutePath());
      }
    }

    for (AllowedPeptideShakerParams aParameter : AllowedPeptideShakerParams.values()) {
      if (parameters.containsKey(aParameter.getId())) {
        cmdArgs.add("-" + aParameter.getId());
        cmdArgs.add(parameters.get(aParameter.getId()));
      } else if (aParameter.isMandatory()) {
        throw new IllegalArgumentException("Missing mandatory parameter : " + aParameter.id);
      }
    }
    // check if spectra need to be exported
    if (parameters.containsKey("spectrum_folder")) {
      File exportFolder = new File(parameters.get("spectrum_folder"));
      exportFolder.mkdirs();
    }
    // also add these for other possible CLI's?
    for (AllowedPeptideShakerFollowUpParams aParameter :
        AllowedPeptideShakerFollowUpParams.values()) {
      if (parameters.containsKey(aParameter.getId())) {
        cmdArgs.add("-" + aParameter.getId());
        cmdArgs.add(parameters.get(aParameter.getId()));
      }
    }

    for (Map.Entry<String, String> aParameter : parameters.entrySet()) {
      cmdArgs.add("-" + aParameter.getKey());
      cmdArgs.add(parameters.get(aParameter.getValue()));
    }

    return cmdArgs;
  }
コード例 #2
0
 /** @param usageThreshold the memory threshold */
 public MemoryWarningSystem(double usageThreshold) {
   LOGGER.debug("Started memory monitoring");
   MemoryWarningSystem.setPercentageUsageThreshold(usageThreshold);
   MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
   NotificationEmitter emitter = (NotificationEmitter) mbean;
   emitter.addNotificationListener(
       new NotificationListener() {
         @Override
         public void handleNotification(Notification n, Object hb) {
           if (n.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
             long maxMemory = tenuredGenPool.getUsage().getMax();
             long usedMemory = tenuredGenPool.getUsage().getUsed();
             for (MemoryListener listener : listeners) {
               listener.checkMemoryUsage(usedMemory, maxMemory);
             }
           }
         }
       },
       null,
       null);
 }