core-analysis.html 62.3 KB
Newer Older
Penom Nom's avatar
Penom Nom committed
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
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>NG6</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="css/bootstrap-theme.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/theme.css" rel="stylesheet">

	<!--  Highlight code -->
	<link href="css/tomorrow-night-eighties.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body role="document">
  
    <!-- Fixed navbar -->
    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="./index.html">NG6</a>
        </div>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li><a href="./index.html">About</a></li>
            <li><a href="./install.html">Install</a></li>
            <li><a href="./quickstart.html">Quick start</a></li>
            <li class="dropdown active">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation<span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="./core-workflow.html">Add a workflow</a></li>
Jerome Mariette's avatar
Jerome Mariette committed
50
                <li class="active"><a href="./core-analysis.html">Add an analysis</a></li>
Penom Nom's avatar
Penom Nom committed
51 52 53 54 55
                <li><a href="./type.html">Add a data type</a></li>
                <li><a href="./format.html">Add a file format</a></li>
                <li><a href="./advanced-configuration.html">Advanced configuration</a></li>
              </ul>
            </li>
56 57
			<li><a target="_blank" href="https://forgemia.inra.fr/genotoul-bioinfo/ng6/">Sources</a></li>
			<li><a href="mailto:support.bioinfo.genotoul@inra.fr">Contact</a></li>
Penom Nom's avatar
Penom Nom committed
58 59 60 61 62 63 64 65 66 67 68 69 70
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </div>

    <div class="container">
      <div class="row">
        <!--Nav Bar -->
	    <nav class="col-xs-3 bs-docs-sidebar">
	        <ul id="sidebar" class="nav nav-stacked fixed">
	        	<li><a href="#what" class="active">What is an Analysis</a></li>
		        <li><a href="#analysis-architecture" >Where to add a new Analysis</a></li>
		        <li><a href="#analysis" >The Analysis class</a></li>
Jerome Mariette's avatar
Jerome Mariette committed
71
		       	<li><a href="#define_parameters">Analysis.define_parameters()</a>
Penom Nom's avatar
Penom Nom committed
72 73 74 75 76 77
			       	<ul class="nav nav-stacked">
			       		<li><a href="#parameters">Parameters</a></li>
			       		<li><a href="#input_parameters">Inputs</a></li>
			       		<li><a href="#output_parameters">Outputs</a></li>
	                </ul>
                </li>
Jerome Mariette's avatar
Jerome Mariette committed
78 79 80
                <li><a href="#define_analysis">Analysis.define_analysis()</a></li>
                <li><a href="#get_version_fn">Analysis.get_version()</a></li>
				<li><a href="#process">Analysis.process()</a>
Penom Nom's avatar
Penom Nom committed
81 82 83 84 85
				  	<ul class="nav nav-stacked">
				        <li><a href="#functions">Functions</a></li>
						<li><a href="#abstractions">Abstractions</a></li>
					</ul>
				</li>
Jerome Mariette's avatar
Jerome Mariette committed
86
				<li><a href="#post_process">Analysis.post_process()</a></li>
Jerome Mariette's avatar
Jerome Mariette committed
87
				<li><a href="#analysis_template">The analysis display</a>
Penom Nom's avatar
Penom Nom committed
88 89 90
					
					<ul class="nav nav-stacked">
				        <li><a href="#template_file">Template file</a></li>
Jerome Mariette's avatar
Jerome Mariette committed
91
						<li><a href="#javascript_file">Javascript file</a></li>
Penom Nom's avatar
Penom Nom committed
92 93 94
					</ul>
				
				</li>
Penom Nom's avatar
Penom Nom committed
95 96 97 98 99 100 101 102
	        </ul>
   	    </nav>
   	 
        <div class="col-xs-12 col-sm-9">
        
        	<section id="what" class="group">
		    	<h1 class="page-header">What is an Analysis</h1>
		    	<p>
Gerald Salin's avatar
#37  
Gerald Salin committed
103
		    		An analysis presents the results of the execution of one or multiple software, which can be external scripts or python code, using NGS data.
Penom Nom's avatar
Penom Nom committed
104 105 106
		    		It is represented by two main objects :
		    	</p>
		    	<ul>
Jerome Mariette's avatar
Jerome Mariette committed
107
		    		<li><b>An analysis component</b> represented by a Python class inheriting from <code>ng6.analysis.Analysis</code>, lists all the inputs, outputs and parameters
Penom Nom's avatar
Penom Nom committed
108
		    		required to run the command line(s) and defines its structure. </li>
Jerome Mariette's avatar
Jerome Mariette committed
109
		    		<li><b>A template file</b> written in <a target="_blank" href="http://www.smarty.net/">Smarty</a> and which will presents the results of the analysis to the user.</li>
Penom Nom's avatar
Penom Nom committed
110 111
		    	</ul>
		    	
Jerome Mariette's avatar
Jerome Mariette committed
112 113 114
			  <div class="alert alert-info" role="alert">
			  	<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
		    		In a NG6Workflow, the developper can also add instances of <code>jflow.component.Component</code> object. It is recommended to use <code>Component</code> 
Jerome Mariette's avatar
Jerome Mariette committed
115
		    		when the result of the execution has not to be presented to the final user (for example indexing a reference file) and <code>Analysis</code> when 
Gerald Salin's avatar
#37  
Gerald Salin committed
116
		    		results must be presented to the user, like a fastqc report. The differences are the necessity to develop <span style="text-decoration: underline;">define_analysis()</span>, <span style="text-decoration: underline;">post_process()</span> functions and a <span style="text-decoration: underline;">template HTML</span> file for <code>Analysis</code> component.
Jerome Mariette's avatar
Jerome Mariette committed
117
			  </div>
Penom Nom's avatar
Penom Nom committed
118 119 120 121 122 123
		    	
	    	</section>
        	
        	<section id="analysis-architecture" class="group">
			    <h1 class="page-header">Where to add a new Analysis</h1>
		    	<p>
Gerald Salin's avatar
#37  
Gerald Salin committed
124
		    		The new analysis must be added in a Python package. Two different locations are possible in order to be imported by ng6 : 
Penom Nom's avatar
Penom Nom committed
125 126 127 128 129 130
		    	</p>
		    	<ul>
		    		<li><code>workflows.components</code>: the analysis will be visible by all workflows,</li>
		    		<li><code>workflows.myWorkflow.components</code>: the analysis will only be available for<code>myWorkflow</code>.</li>
		    	</ul>
				<p>
Gerald Salin's avatar
#37  
Gerald Salin committed
131
					The template file presenting the results of the analysis must be added in ui/nG6/pi1/analyzes/. The template file must
Jerome Mariette's avatar
Jerome Mariette committed
132
					have the same name as the Python class of the Analysis.
Gerald Salin's avatar
#37  
Gerald Salin committed
133
					The following code represents the structure of the source, and the location where to add specific files.
Penom Nom's avatar
Penom Nom committed
134 135
				</p>

Penom Nom's avatar
Penom Nom committed
136
		    		<pre class="pre-hl "><code class="ini">nG6/
