This is a very simple and artificial example, and it is described here in very detail. It should help you to grasp the basic MXP concepts.
Before trying this example, you have to install MXP. Do not forget to add path to MXP binaries to PATH
!
It is assumed that everything that will be created during running this example is located in ~/MXP_Examples
directory. If you prefer another location, replace paths given below accordingly.
In the code snippets given below, what you have type in the terminal is typeset in blue, and what computer responds is in black. When computer response is insignificant, it is omitted.
Preparation
Create directory for running examples and download Toy-1.tar.gz to it and unpack:
cd ~
mkdir MXP_Examples
cd MXP_Examples
wget --content-disposition https://duke.box.com/shared/static/j731poceictx4cy2ckuhz1jtgmp4c1a0.gz
tar -xzf Toy-1.tar.gz
Now, we have to initialize directory Toy-1
. Initialization means creation of mxp.conf
file in mxp
subdirectory, that specifies (a) dataset name, and (b) parent pipeline.
In our case, dataset name is insignificant (name of our directory is OK, and it is default), and parent pipeline is MXP base, which also is a default. Thus, command for initialization is very simple:
mxp-init Toy-1
MXP: initializing directory ~/MXP_Examples/Toy-1
-- using existing directory ~/MXP_Examples/Toy-1/mxp
-- creating new file ~/MXP_Examples/Toy-1/mxp/mxp.conf
+ Contents of created file ~/MXP_Examples/Toy-1/mxp/mxp.conf
============================================================
MXP_DATASET="Toy-1"
MXP_PARENT_PIPELINE="MXP"
============================================================
You are ready to play with Toy-1 example. To simplify subsequent steps, change current directory to Toy-1
:
cd Toy-1
All commands below assume that the current directory is Toy-1
.
Examine Makefile
cat mxp/Makefile.sh
# This is Toy-1 Makefile.
# It is just a very simple example of MXP usage.
MXP_MAKEFILE[t01_idata]="idata"
MXP_MAKEFILE[t02_something]="(idata_DIR=t01_idata) do_something"
MXP_MAKEFILE[t03_result1]="(idata_DIR=t01_idata) r1 : make_results"
MXP_MAKEFILE[t03_result2]="(idata_DIR=t01_idata) r2 : make_results"
MXP_MAKEFILE[t04_combined_results]=" ( r1 = t03_result1, r2 = t03_result2 ) combine_results"
It defines 5 targets: t01_idata, t02_something, t03_result1, t03_result2, t04_combined_results
.
It also says that 4 methods (idata, do_something, make_results, combine_results
) and 2 parameter sets (r1, r2
) are needed. You can find corresponding scripts (idata.sh, do_something.sh, make_results.sh, combine_results.sh, r1.params.sh, r2.params.sh
) in the mxp
subdirectory.
As you may recall, Makefile.sh
is a Bash script. It defines elements of associative array MXP_MAKEFILE
. The name (index) of an element is the name of the target, and the value is a description of how this target should be obtained.
As Makefile.sh
is a Bash script, it must obey Bash syntax. In particular, no spaces are allowed before the opening quotation mark. The line:
MXP_MAKEFILE[t01_idata] = "idata"
is syntactically incorrect from Bash point of view.
In contrast, the description of how the target should be obtained can use spaces freely to increase readability — the last line of Makefile.sh
is an example.
Obtain the first target
Let us try to obtain target t01_idata
. According to Makefile, it has no required targets (the definition does not contain expression in parentheses), and in order to obtain it, script idata.sh
should be executed. You can find this script in mxp
subdirectory. If you look inside, you can see that it just writes two files to the target directory and reports its actions to the terminal. So, enter command:
mxp t01_idata