How to script table filters.

15 views
Skip to first unread message

Andrew Orry

unread,
Sep 18, 2018, 2:35:43 PM9/18/18
to MolSoft ICM Knowledge Base
Q.
 I have a script generating a table with different columns and numerical values. In that table I then add filters manually. I would like to add those filters directly in the script instead. How can I do this?
A.

Column filters can be set using 'set format' command and get by Collection( <column> format ) function

For example try to set filter in GUI and then type
Collection( t.A format )     # t.A should correspond to the column you've set filter to

You should see something like that:
icm/def> Collection(COX2.SET format)
{
 "filter": "_ in {1,3}",
 "mask": 0,
 "pos": 3,
 "type": "Int",
 "width": 124
}

To set filter you can copy the filter expression and pass it to the 'set format' command like below:
('_' in the expression refers to the values of this column)

add column t {1 2 3}
set format t.A filter="_ in {1,2}"
set format t.A filter="_ == 1 | _ == 2"
set format t.A filter="_ < 3"

For string and chemical columns you can also use '~' operator which means sub-string or substructure

E.g:

add column tt Chemical({"CCO","CCN","CCC"})
set format tt.mol filter="_ ~ '[N;H2]'"  # filter primary amines

Reply all
Reply to author
Forward
0 new messages