Filter-Rules

Overview

Filter-Rules is a utility for post-processing rules produced by AssRuleX. With this utility you can filter rules that satisfy certain criteria.

Synopsis

Usage: ./post01_filterRules.sh  <rules_file>  <reg_exp>  <option_1>  <option_2> [additionnal_option]
where
   <rules_file>  is a text file with the rules
   <reg_exp>     is a Java regular expression
   <option_1>    is either '-delete' or '-keep'
   <option_2>    is either '-left', '-right', or '-any'

Additional options:
   -ls1 and -rs1
       filter rules with only one element on the left/right side
   -nonl
       don't print newline characters between rules
   -of:<output_file>
       redirect the output to the given file

Examples

Consider the following file (sample/example.txt):

{ANP_7ValVal} => {Hypertension}
{ADRB3_64TrpTrp} => {Hypertension}
{ANP_8Val, ENaCa_493TrpTrp} => {Hypertension, Something}
{Hypertension, FCER1B_237GluGlu} => {LPL_9AspAsp}
{Hypertension, CCR3_39ProPro, LPL-93TT, LPL_291AsnAsn} => {LPL_9AspAsp}
{Hypertension, LPL-93TT} => {LPL_9AspAsp}
{Hypertension} => {Something_1, Something_2}

Example 1 (-keep)

./post01_filterRules.sh sample/example.txt "Val" -keep -left

Meaning: show all rules that have attributes on the left side with the "Val" substring.

Result:

{ANP_7ValVal} => {Hypertension}
{ANP_8Val, ENaCa_493TrpTrp} => {Hypertension, Something}
# Number of filtered rules: 2

Note that "Val" is not a simple string but a Java regular expression that matches any attribute that contains the substring "Val". If you want exact matching, then use "^Val$" instead. Note that with "^Val$" we could not find any matching rule in this example.

Example 2 (-keep)

./post01_filterRules.sh sample/example.txt "^Hypertension$" -keep -right

Meaning: show the rules that have the attribute "Hypertension" on the right side.

Result:

{ANP_7ValVal} => {Hypertension}
{ADRB3_64TrpTrp} => {Hypertension}
{ANP_8Val, ENaCa_493TrpTrp} => {Hypertension, Something}
# Number of filtered rules: 3

Example 3 (-delete)

./post01_filterRules.sh sample/example.txt "^LPL-93TT$" -delete -any

Meaning: delete rules that contain the attribute "LPL-93TT". Actually, it means displaying rules that do not contain the attribute "LPL-93TT".

Result:

{ANP_7ValVal} => {Hypertension}
{ADRB3_64TrpTrp} => {Hypertension}
{ANP_8Val, ENaCa_493TrpTrp} => {Hypertension, Something}
{Hypertension, FCER1B_237GluGlu} => {LPL_9AspAsp}
{Hypertension} => {Something_1, Something_2}
# Number of filtered rules: 5
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License