Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Tutorial

Taverna tutorial 2014: Advanced Taverna features includes a tutorial exercise on Looping.

Looping in Taverna

Taverna workflows are inherently data-driven workflows, where data returned from one service is pushed directly to downstream services. A Taverna workflow definition does not linearly say when a service should be invoked, but where its data should come from and go to. This philosophy lets the user focus on how services are connected together, and the Taverna execution takes care of invoking services as soon as the required inputs are ready.

...

One typical use case for when you need looping is for invoking asynchronous services, that is a web service or similar where you have a pattern of first submitting the job with input parameters, which returns you a job ID, secondly, check the status of the job using that ID. You keep checking the status of the job as long as the job is in an active state (running), and finally when the job is in a final state, you get the results for the given job ID. The EBI Interproscan example workflow shows how this can be used in practice, but below we'll use a dummy workflow to avoid dependencies of third-party services.

...

However, if the service in question could return both PENDING and RUNNING before finally returning COMPLETE it would be better to check on is equal to COMPLETE. More complex scenarios can be covered with a custom looping condition. (See below)

Looping is shown the Diagram by double lines. The Advanced details should now show the looping configuration. (It is a known bug that looping is not shown in the diagram).

The delay will add a sleep between each iteration, which can be useful to avoid 10.000 status checks per second and killing the web service.

...

Tip
titleNot all output ports are listed

Only service output ports returning single values (depth 0) are included in the port drop-down. If you want to compare output ports with lists, you will need to create a Customized loop condition to inspect the list.

You can download the finished example looping workflow from myExperiment. When running you will see that checkStatus takes a while to finish, and that you get the outputs result: 10 and state: COMPLETE.

...

In this dialogue you will see the code generated from the selections in the loop configuration window:

Code Block

loop = "" + (! (Double.parseDouble(divided) < Double.parseDouble("2")));
if ("true".matches(loop)) {
   Thread.sleep(500);
}

...

This example workflow shows how a nested workflow can be looped using this customized loop script:

Code Block

count = Integer.parseInt(count) + 1;
loop = ( list.size() < 5 );

...