|
a |
|
b/exseek/snakefiles/rename_fastq.snakemake |
|
|
1 |
include: 'common.snakemake' |
|
|
2 |
|
|
|
3 |
def get_all_inputs(wildcards): |
|
|
4 |
inputs = [] |
|
|
5 |
if config['paired_end']: |
|
|
6 |
inputs += expand('{output_dir}/unmapped/{sample_id}/clean_{mate_index}.fastq.gz', |
|
|
7 |
output_dir=output_dir, sample_id=sample_ids, mate_index=[1, 2]) |
|
|
8 |
else: |
|
|
9 |
inputs += expand('{output_dir}/unmapped/{sample_id}/clean.fastq.gz', |
|
|
10 |
output_dir=output_dir, sample_id=sample_ids, mate_index=[1, 2]) |
|
|
11 |
return inputs |
|
|
12 |
|
|
|
13 |
rule all: |
|
|
14 |
input: |
|
|
15 |
get_all_inputs |
|
|
16 |
|
|
|
17 |
rule rename_fastq_pe: |
|
|
18 |
input: |
|
|
19 |
auto_gzip_input('{output_dir}/cutadapt/{sample_id}_{mate_index}.fastq') |
|
|
20 |
output: |
|
|
21 |
'{output_dir}/unmapped/{sample_id}/clean_{mate_index}.fastq.gz' |
|
|
22 |
threads: |
|
|
23 |
1 |
|
|
24 |
wildcard_constraints: |
|
|
25 |
mate_index='[12]' |
|
|
26 |
shell: |
|
|
27 |
r'''{bin_dir}/auto_uncompress {input} \ |
|
|
28 |
| awk 'NR%4==1{{printf "@%012d\n", int(NR/4);next}} NR%4==3{{printf "+\n";next}} {{print}}' \ |
|
|
29 |
| pigz -c -p {threads} > {output} |
|
|
30 |
''' |
|
|
31 |
|
|
|
32 |
rule rename_fastq_se: |
|
|
33 |
input: |
|
|
34 |
auto_gzip_input('{output_dir}/cutadapt/{sample_id}.fastq') |
|
|
35 |
output: |
|
|
36 |
'{output_dir}/unmapped/{sample_id}/clean.fastq.gz' |
|
|
37 |
threads: |
|
|
38 |
1 |
|
|
39 |
shell: |
|
|
40 |
r'''{bin_dir}/auto_uncompress {input} \ |
|
|
41 |
| awk 'NR%4==1{{printf "@%012d\n", int(NR/4);next}} NR%4==3{{printf "+\n";next}} {{print}}' \ |
|
|
42 |
| pigz -c -p {threads} > {output} |
|
|
43 |
''' |