Custom composable apps¶
You can make a simple customised app using the user_function app. This is a wrapper class that takes a reference to your function and the input, output and data types. The resulting app can then become part of a composed function.
Defining a user_function requires you consider four things.
funcA function you have written. This is required.
input_typesA type, or collection of type that your function can handle. This setting dictates what other apps have an output that is a compatable input for your function.
output_typesA type, or collection of type that your function produces. This setting dictates what other apps can have yours as input.
data_typesThe data class names, as strings, that your function can handle. Not required, but useful.
A simple example¶
We make a very simple function first4, that returns the first 4 elements of an alignment.
Now we define a user_function instance that takes and returns an ALIGNED_TYPE.
The repr() of your user_function instance indicates the wrapped function and the module it’s in.
You use it like all composable apps which we demonstrate using a small sample alignment.
Renaming sequences¶
This time we wrap a method call on a SequenceCollection (and the alignment sub-classes) for renaming sequences. We also illustrate here that to support both aligned and unaligned data types as input/output, we have to include these in the construction of the custom function.
Note
The SERIALISABLE_TYPE indicates the data has the ability to be converted to json.
A user function for with a different output type¶
In this example, we make an function that returns DistanceMatrix of an alignment.