Snakefile 575 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
rule split_fasta:
    """
    Split a FASTA file with the desired number of sequences per chunk
    """
    input:
        __split_fasta_input
    output:
        __split_fasta_output
    params:
        n_lines = __split_fasta_number_sequences * 2,
        prefix = __split_fasta_prefix
    shell:
        """
        cat {input} | awk '/^>/ {{if(N>0) printf("\\n"); printf("%s\\n",$0);++N;next;}} {{ printf("%s",$0);}} END {{printf("\\n");}}' | split -l {params.n_lines} -a 5 -d - {params.prefix}
15
        for i in `ls {params.prefix}*`; do mv $i ${{i}}.fa;done
16
        """