Analysis of a bitvector

Hi to all,

So I have bitvectors and I would like to find out is bits at certain position are set. Is there a way to do it in Knime?




There may be another way(?), but what sprung to mind is the following:

  • use the Erl Wood 'Fingerprints Expander' node to convert your bitvectors into columns
  • Bring your list of Bits and desired values (or ranges) in (maybe use the 'Table Creator' node if there are only one or two).  Make sure that the bits are named "Bit 1", etc to match the output of the Erl Wood node
  • feed this bit list into the 'Row Splitter' node via a 'RowToVariableLoopStart' node, and match-up the flow variables to the required options
  • Finish with a loop end

I made a quick workflow (tried attaching, but got some very strange errors - so it may or may not be there...) to demonstrate (but actually ran into some problems trying to match the lower/upper bounds of the range checking to my flow variables; so ended-up doing a pattern match to '0' to exclude the non-matches...  Anyway, hopefully this gives an idea of one way round(?)

Kind regards


Hi James,

Thank you for this good idea. I think it is quite similar to what I would like to do. Just something else I was wondering. Is it possible to use more than one bit test at same tame (in one table creator), e.g. "give me only the records in which the bit100 AND bit1000 are set"?  I managed to do this by using two different table creators  and loops but is there a way using smaller number of nodes?

Best Regards


This is quite simple, especially if you already know the bits of interest.  You could use the 'Rule Engine' node, which gives you access to all of the columns and all of the logic operators that you might need.

Your example above could be translated to the rule:

$Bit 100$>0 AND $Bit 1000$>0 => "1"

This would check both columns, and then if they were both 'set' the new output column (eg could be named "Test" would be set to "1".  If either bit were not set, then the output column would take the default label (eg 0).

You can also make use of OR, XOR, NOT, IN, MISSING and you can set multiple rules in one node, which will be assessed sequentially.

Hope this helps

Kind regards


Hi James,

Thank you once again! That is just I wanted to do!

Best Regards!


I have question about using the 'Rule engine' node. Is it possible to pass outside rules to the node, something like from loop, or some file where there are created beforehand?



This is quite easy to do. Setup your rule engine node how you want it. When done go to the flow variables tab, expand the rules section by clicking on the "+". Ignore the "array-size" option (this is saying how many rules there are), you will now have a list of numbers counting from 0 upwards, each one of these numbers represents a rule in the order they are shown in the table in your Rule Editor. Next to each of the numbers is an empty white box (not the dropdown box), enter in a label for each. This will now copy that particular rule as a variable under the name of that label you gave it.

To put these rules into your data table, now run this rule engine node, and then connect up "Variable To Table Column" node, make sure you connect both the black data line, and the variable red line between the "Rule Engine" node and "Variable to To Table Column" node. If you are now asking where is the red outport of the "Rule Engine" node, right click on it and choose "Show Flow Variable Ports". Now configure the "Variable to Table Column" node by selecting all the variables you want to put in as a column, you will see the label names you entered earlier, use the Shift key to select more than one.


Hope this helps, Simon.

May be I don't understand you but I want to do is:

Read external file and create rules from it and then whitin loop to pass them to 'Rule engine' flow variable port which then check data from the input port against the rules. I did some attempts but doesn't work.

If it is possible is there specific format for the rules?


Apologies I misunderstood what you wanted.

You could however use the above procedure to export the hand entered rules out from the Rule Engine and you can then export this to a text file from KNIME so you can see how the format of the rules should look like so as to import as a file and then import into the node via variables.

I would anticipate just importing the text file of rules and then using the "TableROw to Variable  Loop Start" node should work followed by the "Rule Engine" node and a "Loop ENd" and just configuring the "Rule Engine" in the flow variables tab by going to the rules section, clicking "+" and next to "0" from the dropdown select the variable name.

Note for the "0" to appear in the flow variables tab, you will need to manually enter a dummy rule first. Dont worry about what the rule is, it will be overwritten with your rule from your variable.

Any successes yet with this ?


Hi guys,

I did it. I managed to use  'Rule engine' using loop and passing rules from external files. If anyone is interested the proper format should be the same as the rule in tables of the node itself:

$Bit#n1$ > 0 AND $Bit#N2$ > 0 => "true"

Thank you both for the help!