Skip to content

Commit

Permalink
feat: genefuse wrapper (#493)
Browse files Browse the repository at this point in the history
* feat: genefuse wrapper

* fix: set strict mode for conda channels

* feat: write output files to a temp folder

* docs: update meta data

* Removed format

* Added URL

* Changed extra

* Removed format

* Removed format

* Removed format

* Removed format

* Removed patch version

Co-authored-by: Filipe G. Vieira <fgarrettvieira@gmail.com>
  • Loading branch information
Smeds and fgvieira committed Aug 30, 2022
1 parent 7bf2233 commit 9bcf282
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Expand Up @@ -19,7 +19,7 @@ jobs:
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
pip install -r docs/requirements.txt
- name: Test doc generation
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
Expand Down Expand Up @@ -57,6 +57,6 @@ jobs:
# activate conda env
export PATH="/usr/share/miniconda/bin:$PATH"
source activate snakemake
# run tests
pytest test.py -v
6 changes: 6 additions & 0 deletions bio/genefuse/environment.yaml
@@ -0,0 +1,6 @@
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- genefuse=0.6
15 changes: 15 additions & 0 deletions bio/genefuse/meta.yaml
@@ -0,0 +1,15 @@
name: GeneFuse
description: A tool to detect and visualize target gene fusions by scanning FASTQ files directly.
url: https://github.com/OpenGene/GeneFuse
authors:
- Patrik Smeds
input:
- fastq files
- gene fuse settings files
- refeference genome
output:
- txt file with fusions
- html report
- json report
notes: |
* The `extra` param allows for additional program arguments.
18 changes: 18 additions & 0 deletions bio/genefuse/test/Snakefile
@@ -0,0 +1,18 @@
rule genefuse:
input:
fastq1="reads/{sample}_R1.fastq",
fastq2="reads/{sample}_R2.fastq",
config="genes.csv",
reference="genome.fasta",
output:
html="{sample}_genefuse_report.html",
json="{sample}_genefuse_report.json",
fusions="{sample}_fusions.txt",
log:
"logs/{sample}_genefuse.log",
params:
# optional parameters
extra="",
threads:1
wrapper:
"master/bio/genefuse"
7 changes: 7 additions & 0 deletions bio/genefuse/test/genes.csv
@@ -0,0 +1,7 @@
>GENE,chr1:10-70
1,15,20
2,25,30
3,35,40
4,45,50
5,55,60
6,65,70
2 changes: 2 additions & 0 deletions bio/genefuse/test/genome.fasta
@@ -0,0 +1,2 @@
>chr1
GCTAGCTCAGAAAAAAAAAAGATGCGAGGCGTAGGCGATGCGATCGATCGATCTATAGGCTCGAGGCTAGGGCTAGCTGA
4 changes: 4 additions & 0 deletions bio/genefuse/test/reads/a_R1.fastq
@@ -0,0 +1,4 @@
@1
CTCAGGAGGC
+
!!!!!!!!!!
4 changes: 4 additions & 0 deletions bio/genefuse/test/reads/a_R2.fastq
@@ -0,0 +1,4 @@
@1
CTCAGGAGGC
+
!!!!!!!!!!
41 changes: 41 additions & 0 deletions bio/genefuse/wrapper.py
@@ -0,0 +1,41 @@
__author__ = "Patrik Smeds"
__copyright__ = "Copyright 2022, Patrik Smeds"
__email__ = "patrik.smeds@scilifelab.uu.se"
__license__ = "MIT"


from snakemake.shell import shell
from tempfile import TemporaryDirectory

# Formats the log redrection string
log = snakemake.log_fmt_shell(stdout=False, stderr=True)

extra = snakemake.params.get("extra", "")

with TemporaryDirectory() as tempdir:
# Executed shell command
html_path = f"{tempdir}/genefuse.html"
json_path = f"{tempdir}/genefuse.json"
txt_path = f"{tempdir}/gene_fuse_fusions.txt"
shell(
"(genefuse "
"-r {snakemake.input.reference} "
"-t {snakemake.threads} "
"-f {snakemake.input.config} "
"-1 {snakemake.input.fastq1} "
"-2 {snakemake.input.fastq2} "
"-h {html_path} "
"-j {json_path} "
"{extra} > "
"{txt_path}) "
"{log}"
)

if snakemake.output.get("html", None):
shell("mv {html_path} {snakemake.output.html}")

if snakemake.output.get("json", None):
shell("mv {json_path} {snakemake.output.json}")

if snakemake.output.get("fusions", None):
shell("mv {txt_path} {snakemake.output.fusions}")
8 changes: 8 additions & 0 deletions test.py
Expand Up @@ -4510,6 +4510,14 @@ def test_vep_annotate():
)


@skip_if_not_modified
def test_genefuse():
run(
"bio/genefuse",
["snakemake", "--cores", "1", "--use-conda", "-F", "a_fusions.txt", "a_genefuse_report.html"],
)


@skip_if_not_modified
def test_genomepy():
# download dm3 genome (relatively small, +/- 250 mb)
Expand Down

0 comments on commit 9bcf282

Please sign in to comment.