Continue loop upon empty/missing result

Hi,

I have a workflow that loops over a folder with protein structures, and then some calculations are done on each protein. Then the results are written separately for each protein, and the loop reiterates. However the loop stalls when a calculation gives no results and thus produces an empty table somewhere before the loop end.

How can I ignore (skip) these empty results (I don’t need them) and continue with the next iteration? Are there specific nodes for this and a good working example? I am a bit reluctant to share my workflow but I hope you understand my problem at hand.

Thanks/Evert

Hi @evert.homan_scilifelab.se what type of loop are you using?

Is the loop “stalling” because you are hitting some kind of error (e.g. processing fails) when the empty table is produced?

If I mock up a simple loop where under some circumstances, the Joiner produces an Empty table, the loop still continues to completion:

If you need to avoid certain steps when an empty table occurs you can end an Empty Table Switch like this:

Alternatives are that maybe you need to catch a specific error (using try - catch nodes)?

It’s also possible that the stalling of the loop is caused by something else, so if you have more details that you can share about what you are seeing then that would be helpful.

1 Like

Hi,

The loop stalls due to a node producing only missing values, the table is not empty. In the image below the SiteMap node produces missing values for the protein in question as no sites can be found:

thinking out loud without being able to see the specifics of your data, and not being familiar with the protein domain or SiteMap, but could you place a row filter after SiteMap which filters out all rows that have the missing values, and then place an empty table switch and associated nodes (as below) to bypass this iteration:

btw, if the suggested Row Filter is not sufficiently powerful for filtering rows (e.g. if you perhaps have to filter rows based on multiple missing attributes), then it could possibly be replaced with a Rule Based Row Filter.

Many thanks for this, I tried your suggestion on 3 proteins, 2 yielding results and 1 missing and it only saved the output for the 2 successful ones, which is what I wanted. I made sure the unsuccessful entry was the second of the 3, and it was skipped as intended. I learned a lot, have never used case switching before.

BW/Evert

Hi @evert.homan_scilifelab.se , good news and glad to hear it works for you.

I think you’ll find that the “case switch” nodes and “If” nodes open up many possibilities, so good to have a play with them, and see an example in action.

One note though about your workflow…Technically, your loop should be wired more like this:

as this then fully satisfies the flow to both the upper and lower (conditional) ports on the Case Switch End. It probably doesn’t matter for your flow, and if it’s working then maybe don’t fix it! :wink:

You will see on your flow that the output data port on the Case Switch End is showing as blocked.

image

This is because by having only a single conditional port going in to Case Switch End node, you’ve effectively tied the “empty table” (lower) port of the Empty Table Switch to the upper (only!) conditional port present on the Case Switch End.

The standard flow variable port on the Case Switch End, that you have attached your upper branch to, is not a conditional port and so is always active.

To make the loop construct I’ve shown above, when adding the Case Switch End in the Modern UI, you would choose Flow Variable as the output port:

image

and the Excel Writer would then be connected to the Upper conditional Flow port (port 1) rather than the standard “left ear” flow variable port on the top surface of the node.

image

As you have it currently, this would cause you problems if you were wanting to use the data output port of the Case Switch End to pass the data flow to the Variable Loop End.

As it is, though, since you aren’t using that data output port, it probably doesn’t matter. Just something to note (or bookmark!) for future flows. :slight_smile:

1 Like

Thanks, very insightful but quite advanced KNIMEing with these ‘hidden’ variable ports. I have change my workflow accordingly.

BW/Evert

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.