1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
|
.. include:: ../global.inc
#######################
Ruffus Decorators
#######################
.. seealso::
:ref:`Indicator objects <decorators.indicator_objects>`
.. _decorators:
=============================================
*Core*
=============================================
.. csv-table::
:header: "Decorator", "Examples"
:widths: 400, 600,1
"**@originate** (:ref:`Summary <decorators.originate>` / :ref:`Manual <new_manual.originate>`)
- Creates (originates) a set of starting file without dependencies from scratch (*ex nihilo*!)
- Only called to create files which do not exist.
- Invoked onces (a job created) per item in the ``output_files`` list.
", "
* :ref:`@originate <decorators.originate>` ( ``output_files``, [``extra_parameters``,...] )
\
", ""
"**@split** (:ref:`Summary <decorators.split>` / :ref:`Manual <new_manual.split>`)
- Splits a single input into multiple output
- Globs in ``output`` can specify an indeterminate number of files.
", "
* :ref:`@split <decorators.split>` ( ``tasks_or_file_names``, ``output_files``, [``extra_parameters``,...] )
\
", ""
"**@transform** (:ref:`Summary <decorators.transform>` / :ref:`Manual <new_manual.transform>`)
- Applies the task function to transform input data to output.
", "
* :ref:`@transform <decorators.transform>` ( ``tasks_or_file_names``, :ref:`suffix <decorators.transform.suffix_string>`\ *(*\ ``suffix_string``\ *)*\ , ``output_pattern``, [``extra_parameters``,...] )
\
* :ref:`@transform <decorators.transform>` ( ``tasks_or_file_names``, :ref:`regex <decorators.transform.matching_regex>`\ *(*\ ``regex_pattern``\ *)*\ , ``output_pattern``, [``extra_parameters``,...] )
\
* :ref:`@transform <decorators.transform>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.transform.matching_formatter>`\ *(*\ ``regex_pattern``\ *)*\ , ``output_pattern``, [``extra_parameters``,...] )
\
", ""
"**@merge** (:ref:`Summary <decorators.merge>` / :ref:`Manual <new_manual.merge>`)
- Merges multiple input files into a single output.
", "
* :ref:`@merge <decorators.merge>` (``tasks_or_file_names``, ``output``, [``extra_parameters``,...] )
\
", ""
.. _decorators.combinatorics:
=============================================
*Combinatorics*
=============================================
.. csv-table::
:header: "Decorator", "Examples"
:widths: 400, 600,1
"**@product** (:ref:`Summary <decorators.product>` / :ref:`Manual <new_manual.product>`)
- Generates the **product**, i.e. all vs all comparisons, between sets of input files.
", "
* :ref:`@product <decorators.product>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.product.matching_formatter>` *([* ``regex_pattern`` *])* ,*[* ``tasks_or_file_names``, :ref:`formatter <decorators.product.matching_formatter>` *([* ``regex_pattern`` *]), ]*, ``output_pattern``, [``extra_parameters``,...] )
\
", ""
"**@permutations** (:ref:`Summary <decorators.permutations>` / :ref:`Manual <new_manual.permutations>`)
- Generates the **permutations**, between all the elements of a set of **Input**
- Analogous to the python `itertools.permutations <http://docs.python.org/2/library/itertools.html#itertools.permutations>`__
- permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
", "
* :ref:`@permutations <decorators.permutations>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.product.matching_formatter>` *([* ``regex_pattern`` *])*, ``tuple_size``, ``output_pattern``, [``extra_parameters``,...] )
\
", ""
"**@combinations** (:ref:`Summary <decorators.combinations>` / :ref:`Manual <new_manual.combinations>`)
- Generates the **permutations**, between all the elements of a set of **Input**
- Analogous to the python `itertools.combinations <http://docs.python.org/2/library/itertools.html#itertools.permutations>`__
- combinations('ABCD', 3) --> ABC ABD ACD BCD
- Generates the **combinations**, between all the elements of a set of **Input**:
i.e. r-length tuples of *input* elements with no repeated elements (**A A**)
and where order of the tuples is irrelevant (either **A B** or **B A**, not both).
", "
* :ref:`@combinations <decorators.permutations>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.product.matching_formatter>` *([* ``regex_pattern`` *])*, ``tuple_size``, ``output_pattern``, [``extra_parameters``,...] )
\
", ""
"**@combinations_with_replacement** (:ref:`Summary <decorators.combinations_with_replacement>` / :ref:`Manual <new_manual.combinations_with_replacement>`)
- Generates the **permutations**, between all the elements of a set of **Input**
- Analogous to the python `itertools.permutations <http://docs.python.org/2/library/itertools.html#itertools.permutations>`__
- combinations('ABCD', 3) --> ABC ABD ACD BCD
- Generates the **combinations_with_replacement**, between all the elements of a set of **Input**:
i.e. r-length tuples of *input* elements with no repeated elements (**A A**)
and where order of the tuples is irrelevant (either **A B** or **B A**, not both).
", "
* :ref:`@combinations_with_replacement <decorators.permutations>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.product.matching_formatter>` *([* ``regex_pattern`` *])*, ``tuple_size``, ``output_pattern``, [``extra_parameters``,...] )
\
", ""
=============================================
*Advanced*
=============================================
.. csv-table::
:header: "Decorator", "Examples"
:widths: 400, 600,1
"**@subdivide** (:ref:`Summary <decorators.subdivide>` / :ref:`Manual <new_manual.subdivide>`)
- Subdivides a set of *Inputs* each further into multiple *Outputs*.
- The number of files in each *Output* can be set at runtime by the use of globs.
- **Many to Even More** operator.
- The use of **split** is a synonym for subdivide is deprecated.
", "
* :ref:`@subdivide <decorators.subdivide>` ( ``tasks_or_file_names``, :ref:`regex <decorators.subdivide.matching_regex>`\ *(*\ ``regex_pattern``\ *)*\ , [ :ref:`inputs <decorators.inputs>` | :ref:`add_inputs <decorators.add_inputs>`\ *(*\ ``input_pattern``\ *)*\ , ] ``output_pattern``, [``extra_parameters``,...] )
\
* :ref:`@subdivide <decorators.subdivide>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.subdivide.matching_formatter>`\ *(*\ [``regex_pattern``] *)*\ , [ :ref:`inputs <decorators.inputs>` | :ref:`add_inputs <decorators.add_inputs>`\ *(*\ ``input_pattern``\ *)*\ , ] ``output_pattern``, [``extra_parameters``,...] )
\
", ""
"**@transform** (:ref:`Summary <decorators.transform_ex>` / :ref:`Manual <new_manual.inputs>`)
- Infers input as well as output from regular expression substitutions
- Useful for adding additional file dependencies
", "
* :ref:`@transform <decorators.transform_ex>` ( ``tasks_or_file_names``, :ref:`regex <decorators.transform.matching_regex>`\ *(*\ ``regex_pattern``\ *)*\ , [ :ref:`inputs <decorators.inputs>` | :ref:`add_inputs <decorators.add_inputs>`\ *(*\ ``input_pattern``\ *)*\ , ] ``output_pattern``, [``extra_parameters``,...] )
\
* :ref:`@transform <decorators.transform_ex>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.transform.matching_formatter>`\ *(*\ ``regex_pattern``\ *)*\ , [ :ref:`inputs <decorators.inputs>` | :ref:`add_inputs <decorators.add_inputs>`\ *(*\ ``input_pattern``\ *)*\ , ] ``output_pattern``, [``extra_parameters``,...] )
\
", ""
"**@collate** (:ref:`Summary <decorators.collate>` / :ref:`Manual <new_manual.collate>`)
- Groups multiple input files using regular expression matching
- Input resulting in the same output after substitution will be collated together.
", "
* :ref:`@collate <decorators.collate>` (``tasks_or_file_names``, :ref:`regex <decorators.collate.matching_regex>`\ *(*\ ``regex_pattern``\ *)*\ , ``output_pattern``, [``extra_parameters``,...] )
\
* :ref:`@collate <decorators.collate_ex>` (``tasks_or_file_names``, :ref:`regex <decorators.collate_ex.matching_regex>`\ *(*\ ``regex_pattern``\ *)*\ , :ref:`inputs <decorators.inputs>` | :ref:`add_inputs <decorators.add_inputs>`\ *(*\ ``input_pattern``\ *)*\ , ``output_pattern``, [``extra_parameters``,...] )
\
* :ref:`@collate <decorators.collate>` (``tasks_or_file_names``, :ref:`formatter <decorators.collate.matching_formatter>`\ *(*\ ``formatter_pattern``\ *)*\ , ``output_pattern``, [``extra_parameters``,...] )
\
* :ref:`@collate <decorators.collate_ex>` (``tasks_or_file_names``, :ref:`formatter <decorators.collate_ex.matching_formatter>`\ *(*\ ``formatter_pattern``\ *)*\ , :ref:`inputs <decorators.inputs>` | :ref:`add_inputs <decorators.add_inputs>`\ *(*\ ``input_pattern``\ *)*\ , ``output_pattern``, [``extra_parameters``,...] )
\
", ""
"**@follows** (:ref:`Summary <decorators.follows>` / :ref:`Manual <new_manual.follows>`)
- Indicates task dependency
- optional :ref:`mkdir <decorators.follows.directory_name>` prerequisite (:ref:`see Manual <new_manual.follows.mkdir>`)
", "
* :ref:`@follows <decorators.follows>` ( ``task1``, ``'task2'`` ))
\
* :ref:`@follows <decorators.follows>` ( ``task1``, :ref:`mkdir <decorators.follows.directory_name>`\ ( ``'my/directory/'`` ))
\
", ""
"**@posttask** (:ref:`Summary <decorators.posttask>` / :ref:`Manual <new_manual.posttask>`)
- Calls function after task completes
- Optional :ref:`touch_file <decorators.posttask.file_name>` indicator (:ref:`Manual <new_manual.posttask.touch_file>`)
", "
* :ref:`@posttask <decorators.posttask>` ( ``signal_task_completion_function`` )
\
* :ref:`@posttask <decorators.posttask>` (:ref:`touch_file <decorators.touch_file>`\ ( ``'task1.completed'`` ))
\
", ""
"**@active_if** (:ref:`Summary <decorators.active_if>` / :ref:`Manual <new_manual.active_if>`)
- Switches tasks on and off at run time depending on its parameters
- Evaluated each time :ref:`pipeline_run(...) <pipeline_functions.pipeline_run>`, :ref:`pipeline_printout(...) <pipeline_functions.pipeline_printout>` or :ref:`pipeline_printout_graph(...) <pipeline_functions.pipeline_printout_graph>` is called.
- Dormant tasks behave as if they are up to date and have no output.
", "
* :ref:`@active_if <decorators.active_if>` ( ``on_or_off1, [on_or_off2, ...]`` )
\
", ""
"**@jobs_limit** (:ref:`Summary <decorators.jobs_limit>` / :ref:`Manual <new_manual.jobs_limit>`)
- Limits the amount of multiprocessing for the specified task
- Ensures that fewer than N jobs for this task are run in parallel
- Overrides ``multiprocess`` parameter in :ref:`pipeline_run(...) <pipeline_functions.pipeline_run>`
", "
* :ref:`@jobs_limit <decorators.jobs_limit>` ( ``NUMBER_OF_JOBS_RUNNING_CONCURRENTLY`` )
\
", ""
"**@mkdir** (:ref:`Summary <decorators.mkdir>` / :ref:`Manual <new_manual.mkdir>`)
- Generates paths for `os.makedirs <http://docs.python.org/2/library/os.html#os.makedirs>`__
", "
* :ref:`@mkdir <decorators.mkdir>` ( ``tasks_or_file_names``, :ref:`suffix <decorators.mkdir.suffix_string>`\ *(*\ ``suffix_string``\ *)*\ , ``output_pattern`` )
\
* :ref:`@mkdir <decorators.mkdir>` ( ``tasks_or_file_names``, :ref:`regex <decorators.mkdir.matching_regex>`\ *(*\ ``regex_pattern``\ *)*\ , ``output_pattern`` )
\
* :ref:`@mkdir <decorators.mkdir>` ( ``tasks_or_file_names``, :ref:`formatter <decorators.mkdir.matching_formatter>`\ *(*\ ``regex_pattern``\ *)*\ , ``output_pattern``)
\
", ""
"**@graphviz** (:ref:`Summary <decorators.graphviz>` / :ref:`Manual <new_manual.pipeline_printout_graph>`)
- Customise the graphic for each task in printed flowcharts
", "
* :ref:`@graphviz <decorators.graphviz>` ( ``graphviz_parameter = XXX``, ``[graphviz_parameter2 = YYY ...]``)
\
", ""
=============================================
*Esoteric!*
=============================================
.. csv-table::
:header: "Decorator", "Examples"
:widths: 400, 600,1
"**@files** (:ref:`Summary <decorators.files>` / :ref:`Manual <new_manual.deprecated_files>`)
- I/O parameters
- skips up-to-date jobs
- Should use :ref:`@transform <decorators.transform>` etc instead
", "
* :ref:`@files <decorators.files>`\ ( ``parameter_list`` )
\
* :ref:`@files <decorators.files>`\ ( ``parameter_generating_function`` )
\
* :ref:`@files <decorators.files>` ( ``input_file``, ``output_file``, ``other_params``, ... )
\
", ""
"**@parallel** (:ref:`Summary <decorators.parallel>` / :ref:`Manual <new_manual.deprecated_parallel>`)
- By default, does not check if jobs are up to date
- Best used in conjuction with :ref:`@check_if_uptodate <decorators.check_if_uptodate>`
", "
* :ref:`@parallel <decorators.parallel>` ( ``parameter_list`` ) (:ref:`see Manual <new_manual.deprecated_parallel>`)
\
* :ref:`@parallel <decorators.parallel>` ( ``parameter_generating_function`` ) (:ref:`see Manual <new_manual.on_the_fly>`)
\
", ""
"**@check_if_uptodate** (:ref:`Summary <decorators.check_if_uptodate>` / :ref:`Manual <new_manual.check_if_uptodate>`)
- Custom function to determine if jobs need to be run
", "
* :ref:`@check_if_uptodate <decorators.check_if_uptodate>` ( ``is_task_up_to_date_function`` )
\
", ""
".. tip::
The use of this overly complicated function is discouraged.
**@files_re** (:ref:`Summary <decorators.files_re>`)
- I/O file names via regular
expressions
- start from lists of file names
or |glob|_ results
- skips up-to-date jobs
", "
* :ref:`@files_re <decorators.files_re>` ( ``tasks_or_file_names``, ``matching_regex``, [``input_pattern``,] ``output_pattern``, ``...`` )
``input_pattern``/``output_pattern`` are regex patterns
used to create input/output file names from the starting
list of either glob_str or file names
", ""
|