Penom Nom's avatar
Penom Nom committed
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
├── bin/
├── docs/
├── src/
├── ui/
│   └── nG6/
│       └── pi1/
│           └── analyzes/
│               ├── MyAnalysis.tpl   [ the analysis template file ]
│               └── MyAnalysis.js    [ the analysis specific javascript file ]
├── workflows/
│   ├── myWorkflow/
│   │   ├── components/              [ workflow specific analysis and components ]
│   │   │   └── MyAnalysis.py        [ the analysis code ]
│   │   └── __init__.py
│   ├── components/                  [ general analyzes and components ]
│   │   ├── __init__.py
│   │   └── MyAnalysis.py            [ the analysis code ]
│   ├── extparsers/
│   ├── __init__.py
│   ├── formats.py
│   └── types.py
├── applications.properties
└── README</code></pre>

		    </section>   
     
        	<section id="analysis" class="group">
		    	<h1 class="page-header">The Analysis class</h1>
		    	<p>
		    		An analysis is class defined in the <code>MyAnalysis.py</code> file. In order to add a new analysis, the developper has to: 
	    		</p>
	    		
		    	<ul>
Jerome Mariette's avatar
Jerome Mariette committed
170
		    		<li>implement a class inheriting from the <code>ng6.analysis.Analysis</code> class,</li>
Penom Nom's avatar
Penom Nom committed
171 172
 					<li>overload the <code>define_parameters()</code> method to add the inputs, outputs and parameters,</li>
 					<li>overload the <code>define_analysis()</code> method to describe the analysis (name, software, options ...).</li>
Penom Nom's avatar
Penom Nom committed
173
 					<li>overload the <code>get_version()</code> method to get the version of the analysis.</li>
Penom Nom's avatar
Penom Nom committed
174 175 176 177 178
 					<li>overload the <code>process()</code> method to define the command line(s) structure.</li>
 					<li>overload the <code>post_process()</code> method to define post processing traitment, update the database with analysis data.</li>
 				</ul>
				<p>The class skeleton is given by</p>
			    <div>
Penom Nom's avatar
Penom Nom committed
179
			    	<pre class="pre-hl "><code class="python">from ng6.analysis import Analysis
Penom Nom's avatar
Penom Nom committed
180

Penom Nom's avatar
Penom Nom committed
181
class MyComponent (Analysis):
Penom Nom's avatar
Penom Nom committed
182 183 184 185 186 187 188

    def define_parameters(self, param1, param2, ...):
        # define the parameters

    def process(self):
        # define the command line(s) structure
    
Penom Nom's avatar
Penom Nom committed
189 190 191
    def get_version(self):
        # return a string with the version of the analysis
        
Penom Nom's avatar
Penom Nom committed
192 193 194 195 196 197 198 199
    def define_analysis(self):
        # define the analysis
        self.name = "-"
        self.description = "-"
        self.software = "-"
        self.options = "-"
    
    def post_process(self):
Penom Nom's avatar
Penom Nom committed
200
        # database operations</code></pre>
Penom Nom's avatar
Penom Nom committed
201 202 203 204
			    </div>
			</section>

			<section id="define_parameters" class="group">
Jerome Mariette's avatar
Jerome Mariette committed
205
		    	<h1 class="page-header">Analysis.define_parameters()</h1>
Penom Nom's avatar
Penom Nom committed
206 207 208
				
				<p>
					The <code>define_parameters()</code> method is used to add component parameters, inputs and outputs. To do so, several methods are available. 
209
					Once defined, the new parameters are available as object attributs, thus they are accessible through <code>self.parameter_name</code>.
Penom Nom's avatar
Penom Nom committed
210 211 212 213 214
				</p>

				<p>
					Several types of parameters can be added, all described in the following sections. All have two required positional 
					arguments: <code>name</code> and <code>help</code>. The other arguments are optional and can be given to the method by using their 
215
					keywords. Arguments <code>cmd_format</code> and <code>argpos</code> may simplified the <code>process()</code> function (see <a href="#process">Analysis.process()</a> ).
Penom Nom's avatar
Penom Nom committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
				</p>

	       		<div id="parameters" class="subgroup">
					<h2>Parameters</h2>
					<p>Parameters can be added to handle a single element or a list of elements. Thus, the <code>add_parameter()</code> method can be used to force 
					the final user to provide one and only one value, where the <code>add_parameter_list()</code> method allows the final user to give as many values he 
					wants.</p>
						<h3>add_parameter()</h3>
						<h4>Example</h4>
						<p>
							In the following example, a parameter named <code>sequencer</code> 
							is added to the workflow. It has a list of choices and the default value is "HiSeq2000".
						</p>
				    	<div>
				    		<pre class="pre-hl "><code class="python">self.add_parameter("sequencer",
Jerome Mariette's avatar
Jerome Mariette committed
231 232 233
                   "The sequencer type.", 
                   choices = ["HiSeq2000", "ILLUMINA","SLX","SOLEXA","454","UNKNOWN"], 
                   default="HiSeq2000")</code></pre>
Penom Nom's avatar
Penom Nom committed
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
				    	</div>
			    	
			    				<h4>Options</h4>					
			    	
			    					<p>There are two positional arguments: <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 style="white-space:nowrap">
													<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>-</td>
													<td>false</td>
													<td>None</td>
													<td>The default parameter value. It's type depends on the parameter type.</td>
												</tr>
												
												<tr>
													<td>type</td>
													<td>string</td>
													<td>false</td>
													<td>"str"</td>
													<td>The parameter type. The value provided by the final user will be casted and checked against this type. 
													All built-in Python types are available "int", "str", "float", "bool", "date", ... To create customized types, 
Penom Nom's avatar
Penom Nom committed
284
													refere to the <a href="./type.html">Add a data type</a> documentation.</td>
Penom Nom's avatar
Penom Nom committed
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
												</tr>
												
												<tr>
													<td>choices</td>
													<td>list</td>
													<td>false</td>
													<td>[]</td>
													<td>A list of the allowed values.</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>
												
												<tr>
													<td>cmd_format</td>
													<td>string</td>
													<td>false</td>
													<td>""</td>
													<td>The command format is the parameter skeleton required to build the final command line.</td>
												</tr>
												
												<tr>
													<td>argpos</td>
													<td>integer</td>
													<td>false</td>
													<td>-1</td>
													<td>The parameter position in the command line.</td>
												</tr>
				
											</tbody>
										</table>
									</div>
					    <h3>add_parameter_list()</h3>
					
						<p>The <code>add_parameter_list()</code> method takes the same arguments as <code>add_parameter()</code>. However, adding this parameter,
						the final user will be allowed to enter multiple values for this parameter and the object attribut <code>self.parameter_name</code> will be
						settled as a Python list.</p>
				</div>
	       		
	       		<div id="input_parameters" class="subgroup">
					<h2>Inputs</h2>
					
Penom Nom's avatar
Penom Nom committed
356
					<p>Just like parameters, inputs can be added to handle a single file or a list of files. Thus, the <code>add__input_file()</code> method can be used to force 
Penom Nom's avatar
Penom Nom committed
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
					the component to take one and only one file, where the <code>add__input_file_list()</code> method allows the component to take as many files as possible.</p>
					
						<h3>add_input_file()</h3>
							<h4>Example</h4>
	       				<p>
							In the following example, an input named <code>reads</code> 
							is added to the workflow. The provided file is required and should be in fastq format. No file size limitation is specified. 
						</p>
				    	<div>
				    		<pre class="pre-hl "><code class="python">self.add_input_file_list("reads", 
                         "Which read files should be used", 
                         file_format="fastq", 
                         required=True)</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 style="white-space:nowrap">
												<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>file_format</td>
												<td>string</td>
												<td>false</td>
												<td>"any"</td>
