|
| 1 | +# Advanced Features |
| 2 | + |
| 3 | +## Static dispatch |
| 4 | + |
| 5 | +Here is an example that shows how to swap out constant pressure implementations. |
| 6 | + |
| 7 | +```yaml |
| 8 | +wic: |
| 9 | + default_backend: gromacs |
| 10 | + backends: |
| 11 | + gromacs: |
| 12 | + steps: |
| 13 | + - npt_gromacs.wic: |
| 14 | + amber: |
| 15 | + steps: |
| 16 | + - npt_amber.wic: |
| 17 | + graphviz: |
| 18 | + label: Constant Pressure |
| 19 | +``` |
| 20 | +
|
| 21 | +Then you just need to choose a specific implementation at the call site: |
| 22 | +
|
| 23 | +```yaml |
| 24 | +steps: |
| 25 | + - nvt.wic: |
| 26 | + - npt.wic: |
| 27 | + |
| 28 | +wic: |
| 29 | + graphviz: |
| 30 | + label: Equilibration |
| 31 | + steps: |
| 32 | + (2, npt.wic): |
| 33 | + wic: |
| 34 | + backend: amber |
| 35 | +``` |
| 36 | +This will override the default implementation of `gromacs` and use `amber`. This really just means that `npt_amber.wic` is called instead of `npt_gromacs.wic` (If `--insert_steps_automatically` is enabled, the compiler will attempt to automatically insert the necessary file format conversions as determined below.) |
| 37 | + |
| 38 | +## Subinterpreters |
| 39 | + |
| 40 | +A portion of [`examples/gromacs/nvt.wic`](https://github.com/PolusAI/mm-workflows/blob/main/examples/gromacs/nvt.wic) in `mm-workflows` is shown below. You can see that the `in:` tag of gmx_energy is identical to the `config:` tag of cwl_watcher. This currently needs to be manually copy & pasted (and indented), but it should be possible to automatically do this in the future. |
| 41 | + |
| 42 | +```yaml |
| 43 | +... |
| 44 | + - mdrun: |
| 45 | + out: |
| 46 | + - output_edr_path: !& nvt.edr # Explicit edge reference / anchor |
| 47 | + # (This edge can be inferred, but made explicit for demonstration purposes.) |
| 48 | + - gmx_energy: |
| 49 | + in: |
| 50 | + input_energy_path: !* nvt.edr # Explicit edge dereference / alias |
| 51 | + config: !ii |
| 52 | + terms: [Temperature] |
| 53 | + output_xvg_path: temperature.xvg |
| 54 | +# NOTE: explicit edges are not supported with cwl_watcher, and all filenames |
| 55 | +# must be globally unique! |
| 56 | + - cwl_watcher: |
| 57 | + in: |
| 58 | + #cachedir_path: /absolute/path/to/cachedir/ (automatically filled in by wic) |
| 59 | + file_pattern: '*nvt.edr' # Any strings that start with & or * need to be escaped in quotes |
| 60 | + cwl_tool: gmx_energy # This can also be an arbitrary subworkflow! |
| 61 | + max_times: '5' |
| 62 | + config: !ii |
| 63 | + in: |
| 64 | + input_energy_path: '*nvt.edr' # This * is automatically removed. |
| 65 | + config: !ii |
| 66 | + terms: [Temperature] |
| 67 | + output_xvg_path: temperature.xvg |
| 68 | +... |
| 69 | +``` |
| 70 | + |
| 71 | +Note that although gmx_energy appears before cwl_watcher in the YAML file, gmx_energy is independent of cwl_watcher in the DAG and thus not considered to be a previous step. We include gmx_energy simply to guarantee that the analysis gets run one more time in the main workflow, when all the files are known to be in their final state. |
| 72 | + |
| 73 | +### Known Issues |
| 74 | + |
| 75 | +Since the two runtimes are not linked, there is not currently a reliable way to determine if the previous steps have finished. Thus, to guarantee termination of the second runtime, we simply execute `cwl_tool` upto `max_times`. We also waive any guarantees about the files, so the subworkflow in the second runtime may of course fail for any number of reasons. Thus, we do not propagate speculative failures up to the main workflow. |
| 76 | + |
| 77 | +The runtime system intentionally hides the working sub-directories of each step. Thus, we are forced to use a file watcher (hence the name cwl_watcher) recursively starting from `cachedir_path`. This is why all filenames used with cwl_watcher must be globally unique. (Actually, for technical reasons we cannot use a file watching library; we simply use a good old fashioned polling loop.) |
| 78 | + |
| 79 | +## Real-time plots |
| 80 | + |
| 81 | +It is assumed that the real-time analysis takes care of the complex log file parsing, etc and produces simple tabular data files (i.e. csv files separated by whitespace instead of a comma). We need to use the same file watching / polling trick as above to locate these tabular data files. The first argument to the following command is the directory in which to look for the files. (By default it is `cachedir` because that is the default value of the `--cachedir` wic command line argument.) You can also optionally supply the file patterns, which by default are `*.xvg` and `*.dat`. |
| 82 | + |
| 83 | +``` |
| 84 | +timeseriesplots cachedir <pat1> <pat2> <...> |
| 85 | +``` |
| 86 | +
|
| 87 | +## YAML Metadata Annotations |
| 88 | +
|
| 89 | +### Overloading / Parameter Passing |
| 90 | +
|
| 91 | +This example shows how we can recursively pass in parameters / recursively overload metadata. |
| 92 | +
|
| 93 | +Suppose we want to do a very careful minimization, first in vacuum and then in solvent (i.e. [`examples/gromacs/setup_vac_min.wic`](https://github.com/PolusAI/mm-workflows/blob/main/examples/gromacs/setup_vac_min.wic) in `mm-workflows`). We would like to re-use the abstract minimization protocol from `min.wic`. However, our stability analysis requires an explicit edge definition from the final minimized coordinates (i.e. in solvent). If we try to simply add `- output_tpr_path: !& min.tpr` directly to `min.wic`, there will be duplicate definitions! This is not allowed (it will generate an exception). |
| 94 | +
|
| 95 | +The solution is to pass in this parameter to only the second instance of `min.wic`. |
| 96 | +
|
| 97 | +A portion of [`examples/gromacs/basic.wic`](https://github.com/PolusAI/mm-workflows/blob/main/examples/gromacs/basic.wic) is shown below. |
| 98 | +
|
| 99 | +```yaml |
| 100 | +... |
| 101 | +# Put everything under one top-level wic: tag to facilitate easy merging and removal. |
| 102 | +wic: |
| 103 | + graphviz: |
| 104 | + label: Molecular Dynamics |
| 105 | + steps: |
| 106 | + (1, min.wic): |
| 107 | + wic: |
| 108 | + steps: |
| 109 | + (2, cg.wic): |
| 110 | + wic: |
| 111 | + steps: |
| 112 | + (1, grompp): |
| 113 | + out: |
| 114 | + - output_tpr_path: !& min.tpr |
| 115 | +... |
| 116 | +``` |
0 commit comments