-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from CarsonJM/add-cobra
Added cobra-meta and changed workflow figure
- Loading branch information
Showing
39 changed files
with
1,895 additions
and
9,377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
process { | ||
withName: EXTRACTVIRALASSEMBLIES { | ||
publishDir = [ | ||
enabled: false | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
60
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.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.