Class Fetcher

java.lang.Object
org.biopax.paxtools.controller.Fetcher

public class Fetcher extends Object
This class is used to fetch an element (traverse it to obtain its dependent elements) and to add this element into a model using the visitor and traverse functions. Must be thread safe if the property filters and EditorMap passed to the constructor are safe.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Filter<PropertyEditor>
    A property filter to ignore 'evidence' ('EVIDENCE' in L2) property (it can eventually lead to other organism, experimental entities)
    static final Filter<PropertyEditor>
    This property filter can be used to ignore 'nextStep' ('NEXT-STEP' in L2) property when fetching a sub-graph of child biopax elements, because using this property can eventually lead outside current pathway context into peer pathways, etc.
    static final Filter<PropertyEditor>
    A property filter to visit only biopax object type properties.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Fetcher(EditorMap editorMap, Filter<PropertyEditor>... filters)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Recursively finds and collects all child objects, while escaping possible infinite loops.
    fetch(BioPAXElement bpe, int depth)
    Recursively collects unique child objects from BioPAX object type properties that pass all the filters (as set via Constructor).
    <T extends BioPAXElement>
    Set<T>
    fetch(BioPAXElement element, Class<T> filterByType)
    Goes over object type biopax properties to collect nested objects (using only properties that pass all the filters set in Constructor, and taking #isSkipSubPathways into account) of the given biopax element, its children, etc.
    void
    fetch(BioPAXElement element, Model model)
    Adds the element and all its children (found via traversing into object properties that pass all the filters defined in the Constructor, and also taking #isSkipSubPathways into account) to the target model.
    boolean
     
    void
    setSkipSubPathways(boolean skipSubPathways)
    Use this property to optionally skip (if true) traversing into sub-pathways; i.e., when a biopax property, such as pathwayComponent or controlled, value is a Pathway.
    boolean
    Iterates over child objects of the given biopax element, using BioPAX object-type properties, until the element with specified URI and class (including its sub-classes).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • nextStepFilter

      public static final Filter<PropertyEditor> nextStepFilter
      This property filter can be used to ignore 'nextStep' ('NEXT-STEP' in L2) property when fetching a sub-graph of child biopax elements, because using this property can eventually lead outside current pathway context into peer pathways, etc. (in practice, for a pathway, all its child elements can be reached via 'pathwayComponent', 'pathwayOrder/stepProcess', 'pathwayOrder/stepConvertion' etc. properties; so ignoring the 'nextStep' usually OK). So, this is recommended filter for common BioPAX fetching/traversal tasks, such as to find all proteins or xrefs within a pathway and its sub-pathways, etc.
    • evidenceFilter

      public static final Filter<PropertyEditor> evidenceFilter
      A property filter to ignore 'evidence' ('EVIDENCE' in L2) property (it can eventually lead to other organism, experimental entities)
    • objectPropertiesOnlyFilter

      public static final Filter<PropertyEditor> objectPropertiesOnlyFilter
      A property filter to visit only biopax object type properties.
  • Constructor Details

    • Fetcher

      public Fetcher(EditorMap editorMap, Filter<PropertyEditor>... filters)
      Constructor.
      Parameters:
      editorMap - BioPAX property editors map implementation
      filters - optional, biopax object property filters to skip traversing/visiting into some object property values (the default 'object properties only' filter to is always enabled).
  • Method Details

    • setSkipSubPathways

      public void setSkipSubPathways(boolean skipSubPathways)
      Use this property to optionally skip (if true) traversing into sub-pathways; i.e., when a biopax property, such as pathwayComponent or controlled, value is a Pathway.
      Parameters:
      skipSubPathways - true/false
    • isSkipSubPathways

      public boolean isSkipSubPathways()
    • fetch

      public void fetch(BioPAXElement element, Model model)
      Adds the element and all its children (found via traversing into object properties that pass all the filters defined in the Constructor, and also taking #isSkipSubPathways into account) to the target model. This method fails if there are different child objects with the same ID, because normally a good (self-consistent) model does not contain duplicate BioPAX elements. Consider using fetch(BioPAXElement) method instead if you want to get all the child elements anyway.
      Parameters:
      element - the BioPAX element to be added into the model
      model - model into which elements will be added
    • fetch

      public Set<BioPAXElement> fetch(BioPAXElement element)
      Recursively finds and collects all child objects, while escaping possible infinite loops. This method can eventually return different objects with the same URI if these are present among child elements.
      Parameters:
      element - to traverse into
      Returns:
      a set of child biopax objects
    • fetch

      public Set<BioPAXElement> fetch(BioPAXElement bpe, int depth)
      Recursively collects unique child objects from BioPAX object type properties that pass all the filters (as set via Constructor). The #isSkipSubPathways flag is ignored. Note: this method might return different objects with the same URI if such are present among the child elements for some reason (for a self-integral BioPAX Model, this should not happen).
      Parameters:
      bpe - biopax object to traverse into properties of
      depth - positive int.; 1 means - get only direct children, 2 - include children of children, etc.;
      Returns:
      set of child objects
      Throws:
      IllegalArgumentException - when depth is less or equals 0
    • fetch

      public <T extends BioPAXElement> Set<T> fetch(BioPAXElement element, Class<T> filterByType)
      Goes over object type biopax properties to collect nested objects (using only properties that pass all the filters set in Constructor, and taking #isSkipSubPathways into account) of the given biopax element, its children, etc. (it also escapes any infinite semantic loops in the biopax model) It saves only biopax objects of the given type, incl. sub-types. Note: this method can eventually return different objects with the same URI if these are present among child elements.
      Type Parameters:
      T - biopax type
      Parameters:
      element - to fetch child objects from
      filterByType - biopax type filter
      Returns:
      set of biopax objects
    • subgraphContains

      public boolean subgraphContains(BioPAXElement root, String uri, Class<? extends BioPAXElement> type)
      Iterates over child objects of the given biopax element, using BioPAX object-type properties, until the element with specified URI and class (including its sub-classes). is found.
      Parameters:
      root - biopax element to process
      uri - URI to match
      type - class to match
      Returns:
      true if the match found; false - otherwise