예제 #1
0
  @Override
  public Collection<ValidatorMessage> check(InteractionEvidence interaction)
      throws ValidatorException {

    if (interaction.isNegative()) {
      MiContext context = RuleUtils.buildContext(interaction, "interaction");

      return Collections.singletonList(
          new ValidatorMessage(
              "Negative interactions are currently outside of the remit of IMEx and "
                  + "should be removed from the record.",
              MessageLevel.WARN,
              context,
              this));
    }

    return Collections.EMPTY_LIST;
  }
예제 #2
0
  @Override
  public Collection<ValidatorMessage> check(Confidence confidence) throws ValidatorException {
    if (confidence != null) {
      // list of messages to return
      List<ValidatorMessage> messages = Collections.EMPTY_LIST;
      final OntologyAccess access = ontologyManager.getOntologyAccess("MI");

      CvTerm type = confidence.getType();

      if (type == null
          || PsiXmlUtils.UNSPECIFIED.equals(type.getShortName())
          || MitabUtils.UNKNOWN_TYPE.equals(type.getShortName())) {
        MiContext xrefContext = RuleUtils.buildContext(confidence, "confidence");
        messages = new ArrayList<ValidatorMessage>();
        messages.add(
            new ValidatorMessage(
                "Confidences must have a valid confidence type.'",
                MessageLevel.ERROR,
                xrefContext,
                this));
      } else if (type != null && type.getMIIdentifier() != null) {
        final OntologyTermI dbTerm = access.getTermForAccession(type.getMIIdentifier());

        if (dbTerm == null) {
          MiContext context = RuleUtils.buildContext(confidence, "confidence");
          if (messages.isEmpty()) {
            messages = new ArrayList<ValidatorMessage>();
          }
          messages.add(
              new ValidatorMessage(
                  "The confidence type MI identifier "
                      + type.getMIIdentifier()
                      + "  does not exist in the PSI-MI ontology. The valid MI terms for confidence types are available here: http://www.ebi.ac.uk/ontology-lookup/browse.do?ontName=MI&termId=MI%3A1064&termName=interaction%20confidence",
                  MessageLevel.ERROR,
                  context,
                  this));
        } else {
          Collection<OntologyTermI> parents = access.getAllParents(dbTerm);

          boolean foundParent = false;

          for (OntologyTermI p : parents) {
            if ("MI:1064".equals(p.getTermAccession())) {
              foundParent = true;
              break;
            }
          }

          if (!foundParent) {
            MiContext context = RuleUtils.buildContext(confidence, "confidence");
            if (messages.isEmpty()) {
              messages = new ArrayList<ValidatorMessage>();
            }
            messages.add(
                new ValidatorMessage(
                    "The MI identifier "
                        + type.getMIIdentifier()
                        + " is not a valid MI identifier for confidence types. The valid MI terms for confidence types are available here: http://www.ebi.ac.uk/ontology-lookup/browse.do?ontName=MI&termId=MI%3A1064&termName=interaction%20confidence",
                    MessageLevel.ERROR,
                    context,
                    this));
          }
        }
      }

      if (confidence.getValue() == null
          || confidence.getValue().trim().length() == 0
          || PsiXmlUtils.UNSPECIFIED.equals(confidence.getValue())
          || MitabUtils.UNKNOWN_ID.equals(confidence.getValue())) {
        MiContext xrefContext = RuleUtils.buildContext(confidence, "confidence");
        if (messages.isEmpty()) {
          messages = new ArrayList<ValidatorMessage>();
        }
        messages.add(
            new ValidatorMessage(
                "Confidences must have a valid and non empty confidence value.'",
                MessageLevel.ERROR,
                xrefContext,
                this));
      }

      return messages;
    }
    return Collections.EMPTY_LIST;
  }