417
												<td>The file format is checked before running the workflow. Available format are "any", "bam", "fasta", "fastq", and "sff". To create customized format, 
Penom Nom's avatar
Penom Nom committed
418
													refere to the <a href="./format.html">Add a file format</a> documentation.</td>
Penom Nom's avatar
Penom Nom committed
419 420 421 422 423 424 425 426 427
											</tr>
											
											<tr>
												<td>type</td>
												<td>string</td>
												<td>false</td>
												<td>"inputfile"</td>
												<td>The type can be "inputfile", "localfile", "urlfile" or "browsefile". An "inputfile" allows the 
												final user to provide a "localfile" or an "urlfile" or a "browsefile". A "localfile" restricts the final
Penom Nom's avatar
Penom Nom committed
428
												user to provide a path to a file visible by ng6. An "urlfile" only permits the final user to give an 
Penom Nom's avatar
Penom Nom committed
429 430
												URL as input, where a "browsefile" force the final user to upload a file from its own computer. This last
												option is only available from the GUI and is considered as a "localfile" from the command line. All the 
Penom Nom's avatar
Penom Nom committed
431
												uploading process is handled by ng6.</td>
Penom Nom's avatar
Penom Nom committed
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
											</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>
Penom Nom's avatar
Penom Nom committed
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
											<tr>
												<td>cmd_format</td>
												<td>string</td>
												<td>false</td>
												<td>""</td>
												<td>The command format is the parameter skeleton required to build the final command line.</td>
											</tr>
											
											<tr>
												<td>argpos</td>
												<td>integer</td>
												<td>false</td>
												<td>-1</td>
												<td>The parameter position in the command line.</td>
											</tr>
Penom Nom's avatar
Penom Nom committed
480 481 482 483 484 485 486 487 488 489
											
										</tbody>
									</table>
								</div>
					    
					    
					    <h3>add_input_file_list()</h3>
					    
						<p>This method takes the same arguments as <code>add_input_file()</code>. However, adding this parameter,
						the component can take a list file files and the object attribut <code>self.parameter_name</code> will be
Penom Nom's avatar
Penom Nom committed
490
						settled as a Python list.</p>
Penom Nom's avatar
Penom Nom committed
491 492 493 494 495
				</div>       		
			       		
				<div id="output_parameters" class="subgroup">
					<h2>Outputs</h2>
					
496 497 498 499 500
					<p>Just like inputs, outputs can be added to handle a single file or a list of files. Thus, the <code>add_output_file()</code> method can be used to force 
					the component to produce one and only one file, where the <code>add_output_file_list()</code> method allows the component to produce as many files as possible. 
					There are also two specific functions <code>add_output_file_endswith()</code> and <code>add_output_file_pattern()</code>.
					<br /><br /> 
					</p>
Penom Nom's avatar
Penom Nom committed
501 502 503 504 505 506 507 508 509 510

						<h3>add_output_file()</h3>
							<h4>Example</h4>
	       				<p>
							In the following example, an output named <code>databank</code> 
							is defined. The process have to produce the file, otherwise the workflow will failed. The file written on the disk will be named
							with the same name as the one stored in the variable <code>input_fasta</code>.
						</p>
				    	<div>
				    		<pre class="pre-hl "><code class="python">self.add_output_file("databank", 
Jerome Mariette's avatar
Jerome Mariette committed
511 512
                     "The indexed databank", 
                     filename=os.path.basename(input_fasta))</code></pre>
Penom Nom's avatar
Penom Nom committed
513 514 515
				    	</div>
							<h4>Options</h4>
								
516
								<p>The two positional arguments <code>name</code> and <code>help</code> are always present.</p>
Penom Nom's avatar
Penom Nom committed
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
                      
								<div class="table-responsive">
									<table class="table table-bordered table-striped">
										<thead>
											<tr style="white-space:nowrap">
												<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>filename</td>
												<td>string</td>
												<td>false</td>
												<td>None</td>
												<td>The expected name of the output file.</td>
											</tr>
										
											<tr>
												<td>file_format</td>
												<td>string</td>
												<td>false</td>
												<td>"any"</td>
560
												<td>The file format is checked before running the workflow. Available format are "any", "bam", "fasta", "fastq", and "sff". To create customized format, 
Penom Nom's avatar
Penom Nom committed
561
													refere to the <a href="./format.html">Add a file format</a> documentation.</td>
Penom Nom's avatar
Penom Nom committed
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
											</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>
Penom Nom's avatar
Penom Nom committed
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
											<tr>
												<td>cmd_format</td>
												<td>string</td>
												<td>false</td>
												<td>""</td>
												<td>The command format is the parameter skeleton required to build the final command line.</td>
											</tr>
											
											<tr>
												<td>argpos</td>
												<td>integer</td>
												<td>false</td>
												<td>-1</td>
												<td>The parameter position in the command line.</td>
											</tr>
Penom Nom's avatar
Penom Nom committed
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
											
										</tbody>
									</table>
								</div>
					    
					<h3>add_output_file_list()</h3>
							<h4>Example</h4>
	       				<p>
							In the following example, an output named <code>sam_files</code> 
							is defined. The files written on the disk will all have the pattern <code>{basename_woext}.sam</code> defined by the 
							<code>self.reads</code> variable. The resulting list will gathers files with the same basename as <code>self.reads</code> but
							with an extension substituted by ".sam". 
						</p>
				    	<div>
				    		<pre class="pre-hl "><code class="python">self.add_output_file_list("sam_files", 
Jerome Mariette's avatar
Jerome Mariette committed
609 610 611
                          "The BWA output files", 
                          pattern='{basename_woext}.sam', 
                          items=self.reads)</code></pre>
Penom Nom's avatar
Penom Nom committed
612 613 614 615
				    	</div>
					
							<h4>Options</h4>
								
616
								<p>The two positional arguments <code>name</code> and <code>help</code> are always present.</p>
Penom Nom's avatar
Penom Nom committed
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
							
							<div class="table-responsive">
								<table class="table table-bordered table-striped">
									<thead>
										<tr style="white-space:nowrap">
											<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>items</td>
											<td>list</td>
											<td>false</td>
											<td>None</td>
											<td>A list of element through which <code>add_output_file_list()</code> should iterate to produce the output
											list.</td>
										</tr>
										
										<tr>
											<td>pattern</td>
											<td>string</td>
											<td>false</td>
											<td>'{basename_woext}.out'</td>
											<td>The pattern is used to produce the output list. <code>add_output_file_list()</code> maps the pattern on each <code>items</code>
											to produce the final value.
											The pattern can accepts these predefined values:
												<ul>
													<li><code>{fullpath}</code>, <code>{FULL}</code> for full input file path,</li>
	       											<li><code>{basename}</code>, <code>{BASE}</code> for base input file name,</li>
	       											<li><code>{fullpath_woext}</code>, <code>{FULLWE}</code> for full input file path without extension,</li>
668
	       											<li><code>{basename_woext}</code>, <code>{BASEWE}</code> for base input file name without extension. note that ".gz" is not considered as an extension.</li>
Penom Nom's avatar
Penom Nom committed
669 670 671 672
												</ul> 
											</td>
										</tr>
										
Penom Nom's avatar
Penom Nom committed
673 674 675 676 677
										<tr>
											<td>file_format</td>
											<td>string</td>
											<td>false</td>
											<td>"any"</td>
