Package org.biopax.paxtools.controller
Class Fetcher
java.lang.Object
org.biopax.paxtools.controller.Fetcher
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
FieldsModifier and TypeFieldDescriptionstatic 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
ConstructorsConstructorDescriptionFetcher(EditorMap editorMap, Filter<PropertyEditor>... filters) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfetch(BioPAXElement element) 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.voidfetch(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.booleanvoidsetSkipSubPathways(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.booleansubgraphContains(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).
-
Field Details
-
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
A property filter to ignore 'evidence' ('EVIDENCE' in L2) property (it can eventually lead to other organism, experimental entities) -
objectPropertiesOnlyFilter
A property filter to visit only biopax object type properties.
-
-
Constructor Details
-
Fetcher
Constructor.- Parameters:
editorMap- BioPAX property editors map implementationfilters- 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
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 usingfetch(BioPAXElement)method instead if you want to get all the child elements anyway.- Parameters:
element- the BioPAX element to be added into the modelmodel- model into which elements will be added
-
fetch
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
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 ofdepth- 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
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 fromfilterByType- 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 processuri- URI to matchtype- class to match- Returns:
- true if the match found; false - otherwise
-