File: Snakefile

package info (click to toggle)
snakemake 7.32.4-8.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 25,836 kB
  • sloc: python: 32,846; javascript: 1,287; makefile: 247; sh: 163; ansic: 57; lisp: 9
file content (58 lines) | stat: -rw-r--r-- 1,421 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
A test case for this bug
"""

n_files = 4

rule all:
    input:
        faa='all.faa',
        fasta='all.fasta'

checkpoint make_files:
    output: 
        files=directory('files')
    run:
        os.makedirs(output.files)
        for i in range(n_files):
            filename = f'{output.files}/f{i}.fasta'
            with open(filename, 'wt') as fasta_out:
                fasta_out.write('>blank\nACTGACTG\n')

def get_report_files(wildcards):
    " get the names of the faa files to be created "
    files_dir = checkpoints.make_files.get().output.files
    files, = glob_wildcards(f'{files_dir}/{{file}}.fasta')
    return expand(f'{files_dir}/{{file}}.txt', file=files)
    
rule pattern:
    input: "{any_file}.fasta"
    output: "{any_file}.faa"
    shell: "cp {input} {output}"
        

rule multiple:
    """ in my original example,  compiled a bunch of sets of report, fasta and faa files
    into a master file of each type.
    
    only the reports were the actual inputs. Neitheer the fasta or faa were listed 
    """
    input: 
        reports=get_report_files
    output:
        fasta='all.fasta',
        faa='all.faa'
    shell:
        "touch {output}"

rule report:
    input:
        "f{n}.faa"
    output:
        "f{n}.txt"
    shell: "wc {input} > {output}"
        
rule make_fasta:
    " just create a placehlder"
    output: "f{n}.fasta"
    shell: "echo {wildcards.n} > {output}"