678
											<td>The file format is checked before running the workflow. Available format are "any", "bam", "fasta", "fastq", and "sff". To create customized format, 
Penom Nom's avatar
Penom Nom committed
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711
												refere to the <a href="./format.html">Add a file format</a> documentation.</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>
										<tr>
											<td>cmd_format</td>
											<td>string</td>
											<td>false</td>
											<td>""</td>
											<td>The command format is the parameter skeleton required to build the final command line.</td>
										</tr>
										
										<tr>
											<td>argpos</td>
											<td>integer</td>
											<td>false</td>
											<td>-1</td>
											<td>The parameter position in the command line.</td>
										</tr>
Penom Nom's avatar
Penom Nom committed
712 713 714 715 716 717 718 719
											
									</tbody>
								</table>
							</div>
						

						<h3>add_output_file_endswith()</h3>
						
Jerome Mariette's avatar
Jerome Mariette committed
720 721 722 723
						<div class="alert alert-info" role="alert">
							<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
							This method should only be used with components producing unknown number of outputs (like some demultiplexing tools).
						</div>
Penom Nom's avatar
Penom Nom committed
724 725 726 727 728 729 730 731 732 733
							<h4>Example</h4>
	       				<p>
							In the following example, an output named <code>sam_files</code> 
							is defined. The list files will be made of all the files written on the disk with an extension equal to <code>.sam</code>. This is performed
							at the end of the execution and can be useful when the component produces an unknown number of ouptut files.
						</p>
						
						
				    	<div>
				    		<pre class="pre-hl "><code class="python">self.add_output_file_endswith("sam_files", 
Jerome Mariette's avatar
Jerome Mariette committed
734 735
                              "The BWA output files", 
                              pattern='.sam')</code></pre>
Penom Nom's avatar
Penom Nom committed
736 737 738 739
				    	</div>
							<h4>Options</h4>
						
							<p>
Penom Nom's avatar
Penom Nom committed
740 741
								This method is very different from <code>add_output_file_list()</code> because it should only be used when 
								the number of output files returned by the component is unknown. Three options are required:
742
								<code>name</code>, <code>help</code> and <code>pattern.</code></p>
Penom Nom's avatar
Penom Nom committed
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
							
							<div class="table-responsive">
								<table class="table table-bordered table-striped">
									<thead>
										<tr style="white-space:nowrap">
											<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>pattern</td>
											<td>string</td>
											<td>true</td>
											<td>None</td>
											<td>The extension of the files to return.</td>
										</tr>
										
										<tr>
											<td>behaviour</td>
											<td>string</td>
											<td>false</td>
											<td>"include"</td>
											<td>How to process selected files. Other values than "include" mean that all files not ending with the pattern will be selected.</td>
										</tr>
										
											<tr>
												<td>file_format</td>
												<td>string</td>
												<td>false</td>
												<td>"any"</td>
795
												<td>The file format is checked before running the workflow. Available format are "any", "bam", "fasta", "fastq", and "sff". To create customized format, 
Penom Nom's avatar
Penom Nom committed
796
													refere to the <a href="./format.html">Add a file format</a> documentation.</td>
Penom Nom's avatar
Penom Nom committed
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
											</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>
												<tr>
													<td>cmd_format</td>
													<td>string</td>
													<td>false</td>
													<td>""</td>
													<td>The command format is the parameter skeleton required to build the final command line.</td>
												</tr>
												
												<tr>
													<td>argpos</td>
													<td>integer</td>
													<td>false</td>
													<td>-1</td>
													<td>The parameter position in the command line.</td>
												</tr>
										
									</tbody>
								</table>
							</div>



						<h3>add_output_file_pattern()</h3>
						
Jerome Mariette's avatar
Jerome Mariette committed
838 839 840 841
						<div class="alert alert-info" role="alert">
							<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
							This method should only be used with components producing unknown number of outputs (like some demultiplexing tools).
						</div>
Penom Nom's avatar
Penom Nom committed
842 843 844 845 846 847 848 849 850 851
							<h4>Example</h4>
	       				<p>
							In the following example, an output named <code>sam_files</code> 
							is defined. The list files will be made of all the files written on the disk with the pattern <code>*_R1.sam</code>. This is performed
							at the end of the execution and can be useful when the component produces an unknown number of ouptut files.
						</p>
						
						
				    	<div>
				    		<pre class="pre-hl "><code class="python">self.add_output_file_pattern("sam_files", 
Jerome Mariette's avatar
Jerome Mariette committed
852 853
                             "The BWA output files", 
                             pattern='*_R1.sam')</code></pre>
Penom Nom's avatar
Penom Nom committed
854 855 856 857
				    	</div>
							<h4>Options</h4>
						
							<p>
Penom Nom's avatar
Penom Nom committed
858
								This method is slightly different from <code>add_output_file_endswith()</code> because it
Penom Nom's avatar
Penom Nom committed
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
								returns all the file corresponding to the given pattern instead of only the extension. All the options are the same,
								only <code>pattern</code> differs.
							</p>
							
							<div class="table-responsive">
								<table class="table table-bordered table-striped">
									<thead>
										<tr style="white-space:nowrap">
											<th>Name</th>
											<th>Type</th>
											<th>Required</th>
											<th>Default value</th>
											<th>Description</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td>pattern</td>
											<td>string</td>
											<td>true</td>
											<td>None</td>
											<td>The regepx string used to retrieve the ouput files. </td>
										</tr>
									</tbody>
								</table>
							</div>
				</div>
				
			</section>
				    	

			<section id="define_analysis" class="group">
Jerome Mariette's avatar
Jerome Mariette committed
891
				<h1 class="page-header">Analysis.define_analysis()</h1>
Penom Nom's avatar
Penom Nom committed
892
					<p>
Jerome Mariette's avatar
Jerome Mariette committed
893
						This method is in charge of describing the analysis: its name, its description, its options and so on ...
Penom Nom's avatar
Penom Nom committed
894 895 896
					</p>
					
					<h3>Example</h3>
Jerome Mariette's avatar
Jerome Mariette committed
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
					<p>
						Here is the example of the descritpion of a fastqc analysis, it defines the name, description, software and options used 
					</p>
					<pre class="pre-hl "><code class="python">def define_analysis(self):
    self.name = "ReadsStats"
    self.description = "Statistics on reads and their qualities."
    self.software = "fastqc"
    self.options = " --nogroup --casava"</code></pre>
   				
   					<h3>Options</h3>
					<p>
						The <code>define_analysis()</code> method does not take any option.
						This table presents the attributes that can be created in <code>define_analysis()</code>. All attributes must be strings.
					</p>
					<div class="table-responsive">
						<table class="table table-bordered table-striped">
							<thead>
								<tr style="white-space:nowrap">
									<th>Name</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>self.name</td>
									<td>Give a name to your analysis.</td>
								</tr>
								
								<tr>
									<td>self.description</td>
									<td>Give a description to your analysis.</td>
								</tr>
								
								<tr>
									<td>self.software</td>
									<td>Which software was used for this analysis.</td>
								</tr>
								<tr>
									<td>self.options</td>
									<td>Which software options were used for this analysis.</td>
								</tr>
							</tbody>
						</table>

Penom Nom's avatar
Penom Nom committed
941
				</div>
