Commit df53f573 authored by Penom Nom's avatar Penom Nom
Browse files

update pacbio_qc

parent 83655099
......@@ -18,6 +18,7 @@
import os
import sys
import inspect
import logging
from ConfigParser import ConfigParser, NoOptionError
......
......@@ -191,8 +191,8 @@ class MultipleParameters(object):
else:
try:
value = self.types[parts[0]](parts[1])
except:
raise argparse.ArgumentTypeError("invalid " + self.types[parts[0]].__name__ + " value: '" + parts[1] + "' for sub parameter '" + parts[0] + "'")
except Exception, e:
raise argparse.ArgumentTypeError("invalid " + self.types[parts[0]].__name__ + " value: '" + parts[1] + "' for sub parameter '" + parts[0] + "' - " + str(e))
if self.choices[parts[0]] != None:
if value not in self.choices[parts[0]]:
......
......@@ -210,8 +210,8 @@ class NG6Workflow (BasicNG6Workflow):
def __add_sample_parameters__(self):
self.add_multiple_parameter_list("input_sample", "Definition of a sample", flag="--sample", required = True, group="Sample description")
self.add_parameter("sample_id", "The uniq identifier of the sample", add_to = "input_sample")
self.add_parameter("sample_name", "A descriptive name for the sample", add_to = "input_sample")
self.add_parameter("sample_id", "The uniq identifier of the sample", type="nospacestr", add_to = "input_sample")
self.add_parameter("sample_name", "A descriptive name for the sample", type="nospacestr", add_to = "input_sample")
self.add_parameter("sample_description", "A brief description of the sample", add_to = "input_sample")
self.add_parameter("type", "Read orientation and type", choices = Sample.AVAILABLE_TYPES, default='se', add_to = "input_sample")
self.add_parameter("insert_size", "Insert size for paired end reads", type = int, add_to = "input_sample")
......
......@@ -30,7 +30,7 @@ $(function () {
$('a[data-toggle="tab"]').on('shown', function () {
if ($(this).attr("href") == "#adaptor") {
var oTable = $('#adaptor-table').dataTable();
var oTable = $('#adaptor-table').DataTable();
oTable.fnDraw();
oTable.fnAdjustColumnSizing();
}
......
......@@ -23,7 +23,7 @@
$(function () {
var udateTableStatus = function($elmt){
var updateTableStatus = function($elmt){
var table = $("#rs_subreads_datatable").DataTable();
var column = table.column($elmt.attr('data-column')) ;
column.visible($elmt[0].checked );
......@@ -31,12 +31,12 @@ $(function () {
$('#rs_subreads_datatable').on( 'draw.dt', function () {
$(':checkbox.toogle-vis').each(function(e){
udateTableStatus($(this));
updateTableStatus($(this));
});
});
$(':checkbox.toogle-vis').change(function(e) {
udateTableStatus($(this));
updateTableStatus($(this));
});
$(':checkbox#view_all_metrics').change(function(e) {
......@@ -126,6 +126,10 @@ $(function () {
$("#ng6modal").modal();
}
}) ;
$(':checkbox.toogle-vis').each(function(e){
updateTableStatus($(this));
});
});
......
......@@ -18,6 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{extends file='AnalysisTemplate.tpl'}
{block name=results_title} Reports {/block}
{block name=nav_menu_downloads}{/block}
{block name=tab_content_downloads}{/block}
{block name=results}
{assign var="analyse_results_sorted" value=$analyse_results|@ksort}
......@@ -57,7 +61,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<li>
<div class="checkbox">
<label>
<input type="checkbox" data-column="{$data_col}" class="toogle-vis"/> {$head}
<input type="checkbox" data-column="{$data_col}" class="toogle-vis" checked/> {$head}
</label>
</div>
</li>
......@@ -146,7 +150,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tr>
<th rowspan="2"><center><input type="checkbox" id="chk_all_sample"/></center></th>
{assign var="nb_samples" value=$analyse_results|@count - 1 }
<th class="string-sort" rowspan="2" id="th_id_1"><center>SMRT Cell ID {if $nb_samples > 1 }({$nb_samples}){/if}</center></th>
<th class="string-sort" rowspan="2" id="th_id_1"><center>Sample {if $nb_samples > 1 }({$nb_samples}){/if}</center></th>
{if $metrics['loading']}
<th colspan="{$loading_stats_count}"><center>Loading report</center></th>
......
......@@ -30,19 +30,19 @@ $(function () {
$('a[data-toggle="tab"]').on('shown', function () {
if ($(this).attr("href") == "#contigs") {
var oTable = $('#contigs-table').dataTable();
var oTable = $('#contigs-table').DataTable();
oTable.fnDraw();
oTable.fnAdjustColumnSizing();
} else if ($(this).attr("href") == "#isogroups") {
var oTable = $('#isogroups-table').dataTable();
var oTable = $('#isogroups-table').DataTable();
oTable.fnDraw();
oTable.fnAdjustColumnSizing();
} else if ($(this).attr("href") == "#isotigs") {
var oTable = $('#isotigs-table').dataTable();
var oTable = $('#isotigs-table').DataTable();
oTable.fnDraw();
oTable.fnAdjustColumnSizing();
} else if ($(this).attr("href") == "#ace") {
var oTable = $('#ace-table').dataTable();
var oTable = $('#ace-table').DataTable();
oTable.fnDraw();
oTable.fnAdjustColumnSizing();
}
......
......@@ -369,10 +369,6 @@ class tx_nG6_pi1 extends tslib_pibase {
// Try to process the analyse template
try {
if (file_exists(t3lib_extMgm::extPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js')) {
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js"></script>';
}
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1_analysis.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.venny.min.js"></script>
......@@ -386,6 +382,12 @@ class tx_nG6_pi1 extends tslib_pibase {
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.jstree.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/d3-3.4.4.min.js"></script>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/unitip.css"/>';
if (file_exists(t3lib_extMgm::extPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js')) {
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js"></script>';
}
return $smarty->fetch($analyse['class'].'.tpl');
} catch (Exception $e) {
return 'No template found for class ' . $analyse['class'];
......
......@@ -197,7 +197,7 @@ $(function () {
// Build dataTable
if ($(this).children("tbody").children("tr").children("td:has(input:checkbox)").length > 0) {
$(this).dataTable({
$(this).DataTable({
"scrollX" : "90%",
"sScrollXInner" : "100%",
"order" : [[1, 'desc']],
......@@ -205,7 +205,7 @@ $(function () {
"columnDefs": [ { "orderable": false, "targets": 0 } ]
});
} else {
$(this).dataTable({
$(this).DataTable({
"scrollX" : "90%",
"sScrollXInner" : "100%",
"order" : [[1, 'desc']],
......
......@@ -18,7 +18,6 @@
from ng6.ng6workflow import NG6Workflow
from ng6.utils import Utils
class PacBioQualityCheck (NG6Workflow):
def get_name(self):
......@@ -31,9 +30,15 @@ class PacBioQualityCheck (NG6Workflow):
self.add_parameter("nb_threads", "Number of threads to use for fastqc. Each thread will be allocated 250MB of memory.", default=3)
def process(self):
sample_names = []
infiles = []
for sample in self.samples :
sample_names.append( sample.name )
infiles.append(sample.reads1[0])
add_pacbio_raw_file = self.add_component("AddPacBioRawFiles", [self.runobj, self.get_all_reads()])
h5tofastq = self.add_component("H5toFastq", [self.get_all_reads()])
h5tofastq = self.add_component("H5toFastq", [sample_names, infiles])
fastqc = self.add_component("FastQC", [h5tofastq.output_fastqs, False, False, "fastqc.tar.gz", self.nb_threads], parent = h5tofastq)
self.add_component("RS_Subreads", [self.get_all_reads()])
self.add_component("RS_Subreads", [sample_names, infiles])
\ No newline at end of file
......@@ -44,10 +44,10 @@ def h5_to_fastq(input_file, fastqfile):
class H5toFastq (Analysis):
def define_parameters(self, input_files):
def define_parameters(self, sample_names, input_files):
self.add_parameter_list("sample_names", "sample names, each sample name must correspond to an input file", default=sample_names, required=True)
self.add_input_file_list( "input_files", "Input pacbio bas.h5 files", default=input_files, file_format = h5file, required=True)
items = [os.path.basename(os.path.splitext(os.path.splitext(filename)[0])[0]) for filename in self.input_files]
self.add_output_file_list( 'output_fastqs', "Output fastq files", pattern="{basename_woext}.fastq.gz", file_format="fastq", items=items)
self.add_output_file_list( 'output_fastqs', "Output fastq files", pattern="{basename_woext}.fastq.gz", file_format="fastq", items=self.sample_names)
def process(self):
convertion = PythonFunction(h5_to_fastq, cmd_format="{EXE} {IN} {OUT}")
......@@ -55,7 +55,7 @@ class H5toFastq (Analysis):
def define_analysis(self):
self.name = "H5toFastq"
self.description = "Convert pacbio bas.h5 to fastq files"
self.description = "Extract subreads of pacbio bas.h5 files to fastq files"
self.software = "Python"
self.options = ""
......
......@@ -73,13 +73,27 @@ def rs_subreads(inputfile, componentdir, smrtpipe, fofnToSmrtpipeInput, min_subr
# run smrtpipe
subprocess.check_call("%s --output=%s --params=%s xml:%s >> %s"%(smrtpipe, outputdir, settings_xml, inputs_xml,stdout), shell = True)
def extract_metrics(inputfile):
import h5py
import os
from workflows.pacbio_qc.lib.pacbiolib import PacbioH5Reader
reader = PacbioH5Reader(inputfile)
for baxh5 in reader.bash5.parts :
h5 = h5py.File(baxh5,'r')
metrics = h5['PulseData']['BaseCalls']['ZMWMetrics']
class RS_Subreads (Analysis):
"""
implementation of pacbio RS_Subreads.1 protocol
This module filters reads based on a minimum subread length, polymerase read quality and polymerase read length
"""
def define_parameters(self, input_files, min_subreads_length = 50, polymerase_read_qual = 75.0, polymerase_read_length = 50):
def define_parameters(self, sample_names, input_files, min_subreads_length = 50, polymerase_read_qual = 75.0, polymerase_read_length = 50):
self.add_parameter_list("sample_names", "sample names, each sample name must correspond to an input file", default=sample_names, required=True)
self.add_input_file_list( "input_files", "Input pacbio bas.h5 files", default=input_files, file_format = h5file, required=True)
self.add_parameter("min_subreads_length", "Subreads shorter than this value (in base pairs) are filtered out and excluded from analysis", default=min_subreads_length, type='int')
self.add_parameter("polymerase_read_qual", "Polymerase reads with lower quality than this value are filtered out and excluded from analysis", default=polymerase_read_qual, type='float')
......@@ -109,8 +123,9 @@ class RS_Subreads (Analysis):
metrics = []
for i,samplefile in enumerate(self.input_files) :
sample = os.path.basename(os.path.splitext(os.path.splitext(samplefile)[0])[0])
sample_outdir = os.path.join(self.output_directory, sample)
sample = self.sample_names[i]
sdir = os.path.basename(os.path.splitext(os.path.splitext(samplefile)[0])[0])
sample_outdir = os.path.join(self.output_directory, sdir)
# loading
jsonfile = os.path.join(sample_outdir, 'results', 'filter_reports_loading.json')
......
......@@ -33,5 +33,6 @@ pacbio demo workflow
Demo project
--sample
sample-name=Pacbio_sample
read1=workflows/pacbio_qc/data/primary/lambda_v210/Analysis_Results/m130802_062611_ethan_c100542982550000001823084811241306_s1_p0.bas.h5
......@@ -59,7 +59,7 @@ class PacbioH5Reader(object):
return (np.clip(a, 0, 93).astype(np.uint8) + 33).tostring()
def __iter__(self):
for zmwRead in self.bash5.reads():
for zmwRead in self.bash5.subreads():
yield Sequence(zmwRead.readName, zmwRead.readName, zmwRead.basecalls(), self.asciiFromQvs(zmwRead.QualityValue()))
def h5file(ifile):
......
......@@ -112,6 +112,11 @@ def email(val):
return val
def nospacestr(val):
if re.search(r"\s+", val):
raise argparse.ArgumentTypeError("The string value '%s' must not contain spaces" % val)
return val
def samplemetadata(metadata):
key, val = metadata.split(':', 2)
if not (key and val) :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment