Skip to content

Commit

Permalink
feat: Handle trimmed fastqs plus additional fixes (#252)
Browse files Browse the repository at this point in the history
* feat: Handle trimmed fastqs

* update github action

* update github action

* temp update all actions

* Update to stable github action
  • Loading branch information
FelixMoelder committed Aug 7, 2023
1 parent 520e361 commit 13ae724
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Lint workflow
uses: snakemake/snakemake-github-action@v1.24.0
uses: snakemake/snakemake-github-action@v1.25.0
with:
directory: .
snakefile: workflow/Snakefile
Expand All @@ -50,21 +50,23 @@ jobs:
directory: .test
snakefile: workflow/Snakefile
args: "--configfile .test/config-simple/config.yaml --use-conda --show-failed-logs -j 10 --conda-cleanup-pkgs cache"
show-disk-usage-on-error: true

- name: Test testcase generation
uses: snakemake/snakemake-github-action@v1
with:
directory: .test
snakefile: workflow/Snakefile
args: "results/testcases/a/freebayes/IX:314200 --configfile .test/config-simple/config.yaml --use-conda --show-failed-logs -j 10 --conda-cleanup-pkgs cache"
show-disk-usage-on-error: true

- name: Test report
uses: snakemake/snakemake-github-action@v1
with:
directory: .test
snakefile: workflow/Snakefile
args: "--configfile .test/config-simple/config.yaml --report report.zip"

show-disk-usage-on-error: true

- name: Test workflow (local FASTQs, target regions)
uses: snakemake/snakemake-github-action@v1
Expand All @@ -74,6 +76,7 @@ jobs:
args: "--configfile .test/config-target-regions/config.yaml --use-conda --show-failed-logs -j 10 --conda-cleanup-pkgs cache"
stagein: |
rm -rf .test/results
show-disk-usage-on-error: true

- name: Test workflow (local FASTQs, multiple target regions BED files)
uses: snakemake/snakemake-github-action@v1
Expand All @@ -83,6 +86,7 @@ jobs:
args: "--configfile .test/config-target-regions/config_multiple_beds.yaml --use-conda --show-failed-logs -j 10 --conda-cleanup-pkgs cache"
stagein: |
rm -rf .test/results
show-disk-usage-on-error: true

- name: Test workflow (local FASTQs, no candidate filtering)
uses: snakemake/snakemake-github-action@v1
Expand All @@ -92,6 +96,7 @@ jobs:
args: "--configfile .test/config-no-candidate-filtering/config.yaml --dryrun --use-conda --show-failed-logs -j 10 --conda-cleanup-pkgs cache"
stagein: |
rm -rf .test/results
show-disk-usage-on-error: true

- name: Test workflow (local FASTQs primer)
uses: snakemake/snakemake-github-action@v1
Expand All @@ -101,6 +106,7 @@ jobs:
args: "--configfile .test/config_primers/config.yaml --use-conda --show-failed-logs -j 10 --conda-cleanup-pkgs cache"
stagein: |
rm -rf .test/results
show-disk-usage-on-error: true

- name: Test workflow (SRA FASTQs)
uses: snakemake/snakemake-github-action@v1
Expand All @@ -110,3 +116,4 @@ jobs:
args: "--configfile .test/config-sra/config.yaml --show-failed-logs --use-conda -n -j 10 --conda-cleanup-pkgs cache"
stagein: |
rm -rf .test/results
show-disk-usage-on-error: true
2 changes: 1 addition & 1 deletion workflow/rules/annotation.smk
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ rule annotate_variants:
"logs/vep/{group}.{scatteritem}.annotate.log",
threads: get_vep_threads()
wrapper:
"v1.31.1/bio/vep/annotate"
"v2.2.1/bio/vep/annotate"


# TODO What about multiple ID Fields?
Expand Down
6 changes: 3 additions & 3 deletions workflow/rules/candidate_calling.smk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ rule freebayes:
ref_idx=genome_fai,
regions="results/regions/{group}.expanded_regions.filtered.bed",
# you can have a list of samples here
samples=lambda w: get_group_bams(w),
indexes=lambda w: get_group_bams(w, bai=True),
alns=lambda w: get_group_bams(w),
idxs=lambda w: get_group_bams(w, bai=True),
output:
"results/candidate-calls/{group}.freebayes.bcf",
log:
Expand All @@ -19,7 +19,7 @@ rule freebayes:
),
threads: max(workflow.cores - 1, 1) # use all available cores -1 (because of the pipe) for calling
wrapper:
"v1.19.0/bio/freebayes"
"v2.3.0/bio/freebayes"


rule delly:
Expand Down
32 changes: 19 additions & 13 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -796,12 +796,16 @@ def get_untrimmed_fastqs(wc):


def get_trimmed_fastqs(wc):
return expand(
"results/trimmed/{sample}/{unit}_{read}.fastq.gz",
unit=units.loc[wc.sample, "unit_name"],
sample=wc.sample,
read=wc.read,
)
if units.loc[wc.sample, "adapters"].notna().all():
return expand(
"results/trimmed/{sample}/{unit}_{read}.fastq.gz",
unit=units.loc[wc.sample, "unit_name"],
sample=wc.sample,
read=wc.read,
)
else:
fq = "fq1" if wc.read == "R1" or wc.read == "single" else "fq2"
return units.loc[wc.sample, fq]


def get_umi_fastq(wc):
Expand Down Expand Up @@ -844,6 +848,7 @@ def get_vembrane_config(wildcards, input):
"CANONICAL",
"MANE_PLUS_CLINICAL",
{"name": "clinical significance", "expr": "ANN['CLIN_SIG']"},
{"name": "gnomad genome af", "expr": "ANN['gnomADg_AF']"},
]

annotation_fields.extend(
Expand Down Expand Up @@ -1006,13 +1011,14 @@ def get_fastqc_results(wildcards):
)

# cutadapt
pattern = "results/trimmed/{unit.sample_name}/{unit.unit_name}.{mode}.qc.txt"
yield from expand(
pattern, unit=sample_units[paired_end_units].itertuples(), mode="paired"
)
yield from expand(
pattern, unit=sample_units[~paired_end_units].itertuples(), mode="single"
)
if sample_units["adapters"].notna().all():
pattern = "results/trimmed/{unit.sample_name}/{unit.unit_name}.{mode}.qc.txt"
yield from expand(
pattern, unit=sample_units[paired_end_units].itertuples(), mode="paired"
)
yield from expand(
pattern, unit=sample_units[~paired_end_units].itertuples(), mode="single"
)

# samtools idxstats
yield from expand("results/qc/{sample}.bam.idxstats", sample=group_samples)
Expand Down

0 comments on commit 13ae724

Please sign in to comment.