Class SSSOMTUriExpressionContainsFunction<T>

java.lang.Object
org.incenp.obofoundry.sssom.uriexpr.SSSOMTUriExpressionContainsFunction<T>
Type Parameters:
T - The type of object produced by the application this function belongs to.
All Implemented Interfaces:
IMappingFilter, ISSSOMTFunction<IMappingFilter>

public class SSSOMTUriExpressionContainsFunction<T> extends Object implements ISSSOMTFunction<IMappingFilter>, IMappingFilter
Represents the SSSOM/T filter function "uriexpr_contains".

That function allows the filtering of mappings depending on the contents of a “URI Expression”. It takes (at least) three arguments:

  • the Expression URI to look into (typically provided as %subject_id or %object_id);
  • the name of a URI Expression slot;
  • the expected value of that slot.

A mapping will be selected if (1) the first argument is a valid URI Expression, and (2) it contains a slot with a name matching the second argument, and (3) that slot has the expected value. Otherwise, the mapping will be rejected.

The first argument may contain standard SSSOM/T placeholders (and that is typically expected).

Matching the expected value with the actual value of the slot follows the same rule as all other ID comparisons in SSSOM/T, in that the expected value may end with a '*' character to test whether the actual value starts with the same prefix as the expected value.

The function may take additional pairs of arguments to check several slots in the same call.

Example:

 uriexpr_contains(%{subject_id}, 'disease', MONDO:1234, 'phenotype', HP:*) -> ...;
 

This will select any mapping whose subject ID is a URI Expression containing a disease slot with the value MONDO:1234 and a phenotype slot with any value starting with the HP prefix.

  • Constructor Details

    • SSSOMTUriExpressionContainsFunction

      public SSSOMTUriExpressionContainsFunction(SSSOMTransformApplication<T> application)
      Creates a new instance.
      Parameters:
      application - The application this function belongs to.
  • Method Details

    • getName

      public String getName()
      Description copied from interface: ISSSOMTFunction
      Gets the name of the function, by which it can be called in a SSSOM/T ruleset.
      Specified by:
      getName in interface ISSSOMTFunction<T>
      Returns:
      The function name.
    • getSignature

      public String getSignature()
      Description copied from interface: ISSSOMTFunction
      Gets the expected signature of the function. It should be a string that represents how many arguments (excluding keyed arguments) the function is expecting, where a single S character represents an argument.

      Regular expression syntax may be used to represent arguments that are optional or represent other kinds of constraints about the arguments list.

      Examples:

      • SSS for a function that expects exactly 3 arguments;
      • S+ for a function that expects at least one argument, possibly more;
      • (SS)+ for a function that one or more pairs of arguments (e.g. 2, 4, 6, but not 3 or 5).
      Specified by:
      getSignature in interface ISSSOMTFunction<T>
      Returns:
      The function signature.
    • call

      public IMappingFilter call(List<String> arguments, Map<String,String> keyedArguments) throws SSSOMTransformError
      Description copied from interface: ISSSOMTFunction
      Executes the function.

      Before this method is called, the arguments list will have been checked against the signature and will be guaranteed to be correct (e.g. if the function declared to expects two arguments, it is guaranteed the arguments list will contains two items).

      Specified by:
      call in interface ISSSOMTFunction<T>
      Parameters:
      arguments - The arguments to the function. May be empty, but not null.
      keyedArguments - The keyed arguments to the function. May be empty, but null.
      Returns:
      The result of executing the function.
      Throws:
      SSSOMTransformError - If any error occurred when executing the function (which may include the case where the number of arguments was correct but their contents was not).
    • filter

      public boolean filter(Mapping mapping)
      Description copied from interface: IMappingFilter
      Check if a mapping satisfies a given condition.
      Specified by:
      filter in interface IMappingFilter
      Parameters:
      mapping - The mapping to test.
      Returns:
      true if the mapping satisfies the condition, false otherwise.