Created: 2007-11-29 15:31:32

Implementation of the iteration workaround by Tom Oin conform the Q&A below. The nested workflow 'NestedProcessor' is called that to conform to Tom's explanation. For an alternative solution using a java beanshell to clone list items see 'TestIteratorStrategy_withCloning.

This workflow implements the following Q&A:

Marco Roos wrote:

> Dear Taverna user, > > Issue 1: Complex iteration > > I would like to perform an iteration including a dot product between > a list and a list of lists; example:

> Input:

> > [1] > [A,B,C] > [[a,b],[c,d],[e,f]] > > Desired output:

> > [1Aa, 1Ab, 1Bc, 1Bd, 1Ce, 1Cf] > > Is this possible? If so, how can I achieve this?

Yes, but not directly. This is actually the reason for the new T2 feature called 'staged iteration'. The issue is that assuming you iterate down to single items (which appears to be the case) you want to go half way with a dot product and then use a cross product. As the iteration strategies always (in the current code) drill down to the final thing you're asking for you can't do this, at least you can't do it without a trick...

So... the trick :

First off the [1] is a red herring, that's the easy bit! it doesn't matter where you put that in as it'll always be added onto every single job.

So you now have a list and a list of lists, you want to combine item 'n' in the first list with all the items of list 'n' in the second. Firstly you'll need a nested workflow into which you put your processor, the trick being that you also put in an 'echo list' operation. Connect the echo list output to the input of your processor being fed needing the list of lists and the echo list input to a workflow input. Connect the other input (the list) of your processor to a workflow input. The workflow inputs will have type of 'single item' and 'list' as the workflow inputs copy the types of the inputs they're connected to.

It should be obvious that if you give this nested workflow the inputs 'A' and [a,b] it'll iterate and give you [f(A*a),f(A*b]. Also note that now the nested workflow mismatches by the same level on both inputs - it has one input with a single item type which you'll feed it a list and another of a list where you feed it a list of lists. This means you can set a dot iteration strategy over the nested workflow with the cross product (default) iteration strategy over the processor within it.

This nested workflow will now produce the result you want; it will be called three times with :

[A*[a,b], B*[c,d], C*[e,f]]

Each one of these then creates a cross product iteration within the nested workflow, so the output is :


Passing the output through a list flatten operation then gives you (leaving out the 'F(x)' and replacing with 'x') :

[Aa,Ab,Bc,Bd,Ce,Cf] which is what I believe you wanted? :) Adding the [1] bit in is easy from there!

We actually did this exact thing some time ago for Paul, he had a structure he was viewing as two lists of directories where the lists were the same length but the directories could have any number of items in, he wanted a comparison between every item in directory 'n' from list 1 and every item in directory 'n' from list 2.

Hope that helps, if you were wondering why we have a superficially pointless 'echo list' local worker now you know :)


Information Preview

Information Run

Run this Workflow in the Taverna Workbench...

Option 1:

Copy and paste this link into File > 'Open workflow location...'
[ More InfoExpand ]

Information Workflow Components

Inputs (0)
Processors (6)
Beanshells (2)
Outputs (5)
Links (10)
Coordinations (0)

Information Workflow Type

Taverna 1

Information Uploader

Information License

All versions of this Workflow are licensed under:

Information Version 1 (of 1)

Information Credits (2)


Information Attributions (0)



Information Tags (5)

Log in to add Tags

Information Shared with Groups (0)


Information Featured In Packs (0)


Log in to add to one of your Packs

Information Attributed By (0)



Information Favourited By (0)

No one

Information Statistics


Citations (0)


Version History

In chronological order:

Reviews Reviews (0)

No reviews yet

Be the first to review!

Comments Comments (0)

No comments yet

Log in to make a comment

Workflow Other workflows that use similar services (0)

There are no workflows in myExperiment that use similar services to this Workflow.