Home » MXP — Modular eXpandable framework for building Pipelines » MXP Base » MXP Documentation » Writing Your Method and Parameter Scripts

Writing Your Method and Parameter Scripts

Methods and parameter sets are Bash scripts. This means that you may use any Bash code in them. It is useful, however, to know what environment this scripts are executed in.

Please recollect that actually there is no difference between parameters and methods. This separation only suggest you the better usage.

Assume that Makefile contains statement:

MXP_MAKEFILE[target]="(t1_DIR = target1, t2_DIR = target2) param1 + param2 : method1 + method2"

This means that target target will be obtained in the following way:

  • Environmental variable t1_DIR will be set to the full path to directory of target1; similarly, variable t2_DIR will be set to the full path to directory of target2. These variables will be exported.
  • Files param1.params.sh, param2.params.sh, method1.sh, and method2.sh will be sequentially sourced in subshell. In nother words, MXP will execute Bash statement:

    ( source param1.params.sh;  source param2.params.sh;  source method1.sh;  source method2.sh )
    

Sourcing scripts allows you to define Bash arrays in parameter scripts and use them in method scripts. Note that arrays cannot be exported.

In addition to environmental variables t1_DIR and t2_DIR explicitly specified in Makefile statement, MXP will export the following environmental variables:

MXP_MAINDIR
Full path to the analysis directory.
MXP_DATASET
Dataset name (taken from mxp/mxp.conf file).
MXP_TARGET
The name of the target being built.
MXP_TARGET_DIR
Full path to the directory of the target being built. All output files should be written to this directory.
MXP_REQUIRED_TARGETS
Space-separated list of required target names, in the order they appear in Makefile statement.
MXP_REQUIRED_TARGET_DIRS
Space-separated list of full paths to required target directories. In our example, it is the same as "$t1_DIR $t2_DIR".

In addition, subdirectory tmp is created inside $MXP_TARGET_DIR. The script(s) should write all intermediate output to this directory. It is recommended to preserve the contents of this directory until it is clear that pipeline works correctly — if something went wrong, the intermediate output may help to find a reason. Later tmp subdirectory may be safely removed with all its contents.