Compound filters use the boolean expressions AND and OR to combine simple filters into filters with more complex behavior.
It is possible to create compound term filters or compound link filters. The interface works exactly the same either way.
Let's say we want to find all the terms that are children of the term "molecular_function" AND have a name that contains the word "kinase" or "protein". We might express such a filter as:
[Ancestor] [Name] [equals] "molecular_function" AND
([Self] [Name] [contains] "kinase" OR
[Self] [Name] [contains] "protein")
This way of writing boolean expressions with the boolean operation between the two connected terms is called infix notation. Infix notation is pretty familiar; it's the way we express boolean statements in english, and it's the typical notation in mathematics.
Brace yourself, because OBO-Edit doesn't use this notation.
OBO-Edit uses prefix notation for boolean expressions. In prefix notation, the boolean operation comes before the terms to be combined. So the expression "x AND y" is "AND x y" in prefix notation.
In prefix notation, our search from above could be written as:
If you are using a user-configurable filter editor, make sure that compound filtering is enabled. Go to the "Advanced" tab and make sure that "Keyword filtering" is disabled and "Compound filtering" is checked.
When compound filtering is enabled, the interface looks like this:
There are two new pieces to this interface. At the bottom is a little label called the compound filter description box. This box contains a description of the compound filter in infix notation. To the left is the compound filter editor.
The compound filter editor represents the compound filter as a tree. The leaves of the tree are term or link filters. The internal nodes are the boolean operators AND and OR.
The boolean operators combine their child nodes. An AND branch of the tree matches if all its children match. An OR branch of the tree matches if any of its children match.
To edit a node in the tree, left-click it to select the node. When a node is selected, the editor for that node will appear to the right. If the node is a term filter or link filter, a standard term or link filter editor will appear (as in the screen shot above). The filter can be edited as described in the Term Filters and Link Filters sections.
If a boolean operation is selected, a boolean operation editor will appear:
The boolean operation editor allows you to change the boolean operator. To change the operator, choose an operator from the dropdown menu. The available options are AND and OR.
To delete an existing node, select the node to delete by clicking it. Then bring up the right-click menu by right-clicking anywhere inside the compound filter editor. The right-click menu will appear:
Choose "Delete" from the right-click menu to delete the currently selected node.
Boolean operations can only be deleted if they have no children. If a boolean operation has children, all the children must be deleted before the boolean operation can be deleted.
New nodes can only be added as children of boolean operations. To add a new node, select the boolean operation that will be the new node's parent. Right-click to bring up the right-click menu:
To add a new filter, choose "Add filter" from the right-click menu. To add a new boolean operation, choose "Add Boolean Filter".
Edit the new filter as described above.
Compound filters are matched by evaluating whether their constituent filters match.
Constituent filters are matched in the order they were specified. The evaluation stops if the value of the compound filter can be determined, even if all the constituent filters have not been checked. For example, if the boolean operation is AND and one of the constituent filters doesn't match, the evaluation stops and the entire compound filter announces that it doesn't match (because if even one term of an AND expression is false, the whole expression is false). Similarly, if the boolean operation is OR and a constituent filter matches, the evaluation stops and the entire compound filter announces that it matches (if even one term of an OR expression is true, the whole expression is true).
Therefore: When constructing a compound filter, put quickly evaluated filters FIRST. For example, it takes a long time to do any search with an "Ancestor" or "Descendant" search aspect, because all the descendants or ancestors of every term in the ontology have to be calculated. So add any filters that use an ancestor or descendant last. Add quickly evaluated filters first. That way slow filters don't have to be evaluated unless absolutely necessary, and the whole filtering operation will work more quickly.