Skip to content

Commit

Permalink
feat: hifiasm wrapper (#510)
Browse files Browse the repository at this point in the history
* Added hifiasm wrapper

* Finished doc

* Added some files to keep memory usage down

* Update bio/hifiasm/environment.yaml

* Update test.py

Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
fgvieira and johanneskoester committed Aug 16, 2022
1 parent bb050e4 commit 5360346
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bio/hifiasm/environment.yaml
@@ -0,0 +1,6 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- hifiasm =0.16
12 changes: 12 additions & 0 deletions bio/hifiasm/meta.yaml
@@ -0,0 +1,12 @@
name: Hifiasm
description: A haplotype-resolved assembler for accurate Hifi reads
url: https://github.com/chhylp123/hifiasm
authors:
- Filipe G. Vieira
input:
- PacBio HiFi reads (fasta)
- Hi-C reads (fastq; optional)
output:
- assembly graphs (GFA)
notes: |
* The `extra` param allows for additional program arguments.
34 changes: 34 additions & 0 deletions bio/hifiasm/test/Snakefile
@@ -0,0 +1,34 @@
rule hifiasm:
input:
fasta=[
"reads/HiFi_dataset_01.fasta.gz",
"reads/HiFi_dataset_02.fasta.gz",
],
# optional
# hic1="reads/Hi-C_dataset_R1.fastq.gz",
# hic2="reads/Hi-C_dataset_R2.fastq.gz",
output:
multiext(
"hifiasm/{sample}.",
"a_ctg.gfa",
"a_ctg.lowQ.bed",
"a_ctg.noseq.gfa",
"p_ctg.gfa",
"p_ctg.lowQ.bed",
"p_ctg.noseq.gfa",
"p_utg.gfa",
"p_utg.lowQ.bed",
"p_utg.noseq.gfa",
"r_utg.gfa",
"r_utg.lowQ.bed",
"r_utg.noseq.gfa",
),
log:
"logs/hifiasm/{sample}.log",
params:
extra="--primary -f 37 -l 1 -s 0.75 -O 1",
threads: 2
resources:
mem_mb=1024,
wrapper:
"master/bio/hifiasm"
Binary file added bio/hifiasm/test/hifiasm/a.ec.bin
Binary file not shown.
Binary file added bio/hifiasm/test/hifiasm/a.ovlp.reverse.bin
Binary file not shown.
Binary file added bio/hifiasm/test/hifiasm/a.ovlp.source.bin
Binary file not shown.
Binary file added bio/hifiasm/test/reads/HiFi_dataset_01.fasta.gz
Binary file not shown.
Binary file added bio/hifiasm/test/reads/HiFi_dataset_02.fasta.gz
Binary file not shown.
38 changes: 38 additions & 0 deletions bio/hifiasm/wrapper.py
@@ -0,0 +1,38 @@
__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2022, Filipe G. Vieira"
__license__ = "MIT"


import os
from snakemake.shell import shell


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


hic1 = snakemake.input.get("hic1", "")
if hic1:
if isinstance(hic1, list):
hic1 = ",".join(hic1)
hic1 = "--h1 {}".format(hic1)

hic2 = snakemake.input.get("hic2", "")
if hic2:
if isinstance(hic2, list):
hic2 = ",".join(hic2)
hic2 = "--h2 {}".format(hic2)


out_prefix = os.path.commonprefix(snakemake.output).rstrip(".")


shell(
"hifiasm"
" -t {snakemake.threads}"
" {extra}"
" {hic1} {hic2}"
" -o {out_prefix}"
" {snakemake.input.fasta}"
" {log}"
)
8 changes: 8 additions & 0 deletions test.py
Expand Up @@ -140,6 +140,14 @@ def run(wrapper, cmd, check_log=None):



@skip_if_not_modified
def test_hifiasm():
run(
"bio/hifiasm",
["snakemake", "--cores", "2", "hifiasm/a.a_ctg.gfa", "--use-conda", "-F"],
)


@skip_if_not_modified
def meryl_count():
run(
Expand Down

0 comments on commit 5360346

Please sign in to comment.