Skip to content
Snippets Groups Projects
pindel.snk 2.65 KiB
Newer Older
Thomas Faraut's avatar
Thomas Faraut committed
pindel_sv = ['DEL', 'INV', 'DUP']
rule statfile:
    input:
        unpack(snakemake_utils.get_inputs_bams)
Floreal Cabanettes's avatar
Floreal Cabanettes committed
        statfile = "{batch}/pindel/pindel_stat.cfg"
    log:
Floreal Cabanettes's avatar
Floreal Cabanettes committed
        stdout = "{batch}/logs/pindel/statfile.o",
        stderr = "{batch}/logs/pindel/statfile.e"
        from svrunner_utils import get_insert_size
        cfg = open(output.statfile, "w")
        for sample in samples[wildcards.batch]:
            bamfile = "data/bams/%s.bam" % sample
            statfile = "{wildcards.batch}/pindel/%s.cfg" % sample
            insert_size = get_insert_size(bamfile)
            cfg.write("\t".join([bamfile, str(insert_size), sample]) + "\n")
        cfg.close()

        unpack(snakemake_utils.get_inputs_bams),
Floreal Cabanettes's avatar
Floreal Cabanettes committed
        statfile = "{batch}/pindel/pindel_stat.cfg",
        excluded = "exclusion/excluded.bed",
        genome = REFERENCE,
        fai = REFERENCE + ".fai"
        "{batch}/pindel/{chrom}/{chrbatch}/pindel_{chrom}_D.gz",
        "{batch}/pindel/{chrom}/{chrbatch}/pindel_{chrom}_INV.gz",
        "{batch}/pindel/{chrom}/{chrbatch}/pindel_{chrom}_TD.gz",
        get_threads("pindel", 5)
    log:
        stdout = "{batch}/logs/pindel/{chrom}_{chrbatch}.o",
        stderr = "{batch}/logs/pindel/{chrom}_{chrbatch}.e"
    shell:
        "pindel -f {input.genome} -i {input.statfile}"
        "       --min_perfect_match_around_BP 20 "
        "       --exclude {input.excluded}"
        "       --number_of_threads {threads}"
        "       --report_interchromosomal_events false"
        "       --window_size 1" # 1Mb
        "       --minimum_support_for_event 3 -c {wildcards.chrom}:{wildcards.chrbatch}"
Floreal Cabanettes's avatar
Floreal Cabanettes committed
        "       -o {wildcards.batch}/pindel/{wildcards.chrom}/{wildcards.chrbatch}/pindel_{wildcards.chrom}"
        "       1>{log.stdout} 2>{log.stderr}"
        gzip -f {wildcards.batch}/pindel/{wildcards.chrom}/{wildcards.chrbatch}/*

rule mergepindelbatches:
    input:
        unpack(snakemake_utils.get_pindel_chr_batches)
    output:
        D="{batch}/pindel/pindel_{chrom}_D.gz",
        INV="{batch}/pindel/pindel_{chrom}_INV.gz",
        TD="{batch}/pindel/pindel_{chrom}_TD.gz"
Floreal Cabanettes's avatar
Floreal Cabanettes committed
    log:
Floreal Cabanettes's avatar
Floreal Cabanettes committed
        stdout = "{batch}/logs/pindel/{chrom}.o",
        stderr = "{batch}/logs/pindel/{chrom}.e",
        "mergepindelbatches.py {output.D} {input.D} 1>{log.stdout} 2>{log.stderr};\n"
        "mergepindelbatches.py {output.INV} {input.INV} 1>>{log.stdout} 2>>{log.stderr};\n"
        "mergepindelbatches.py {output.TD} {input.TD} 1>>{log.stdout} 2>>{log.stderr};\n"
        "rm -rf {wildcards.batch}/pindel/{wildcards.chrom}"