Jerome Mariette's avatar
Jerome Mariette committed
942 943 944
		
			<section id="get_version_fn" class="group">
				<h1 class="page-header">Analysis.get_version()</h1>
Penom Nom's avatar
Penom Nom committed
945 946 947 948 949 950 951 952 953 954 955 956 957
					
					<p>The get version must return a string representing the version of this analysis.</p>
				
					<h3>Example</h3>
					
						<p>This example presents the get version of the fastqc analysis</p>
					
						<pre class="pre-hl "><code class="python">def get_version(self):
    cmd = [self.get_exec_path("fastqc"), "--version"]
    p = Popen(cmd, stdout=PIPE, stderr=PIPE)
    stdout, stderr = p.communicate()
    return stdout.split()[1]</code></pre>
					
Jerome Mariette's avatar
Jerome Mariette committed
958

Penom Nom's avatar
Penom Nom committed
959 960 961
			</section>
   	
	  		<section id="process" class="group">
Jerome Mariette's avatar
Jerome Mariette committed
962
		    	<h1 class="page-header">Analysis.process()</h1>
Penom Nom's avatar
Penom Nom committed
963 964 965
		    	<p>The <code>process()</code> method is in charge of the specification of the executables used to process the data (a command 
		    	line or a Python function) and of the definition of the pattern of execution that determine how the functions are applied on the
		    	data, what is named hereunder an abstraction. To build the process, ng6 provides two main functions named 
Penom Nom's avatar
Penom Nom committed
966 967 968
		    	<code>ShellFunction</code> and <code>PythonFunction</code> and two main abstractions: <code>Map</code> and 
		    	<code>MultiMap</code>.</p>
		    	
Jerome Mariette's avatar
Jerome Mariette committed
969 970
			  <div class="alert alert-info" role="alert">
			  	<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
Penom Nom's avatar
Penom Nom committed
971
		    		Overloading <code>process()</code> can be omitted. NG6 offers, for analyzes and components with easy command lines, 
Penom Nom's avatar
Penom Nom committed
972 973
		    		an automatic built of the <code>process()</code> method. 
				   In this case, options <code>argpos</code> and <code>cmd_format</code> must be provided by the developper for each parameter. 
Gerald Salin's avatar
#37  
Gerald Salin committed
974
				   Also, two other methods must be overloaded. <code>get_command()</code>, which must returns 
Jerome Mariette's avatar
Jerome Mariette committed
975 976
				   the execution path and <code>get_abstraction()</code> which returns the abstraction name to use.
				</div>
Penom Nom's avatar
Penom Nom committed
977 978 979 980 981 982 983 984
				
				<div id="functions" class="subgroup">
				
		    		<h2>Functions</h2>
					<p>The two provided functions allows the developper to specify the executables used to process the data.</p>
					
					<h3>ShellFunction</h3>
					<p>The <code>ShellFunction</code> can be called when the workflow requires to run an external command line. This function
Penom Nom's avatar
Penom Nom committed
985
					allows to define the command line structure so ng6 can build and run it automaticly on the final user inputs.</p>
Penom Nom's avatar
Penom Nom committed
986 987 988 989

					<h4>Example</h4>
					Considering the following <code>blastall</code> command line:
					<pre class="pre-hl "><code class="ini">blastall -p [program_name] -i [query_file] -d [database] -o [file_out]</code></pre>
Penom Nom's avatar
Penom Nom committed
990
					<p>When using a ng6 function, the command format has to be given in order to set the inputs, outputs and arguments order.
Penom Nom's avatar
Penom Nom committed
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
					Let's fix it at <code>cmd_format="{EXE} {IN} {OUT}"</code>, which is a classic value for this option. Doing so jflow will consider the following inputs and outputs order: 
					<code>query_file</code>, <code>database</code> and then <code>file_out</code>. resulting to the following command structure:</p>
					<pre class="pre-hl "><code class="ini">blastall -p [program_name] -i [$1] -d [$2] -o [$3]</code></pre>
					
		    		<p>The <code>ShellFunction</code> can then be applied as following:</p>
		    		<pre class="pre-hl "><code class="python">blast = ShellFunction("blastall -p blastn -i $1 -d $2 -o $3", cmd_format="{EXE} {IN} {OUT}")</code></pre>
		    		<p>And can be executed by calling the new created function</p>
					<pre class="pre-hl "><code class="python">blast( inputs=[query_file, database], outputs=[file_out] )</code></pre>

					<h4>Options</h4>
					
					<div class="table-responsive">
						<table class="table table-bordered table-striped">
							<thead>
								<tr style="white-space:nowrap">
									<th>Name</th>
									<th>Type</th>
									<th>Required</th>
									<th>Default value</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>source</td>
									<td>string</td>
									<td>true</td>
									<td>None</td>
									<td>The command line structure defining inputs, outputs and arguments positions.</td>
								</tr>
								<tr>
									<td>shell</td>
									<td>string</td>
									<td>false</td>
									<td>"sh"</td>
									<td>Which shell should be used to interpret the command line, the value can be "sh" | "ksh" | "bash" | "csh" | "tcsh".</td>
								</tr>
								<tr>
									<td>cmd_format</td>
									<td>string</td>
									<td>false</td>
									<td>'{EXE} {ARG} {IN} > {OUT}'</td>
									<td>The <code>cmd_format</code> supports the following fields:
										<ul>
											<li><code>{executable}</code>, <code>{EXE}</code> for the path to the executable,</li>
											<li><code>{inputs}</code>, <code>{IN}</code> for the inputs files,</li>
											<li><code>{outputs}</code>, <code>{OUT}</code> for the output files,</li>
											<li><code>{arguments}</code>, <code>{ARG}</code> for the arguments.</li>
										</ul>
									</td>
								</tr>
							</tbody>
						</table>
					</div>

		    		<h3>PythonFunction</h3>
		    		
1048
					<p>The <code>PythonFunction</code> can be called when the workflow requires to run an internal Python code defined in a Python function. This function
Penom Nom's avatar
Penom Nom committed
1049
					allows to define the way the function should be called so ng6 can call and run it automaticly on the final user inputs.</p>
Penom Nom's avatar
Penom Nom committed
1050 1051 1052 1053 1054 1055

					<h4>Example</h4>
					<p>Considering a function named <code>fastq2fasta</code> defined by:</p>
					<pre class="pre-hl "><code class="python">def fastq2fasta(fastq_file, fasta_file):
    # python code goes here</code></pre>
					<p>When using a jflow function, the command format has to be given in order to set the inputs, outputs and arguments order.
Penom Nom's avatar
Penom Nom committed
1056
					Let's fix it at <code>cmd_format="{EXE} {IN} {OUT}"</code>, which is a classic value for this option. Doing so ng6 will consider the following variables 
