Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow bam input files #94

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .test/config/units.tsv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sample unit fragment_len_mean fragment_len_sd fq1 fq2
sample unit fragment_len_mean fragment_len_sd fq1 fq2 bam_single bam_paired
A 1 ngs-test-data/reads/a.chr21.1.fq ngs-test-data/reads/a.chr21.2.fq
B 1 ngs-test-data/reads/b.chr21.1.fq ngs-test-data/reads/b.chr21.2.fq
B 2 300 14 ngs-test-data/reads/b.chr21.1.fq
Expand Down
2 changes: 1 addition & 1 deletion .test/three_prime/config/units.tsv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sample unit fragment_len_mean fragment_len_sd fq1 fq2
sample unit fragment_len_mean fragment_len_sd fq1 fq2 bam_single bam_paired
SRR8309096 u1 430 43 quant_seq_test_data/SRR8309096.fastq.gz
SRR8309094 u1 430 43 quant_seq_test_data/SRR8309094.fastq.gz
SRR8309095 u1 430 43 quant_seq_test_data/SRR8309095.fastq.gz
Expand Down
2 changes: 1 addition & 1 deletion config/units.tsv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sample unit fragment_len_mean fragment_len_sd fq1 fq2
sample unit fragment_len_mean fragment_len_sd fq1 fq2 bam_single bam_paired
A 1 raw/a.chr21.1.fq raw/a.chr21.2.fq
B 1 raw/b.chr21.1.fq raw/b.chr21.2.fq
B 2 300 14 raw/b.chr21.1.fq
Expand Down
27 changes: 27 additions & 0 deletions workflow/rules/bam.smk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
rule separate_bam_paired:
fxwiegand marked this conversation as resolved.
Show resolved Hide resolved
input:
"{bam_file}.bam",
output:
"{bam_file}.1.fq",
"{bam_file}.2.fq",
fxwiegand marked this conversation as resolved.
Show resolved Hide resolved
log:
"{bam_file}.separate.log",
params:
fastq="-n",
threads: 3
wrapper:
"v3.10.2/bio/samtools/fastq/separate"


rule samtools_fastq_interleaved:
fxwiegand marked this conversation as resolved.
Show resolved Hide resolved
input:
"{bam_file}.bam",
output:
"{bam_file}.fq",
log:
"{bam_file}.interleaved.log",
params:
" ",
threads: 3
wrapper:
"v3.10.2/bio/samtools/fastq/interleaved"
15 changes: 14 additions & 1 deletion workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,20 @@ def is_single_end(sample, unit):

def get_fastqs(wildcards):
"""Get raw FASTQ files from unit sheet."""
if is_single_end(wildcards.sample, wildcards.unit):
if not pd.isnull(units.loc[(wildcards.sample, wildcards.unit), "bam_single"]):
fqfrombam = units.loc[(wildcards.sample, wildcards.unit), "bam_single"].replace(
".bam", ".fq"
)
return fqfrombam
elif not pd.isnull(units.loc[(wildcards.sample, wildcards.unit), "bam_paired"]):
fqfrombam1 = units.loc[
(wildcards.sample, wildcards.unit), "bam_paired"
].replace(".bam", ".1.fq")
fqfrombam2 = units.loc[
(wildcards.sample, wildcards.unit), "bam_paired"
].replace(".bam", ".2.fq")
return [fqfrombam1, fqfrombam2]
elif is_single_end(wildcards.sample, wildcards.unit):
return units.loc[(wildcards.sample, wildcards.unit), "fq1"]
else:
u = units.loc[(wildcards.sample, wildcards.unit), ["fq1", "fq2"]].dropna()
Expand Down
8 changes: 5 additions & 3 deletions workflow/rules/quant.smk
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
rule kallisto_index:
input:
fasta="resources/transcriptome.cdna.without_poly_a.fasta"
if is_3prime_experiment
else "resources/transcriptome.cdna.fasta",
fasta=(
"resources/transcriptome.cdna.without_poly_a.fasta"
if is_3prime_experiment
else "resources/transcriptome.cdna.fasta"
),
output:
index="results/kallisto_cdna/transcripts.cdna.idx",
log:
Expand Down
Loading