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

Commit eec83724 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

component doc started

parent 204a708d
......@@ -70,8 +70,8 @@
<ul id="sidebar" class="nav nav-stacked fixed">
<li><a href="#what" class="active">What is a component</a></li>
<li><a href="#component-architecture" >Where to add a new component</a></li>
<li><a href="#component" >Component definition</a></li>
<li><a href="#define_parameters">Defining parameters</a>
<li><a href="#component" >The Component class</a></li>
<li><a href="#define_parameters">Define parameters</a>
<ul class="nav nav-stacked">
<li><a href="#parameters">Parameters</a></li>
<li><a href="#input_parameters">Input parameters</a></li>
......@@ -104,19 +104,18 @@
<section id="what" class="group">
<h1 class="page-header">What is a component</h1>
<p>A component can be viewed as the representation of a step in a workflow. It is a special python class
inerhiting from <code>jflow.components.Component</code> and describes the execution of one or multiple commands, which
can be external scripts or python code. This page shows how to define a component.</p>
<p>A component is one or a collection of command lines, which can be external scripts or python code. In jflow, a component is represented by a
Python class inerhiting from <code>jflow.component.Component</code>. It lists all the inputs, outputs and parameters required to run the
command line(s) and defines its structure.</p>
</section>
<section id="component-architecture" class="group">
<h1 class="page-header">Where to add a new component</h1>
<p>The new component must be defined in a python module in two specific location in order to be seen and used. Those two locations are : </p>
<p>New components must be added in a Python package. Two different location are possible in order to be imported by jflow: </p>
<ul>
<li>in <code>workflows.components</code> - the component will be visible by <b>all</b> workflows.</li>
<li>in <code>workflows.myWorkflowName.components</code> - where <i>myWorkflowName</i> is the package of a specific workflow.
The component will be visible and usable only in <i>myWorkflowName</i>.</li>
<li><code>workflows.components</code>: the component will be visible by all workflows,</li>
<li><code>workflows.myWorkflow.components</code>: the component will only be available for<code>myWorkflow</code>.</li>
</ul>
<p>The following code represent the structure of the source, and the location where to add component packages.</p>
......@@ -126,13 +125,13 @@
├── docs/
├── src/
├── workflows/
│ ├── myWorkflowName/
│ │ ├── components/ [ workflow specific components ]
│ │ │ └── myComponentName.py [ the component code ]
│ ├── myWorkflow/
│ │ ├── components/ [ workflow specific components ]
│ │ │ └── myComponent.py [ the component code ]
│ │ └── __init__.py
│ ├── components/ [ general components ]
│ ├── components/ [ general components ]
│ │ ├── __init__.py
│ │ └── myComponentName.py [ the component code ]
│ │ └── myComponent.py [ the component code ]
│ ├── extparsers/
│ ├── __init__.py
│ ├── formats.py
......@@ -142,35 +141,29 @@
</section>
<section id="component" class="group">
<h1 class="page-header">The <i>Component</i> definition</h1>
<p>The new component is a python class defined in <code>myComponentName.py</code>. This class must:</p>
<h1 class="page-header">The Component class</h1>
<p>In jflow, a component is a class defined in the <code>myComponent.py</code> file. In order to add a new component, the developper has to: </p>
<ul>
<li>Inherit from the <code>jflow.components.Component</code> class</li>
<li>Overload the <code>define_parameters()</code> function to define parameters, inputs AND outputs</li>
<li>Overload the <code>process()</code> function to define the component execution using weaver concepts</li>
<li>implement a class inheriting from the <code>jflow.component.Component</code> class,</li>
<li>overload the <code>define_parameters()</code> method to add the component inputs, outputs and parameters,</li>
<li>overload the <code>process()</code> method to define the command line(s) structure.</li>
</ul>
<p>The class skeleton is given by</p>
<div>
<pre class="pre-hl "><code class="python">from jflow.component import Component
from weaver.function import ShellFunction
class BWAAln (Component):
def define_parameters(self, input_files, reference_genome):
self.add_input_file("reference_genome", "the reference file",
file_format="fasta", default=reference_genome, required=True)
self.add_input_file_list("input_files", "fastq files", default=input_files,
file_format="fastq", required=True)
self.add_output_file_list("sais", "sai files",
pattern="{basename_woext}.sai", items=self.input_files)
class MyComponent (Component):
def define_parameters(self, param1, param2, ...):
# define the parameters
def process(self):
bwaaln = ShellFunction(self.get_exec_path("bwa") + " aln " + self.reference_genome + " $1 > $2")
Map(bwaaln, inputs=self.input_files, outputs=self.sais)</code></pre>
# define the command line(s) structure</code></pre>
</div>
</section>
<section id="define_parameters" class="group">
<h1 class="page-header">Defining parameters</h1>
<h1 class="page-header">Define parameters</h1>
<p>
The <code>define_parameters()</code> function is used to add component parameters, inputs and outputs. Several methods are available to add different
......
......@@ -127,7 +127,7 @@
<p>In jflow, a workflow is a class defined in the <code>__init__.py</code> file. In order to add a new workflow, the developper has to: </p>
<ul>
<li>implement a class inheriting from the <code>Workflow</code> class,</li>
<li>implement a class inheriting from the <code>jflow.workflow.Workflow</code> class,</li>
<li>overload the <code>get_description()</code> method to provide to the final user a description of the workflow,</li>
<li>overload the <code>define_parameters()</code> method to add the workflow inputs and parameters,</li>
<li>overload the <code>process()</code> method by adding components and setting their arguments,</li>
......
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