File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import sys
2
+ from os import path
3
+
4
+
5
+ def get_samtools_opts (snakemake , parse_threads = True , parse_output_format = True ):
6
+ """Obtain samtools_opts from output, params, and handle resource definitions in resources."""
7
+ samtools_opts = ""
8
+ extra = snakemake .params .get ("extra" , "" )
9
+
10
+ ###############
11
+ ### Threads ###
12
+ ###############
13
+ if parse_threads :
14
+ if "-@" in extra or "--threads" in extra :
15
+ sys .exit (
16
+ "You have specified number of threads (`-@/--threads`) in params.extra; please use only `threads`."
17
+ )
18
+ samtools_opts += (
19
+ ""
20
+ if snakemake .threads <= 1
21
+ else "--threads {}" .format (snakemake .threads - 1 )
22
+ )
23
+
24
+ #####################
25
+ ### Output format ###
26
+ #####################
27
+ if parse_output_format :
28
+ if "-O" in extra or "--output-fmt" in extra :
29
+ sys .exit (
30
+ "You have specified output format (`-O/--output-fmt`) in params.extra; this is automatically infered from output file extension."
31
+ )
32
+
33
+ out_name , out_ext = path .splitext (snakemake .output [0 ])
34
+ out_ext = out_ext [1 :].upper ()
35
+ samtools_opts += f" --output-fmt { out_ext } "
36
+
37
+ return samtools_opts
You can’t perform that action at this time.
0 commit comments