diff doc/_build/html/_modules/hubArchiveCreator.html @ 0:f493979f1408 draft default tip

planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
author yating-l
date Wed, 21 Dec 2016 12:13:04 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/_build/html/_modules/hubArchiveCreator.html	Wed Dec 21 12:13:04 2016 -0500
@@ -0,0 +1,400 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>hubArchiveCreator &#8212; HubArchiveCreator 2.3 documentation</title>
+    
+    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
+    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    '../',
+        VERSION:     '2.3',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="../_static/jquery.js"></script>
+    <script type="text/javascript" src="../_static/underscore.js"></script>
+    <script type="text/javascript" src="../_static/doctools.js"></script>
+    <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="index" title="Index" href="../genindex.html" />
+    <link rel="search" title="Search" href="../search.html" />
+    <link rel="top" title="HubArchiveCreator 2.3 documentation" href="../index.html" />
+    <link rel="up" title="Module code" href="index.html" /> 
+  </head>
+  <body role="document">
+    <div class="related" role="navigation" aria-label="related navigation">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../genindex.html" title="General Index"
+             accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li class="nav-item nav-item-0"><a href="../index.html">HubArchiveCreator 2.3 documentation</a> &#187;</li>
+          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Module code</a> &#187;</li> 
+      </ul>
+    </div>  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body" role="main">
+            
+  <h1>Source code for hubArchiveCreator</h1><div class="highlight"><pre>
+<span></span><span class="ch">#!/usr/bin/python</span>
+<span class="c1"># -*- coding: utf8 -*-</span>
+
+<span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">This Galaxy tool permits to prepare your files to be ready for</span>
+<span class="sd">Assembly Hub visualization.</span>
+<span class="sd">Program test arguments:</span>
+<span class="sd">hubArchiveCreator.py -g test-data/augustusDbia3.gff3 -f test-data/dbia3.fa -d . -u ./tools -o output.html</span>
+<span class="sd">&quot;&quot;&quot;</span>
+
+<span class="kn">import</span> <span class="nn">argparse</span>
+<span class="kn">import</span> <span class="nn">collections</span>
+<span class="kn">import</span> <span class="nn">json</span>
+<span class="kn">import</span> <span class="nn">logging</span>
+<span class="kn">import</span> <span class="nn">os</span>
+<span class="kn">import</span> <span class="nn">sys</span>
+
+<span class="c1"># Internal dependencies</span>
+<span class="kn">from</span> <span class="nn">Bam</span> <span class="k">import</span> <span class="n">Bam</span>
+<span class="kn">from</span> <span class="nn">BedSimpleRepeats</span> <span class="k">import</span> <span class="n">BedSimpleRepeats</span>
+<span class="kn">from</span> <span class="nn">Bed</span> <span class="k">import</span> <span class="n">Bed</span>
+<span class="kn">from</span> <span class="nn">BigWig</span> <span class="k">import</span> <span class="n">BigWig</span>
+<span class="kn">from</span> <span class="nn">util.Fasta</span> <span class="k">import</span> <span class="n">Fasta</span>
+<span class="kn">from</span> <span class="nn">util.Filters</span> <span class="k">import</span> <span class="n">TraceBackFormatter</span>
+<span class="kn">from</span> <span class="nn">Gff3</span> <span class="k">import</span> <span class="n">Gff3</span>
+<span class="kn">from</span> <span class="nn">Gtf</span> <span class="k">import</span> <span class="n">Gtf</span>
+<span class="kn">from</span> <span class="nn">Psl</span> <span class="k">import</span> <span class="n">Psl</span>
+<span class="kn">from</span> <span class="nn">TrackHub</span> <span class="k">import</span> <span class="n">TrackHub</span>
+
+<span class="c1"># TODO: Verify each subprocessed dependency is accessible [gff3ToGenePred, genePredToBed, twoBitInfo, faToTwoBit, bedToBigBed, sort</span>
+
+
+<span class="k">def</span> <span class="nf">main</span><span class="p">(</span><span class="n">argv</span><span class="p">):</span>
+    <span class="c1"># Command Line parsing init</span>
+    <span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s1">&#39;Create a foo.txt inside the given folder.&#39;</span><span class="p">)</span>
+
+    <span class="c1"># Reference genome mandatory</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-f&#39;</span><span class="p">,</span> <span class="s1">&#39;--fasta&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Fasta file of the reference genome&#39;</span><span class="p">)</span>
+
+    <span class="c1"># GFF3 Management</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--gff3&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;GFF3 format&#39;</span><span class="p">)</span>
+
+    <span class="c1"># GTF Management</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--gtf&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;GTF format&#39;</span><span class="p">)</span>
+
+    <span class="c1"># Bed4+12 (TrfBig)</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--bedSimpleRepeats&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Bed4+12 format, using simpleRepeats.as&#39;</span><span class="p">)</span>
+
+    <span class="c1"># Generic Bed (Blastx transformed to bed)</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--bed&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Bed generic format&#39;</span><span class="p">)</span>
+
+    <span class="c1"># BigWig Management</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--bigwig&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;BigWig format&#39;</span><span class="p">)</span>
+
+    <span class="c1"># Bam Management</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--bam&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Bam format&#39;</span><span class="p">)</span>
+
+    <span class="c1"># Psl Management</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--psl&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Psl format&#39;</span><span class="p">)</span>
+
+    <span class="c1"># TODO: Check if the running directory can have issues if we run the tool outside</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-d&#39;</span><span class="p">,</span> <span class="s1">&#39;--directory&#39;</span><span class="p">,</span>
+                        <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Running tool directory, where to find the templates. Default is running directory&#39;</span><span class="p">)</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-u&#39;</span><span class="p">,</span> <span class="s1">&#39;--ucsc_tools_path&#39;</span><span class="p">,</span>
+                        <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Directory where to find the executables needed to run this tool&#39;</span><span class="p">)</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-e&#39;</span><span class="p">,</span> <span class="s1">&#39;--extra_files_path&#39;</span><span class="p">,</span>
+                        <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Name, in galaxy, of the output folder. Where you would want to build the Track Hub Archive&#39;</span><span class="p">)</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-o&#39;</span><span class="p">,</span> <span class="s1">&#39;--output&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Name of the HTML summarizing the content of the Track Hub Archive&#39;</span><span class="p">)</span>
+
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-j&#39;</span><span class="p">,</span> <span class="s1">&#39;--data_json&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Json containing the metadata of the inputs&#39;</span><span class="p">)</span>
+
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--user_email&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Email of the user who launched the Hub Archive Creation&#39;</span><span class="p">)</span>
+
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--genome_name&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;UCSC Genome Browser assembly ID&#39;</span><span class="p">)</span>
+
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--debug_mode&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Allow more details about the errors&#39;</span><span class="p">)</span>
+
+    <span class="c1"># Begin init variables</span>
+
+    <span class="n">toolDirectory</span> <span class="o">=</span> <span class="s1">&#39;.&#39;</span>
+    <span class="n">extra_files_path</span> <span class="o">=</span> <span class="s1">&#39;.&#39;</span>
+
+    <span class="c1"># Get the args passed in parameter</span>
+    <span class="n">args</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">()</span>
+
+    <span class="n">extra_files_path</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">extra_files_path</span>
+    <span class="n">toolDirectory</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">directory</span>
+
+    <span class="c1">#### Logging management ####</span>
+    <span class="c1"># If we are in Debug mode, also print in stdout the debug dump</span>
+
+    <span class="n">configure_logger</span><span class="p">(</span><span class="n">extra_files_path</span><span class="o">=</span><span class="n">extra_files_path</span><span class="p">,</span> <span class="n">debug</span><span class="o">=</span><span class="n">args</span><span class="o">.</span><span class="n">debug_mode</span><span class="p">)</span>
+
+    <span class="c1">#### END Logging management ####</span>
+
+    <span class="n">array_inputs_reference_genome</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">fasta</span><span class="p">)</span>
+
+    <span class="c1"># TODO: Replace these with the object Fasta</span>
+    <span class="n">input_fasta_file</span> <span class="o">=</span> <span class="n">array_inputs_reference_genome</span><span class="p">[</span><span class="s2">&quot;false_path&quot;</span><span class="p">]</span>
+    <span class="n">input_fasta_file_name</span> <span class="o">=</span> <span class="n">sanitize_name_input</span><span class="p">(</span><span class="n">array_inputs_reference_genome</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">])</span>
+    <span class="n">genome_name</span> <span class="o">=</span> <span class="n">sanitize_name_input</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">genome_name</span><span class="p">)</span>
+
+    <span class="n">reference_genome</span> <span class="o">=</span> <span class="n">Fasta</span><span class="p">(</span><span class="n">input_fasta_file</span><span class="p">,</span>
+                             <span class="n">input_fasta_file_name</span><span class="p">,</span> <span class="n">genome_name</span><span class="p">)</span>
+
+    <span class="n">user_email</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">user_email</span>
+
+
+    <span class="c1"># TODO: Use a class to have a better management of the structure of these inputs</span>
+    <span class="c1"># These inputs are populated in the Galaxy Wrapper xml and are in this format:</span>
+    <span class="c1"># ARRAY[DICT{FILE_PATH: DICT{NAME: NAME_VALUE, EXTRA_DATA: EXTRA_DATA_VALUE}}]</span>
+    <span class="c1"># EXTRA_DATA could be anything, for example the index of a BAM =&gt; {&quot;index&quot;, FILE_PATH}</span>
+    <span class="n">array_inputs_bam</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">bam</span>
+    <span class="n">array_inputs_bed_generic</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">bed</span>
+    <span class="n">array_inputs_bed_simple_repeats</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">bedSimpleRepeats</span>
+    <span class="n">array_inputs_bigwig</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">bigwig</span>
+    <span class="n">array_inputs_gff3</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">gff3</span>
+    <span class="n">array_inputs_gtf</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">gtf</span>
+    <span class="n">array_inputs_psl</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">psl</span>
+
+    <span class="n">outputFile</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">output</span>
+
+    <span class="n">json_inputs_data</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">data_json</span>
+
+    <span class="n">inputs_data</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">json_inputs_data</span><span class="p">)</span>
+    <span class="c1"># We remove the spaces in [&quot;name&quot;] of inputs_data</span>
+    <span class="n">sanitize_name_inputs</span><span class="p">(</span><span class="n">inputs_data</span><span class="p">)</span>
+
+    <span class="c1"># TODO: Check here all the binaries / tools we need. Exception if missing</span>
+
+    <span class="c1"># Create the Track Hub folder</span>
+    <span class="n">trackHub</span> <span class="o">=</span> <span class="n">TrackHub</span><span class="p">(</span><span class="n">reference_genome</span><span class="p">,</span> <span class="n">user_email</span><span class="p">,</span> <span class="n">outputFile</span><span class="p">,</span> <span class="n">extra_files_path</span><span class="p">,</span> <span class="n">toolDirectory</span><span class="p">)</span>
+
+    <span class="n">all_datatype_dictionary</span> <span class="o">=</span> <span class="p">{}</span>
+
+    <span class="k">for</span> <span class="p">(</span><span class="n">inputs</span><span class="p">,</span> <span class="n">datatype_class</span><span class="p">)</span> <span class="ow">in</span> <span class="p">[</span>
+                        <span class="p">(</span><span class="n">array_inputs_bam</span><span class="p">,</span> <span class="n">Bam</span><span class="p">),</span>
+                        <span class="p">(</span><span class="n">array_inputs_bed_generic</span><span class="p">,</span> <span class="n">Bed</span><span class="p">),</span>
+                        <span class="p">(</span><span class="n">array_inputs_bigwig</span><span class="p">,</span> <span class="n">BigWig</span><span class="p">),</span>
+                        <span class="p">(</span><span class="n">array_inputs_bed_simple_repeats</span><span class="p">,</span> <span class="n">BedSimpleRepeats</span><span class="p">),</span>
+                        <span class="p">(</span><span class="n">array_inputs_gff3</span><span class="p">,</span> <span class="n">Gff3</span><span class="p">),</span>
+                        <span class="p">(</span><span class="n">array_inputs_gtf</span><span class="p">,</span> <span class="n">Gtf</span><span class="p">),</span>
+                        <span class="p">(</span><span class="n">array_inputs_psl</span><span class="p">,</span> <span class="n">Psl</span><span class="p">)]:</span>
+        <span class="k">if</span> <span class="n">inputs</span><span class="p">:</span>
+            <span class="n">all_datatype_dictionary</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">create_ordered_datatype_objects</span><span class="p">(</span><span class="n">datatype_class</span><span class="p">,</span> <span class="n">inputs</span><span class="p">,</span> <span class="n">inputs_data</span><span class="p">))</span>
+
+    <span class="c1"># Create Ordered Dictionary to add the tracks in the tool form order</span>
+    <span class="n">all_datatype_ordered_dictionary</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">OrderedDict</span><span class="p">(</span><span class="n">all_datatype_dictionary</span><span class="p">)</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;----- End of all_datatype_dictionary processing -----&quot;</span><span class="p">)</span>
+    <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;all_datatype_ordered_dictionary keys are: </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">all_datatype_ordered_dictionary</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;----- Beginning of Track adding processing -----&quot;</span><span class="p">)</span>
+    <span class="k">for</span> <span class="n">index</span><span class="p">,</span> <span class="n">datatypeObject</span> <span class="ow">in</span> <span class="n">all_datatype_ordered_dictionary</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
+        <span class="n">trackHub</span><span class="o">.</span><span class="n">addTrack</span><span class="p">(</span><span class="n">datatypeObject</span><span class="o">.</span><span class="n">track</span><span class="o">.</span><span class="n">trackDb</span><span class="p">)</span>
+    <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;----- End of Track adding processing -----&quot;</span><span class="p">)</span>
+
+    <span class="c1"># We process all the modifications to create the zip file</span>
+    <span class="c1">#trackHub.createZip()</span>
+
+    <span class="c1"># We terminate le process and so create a HTML file summarizing all the files</span>
+    <span class="n">trackHub</span><span class="o">.</span><span class="n">terminate</span><span class="p">()</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;#### End of HubArchiveCreator Debug Mode: Bye! ####&#39;</span><span class="p">)</span>
+
+    <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
+
+
+<div class="viewcode-block" id="sanitize_name_input"><a class="viewcode-back" href="../code.html#hubArchiveCreator.sanitize_name_input">[docs]</a><span class="k">def</span> <span class="nf">sanitize_name_input</span><span class="p">(</span><span class="n">string_to_sanitize</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    Sanitize the string passed in parameter by replacing &#39;/&#39; and &#39; &#39; by &#39;_&#39;</span>
+
+<span class="sd">    :param string_to_sanitize:</span>
+<span class="sd">    :return :</span>
+
+<span class="sd">    :Example:</span>
+
+<span class="sd">    &gt;&gt;&gt; sanitize_name_input(&#39;this/is an//example&#39;)</span>
+<span class="sd">    this_is_an__example</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">return</span> <span class="n">string_to_sanitize</span> \
+            <span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;/&quot;</span><span class="p">,</span> <span class="s2">&quot;_&quot;</span><span class="p">)</span> \
+            <span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="s2">&quot;_&quot;</span><span class="p">)</span></div>
+
+
+<div class="viewcode-block" id="sanitize_name_inputs"><a class="viewcode-back" href="../code.html#hubArchiveCreator.sanitize_name_inputs">[docs]</a><span class="k">def</span> <span class="nf">sanitize_name_inputs</span><span class="p">(</span><span class="n">inputs_data</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    Sanitize value of the keys &quot;name&quot; of the dictionary passed in parameter.</span>
+
+<span class="sd">    Because sometimes output from Galaxy, or even just file name, from user inputs, have spaces.</span>
+<span class="sd">    Also, it can contain &#39;/&#39; character and could break the use of os.path function.</span>
+
+<span class="sd">    :param inputs_data: dict[string, dict[string, string]]</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">inputs_data</span><span class="p">:</span>
+        <span class="n">inputs_data</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s2">&quot;name&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">sanitize_name_input</span><span class="p">(</span><span class="n">inputs_data</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s2">&quot;name&quot;</span><span class="p">])</span></div>
+
+
+<div class="viewcode-block" id="create_ordered_datatype_objects"><a class="viewcode-back" href="../code.html#hubArchiveCreator.create_ordered_datatype_objects">[docs]</a><span class="k">def</span> <span class="nf">create_ordered_datatype_objects</span><span class="p">(</span><span class="n">ExtensionClass</span><span class="p">,</span> <span class="n">array_inputs</span><span class="p">,</span> <span class="n">inputs_data</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    Function which executes the creation all the necessary files / folders for a special Datatype, for TrackHub</span>
+<span class="sd">    and update the dictionary of datatype</span>
+
+<span class="sd">    :param ExtensionClass:</span>
+<span class="sd">    :param array_inputs:</span>
+<span class="sd">    :param inputs_data:</span>
+<span class="sd">    :type ExtensionClass: Datatype</span>
+<span class="sd">    :type array_inputs: list[string]</span>
+<span class="sd">    :type inputs_data: dict</span>
+<span class="sd">    :rtype: dict</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="n">datatype_dictionary</span> <span class="o">=</span> <span class="p">{}</span>
+
+    <span class="c1"># TODO: Optimize this double loop</span>
+    <span class="k">for</span> <span class="n">input_false_path</span> <span class="ow">in</span> <span class="n">array_inputs</span><span class="p">:</span>
+        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">data_value</span> <span class="ow">in</span> <span class="n">inputs_data</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
+            <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="n">input_false_path</span><span class="p">:</span>
+                <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;input_false_path: &quot;</span> <span class="o">+</span> <span class="n">input_false_path</span><span class="p">)</span>
+                <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;data_value: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">data_value</span><span class="p">))</span>
+                <span class="n">extensionObject</span> <span class="o">=</span> <span class="n">ExtensionClass</span><span class="p">(</span><span class="n">input_false_path</span><span class="p">,</span> <span class="n">data_value</span><span class="p">)</span>
+                <span class="n">datatype_dictionary</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="n">data_value</span><span class="p">[</span><span class="s2">&quot;order_index&quot;</span><span class="p">]:</span> <span class="n">extensionObject</span><span class="p">})</span>
+    <span class="k">return</span> <span class="n">datatype_dictionary</span></div>
+
+<span class="k">def</span> <span class="nf">configure_logger</span><span class="p">(</span><span class="n">extra_files_path</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">debug</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">extra_files_path</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Extra files path is not set. Stopping the application&quot;</span><span class="p">)</span>
+
+
+    <span class="c1"># All case log: log everything in a .log file</span>
+    <span class="n">logger_file_name</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">__name__</span><span class="p">,</span> <span class="s1">&#39;.log&#39;</span><span class="p">])</span>
+    <span class="n">logging_file_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">extra_files_path</span><span class="p">,</span> <span class="n">logger_file_name</span><span class="p">)</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">logging_file_path</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
+
+    <span class="n">log_stdout</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">)</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">debug</span><span class="p">:</span>
+        <span class="n">configure_logger_user</span><span class="p">(</span><span class="n">log_stdout</span><span class="p">)</span>
+    <span class="k">else</span><span class="p">:</span>
+        <span class="n">configure_logger_dev</span><span class="p">(</span><span class="n">log_stdout</span><span class="p">)</span>
+
+    <span class="c1"># stderr configuration</span>
+    <span class="n">configure_logger_stderr</span><span class="p">()</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;#### Welcome in HubArchiveCreator Debug Mode ####</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
+
+<div class="viewcode-block" id="configure_logger_user"><a class="viewcode-back" href="../code.html#hubArchiveCreator.configure_logger_user">[docs]</a><span class="k">def</span> <span class="nf">configure_logger_user</span><span class="p">(</span><span class="n">log_stdout</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    User Logger is defined as following:</span>
+<span class="sd">        - User needs to have WARN, ERROR and CRITICAL but well formatted / without traceback</span>
+<span class="sd">            in STDOUT</span>
+<span class="sd">        - Still access to full, brute and traceback for errors</span>
+<span class="sd">            in STDERR</span>
+<span class="sd">        - And further access to debug if needed</span>
+<span class="sd">            in .log</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">log_stdout</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;No log_stdout given. Stopping the application&quot;</span><span class="p">)</span>
+
+    <span class="c1"># stdout for INFO / WARN / ERROR / CRITICAL</span>
+    <span class="n">log_stdout</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
+
+    <span class="n">formatter</span> <span class="o">=</span> <span class="n">TraceBackFormatter</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%(message)s</span><span class="s1">&#39;</span><span class="p">)</span>
+
+    <span class="n">log_stdout</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">()</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">log_stdout</span><span class="p">)</span></div>
+
+<div class="viewcode-block" id="configure_logger_dev"><a class="viewcode-back" href="../code.html#hubArchiveCreator.configure_logger_dev">[docs]</a><span class="k">def</span> <span class="nf">configure_logger_dev</span><span class="p">(</span><span class="n">log_stdout</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    Dev Logger is defined as following:</span>
+<span class="sd">        - Dev needs to have WARN, ERROR and CRITICAL but well formatted / without traceback, in stdout</span>
+<span class="sd">        - Still access to full, brute and traceback in stderr for errors</span>
+<span class="sd">        - And further access to debug if needed</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">log_stdout</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;No log_stdout given. Stopping the application&quot;</span><span class="p">)</span>
+    <span class="n">log_format</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%(message)s</span><span class="s1">&#39;</span>
+
+    <span class="c1"># stdout and stderr and both identical for INFO / WARN / ERROR / CRITICAL</span>
+    <span class="n">log_stdout</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
+
+    <span class="n">formatter</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="n">log_format</span><span class="p">)</span>
+
+    <span class="n">log_stdout</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">()</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">log_stdout</span><span class="p">)</span></div>
+
+<div class="viewcode-block" id="configure_logger_stderr"><a class="viewcode-back" href="../code.html#hubArchiveCreator.configure_logger_stderr">[docs]</a><span class="k">def</span> <span class="nf">configure_logger_stderr</span><span class="p">():</span>
+    <span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    Configure what should be logged in stderr</span>
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="n">log_error</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span>
+    <span class="n">log_error</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">ERROR</span><span class="p">)</span>
+    <span class="n">log_error_format</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%(message)s</span><span class="s1">&#39;</span>
+
+    <span class="n">formatter_error</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="n">log_error_format</span><span class="p">)</span>
+
+    <span class="n">log_error</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">formatter_error</span><span class="p">)</span>
+
+    <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">()</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">log_error</span><span class="p">)</span></div>
+
+<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
+    <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="n">__name__</span><span class="p">)</span>
+    <span class="n">main</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">)</span>
+</pre></div>
+
+          </div>
+        </div>
+      </div>
+      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
+        <div class="sphinxsidebarwrapper">
+<div id="searchbox" style="display: none" role="search">
+  <h3>Quick search</h3>
+    <form class="search" action="../search.html" method="get">
+      <div><input type="text" name="q" /></div>
+      <div><input type="submit" value="Go" /></div>
+      <input type="hidden" name="check_keywords" value="yes" />
+      <input type="hidden" name="area" value="default" />
+    </form>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+        </div>
+      </div>
+      <div class="clearer"></div>
+    </div>
+    <div class="related" role="navigation" aria-label="related navigation">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../genindex.html" title="General Index"
+             >index</a></li>
+        <li class="right" >
+          <a href="../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li class="nav-item nav-item-0"><a href="../index.html">HubArchiveCreator 2.3 documentation</a> &#187;</li>
+          <li class="nav-item nav-item-1"><a href="index.html" >Module code</a> &#187;</li> 
+      </ul>
+    </div>
+    <div class="footer" role="contentinfo">
+        &#169; Copyright 2016, Remi Marenco.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
+    </div>
+  </body>
+</html>
\ No newline at end of file