示例#1
0
  /**
   * Uses the given PathAccessor to access fields of the seed and return only new elements that is
   * not in the given element set (all).
   *
   * @param pa accessor to the filed
   * @param seed entities to get their fields
   * @param all already found values
   * @return new values
   */
  protected Set access(PathAccessor pa, Set<BioPAXElement> seed, Set<BioPAXElement> all) {
    Set set = pa.getValueFromBeans(seed);
    set.removeAll(all);

    // remove blacklisted
    if (blacklist == null) return set;
    else return blacklist.getNonUbiqueObjects(set);
  }
  /**
   * 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;
  }