Penom Nom's avatar
Penom Nom committed
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
					order to pass to the function: <code>fastq_file</code> and then <code>fasta_file</code>. The <code>PythonFunction</code> can be used as following:</p>
		    		<pre class="pre-hl "><code class="python">fastq2a = PythonFunction(fastq2fasta, cmd_format="{EXE} {IN} {OUT}")</code></pre>
		    		<p>And can be executed by calling the new created function</p>
					<pre class="pre-hl "><code class="python">fasta2q( inputs=[fastq_file], outputs=[fasta_file] )</code></pre>

					<h4>Options</h4>
					
					<div class="table-responsive">
						<table class="table table-bordered table-striped">
							<thead>
								<tr style="white-space:nowrap">
									<th>Name</th>
									<th>Type</th>
									<th>Required</th>
									<th>Default value</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>function</td>
									<td>function</td>
									<td>true</td>
									<td>None</td>
									<td>The Python function use to process the data.</td>
								</tr>
								<tr>
									<td>add_path</td>
									<td>string</td>
									<td>false</td>
									<td>None</td>
									<td>A path to a Python library required to run the function. This is useful in case the library is not
									in the path and not visible by jflow.</td>
								</tr>
								<tr>
									<td>cmd_format</td>
									<td>string</td>
									<td>false</td>
									<td>'{EXE} {ARG} {IN} > {OUT}'</td>
									<td>The <code>cmd_format</code> supports the following fields:
										<ul>
											<li><code>{executable}</code>, <code>{EXE}</code> for the path to the executable,</li>
											<li><code>{inputs}</code>, <code>{IN}</code> for the inputs files,</li>
											<li><code>{outputs}</code>, <code>{OUT}</code> for the output files,</li>
											<li><code>{arguments}</code>, <code>{ARG}</code> for the arguments.</li>
										</ul>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>		
				
				<div id="abstractions" class="subgroup">
		    		<h2>Abstractions</h2>
		    		<p>The abstraction allows to define the pattern of execution that determine how the functions (<code>ShellFunction</code>
		    		or <code>PythonFunction</code>) are applied on the data.</p>
		    	
		    	<h3>__call__</h3>
		    	<p>This first abstraction is executed when calling the <code>ShellFuntion</code> or the <code>PythonFunction</code>
		    	as a basic Python function.</p>
				<h4>Example</h4>
		    	<pre class="pre-hl "><code class="python">fasta_trim = ShellFunction( "fastaTrim.pl --length 50 $1 > $2", cmd_format="{EXE} {IN} {OUT}" )
fasta_trim( inputs="splA.fasta", outputs="splA_trim.fasta" )</code></pre>
     			<p>This abstraction will lead to the execution of the following command line:</p>
     			<pre class="pre-hl "><code class="ini">fastaTrim.pl --length 50 splA.fasta > splA_trim.fasta</code></pre>		
		    	
			    <h4>Options</h4>

					<div class="table-responsive">
						<table class="table table-bordered table-striped">
							<thead>
								<tr style="white-space:nowrap">
									<th>Name</th>
									<th>Type</th>
									<th>Required</th>
									<th>Default value</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>inputs</td>
									<td>list | string</td>
									<td>true</td>
									<td>None</td>
									<td>The input files list required to run the function.</td>
								</tr>
								<tr>
									<td>outputs</td>
									<td>list | string</td>
									<td>false</td>
									<td>None</td>
									<td>The output files list created by the function.</td>
								</tr>
								<tr>
									<td>arguments</td>
									<td>string</td>
									<td>false</td>
									<td>None</td>
									<td>The arguments to provide to the function.</td>
								</tr>
								<tr>
									<td>includes</td>
									<td>list | string</td>
									<td>false</td>
									<td>None</td>
									<td>Files to include for this task.</td>
								</tr>
								<tr>
									<td>collect</td>
									<td>boolean</td>
									<td>false</td>
									<td>false</td>
									<td>Whether or not to mark files for garbage collection.</td>
								</tr>
								<tr>
									<td>local</td>
									<td>boolean</td>
									<td>false</td>
									<td>false</td>
									<td>Whether or not to force local execution.</td>
								</tr>
							</tbody>
						</table>
					</div>
		    	
		    	<h3>Map</h3>
		    	<p>The <code>Map</code> abstraction allows to map one input file list to one output file list.</p>
				
				<h4>Example</h4>
		    	<pre class="pre-hl "><code class="python">fasta_list = ["splA.fasta", "splB.fasta", "splC.fasta"]
out_list = ["splA_trim.fasta", "splB_trim.fasta", "splC_trim.fasta"]

fasta_trim = ShellFunction( "fastaTrim.pl --length 50 $1 > $2", cmd_format="{EXE} {IN} {OUT}" )
Map( fasta_trim, inputs=fasta_list, outputs=out_list )</code></pre>
     			<p>This abstraction will lead to the execution of the following command lines:</p>
     			<pre class="pre-hl "><code class="ini">fastaTrim.pl --length 50 splA.fasta > splA_trim.fasta
fastaTrim.pl --length 50 splB.fasta > splB_trim.fasta
fastaTrim.pl --length 50 splC.fasta > splC_trim.fasta</code></pre>			    
			    
			    <h4>Options</h4>
					<div class="table-responsive">
						<table class="table table-bordered table-striped">
							<thead>
								<tr style="white-space:nowrap">
									<th>Name</th>
									<th>Type</th>
									<th>Required</th>
									<th>Default value</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>function</td>
									<td>function</td>
									<td>true</td>
									<td>None</td>
									<td>The <code>ShellFunction</code> or the <code>PythonFunction</code> to use to process the data.</td>
								</tr>
								<tr>
									<td>inputs</td>
									<td>list | string</td>
									<td>true</td>
									<td>None</td>
									<td>The input files list required to run the function.</td>
								</tr>
								<tr>
									<td>outputs</td>
									<td>list | string</td>
									<td>false</td>
									<td>None</td>
									<td>The output files list created by the function.</td>
								</tr>
								<tr>
									<td>includes</td>
									<td>list | string</td>
									<td>false</td>
									<td>None</td>
									<td>Files to include for each task.</td>
								</tr>
								<tr>
									<td>collect</td>
									<td>boolean</td>
									<td>false</td>
									<td>false</td>
									<td>Whether or not to mark files for garbage collection.</td>
								</tr>
								<tr>
									<td>local</td>
									<td>boolean</td>
									<td>false</td>
									<td>false</td>
									<td>Whether or not to force local execution.</td>
								</tr>
							</tbody>
						</table>
					</div>	
			    
			    
			    <h3>MultiMap</h3>
Gerald Salin's avatar
#37  
Gerald Salin committed
1259
			    <p>The <code>MultiMap</code> abstraction allows to map n input file lists to n output file lists, all of the same length.</p>
Penom Nom's avatar
Penom Nom committed
1260 1261 1262
			    
			    <h4>Example</h4>
			    <pre class="pre-hl "><code class="python">fastq_list = ["splA.fastq", "splB.fastq", "splC.fastq"]
1263 1264
out_list = [ ["splA.fasta", "splB.fasta","splC.fasta"],
             [ "splA.qual", "splB.qual","splC.qual"  ] ]
Penom Nom's avatar
Penom Nom committed
1265 1266 1267 1268

fastq2fasta = ShellFunction( "fastq2fasta.py --input $1 --fasta $2 --qual $3", 
                             cmd_format="{EXE} {IN} {OUT}" )
MultiMap( fastq2fasta, inputs=fastq_list, outputs=out_list )</code></pre>
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278

or
			    <pre class="pre-hl "><code class="python">fastq_list = ["splA.fastq", "splB.fastq", "splC.fastq"]
out_fasta_list = ["splA.fasta", "splB.fasta","splC.fasta"]
out_qual_list =  [ "splA.qual", "splB.qual","splC.qual"  ] 

fastq2fasta = ShellFunction( "fastq2fasta.py --input $1 --fasta $2 --qual $3", 
                             cmd_format="{EXE} {IN} {OUT}" )
