@@ -238,35 +238,15 @@ def blast_subset(self, name, search_string):
238238 batchfile .write (
239239 self ._singularity_exec (
240240 "blast" ,
241- "blastn -db {}/{} -query {}/assembly/{}_contigs.fasta -out {}/blast_search/{}/loci_query_{}.txt -task megablast -num_threads {} -outfmt {}" .format (
242- os .path .dirname (ref ),
243- ref_nosuf ,
244- self .finishdir ,
245- self .name ,
246- self .finishdir ,
247- name ,
248- ref_nosuf ,
249- self .config ["slurm_header" ]["threads" ],
250- blast_format ,
251- ),
241+ f"blastn -db { os .path .dirname (ref )} /{ ref_nosuf } -query { self .finishdir } /assembly/{ self .name } _contigs.fasta -out { self .finishdir } /blast_search/{ name } /loci_query_{ ref_nosuf } .txt -task megablast -num_threads { self .config ['slurm_header' ]['threads' ]} -outfmt { blast_format } " ,
252242 )
253243 + "\n "
254244 )
255245 else :
256246 batchfile .write (
257247 self ._singularity_exec (
258248 "blast" ,
259- "blastn -db {}/{} -query {}/assembly/{}_contigs.fasta -out {}/blast_search/{}/{}.txt -task megablast -num_threads {} -outfmt {}" .format (
260- os .path .dirname (ref ),
261- ref_nosuf ,
262- self .finishdir ,
263- self .name ,
264- self .finishdir ,
265- name ,
266- ref_nosuf ,
267- self .config ["slurm_header" ]["threads" ],
268- blast_format ,
269- ),
249+ f"blastn -db { os .path .dirname (ref )} /{ ref_nosuf } -query { self .finishdir } /assembly/{ self .name } _contigs.fasta -out { self .finishdir } /blast_search/{ name } /{ ref_nosuf } .txt -task megablast -num_threads { self .config ['slurm_header' ]['threads' ]} -outfmt { blast_format } " ,
270250 )
271251 + "\n "
272252 )
@@ -278,17 +258,7 @@ def blast_subset(self, name, search_string):
278258 batchfile .write (
279259 self ._singularity_exec (
280260 "blast" ,
281- "blastn -db {}/{} -query {}/assembly/{}_contigs.fasta -out {}/blast_search/{}/{}.txt -task megablast -num_threads {} -outfmt {}" .format (
282- os .path .dirname (search_string ),
283- ref_nosuf ,
284- self .finishdir ,
285- self .name ,
286- self .finishdir ,
287- name ,
288- ref_nosuf ,
289- self .config ["slurm_header" ]["threads" ],
290- blast_format ,
291- ),
261+ f"blastn -db { os .path .dirname (search_string )} /{ ref_nosuf } -query { self .finishdir } /assembly/{ self .name } _contigs.fasta -out { self .finishdir } /blast_search/{ name } /{ ref_nosuf } .txt -task megablast -num_threads { self .config ['slurm_header' ]['threads' ]} -outfmt { blast_format } " ,
292262 )
293263 + "\n "
294264 )
@@ -310,52 +280,40 @@ def create_variantsection(self):
310280 batchfile .write (
311281 self ._singularity_exec (
312282 "bwa" ,
313- "bwa mem -M -t {} {} {} {} > {}.sam" .format (
314- self .config ["slurm_header" ]["threads" ],
315- ref ,
316- self .concat_files ["f" ],
317- self .concat_files ["r" ],
318- outbase ,
319- ),
283+ f"bwa mem -M -t { self .config ['slurm_header' ]['threads' ]} { ref } { self .concat_files ['f' ]} { self .concat_files ['r' ]} > { outbase } .sam" ,
320284 )
321285 + "\n "
322286 )
323287 batchfile .write (
324288 self ._singularity_exec (
325289 "samtools" ,
326- "samtools view --threads {} -b -o {}.bam -T {} {}.sam" .format (
327- self .config ["slurm_header" ]["threads" ], outbase , ref , outbase
328- ),
290+ f"samtools view --threads { self .config ['slurm_header' ]['threads' ]} -b -o { outbase } .bam -T { ref } { outbase } .sam" ,
329291 )
330292 + "\n "
331293 )
332294 batchfile .write (
333295 self ._singularity_exec (
334296 "samtools" ,
335- "samtools sort --threads {} -o {}.bam_sort {}.bam" .format (
336- self .config ["slurm_header" ]["threads" ], outbase , outbase
337- ),
297+ f"samtools sort --threads { self .config ['slurm_header' ]['threads' ]} -o { outbase } .bam_sort { outbase } .bam" ,
338298 )
339299 + "\n "
340300 )
341301 batchfile .write (
342302 self ._singularity_exec (
343303 "picard" ,
344- "picard MarkDuplicates I={}.bam_sort O={}.bam_sort_rmdup M={}.stats.dup REMOVE_DUPLICATES=true" .format (
345- outbase , outbase , outbase
346- ),
304+ f"picard MarkDuplicates I={ outbase } .bam_sort O={ outbase } .bam_sort_rmdup M={ outbase } .stats.dup REMOVE_DUPLICATES=true" ,
347305 )
348306 + "\n "
349307 )
350308 batchfile .write (
351- self ._singularity_exec ("samtools" , "samtools index {}.bam_sort_rmdup" . format ( outbase ) )
309+ self ._singularity_exec ("samtools" , f "samtools index { outbase } .bam_sort_rmdup" )
352310 + "\n "
353311 )
354312 batchfile .write (
355313 self ._singularity_exec (
356- "samtools" , "samtools idxstats {}.bam_sort_rmdup" . format ( outbase )
314+ "samtools" , f "samtools idxstats { outbase } .bam_sort_rmdup"
357315 )
358- + " &> {}.stats.ref\n " . format ( outbase )
316+ + f " &> { outbase } .stats.ref\n "
359317 )
360318 # Removal of temp aligment files
361319 batchfile .write (f"rm { outbase } .bam { outbase } .sam\n " )
@@ -365,28 +323,26 @@ def create_variantsection(self):
365323 batchfile .write (
366324 self ._singularity_exec (
367325 "picard" ,
368- "picard CollectInsertSizeMetrics I={}.bam_sort_rmdup O={}.stats.ins H={}.hist.ins" .format (
369- outbase , outbase , outbase
370- ),
326+ f"picard CollectInsertSizeMetrics I={ outbase } .bam_sort_rmdup O={ outbase } .stats.ins H={ outbase } .hist.ins" ,
371327 )
372328 + "\n "
373329 )
374330 # Coverage
375331 batchfile .write (
376332 self ._singularity_exec (
377- "samtools" , "samtools stats --coverage 1,10000,1 {}.bam_sort_rmdup" . format ( outbase )
333+ "samtools" , f "samtools stats --coverage 1,10000,1 { outbase } .bam_sort_rmdup"
378334 )
379- + " |grep ^COV | cut -f 2- &> {}.stats.cov\n " . format ( outbase )
335+ + f " |grep ^COV | cut -f 2- &> { outbase } .stats.cov\n "
380336 )
381337 # Mapped rate, no dedup,dedup in MWGS (trimming has no effect)!
382338 batchfile .write (
383- self ._singularity_exec ("samtools" , "samtools flagstat {}.bam_sort" . format ( outbase ) )
384- + " &> {}.stats.map\n " . format ( outbase )
339+ self ._singularity_exec ("samtools" , f "samtools flagstat { outbase } .bam_sort" )
340+ + f " &> { outbase } .stats.map\n "
385341 )
386342 # Total reads, no dedup,dedup in MWGS (trimming has no effect)!
387343 batchfile .write (
388- self ._singularity_exec ("samtools" , "samtools view -c {}.bam_sort" . format ( outbase ) )
389- + " &> {}.stats.raw\n " . format ( outbase )
344+ self ._singularity_exec ("samtools" , f "samtools view -c { outbase } .bam_sort" )
345+ + f " &> { outbase } .stats.raw\n "
390346 )
391347
392348 batchfile .write ("\n \n " )
@@ -433,16 +389,12 @@ def create_preprocsection(self):
433389 batchfile .write (
434390 self ._singularity_exec (
435391 "trimmomatic" ,
436- "trimmomatic PE -threads {} -phred33 {} {} {} {} {} {}\
437- ILLUMINACLIP:{}/NexteraPE-PE.fa:2:30:10 LEADING:3 TRAILING:3 SLIDINGWINDOW:4:15 MINLEN:36" .format (
438- self .config ["slurm_header" ]["threads" ],
439- self .concat_files .get ("f" ),
440- self .concat_files .get ("r" ),
441- fp ,
442- fu ,
443- rp ,
444- ru ,
445- self .config ["singularity" ]["trimmomatic_adapters" ],
392+ (
393+ f"trimmomatic PE -threads { self .config ['slurm_header' ]['threads' ]} "
394+ f" -phred33 { self .concat_files .get ('f' )} { self .concat_files .get ('r' )} "
395+ f" { fp } { fu } { rp } { ru } "
396+ f" ILLUMINACLIP:{ self .config ['singularity' ]['trimmomatic_adapters' ]} /NexteraPE-PE.fa:2:30:10"
397+ " LEADING:3 TRAILING:3 SLIDINGWINDOW:4:15 MINLEN:36"
446398 ),
447399 )
448400 + "\n "
@@ -464,9 +416,7 @@ def create_assemblystats_section(self):
464416 batchfile .write (
465417 self ._singularity_exec (
466418 "quast" ,
467- "quast.py {}/assembly/{}_contigs.fasta -o {}/assembly/quast" .format (
468- self .finishdir , self .name , self .finishdir
469- ),
419+ f"quast.py { self .finishdir } /assembly/{ self .name } _contigs.fasta -o { self .finishdir } /assembly/quast" ,
470420 )
471421 + "\n "
472422 )
0 commit comments