Пример #1
0
  /**
   * Gets to the linked PhysicalEntity.
   *
   * @param match current pattern match
   * @param ind mapped indices
   * @return linked PhysicalEntity
   */
  @Override
  public Collection<BioPAXElement> generate(Match match, int... ind) {
    PhysicalEntity pe = (PhysicalEntity) match.get(ind[0]);
    Set<BioPAXElement> set = getLinkedElements(pe);

    return set;
  }
Пример #2
0
  /**
   * Checks if the generated elements from the first mapped element has either the desired value, or
   * has some value in common with the elements generated from second mapped element.
   *
   * @param match current pattern match
   * @param ind mapped indices
   * @return true if a value match is found
   */
  @Override
  public boolean satisfies(Match match, int... ind) {
    assertIndLength(ind);

    // Collect values of the element group
    Set values = new HashSet();
    for (BioPAXElement gen : con1.generate(match, ind)) {
      values.addAll(pa1.getValueFromBean(gen));
    }

    // If emptiness is desired, check that
    if (value == EMPTY) return values.isEmpty();

    // If cannot be empty, check it
    if (oper == Operation.NOT_EMPTY_AND_NOT_INTERSECT && values.isEmpty()) return false;

    // If the second element is desired value, check that
    else if (value == USE_SECOND_ARG) {
      BioPAXElement q = match.get(ind[1]);
      return oper == Operation.INTERSECT ? values.contains(q) : !values.contains(q);
    }

    // If element group is compared to preset value, but the value is actually a collection,
    // then iterate the collection, see if any of them matches
    else if (value instanceof Collection) {
      Collection query = (Collection) value;
      values.retainAll(query);

      if (oper == Operation.INTERSECT) return !values.isEmpty();
      else return values.isEmpty();
    }

    // If two set of elements should share a field value, check that
    else if (pa2 != null) {
      // Collect values of the second group
      Set others = new HashSet();
      for (BioPAXElement gen : con2.generate(match, ind)) {
        others.addAll(pa2.getValueFromBean(gen));
      }

      switch (oper) {
        case INTERSECT:
          others.retainAll(values);
          return !others.isEmpty();
        case NOT_INTERSECT:
          others.retainAll(values);
          return others.isEmpty();
        case NOT_EMPTY_AND_NOT_INTERSECT:
          if (others.isEmpty()) return false;
          others.retainAll(values);
          return others.isEmpty();
        default:
          throw new RuntimeException("Unhandled operation: " + oper);
      }
    }

    // Check if the element field values contain the parameter value
    else if (oper == Operation.INTERSECT) return values.contains(value);
    else return !values.contains(value);
  }
Пример #3
0
  /**
   * Checks if the controlled Interaction contains a controller as a participant. This constraint
   * filters out such cases.
   *
   * @param match current pattern match
   * @param ind mapped indices
   * @return true if participants of teh controlled Interactions not also a controller of the
   *     Control.
   */
  @Override
  public boolean satisfies(Match match, int... ind) {
    Control ctrl = (Control) match.get(ind[0]);

    for (Process process : ctrl.getControlled()) {
      if (process instanceof Interaction) {
        Interaction inter = (Interaction) process;
        Set<Entity> participant = inter.getParticipant();
        for (Controller controller : ctrl.getController()) {
          if (participant.contains(controller)) return false;
        }
      }
    }
    return true;
  }
  /**
   * Checks the gained and and lost features to predict the activity change is the desired change.
   * If exact matching (terms with locations) is not conclusive, then terms without locations are
   * checked. If still not conclusive, then approximate matching is used.
   *
   * @param match current pattern match
   * @param ind mapped indices
   * @return true if the modification gain or loss is mapped to the desired change
   */
  @Override
  public boolean satisfies(Match match, int... ind) {
    BioPAXElement ele1 = match.get(ind[0]);
    BioPAXElement ele2 = match.get(ind[1]);

    EntityReference er = ((SimplePhysicalEntity) ele1).getEntityReference();

    Set set1 = pa.getValueFromBean(ele1);
    Set set2 = pa.getValueFromBean(ele2);

    Set gain = new HashSet(set2);
    gain.removeAll(set1);

    Set loss = new HashSet(set1);
    loss.removeAll(set2);

    int activatingCnt = 0;
    int inhibitingCnt = 0;

    for (Object o : gain) {
      if (activityFeat.get(er).contains(o)) activatingCnt++;
      if (inactivityFeat.get(er).contains(o)) inhibitingCnt++;
    }
    for (Object o : loss) {
      if (inactivityFeat.get(er).contains(o)) activatingCnt++;
      if (activityFeat.get(er).contains(o)) inhibitingCnt++;
    }

    // Match without considering the locations

    Set<String> gainTypes = null;
    Set<String> lossTypes = null;

    if (activatingCnt + inhibitingCnt == 0) {
      gainTypes = extractModifNames(gain);
      lossTypes = extractModifNames(loss);

      for (String s : gainTypes) {
        if (activityStr.get(er).contains(s)) activatingCnt++;
        if (inactivityStr.get(er).contains(s)) inhibitingCnt++;
      }
      for (String s : lossTypes) {
        if (inactivityStr.get(er).contains(s)) activatingCnt++;
        if (activityStr.get(er).contains(s)) inhibitingCnt++;
      }
    }

    // Try to match modifications with approximate name matching

    if (activatingCnt + inhibitingCnt == 0) {
      for (String genName : general) {
        boolean foundInActivating = setContainsGeneralTerm(activityStr.get(er), genName);
        boolean foundInInhibiting = setContainsGeneralTerm(inactivityStr.get(er), genName);

        if (foundInActivating == foundInInhibiting) continue;

        boolean foundInGain = setContainsGeneralTerm(gainTypes, genName);
        boolean foundInLose = setContainsGeneralTerm(lossTypes, genName);

        if (foundInGain == foundInLose) continue;

        if (foundInActivating && foundInGain) activatingCnt++;
        else if (foundInInhibiting && foundInLose) activatingCnt++;
        else if (foundInActivating && foundInLose) inhibitingCnt++;
        else /*if (foundInInhibiting && foundInGain)*/ inhibitingCnt++;
      }
    }

    if (activatingCnt > 0 && inhibitingCnt > 0) return false;
    return activating ? activatingCnt > 0 : inhibitingCnt > 0;
  }