MultiMap( fastq2fasta, inputs=fastq_list, outputs=[out_fasta_list,out_qual_list] )</code></pre>

Penom Nom's avatar
Penom Nom committed
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347
     			<p>This abstraction will lead to the execution of the following command lines:</p>
     			<pre class="pre-hl "><code class="ini">fastq2fasta.py --input splA.fastq --fasta splA.fasta --qual splA.qual
fastq2fasta.py --input splB.fastq --fasta splB.fasta --qual splB.qual
fastq2fasta.py --input splC.fastq --fasta splC.fasta --qual splC.qual</code></pre>
			    
			    <h4>Options</h4>
					<div class="table-responsive">
						<table class="table table-bordered table-striped">
							<thead>
								<tr style="white-space:nowrap">
									<th>Name</th>
									<th>Type</th>
									<th>Required</th>
									<th>Default value</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>function</td>
									<td>function</td>
									<td>true</td>
									<td>None</td>
									<td>The <code>ShellFunction</code> or the <code>PythonFunction</code> to use to process the data.</td>
								</tr>
								<tr>
									<td>inputs</td>
									<td>list | string</td>
									<td>true</td>
									<td>None</td>
									<td>The input files list required to run the function.</td>
								</tr>
								<tr>
									<td>outputs</td>
									<td>list | string</td>
									<td>false</td>
									<td>None</td>
									<td>The output files list created by the function.</td>
								</tr>
								<tr>
									<td>includes</td>
									<td>list | string</td>
									<td>false</td>
									<td>None</td>
									<td>Files to include for each task.</td>
								</tr>
								<tr>
									<td>collect</td>
									<td>boolean</td>
									<td>false</td>
									<td>false</td>
									<td>Whether or not to mark files for garbage collection.</td>
								</tr>
								<tr>
									<td>local</td>
									<td>boolean</td>
									<td>false</td>
									<td>false</td>
									<td>Whether or not to force local execution.</td>
								</tr>
							</tbody>
						</table>
					</div>	
			</div>
						    
			</section>

			
			<section id="post_process" class="group">
Jerome Mariette's avatar
Jerome Mariette committed
1348
				<h1 class="page-header">Analysis.post_process()</h1>
Penom Nom's avatar
Penom Nom committed
1349
				<p>
1350
					The <code>post_process()</code> method is executed when the <code>process()</code> is done, i.e when output files are generated. 
Penom Nom's avatar
Penom Nom committed
1351 1352 1353 1354
					It is possible to add information to the database using <code>_add_result_element()</code> inside <code>post_process()</code>.
					If the analysis generated some interest files than have to be used in the interface, the method <code>_save_file()</code> can be
					used to save a specific file on the storage directory.
					Adding information using <code>_add_result_element()</code> make them available for display.
Penom Nom's avatar
Penom Nom committed
1355
				</p>
Jerome Mariette's avatar
Jerome Mariette committed
1356

Penom Nom's avatar
Penom Nom committed
1357 1358 1359
				<h2>_add_result_element()</h2>
				
					<p>
Penom Nom's avatar
Penom Nom committed
1360
						This method is used to add a result entry in the database. 
Penom Nom's avatar
Penom Nom committed
1361 1362 1363 1364
					</p>
				
					<h3>Example</h3>
					
Penom Nom's avatar
Penom Nom committed
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388
					<p>
						The following example presents the  <code>define_parameters()</code> and <code>post_process()</code> methods of an analysis.
						The analaysis creates <code>outputs</code> which contains a list of fastq files generated by sampling the input fastq files.
						Each input fastq file corresponding to a sample. In the <code>post_process()</code>, the total amount of sequence extracted 
						from those fastq files are stored for each fastq and stored to the database. 
					</p>
					
					<div>
						<pre class="pre-hl "><code class="python">def define_parameters(self, input_fastq):
    self.add_input_file_list( "input_fastq", "input_fastqs", default=input_fastq)
    self.add_output_file_list( "outputs", "outputs", pattern='{basename_woext}.sample', 
        items=input_fastq)

def get_nbseq(self, fastq):
    # method which returns the number of sequence in a fastq file

def post_process(self):
    for i,infastq in enumerate(self.input_fastqs) :
        outfastq = self.outputs[i]
        name = os.path.splitext(os.path.basename(infastq))[0]
        self._add_result_element(name, "nb_sequence", self.get_nbseq(infastq))
        self._add_result_element(name, "extracted_sequence", self.get_nbseq(outfastq))</code></pre>
					
					</div>
Penom Nom's avatar
Penom Nom committed
1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
					
					<h3>Options</h3>
						<div class="table-responsive">
							<table class="table table-bordered table-striped">
								<thead>
									<tr style="white-space:nowrap">
										<th>Name</th>
										<th>Type</th>
										<th>Required</th>
										<th>Default value</th>
										<th>Description</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td>file</td>
										<td>string</td>
										<td>true</td>
										<td>None</td>
										<td>The file name, sample or any entry the result is linked to.</td>
									</tr>
									
									<tr>
										<td>result_key</td>
										<td>string</td>
										<td>true</td>
										<td>None</td>
										<td>The result key.</td>
									</tr>
									<tr>
										<td>result_value</td>
										<td>string</td>
										<td>true</td>
										<td>None</td>
										<td>the result value associated to the key.</td>
									</tr>
									<tr>
										<td>result_group</td>
										<td>string</td>
										<td>false</td>
										<td>default</td>
										<td>the result group it belongs to.</td>
									</tr>
								</tbody>
							</table>
						</div>
			</section>


			<section id="analysis_template" class="group">
Jerome Mariette's avatar
Jerome Mariette committed
1439
				<h1 class="page-header">The analysis display</h1>
Penom Nom's avatar
Penom Nom committed
1440
				
Penom Nom's avatar
Penom Nom committed
1441
				<p>
1442 1443 1444
					The analysis results, added with the <code>_add_result_element()</code> method in the <code>post_process()</code> function, can be displayed using a template HTMl file. 
					The template is an HTML file written using the PHP Smarty paradigm and must be stored in <code>ui/nG6/pi1/analyses/</code> folder with the same name as your Analysis python file.
					To add interaction with the user, a javascript file	can also be written and associated to the template (same folder, same name).
Penom Nom's avatar
Penom Nom committed
1445
				</p>
Penom Nom's avatar
Penom Nom committed
1446 1447
				
				<div id="template_file" class="subgroup">
Penom Nom's avatar
Penom Nom committed
1448
					<h2>Template file</h2>
Penom Nom's avatar
Penom Nom committed
1449
					<p>
Jerome Mariette's avatar
Jerome Mariette committed
1450 1451 1452
						The template file is an HTML file written in <code>Smarty</code>. NG6 provides a global template named <code>AnalysisTemplate.tpl</code>
						that should be extended. This template defines multiple <code>block</code> that can be redefined by any templates inheriting from
						the NG6 parent template. The blocks than can be overloaded are:
Penom Nom's avatar
Penom Nom committed
1453 1454
					</p>
					<ul>
Jerome Mariette's avatar
Jerome Mariette committed
1455 1456 1457 1458 1459
						<li><code>description_update</code>: can be used to extends the description in the top panel of the analysis,</li>
						<li><code>results</code>: results are displayed in this block. It is empty by default and have to be overloaded,</li>
						<li><code>params_content</code>: contains the parameters used in the analysis,</li>
						<li><code>results_title</code>: allows to change the title of the results tab,</li>
						<li><code>params_title</code>: allows to change the title of the parameters tab.</li>
