Skip to content

Commit

Permalink
feat: Bustools sort (#513)
Browse files Browse the repository at this point in the history
* [fix] (template): Missing code in wrappers' doc. Error #187

* bustools sort

* memory and tempdir used

* environment update

* fix typo

* Update bio/bustools/sort/environment.yaml

* Update bio/bustools/sort/test/Snakefile

Co-authored-by: tdayris <tdayris@gustaveroussy.fr>
Co-authored-by: tdayris <thibault.dayris@gustaveroussy.fr>
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
4 people committed Aug 16, 2022
1 parent 5360346 commit 1415748
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bio/bustools/sort/environment.yaml
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- bustools =0.41
- snakemake-wrapper-utils =0.4
17 changes: 17 additions & 0 deletions bio/bustools/sort/meta.yaml
@@ -0,0 +1,17 @@
name: bustools sort
description: Sort raw BUS output from pseudoalignment programs
url: https://github.com/BUStools/bustools#sort
author:
- Thibault Dayris
input:
- Path to bus file, or list of bus files
output:
- Path to bus file
params:
- extra: Optional parameters
notes: |
`--temp` is automatically defined through `resources.tmpdir`
`--memory` is automatically defined through `resources.mem_mb`
Multiple bus files in input will result in a single bus file in output.
14 changes: 14 additions & 0 deletions bio/bustools/sort/test/Snakefile
@@ -0,0 +1,14 @@
rule test_bustools_sort:
input:
"file.bus",
output:
"sorted.bus",
threads: 1
resources:
mem_mb=765,
params:
extra="--umi",
log:
"bustools.log",
wrapper:
"master/bio/bustools/sort"
Binary file added bio/bustools/sort/test/file.bus
Binary file not shown.
34 changes: 34 additions & 0 deletions bio/bustools/sort/wrapper.py
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# coding: utf-8

"""Snakemake wrapper for bustools sort"""

__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2022, Thibault Dayris"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"

from snakemake.shell import shell
from tempfile import TemporaryDirectory
from snakemake_wrapper_utils.snakemake import get_mem

log = snakemake.log_fmt_shell(stdout=True, stderr=True)
extra = snakemake.params.get("extra", "")

bus_files = snakemake.input
if isinstance(bus_files, list):
bus_files = " ".join(bus_files)

mem = get_mem(snakemake, "MiB")


with TemporaryDirectory() as tempdir:
shell(
"bustools sort "
"--memory {mem} "
"--temp {tempdir} "
"--threads {snakemake.threads} "
"--output {snakemake.output[0]} "
"{bus_files} "
"{log}"
)
8 changes: 8 additions & 0 deletions test.py
Expand Up @@ -273,6 +273,14 @@ def test_bustools_count():
["snakemake", "--cores", "1", "--use-conda", "-F", "buscount.mtx"]
)

@skip_if_not_modified
def test_bustools_sort():
run(
"bio/bustools/sort",
["snakemake", "--cores", "1", "--use-conda", "-F", "sorted.bus"]
)


@skip_if_not_modified
def test_open_cravat_module():
run(
Expand Down

0 comments on commit 1415748

Please sign in to comment.