Skip to content

Commit

Permalink
Merge pull request #108 from CarsonJM/add-cobra
Browse files Browse the repository at this point in the history
Added cobra-meta and changed workflow figure
  • Loading branch information
CarsonJM authored Apr 18, 2024
2 parents 9daf563 + 96ba43a commit 129a138
Show file tree
Hide file tree
Showing 39 changed files with 1,895 additions and 9,377 deletions.
46 changes: 46 additions & 0 deletions bin/extract_viral_assemblies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python

import argparse
import pandas as pd
from Bio import SeqIO
import sys
import gzip


def parse_args(args=None):
Description = "Extract genomes identified as contained via mash screen, and append to the sample's FASTA assembly."
Epilog = "Example usage: python append_screen_hits.py <FILES_IN> <FILE_OUT>"

parser = argparse.ArgumentParser(description=Description, epilog=Epilog)
parser.add_argument(
"-v",
"--virus_fasta",
help="Path to virus FASTA file (gzipped) containing virus sequences.",
)
parser.add_argument(
"-o",
"--output",
help="Output TSV file containing the names of all viral assemblies.",
)
return parser.parse_args(args)


def extract_viral_assemblies(virus_fasta, output):

viral_assemblies = []
with gzip.open(virus_fasta, "rt") as reference_fasta_gunzip:
for record in SeqIO.parse(reference_fasta_gunzip, "fasta"):
viral_assemblies.append(record.id)

out = open(output, "w")
for sequence in viral_assemblies:
out.write(sequence + "\n")


def main(args=None):
args = parse_args(args)
extract_viral_assemblies(args.virus_fasta, args.output)


if __name__ == "__main__":
sys.exit(main())
Binary file modified docs/images/nf-core-phageannotator_workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9,230 changes: 1 addition & 9,229 deletions docs/images/nf-core-phageannotator_workflow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"bowtie2/align": {
"branch": "master",
"git_sha": "3c77ca9aac783e76c3614a06db3bfe4fef619bde",
"git_sha": "0fe30831abbc2ed115e46e92330edf38f56edc3d",
"installed_by": ["fastq_align_bowtie2"]
},
"bowtie2/build": {
Expand All @@ -46,6 +46,12 @@
"installed_by": ["modules"],
"patch": "modules/nf-core/checkv/endtoend/checkv-endtoend.diff"
},
"cobrameta": {
"branch": "master",
"git_sha": "647fb8e703ef352161eac8791ac0468e4727c4f7",
"installed_by": ["modules"],
"patch": "modules/nf-core/cobrameta/cobrameta.diff"
},
"fastqc": {
"branch": "master",
"git_sha": "f4ae1d942bd50c5c0b9bd2de1393ce38315ba57c",
Expand Down Expand Up @@ -158,7 +164,7 @@
},
"fastq_align_bowtie2": {
"branch": "master",
"git_sha": "5caf7640a9ef1d18d765d55339be751bb0969dfa",
"git_sha": "55e7bb6d5279ec21f254bbab0943117cb3d2fc35",
"installed_by": ["subworkflows"]
},
"initialise": {
Expand Down
7 changes: 7 additions & 0 deletions modules/local/extractviralassemblies/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- conda-forge::biopython=1.78
- conda-forge::pandas=1.3.5
49 changes: 49 additions & 0 deletions modules/local/extractviralassemblies/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
process EXTRACTVIRALASSEMBLIES {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/mulled-v2-80c23cbcd32e2891421c54d1899665046feb07ef:77a31e289d22068839533bf21f8c4248ad274b60-0' :
'biocontainers/mulled-v2-80c23cbcd32e2891421c54d1899665046feb07ef:77a31e289d22068839533bf21f8c4248ad274b60-0' }"

input:
tuple val(meta), path(virus_fasta_gz)

output:
tuple val(meta), path("${prefix}_viral_assemblies.tsv") , emit: viral_assemblies
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
extract_viral_assemblies.py \\
--virus_fasta ${virus_fasta_gz} \\
--output ${prefix}_viral_assemblies.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$( python --version | sed 's/Python //' )
biopython: \$(echo \$(biopython_version.py 2>&1))
pandas: \$(echo \$(pandas_version.py 2>&1))
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}_viral_assemblies.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$( python --version | sed 's/Python //' )
biopython: \$(echo \$(biopython_version.py 2>&1))
pandas: \$(echo \$(pandas_version.py 2>&1))
END_VERSIONS
"""
}
7 changes: 7 additions & 0 deletions modules/local/extractviralassemblies/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
process {
withName: EXTRACTVIRALASSEMBLIES {
publishDir = [
enabled: false
]
}
}
61 changes: 61 additions & 0 deletions modules/local/extractviralassemblies/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
nextflow_process {

name "Test process: EXTRACTVIRALASSEMBLIES"
script "../main.nf"
process "EXTRACTVIRALASSEMBLIES"

tag "modules"
tag "modules_local"
tag "extractviralassemblies"


test("fasta.gz") {

when {
params {
outdir = "$outputDir"
}
process {
"""
input[0] = [
[ id: 'test' ],
file(params.modules_testdata_base_path + "genomics/prokaryotes/bacteroides_fragilis/illumina/fasta/test1.contigs.fa.gz", checkifExists: true),
]
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}

test("fasta.gz - stub") {

options "-stub"

when {
params {
outdir = "$outputDir"
}
process {
"""
input[0] = [
[ id: 'test' ],
file(params.modules_testdata_base_path + "genomics/prokaryotes/bacteroides_fragilis/illumina/fasta/test1.contigs.fa.gz", checkifExists: true),
]
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
60 changes: 60 additions & 0 deletions modules/local/extractviralassemblies/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions modules/nf-core/bowtie2/align/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions modules/nf-core/bowtie2/align/tests/cram_crai.config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 129a138

Please sign in to comment.