From 74f04060670e058e5fd3c968a4aa9f65420c4416 Mon Sep 17 00:00:00 2001 From: WardDeb Date: Wed, 26 Apr 2023 11:49:03 +0200 Subject: [PATCH] flake minor formatting --- src/dissectBCL/classes.py | 10 +++++++--- src/dissectBCL/demux.py | 19 ++++++++++--------- src/dissectBCL/drHouse.py | 29 +++++++++++++++-------------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/dissectBCL/classes.py b/src/dissectBCL/classes.py index 7900ae9..389e79d 100644 --- a/src/dissectBCL/classes.py +++ b/src/dissectBCL/classes.py @@ -482,9 +482,13 @@ def optDupRet(optDup): if not self.P5RC: P5RCstr = '' else: - P5RCstr = '\n\nNote that the P5s have been reverse complemented automatically !' - P5RCstr += '\nThe multiQC report contains the barcodes as they are used for demultiplexing.\n' - + P5RCstr = '\n\n ' + P5RCstr += 'Note that the P5s have been reverse complemented ' + P5RCstr += 'automatically. \n\n' + P5RCstr += 'The multiqc report contains ' + P5RCstr += 'the index sequences ' + P5RCstr += 'as they are used for demultiplexing.' + msg = _html.render() +\ P5RCstr +\ '

Top unknown barcodes

' +\ diff --git a/src/dissectBCL/demux.py b/src/dissectBCL/demux.py index 0de26bc..572824c 100644 --- a/src/dissectBCL/demux.py +++ b/src/dissectBCL/demux.py @@ -322,7 +322,7 @@ def writeDemuxSheet(demuxOut, ssDic, laneSplitStatus): f.write('{}\n'.format(line)) -def readDemuxSheet(demuxSheet): +def readDemuxSheet(demuxSheet, what='all'): ''' In case of manual intervention. We want to have the correct info in reports / emails. @@ -371,7 +371,10 @@ def readDemuxSheet(demuxSheet): mask except NameError: mask = None - return (mask, df, dualIx, mmdic) + if what == 'all': + return (mask, df, dualIx, mmdic) + elif what == 'df': + return (df) def parseStats(outputFolder, ssdf): @@ -538,7 +541,7 @@ def demux(sampleSheet, flowcell, config): Path( os.path.join(outputFolder, 'bclconvert.done') ).touch() - if flowcell.sequencer == 'MiSeq': + if flowcell.sequencer == 'MiSeq': if differentialDiagnosis( outputFolder, sampleSheet.ssDic[outLane]['dualIx'], @@ -549,7 +552,6 @@ def demux(sampleSheet, flowcell, config): shutil.rmtree( os.path.join(outputFolder, 'Reports') ) - # bclRunner = Popen( bclOpts, stdout=PIPE @@ -559,12 +561,11 @@ def demux(sampleSheet, flowcell, config): "bclConvert P5fix exit {}".format(exitcode) ) # Update the sampleSheet with proper RC'ed indices. - manual_mask, manual_df, manual_dualIx, man_mmdic = readDemuxSheet( - demuxOut - ) - sampleSheet.ssDic[outLane]['sampleSheet'] = matchingSheets( + sampleSheet.ssDic[outLane][ + 'sampleSheet' + ] = matchingSheets( sampleSheet.ssDic[outLane]['sampleSheet'], - manual_df + readDemuxSheet(demuxOut, what='df') ) sampleSheet.ssDic[outLane]['P5RC'] = True else: diff --git a/src/dissectBCL/drHouse.py b/src/dissectBCL/drHouse.py index 1f98a40..533cb5e 100644 --- a/src/dissectBCL/drHouse.py +++ b/src/dissectBCL/drHouse.py @@ -6,7 +6,6 @@ import glob import datetime import logging -import sys from Bio.Seq import Seq @@ -90,39 +89,41 @@ def differentialDiagnosis(outPath, dualIx): logging.warning( 'More then 90% samples empty. Attempting to salvage by RC the P5.' ) - if not dualIx: # Only RC P5 operations for now. + if not dualIx: # Only RC P5 operations for now. return (False) # Read demuxSheet demuxSheetPath = os.path.join( outPath, 'demuxSheet.csv' ) - demuxHeaders = [] demuxSheet = [] with open(demuxSheetPath) as f: headStatus = True for line in f: - if headStatus: - demuxHeaders.append(line.strip().split(',')) - else: - demuxSheetLine = line.strip().split(',') - ixPos = colnames.index('index2') - oldIx = demuxSheetLine[ixPos] - newIx = str(Seq(oldIx).reverse_complement()) - demuxSheetLine[ixPos] = newIx - demuxSheet.append(demuxSheetLine) if 'Sample_ID' in line.strip(): headStatus = False colnames = line.strip().split(',') + demuxSheet.append(colnames) + if headStatus: + demuxSheet.append(line.strip().split(',')) + else: + if 'Sample_ID' not in line.strip(): + demuxSheetLine = line.strip().split(',') + ixPos = colnames.index('index2') + oldIx = demuxSheetLine[ixPos] + newIx = str(Seq(oldIx).reverse_complement()) + demuxSheetLine[ixPos] = newIx + demuxSheet.append(demuxSheetLine) shutil.move( demuxSheetPath, demuxSheetPath+'.bak' ) with open(demuxSheetPath, 'w') as f: - for l in demuxHeaders + demuxSheet: - f.write(','.join(l) +'\n') + for _l in demuxSheet: + f.write(','.join(_l) + '\n') return (True) + def initClass( outPath, initTime, flowcellID, ssDic, transferTime, exitStats, solPath ):