MobyLite Perl API: Workflow to Perl




Introduction

This script translates simple BioMOBY taverna workflows into a Perl subrutine.
It uses the MobyLite Perl API to execute the web services (as perl functions), create the datatypes (as perl objects), etc.
Please notice that this is just a "beta" script and it does not support all features of taverna.




Download

This utility is included in the MobyLite Perl API.




Quick user guide

This script translates simple BioMOBY taverna workflows into a Perl subrutine.

Usage:
perl WorkflowToPerl.pm MyWorkflow.xml > MyScript.pl

Collection support:
It supports articles which are Simples, Collection and Collection As Simples.

Iteration strategies:
It suports 'dot' and 'cross' products (but all inputs must be the same product).

Beanshells:
Beanshells are treated as perl functions; only the header of the beanshell is automaitcally generated.
The content of the function should be programed by the developer.





Example

Imagine we have this simple workflow:


You can download the workflow xml here: wf_example.xml

The result of the WorkflowToPerl.pl script would be this script:
sub wf_example{

	my $input = shift;
	my $result;

	my $idAA = $input->{idAA};
	my $namespaceAA = $input->{namespaceAA};
	my $namespaceDNA = $input->{namespaceDNA};
	my $idDNA = $input->{idDNA};

	my $ObjectAA = Object->new();
	$ObjectAA->id($idAA);
	$ObjectAA->namespace($namespaceAA);

	my $getAminoAcidSequence = MOBY::INB::MobyLite::Services::inb_bsc_es::getAminoAcidSequence(
		'input' => $ObjectAA
	);


	my $ObjectDNA = Object->new();
	$ObjectDNA->id($idDNA);
	$ObjectDNA->namespace($namespaceDNA);


	my $runNCBIBlastp = MOBY::INB::MobyLite::Services::www_pcm_uam_es::runNCBIBlastp(
		'scores' => '25',
		'dropoff' => '',
		'expected_threshold' => '10.0',
		'filter' => 'false',
		'extendgap' => '2',
		'alignments' => '15',
		'matrix' => 'BLOSUM62',
		'database' => 'Swiss-Prot',
		'gapalign' => 'true',
		'opengap' => '11',
		'sequence' => $getAminoAcidSequence->{'sequence'}
	);


	my $getNucleotideSequence = MOBY::INB::MobyLite::Services::inb_bsc_es::getNucleotideSequence(
		'input' => $ObjectDNA
	);


	my $runNCBIBlastn = MOBY::INB::MobyLite::Services::www_pcm_uam_es::runNCBIBlastn(
		'scores' => '25',
		'dropoff' => '',
		'expected_threshold' => '10.0',
		'filter' => 'true',
		'extendgap' => '1',
		'alignments' => '15',
		'database' => 'GenBank UNA',
		'gapalign' => 'true',
		'opengap' => '11',
		'sequence' => $getNucleotideSequence->{'sequence'}
	);

	my $result = {
		blastn => $runNCBIBlastn->{'blast_report'},
		blastp => $runNCBIBlastp->{'blast_report'},
	};

	return $result;
}
As you can see, the workflow is translated into a Perl function. The input and the output of this function are hashes. Each key corresponds to one of the inputs (resp. outputs) of the original workflow.

We could complete the previous script by calling the function with the proper parameters and printing its output:
my $input;
$input->{idAA} = "108_LYCES";
$input->{namespaceAA} = "UniProt";
$input->{namespaceDNA} = "GenBank";
$input->{idDNA} = "AA070781";

my $output = wf_example($input);

print $output->{'blastn'}->content . "\n\n";
print $output->{'blastp'}->content . "\n\n";
You can download the whole script here: wf_example.pl