-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1003 from maxplanck-ie/allelic_frombam
Allelic frombam
- Loading branch information
Showing
12 changed files
with
168 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,74 @@ | ||
import os | ||
|
||
rule link_bam: | ||
input: | ||
indir + "/{sample}" + bamExt | ||
output: | ||
aligner + "/{sample}.unsorted.bam" if pipeline=="noncoding-rna-seq" else aligner + "/{sample}.bam" | ||
params: | ||
input_bai = indir + "/{sample}" + bamExt + ".bai", | ||
output_bai = aligner + "/{sample}.unsorted.bam.bai" if pipeline=="noncoding-rna-seq" else aligner + "/{sample}.bam.bai" | ||
run: | ||
if os.path.exists(params.input_bai) and not os.path.exists(os.path.join(outdir,params.output_bai)): | ||
os.symlink(params.input_bai,os.path.join(outdir,params.output_bai)) | ||
if not os.path.exists(os.path.join(outdir,output[0])): | ||
os.symlink(os.path.join(outdir,input[0]),os.path.join(outdir,output[0])) | ||
|
||
if not pipeline=="noncoding-rna-seq": | ||
if pipeline=="rna-seq" and "allelic-counting" in mode: | ||
rule link_bam: | ||
input: | ||
indir + "/{sample}.{suffix}" + bamExt | ||
output: | ||
"allelic_bams/{sample}.{suffix}" + bamExt | ||
params: | ||
input_bai = indir + "/{sample}.{suffix}" + bamExt + ".bai", | ||
output_bai = "allelic_bams/{sample}.{suffix}" + bamExt + ".bai" | ||
run: | ||
if os.path.exists(params.input_bai) and not os.path.exists(os.path.join(outdir,params.output_bai)): | ||
os.symlink(params.input_bai,os.path.join(outdir,params.output_bai)) | ||
if not os.path.exists(os.path.join(outdir,output[0])): | ||
os.symlink(os.path.join(outdir,input[0]),os.path.join(outdir,output[0])) | ||
|
||
rule samtools_index_external: | ||
input: | ||
aligner + "/{sample}.bam" | ||
"allelic_bams/{sample}.{suffix}" + bamExt | ||
output: | ||
aligner + "/{sample}.bam.bai" | ||
"allelic_bams/{sample}.{suffix}" + bamExt + ".bai" | ||
conda: CONDA_SHARED_ENV | ||
shell: "if [[ ! -f {output[0]} ]]; then samtools index {input[0]}; fi" | ||
|
||
if not pipeline=="WGBS" or pipeline=="WGBS" and skipBamQC: | ||
rule link_bam_bai_external: | ||
|
||
else: | ||
rule link_bam: | ||
input: | ||
indir + "/{sample}" + bamExt | ||
output: | ||
aligner + "/{sample}.unsorted.bam" if pipeline=="noncoding-rna-seq" else aligner + "/{sample}.bam" | ||
params: | ||
input_bai = indir + "/{sample}" + bamExt + ".bai", | ||
output_bai = aligner + "/{sample}.unsorted.bam.bai" if pipeline=="noncoding-rna-seq" else aligner + "/{sample}.bam.bai" | ||
run: | ||
if os.path.exists(params.input_bai) and not os.path.exists(os.path.join(outdir,params.output_bai)): | ||
os.symlink(params.input_bai,os.path.join(outdir,params.output_bai)) | ||
if not os.path.exists(os.path.join(outdir,output[0])): | ||
os.symlink(os.path.join(outdir,input[0]),os.path.join(outdir,output[0])) | ||
|
||
if not pipeline=="noncoding-rna-seq": | ||
rule samtools_index_external: | ||
input: | ||
bam = aligner + "/{sample}.bam", | ||
bai = aligner + "/{sample}.bam.bai" | ||
aligner + "/{sample}.bam" | ||
output: | ||
bam_out = "filtered_bam/{sample}.filtered.bam", | ||
bai_out = "filtered_bam/{sample}.filtered.bam.bai", | ||
shell: """ | ||
ln -s ../{input.bam} {output.bam_out}; | ||
ln -s ../{input.bai} {output.bai_out} | ||
""" | ||
|
||
|
||
rule sambamba_flagstat: | ||
input: | ||
aligner + "/{sample}.bam" | ||
output: | ||
"Sambamba/{sample}.markdup.txt" | ||
log: "Sambamba/logs/{sample}.flagstat.log" | ||
conda: CONDA_SAMBAMBA_ENV | ||
shell: """ | ||
sambamba flagstat -p {input} > {output} 2> {log} | ||
""" | ||
aligner + "/{sample}.bam.bai" | ||
conda: CONDA_SHARED_ENV | ||
shell: "if [[ ! -f {output[0]} ]]; then samtools index {input[0]}; fi" | ||
|
||
if not pipeline=="WGBS" or pipeline=="WGBS" and skipBamQC: | ||
rule link_bam_bai_external: | ||
input: | ||
bam = aligner + "/{sample}.bam", | ||
bai = aligner + "/{sample}.bam.bai" | ||
output: | ||
bam_out = "filtered_bam/{sample}.filtered.bam", | ||
bai_out = "filtered_bam/{sample}.filtered.bam.bai", | ||
shell: """ | ||
ln -s ../{input.bam} {output.bam_out}; | ||
ln -s ../{input.bai} {output.bai_out} | ||
""" | ||
|
||
|
||
rule sambamba_flagstat: | ||
input: | ||
aligner + "/{sample}.bam" | ||
output: | ||
"Sambamba/{sample}.markdup.txt" | ||
log: "Sambamba/logs/{sample}.flagstat.log" | ||
conda: CONDA_SAMBAMBA_ENV | ||
shell: """ | ||
sambamba flagstat -p {input} > {output} 2> {log} | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.