Applications on BioLib consist of one or more modules. A module executes a coding job doing some task (transforming data, calculating statistics, fetching external data, machine learning inference, etc.). In many ways, on can think of the modules in an application as the BioLib equivalent of the programs that are locally available for a script to call. Each module contains one executable code file, where the code for each module can be written in any of the supported languages.

The module system functions similarly to the classic UNIX command-line framework, in that the code in modules can read inputs and write outputs/errors in three distinct streams: stdin, stdout and stderr. In addition, modules also have access to a virtual filesystem, that can be used by modules to interact and that the user of an application will be able to download once the computation has completed.

Modules Settings and Images

To be able to call code from a module, that module has to be declared with a name and path in the "Modules" section of the application editor. The module called main is the module that will be executed first.

The "Image" referes to the container your code will be exectured in. To read more about how the images work, supported languages and libraries, please refer to this page.

Example 1: Moving data between modules

In the following example one Python script module (main) calls another Python script (module2) and a value generated in the first module is moved to the second and back again. Note that, in the "Modules" section of the application editor, each of the modules should be named main and `module2` respectively.

# main
import subprocess
result ="module_2").communicate(1)
assert(result == 2)
# module 2, named module_2 in UI
import sys
input =
input + 1

Here Main uses the subprocess functions .call() and .communicate() to pass the number 1 to module_2 which returns the result of the last line (input + 1). By default, code snippets follow this return pattern.

External applications as modules

BioLib applications can use other BioLib applications as modules. Note a user can only create or run an application calling other applications if they have the license to run the applications that are called by the main application.