Icon

05. Workflow Control - solution

Workflow Control Solution

Solution for "Workflow Control" exercise for advanced Life Science User Training - Handle and write groups of data to separate sheets in an Excel file - Read and concatenate many sheets using a loop - Activate a workflow branch based on a user selection




Activity I: Group Looping - Read the file: CHEMBLID228_SERT_ligands.table - Group over all the AssayIDs with a group loop - Write each AssayID to a separate sheet in an Excel file Activity II: Reading Many Sheets - Use Read Excel Sheet Names to list all sheet names in an Excel file - Iterate over that list of sheets with a Table Row to Variable Loop, and aggregate them into a single KNIME table Activity III: If Switch Extend the workflow below with a switch to select the kind of visualisation. - Use a Single Selection Configuration node to let a user choose the values "Parallel Coordinates Plot" or "Scatter Plot", use the flowvariable "port index" as output port - Use a CASE Switch Data (Start) to create either a parallel coordinate plot or a scatter plot depending on the input. - Use Column Rename node to rename the plot selection column in both branches "Selection" - Combine the two paths with a CASE Switch Data (End) and use a Row Filter node to filter only the selected compounds Step 1Use the Table Reader node toload theChEMBLID228_SERT_ligands.table Step 2Use the Group LoopStart node to groupand iterate over eachassay_chmebl_id Step 3Use the Excel Writer node to writeeacht AssayID data table to aseparate sheet on Excel file. Thesheet name should be the AssayIDfor the current iteration (Hint: Passthe current AssayID as a sheetname in the Flow Variable tab) Step 4Use the Variable Loop End nodeto end the loop. Step 1Use the Read ExcelSheet Names node to geta list of all sheet in the file"data/temp/assays.xlsx". Step 2Use the Table Row toVariable Loop Start nodeto iterate over all sheets inthe list Step 3Use the Excel Readernode and connect theFlow Variable port fromthe Table Row to VariableLoop Start. Use the flowvariable created by theTable Row to VariableLoop node to control thesetting sheet_name in theFlow Variable tab Step 4Use the Loop End nodeto end the loop. Payattention: the combineddata from all loops isavailable in the output portof the node. Step 1Use the CASE SwitchData (Start) node andcontrol the PortIndexby the Flow Variable"plot-type (index)" fromthe Single SelectionConfiguration node. Step 2Use the CASESwitch Data(End) node toend the switchcase. do one iterationper A ssayIDCollect variableand end loopWrite compounds from current iterationinto an Excel SheetList all sheet names from an Excel fileRead sheetLoop oversheet names(1 per iteration)CHEMBLID228_SERT_ligands.tableCHEMBLID228_SERT_ligands.tableCombineinto oneCombine all sheetsinto single tableGroup Loop Start RDKit DescriptorCalculation ParallelCoordinates Plot Scatter Plot Single SelectionConfiguration Column Rename Column Rename Row Filter Variable Loop End Excel Writer Read ExcelSheet Names Excel Reader Table Row ToVariable Loop Start Table Reader Table Reader CASE Switch Start CASE Switch End Loop End Activity I: Group Looping - Read the file: CHEMBLID228_SERT_ligands.table - Group over all the AssayIDs with a group loop - Write each AssayID to a separate sheet in an Excel file Activity II: Reading Many Sheets - Use Read Excel Sheet Names to list all sheet names in an Excel file - Iterate over that list of sheets with a Table Row to Variable Loop, and aggregate them into a single KNIME table Activity III: If Switch Extend the workflow below with a switch to select the kind of visualisation. - Use a Single Selection Configuration node to let a user choose the values "Parallel Coordinates Plot" or "Scatter Plot", use the flowvariable "port index" as output port - Use a CASE Switch Data (Start) to create either a parallel coordinate plot or a scatter plot depending on the input. - Use Column Rename node to rename the plot selection column in both branches "Selection" - Combine the two paths with a CASE Switch Data (End) and use a Row Filter node to filter only the selected compounds Step 1Use the Table Reader node toload theChEMBLID228_SERT_ligands.table Step 2Use the Group LoopStart node to groupand iterate over eachassay_chmebl_id Step 3Use the Excel Writer node to writeeacht AssayID data table to aseparate sheet on Excel file. Thesheet name should be the AssayIDfor the current iteration (Hint: Passthe current AssayID as a sheetname in the Flow Variable tab) Step 4Use the Variable Loop End nodeto end the loop. Step 1Use the Read ExcelSheet Names node to geta list of all sheet in the file"data/temp/assays.xlsx". Step 2Use the Table Row toVariable Loop Start nodeto iterate over all sheets inthe list Step 3Use the Excel Readernode and connect theFlow Variable port fromthe Table Row to VariableLoop Start. Use the flowvariable created by theTable Row to VariableLoop node to control thesetting sheet_name in theFlow Variable tab Step 4Use the Loop End nodeto end the loop. Payattention: the combineddata from all loops isavailable in the output portof the node. Step 1Use the CASE SwitchData (Start) node andcontrol the PortIndexby the Flow Variable"plot-type (index)" fromthe Single SelectionConfiguration node. Step 2Use the CASESwitch Data(End) node toend the switchcase. do one iterationper A ssayIDCollect variableand end loopWrite compounds from current iterationinto an Excel SheetList all sheet names from an Excel fileRead sheetLoop oversheet names(1 per iteration)CHEMBLID228_SERT_ligands.tableCHEMBLID228_SERT_ligands.tableCombineinto oneCombine all sheetsinto single tableGroup Loop Start RDKit DescriptorCalculation ParallelCoordinates Plot Scatter Plot Single SelectionConfiguration Column Rename Column Rename Row Filter Variable Loop End Excel Writer Read ExcelSheet Names Excel Reader Table Row ToVariable Loop Start Table Reader Table Reader CASE Switch Start CASE Switch End Loop End

Nodes

Extensions

Links