Change RowKey in BufferedDataTable

#1

I need to change the row keys in a BufferedDataTable and can’t see how this is possible.

For context:

I’m reading in an sd-file that has the row key as a property and not as molecule name. 3rd party tool that creates the sd-file sadly can’t set the molecule name. Due to that I can’t use the SdfReader option to use molecule name as row id. So I get BufferedDataTable in which I would need to change the row id again.

Is that possible?

0 Likes

#2

Hi @beginner,
You can set the RowKey with the RowID node.

best,
Gabriel

0 Likes

#3

Hi Gabriel.

I meant in code in my own node.

The node writes input table to disk which processed by 3rd party tool which outputs an sd-file. Then my node should read back in that sd-file an join the result to the existing table (using exec.createJoinedTable) which requires same row ids.

1 Like

#4

You could use something like:

RowKey newKey = new RowKey(key); //key = new String row key
DataRow newRow = new DefaultRow(newKey, row); // row = existing row

Alternatively, you might be able to process your input table and add the new cells to each row directly with

DataRow newRow = new AppendedColumnRow(inRow, newCells);

where inRow is your incoming table data row, and newCells is a DataCell[] of the cells to be added. there is also a constructor I think for a new RowKey in AppendedColumnRow if you wish to change the key.

Steve

1 Like

#5

Haha alright :slight_smile: then do what steve said.
best,
Gabriel

1 Like