Penom Nom's avatar
Penom Nom committed
1460 1461 1462
					</ul>

					<p>
Jerome Mariette's avatar
Jerome Mariette committed
1463 1464 1465
						All analysis results added with <code>_add_result_element()</code> are available within the template in the <code>{$analyse_results}</code> 
						variable. The result added by <code>_add_result_element("myelement", "nbseq", "120", "default")</code>, can be accessed within the 
						template by <code>{$analyse_results["myelement"]["default"].nbseq}</code>.
Penom Nom's avatar
Penom Nom committed
1466
					</p>
Penom Nom's avatar
Penom Nom committed
1467
					
Penom Nom's avatar
Penom Nom committed
1468 1469 1470
					
					<h3>Example</h3>
					<p>
Jerome Mariette's avatar
Jerome Mariette committed
1471 1472 1473 1474
						This example takes the <code>post_process()</code> function defined previously and write a template file that creates a table with
						the number of sequence and the number of extracted sequence for each sample. The template overwrite the <code>results</code> and <code>results_title</code>
						blocks. NG6 interface uses <a target="_blanc" href="http://getbootstrap.com/">Bootstrap</a>, so all bootstrap classes are available from
						a template.
Penom Nom's avatar
Penom Nom committed
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490
						The <a target="_blank" href="https://www.datatables.net/">jquery datatable</a> plugin can also be used. The <code>dataTable</code> CSS class is
						used to format the results table. 
					</p>
					<div>
						<pre class="pre-hl "><code class="python">def post_process(self):
    for i,infastq in enumerate(self.input_fastqs) :
        outfastq = self.outputs[i]
        name = os.path.splitext(os.path.basename(infastq))[0]
        self._add_result_element(name, "nb_sequence", self.get_nbseq(infastq))
        self._add_result_element(name, "extracted_sequence", self.get_nbseq(outfastq))</code></pre>
					
					</div>
					
					<div>
						<pre class="pre-hl "><code class="xml">{extends file="AnalysisTemplate.tpl"}
{block name=results_title} Fastq results {/block}
Penom Nom's avatar
Penom Nom committed
1491
{block name=results}
Jerome Mariette's avatar
Jerome Mariette committed
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509
    &lt;table class="table table-striped table-bordered dataTable analysis-result-table"&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;th class="string-sort" &gt;Sample&lt;/th&gt;
                &lt;th class="string-sort" &gt;Number of seqence&lt;/th&gt;
                &lt;th class="string-sort" &gt;Number of extracted sequence&lt;/th&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
            {foreach from=$analyse_results key=sample item=sample_results}
                &lt;tr&gt;
                    &lt;td&gt; {$sample|get_description:$descriptions}&lt;/td&gt;
                    &lt;td&gt;{$sample_results["default"].nb_sequence}&lt;/td&gt;
                    &lt;td&gt;{$sample_results["default"].extracted_sequence}&lt;/td&gt;
                &lt;/tr&gt;
            {/foreach}
        &lt;/tbody&gt;
    &lt;/table&gt;
Penom Nom's avatar
Penom Nom committed
1510
{/block}</code></pre>
Penom Nom's avatar
Penom Nom committed
1511 1512 1513 1514 1515 1516 1517
					</div>
					
				</div>
				
				<div id="javascript_file" class="subgroup">
					<h2>Javascript file</h2>
					<p>
Jerome Mariette's avatar
Jerome Mariette committed
1518 1519
						It is also possible to add a javascript file to make the template more dynamic (for example adding buttons actions and so on ...). To do so, the developer 
						can write a javascript file named as the Analysis class name.
Penom Nom's avatar
Penom Nom committed
1520 1521 1522
					</p>
					<h3>Example</h3>
					<p>
Jerome Mariette's avatar
Jerome Mariette committed
1523
						The previous template file has been updated to add checkboxes for each sample and a buton in the table footer. In the javascript file, jquery is used
Penom Nom's avatar
Penom Nom committed
1524 1525
						to retrieve selected lines.
					</p>
Penom Nom's avatar
Penom Nom committed
1526
						<div>
Penom Nom's avatar
Penom Nom committed
1527 1528
						<pre class="pre-hl "><code class="xml">{extends file="AnalysisTemplate.tpl"}
{block name=results_title} Fastq results {/block}
Jerome Mariette's avatar
Jerome Mariette committed
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557
{block name=results}
    &lt;table class="table table-striped table-bordered dataTable analysis-result-table"&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;th class="string-sort" &gt;Sample&lt;/th&gt;
                &lt;th class="string-sort" &gt;Number of seqence&lt;/th&gt;
                &lt;th class="string-sort" &gt;Number of extracted sequence&lt;/th&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
            {foreach from=$analyse_results key=sample item=sample_results}
                &lt;tr&gt;
                    &lt;td&gt;&lt;center&gt;&lt;input type="checkbox" id="chk_sample_{$i}" 
                        value="sample"/&gt;&lt;/center&gt;&lt;/td&gt;	
                    &lt;td&gt; {$sample|get_description:$descriptions}&lt;/td&gt;
                    &lt;td&gt;{$sample_results["default"].nb_sequence}&lt;/td&gt;
                    &lt;td&gt;{$sample_results["default"].extracted_sequence}&lt;/td&gt;
                &lt;/tr&gt;
            {/foreach}
        &lt;/tbody&gt;
        &lt;tfoot&gt;
            &lt;tr&gt;
                &lt;th align="left" colspan="4"&gt;
                    &lt;button type="button" class="btn btn-default" 
                        id="my_button"&gt;click&lt;/button&gt;
                &lt;/th&gt;
            &lt;/tr&gt;
        &lt;/tfoot&gt;
    &lt;/table&gt;
Penom Nom's avatar
Penom Nom committed
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567
{/block}</code></pre>					
					</div>
					
					<div>
					<pre class="pre-hl "><code class="javascript">$(function () {
    $("#my_button").click(function() {
    	var samples = new Array() ;
		$("input[id^='chk_sample_']:checked").each( function() {
    		samples.push( parseInt($(this).attr("id").split('_')[2]) ) ;
    	}) ;
Jerome Mariette's avatar
Jerome Mariette committed
1568
        // Do something with selected samples
Penom Nom's avatar
Penom Nom committed
1569 1570 1571 1572 1573
    }) ;
});</code></pre>
					</div>
				</div>
				
Penom Nom's avatar
Penom Nom committed
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607
			</section>
		</div>
	  </div>
		
      <hr>
      <footer>
      	<div class="container" style="text-align: center;">
		  <p>Copyright © 2015, INRA | Designed by <a target="_blank" href="http://bioinfo.genotoul.fr/">GenoToul Bioinfo platform</a> and <a target="_blank" href="http://www.sigenae.org/">Sigenae platform</a>.</p>
		</div>
      </footer>
	  
	</div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!-- <script src="../../assets/js/docs.min.js"></script> -->
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <!-- <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script> -->

	<!--  Highlight code -->
	<script src="js/highlight.pack.js"></script>
	<script>hljs.initHighlightingOnLoad();</script>
	
	<script type='text/javascript'>
		$('body').scrollspy({
    		target: '.bs-docs-sidebar',
    		offset: 150
		});
	</script>
</body>
</html>