public void run() {
    if (main.getBioPAXModel() == null) {
      MessageDialog.openError(main.getShell(), "Error!", "Load or query a BioPAX model first!");

      return;
    }

    // open dialog
    CompartmentQueryParamWithEntitiesDialog dialog =
        new CompartmentQueryParamWithEntitiesDialog(main);
    options = dialog.open(options);

    if (!options.isCancel()) {
      options.setCancel(true);
    } else {
      return;
    }

    // Source and target node sets

    Set<String> source = new HashSet<String>(dialog.getSourceAddedCompartments());
    Set<String> target = new HashSet<String>(dialog.getTargetAddedCompartments());

    Set<BioPAXElement> result =
        QueryExecuter.runPathsFromTo(
            BioPAXUtil.getElementsAtLocations(main.getBioPAXModel(), source),
            BioPAXUtil.getElementsAtLocations(main.getBioPAXModel(), target),
            main.getBioPAXModel(),
            options.getLimitType() ? LimitType.NORMAL : LimitType.SHORTEST_PLUS_K,
            options.getLengthLimit());

    viewAndHighlightResult(result, options.isCurrentView(), "Query Result");
  }
Exemplo n.º 2
0
  /**
   * After creating the dialog box, initial values are assigned to the fields with data in opt
   * OptionsPack
   */
  public void setInitialValues(QueryOptionsPack opt) {
    if (main.getPathwayGraph() == null) {
      newViewButton.setSelection(true);
      currentViewButton.setSelection(false);
      currentViewButton.setEnabled(false);
      opt.setCurrentView(false);
    }

    if (opt.isCurrentView()) {
      currentViewButton.setSelection(true);
    } else {
      newViewButton.setSelection(true);
    }

    lengthLimit.setText(String.valueOf(opt.getLengthLimit()));

    if (sourceST != null && opt.getSourceList() != null) {
      sourceST.symbolText.setText(opt.getOneStringSources());
    }
    if (targetST != null && opt.getTargetList() != null) {
      targetST.symbolText.setText(opt.getOneStringTargets());
    }

    if (downstreamButton != null) {
      // Downstream, Upstream or Both

      if (opt.isDownstream() && opt.isUpstream() && bothButton != null) {
        bothButton.setSelection(true);
      } else if (opt.isDownstream()) {
        downstreamButton.setSelection(true);
      } else if (opt.isUpstream()) {
        upstreamButton.setSelection(true);
      }
    }

    if (strictButton != null) {
      // Strict
      if (opt.isStrict()) {
        strictButton.setSelection(true);
      }
    }

    // Set both texts' values

    if (shortestPlusK != null) {
      shortestPlusK.setText(String.valueOf(opt.getShortestPlusKLimit()));
    }

    if (shortestPlusKButton != null) {
      shortestPlusKButton.setSelection(!opt.getLimitType());
    }
  }