RAPPEL : Opération de maintenance > ForgeMIA indisponible le 20 Janvier entre 7h et 12h

Commit 972fcba0 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

No commit message

No commit message
parent 6a71f45a
......@@ -450,6 +450,128 @@ class MyWorkflow (Workflow):
<p>This method takes the same arguments as <code>add_input_file()</code>. However, adding this parameter,
the final user will be allowed to provide multiple files and the object attribut <code>self.parameter_name</code> will be
settled as a Python list.</p>
<h3>add_input_directory()</h3>
<p>
The <code>add_input_directory()</code> method allows the user to select files from a specific directory. This
kind of input can be useful for tools outputing not only files but an organized directory.
The parameter <code>get_files_fn</code> specify the function that will be used to retrieve the files. This method can
take as many arguments as required, but the first argument has to be a string representing the folder path.
By default all files will be selected. From the workflow <code>process()</code> function, the files can be retrieved
by using the <code>get_files()</code> method.
</p>
<h4>Example</h4>
<p>
In the following example, the <code>add_input_directory()</code> method is used to parse a directory and retrieve only fasta files
inside this directory. <code>get_files()</code> will browse the directory and get all fasta files.
</p>
<div>
<pre class="pre-hl "><code class="python">import os
from jflow.Workflow import Workflow
def fasta_files(folder):
res = []
for file in os.listdir(folder):
if file.endswith(".fasta"):
res.append(file)
return res
class MyWorkflow(Workflow):
def define_parameters(self, function="process"):
self.add_input_directory("fastadir", "Path to folder with fasta files",
get_files_fn=fasta_files)
def process(self):
# to retrieve the files
for fastafile in self.fastadir.get_files():
# do something</code></pre>
</div>
<h4>Options</h4>
<p>There are two positional argument : <code>name</code> and <code>help</code>. All other options are keyword options. </p>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required</th>
<th>Default value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>string</td>
<td>true</td>
<td>None</td>
<td>The name of the parameter. The parameter value is accessible
within the workflow object through the attribute named <code>self.parameter_name</code>.</td>
</tr>
<tr>
<td>help</td>
<td>string</td>
<td>true</td>
<td>None</td>
<td>The parameter help message.</td>
</tr>
<tr>
<td>default</td>
<td>string</td>
<td>false</td>
<td>None</td>
<td>The default path value.</td>
</tr>
<tr>
<td>get_files_fn</td>
<td>function</td>
<td>false</td>
<td>-</td>
<td>
get_files_fn will be the method called when executing <code>param.get_files()</code>. All argument from get_files()
will be used as arguments in get_files_fn
</td>
</tr>
<tr>
<td>required</td>
<td>boolean</td>
<td>false</td>
<td>false</td>
<td>Wether or not the parameter can be ommitted.</td>
</tr>
<tr>
<td>flag</td>
<td>string</td>
<td>false</td>
<td>None</td>
<td>The command line flag (if the value is None, the flag will be <code>--name</code>).</td>
</tr>
<tr>
<td>group</td>
<td>string</td>
<td>false</td>
<td>"default"</td>
<td>The value is used to group a list of parameters in sections. The group is used in both command line and GUI.</td>
</tr>
<tr>
<td>display_name</td>
<td>string</td>
<td>false</td>
<td>None</td>
<td>The parameter name that should be displayed on the final form.</td>
</tr>
</tbody>
</table>
</div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment