-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add module to extract distances * feat: Incorporate subsampling into main workflows * test: Add test for subsampling subworkflow * chore: Remove commented out code * test: Add subsetting to poppunk test * test: Add subsetting to test profile * fix: Change way of setting distance output * refactor: Extract distances should be part of subsetting * test: Change test to use popdb * test: Fix poppunk trace size * refactor: Update default threshold * feat: Write removed genomes to a file * test: Update similarity * feat: Add poppunk entry * fix: Change variable declaration * refactor: Change calculus * test: Update subsampling test
- Loading branch information
Showing
14 changed files
with
265 additions
and
26 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
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
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,32 @@ | ||
process POPPUNK_EXTRACT_DISTANCES { | ||
label 'process_high' | ||
|
||
conda (params.enable_conda ? "bioconda::poppunk=2.6.0" : null) | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/poppunk:2.6.0--py39h9b916c0_0': | ||
'quay.io/biocontainers/poppunk:2.6.0--py39h9b916c0_0' }" | ||
|
||
input: | ||
|
||
path poppunk_db | ||
|
||
output: | ||
|
||
path "poppunk_db_distances.tsv", emit: poppunk_distances | ||
path "versions.yml", emit: versions | ||
|
||
script: | ||
def args = task.ext.args ?: '' | ||
|
||
""" | ||
poppunk_extract_distances.py \\ | ||
--distances $poppunk_db/${poppunk_db}.dists \\ | ||
--output poppunk_db_distances.tsv \\ | ||
$args | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
poppunk: \$(echo \$(poppunk --version 2>&1) | sed 's/^.*poppunk //;') | ||
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,33 @@ | ||
name: poppunk_extract_distances | ||
description: Extract pairwise distances between genomes | ||
keywords: | ||
- genomes | ||
- poppunk | ||
- database | ||
- distances | ||
tools: | ||
- poppunk: | ||
description: Population partitioning using nucleotide k-mers | ||
homepage: https://poppunk.net/ | ||
documentation: https://poppunk.readthedocs.io/en/latest/ | ||
tool_dev_url: https://github.com/bacpop/PopPUNK | ||
doi: "doi:10.1101/gr.241455.118" | ||
licence: ["Apache-2.0"] | ||
|
||
input: | ||
- poppunk_db: | ||
type: directory | ||
description: Directory containing the PopPunk database | ||
|
||
output: | ||
- poppunk_distances: | ||
type: file | ||
description: TSV file containing pairwise distances | ||
pattern: "poppunk_db_distances.tsv" | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
|
||
authors: | ||
- "@jvfe" |
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
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,36 @@ | ||
include { POPPUNK_EXTRACT_DISTANCES } from '../../modules/local/poppunk/extractdistances/main' | ||
|
||
workflow SUBSET_GENOMES { | ||
|
||
take: | ||
genome_assemblies | ||
poppunk_db | ||
|
||
main: | ||
|
||
POPPUNK_EXTRACT_DISTANCES(poppunk_db) | ||
POPPUNK_EXTRACT_DISTANCES.out.poppunk_distances.set{ poppunk_distances } | ||
|
||
def core_threshold = 100.0 - params.core_similarity | ||
def accessory_threshold = 100.0 - params.accessory_similarity | ||
|
||
poppunk_distances | ||
.splitCsv(header: true, sep: '\t') | ||
.filter { row -> (row.Core.toFloat() * 100) < core_threshold && (row.Accessory.toFloat() * 100) < accessory_threshold } | ||
.map { row -> row.Query } | ||
.set { genomes_to_remove } | ||
|
||
genomes_to_remove | ||
.unique() | ||
.collectFile(newLine: true) | ||
.collectFile(name: 'removed_genomes.txt', storeDir: "${params.outdir}/poppunk_results") | ||
|
||
genome_assemblies | ||
.combine (genomes_to_remove.collect().map { [it] }) | ||
.filter { meta, path, to_remove -> !(meta.id in to_remove) } | ||
.map { it[0, 1] } | ||
.set { filtered_genomes } | ||
|
||
emit: | ||
filtered_genomes = filtered_genomes | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,44 @@ | ||
nextflow_workflow { | ||
|
||
name "Test Workflow SUBSET_GENOMES" | ||
script "subworkflows/local/subsample.nf" | ||
workflow "SUBSET_GENOMES" | ||
|
||
test("Subsampling subworkflow runs without failures") { | ||
|
||
when { | ||
params { | ||
// define parameters here. Example: | ||
outdir = "$outputDir" | ||
core_similarity = 99 | ||
accessory_similarity = 95 | ||
} | ||
workflow { | ||
""" | ||
// define inputs of the workflow here. Example: | ||
input[0] = Channel.of( | ||
[[id:'SRR14022735'], "$baseDir/test/SRR14022735_T1.scaffolds.fa"], | ||
[[id:'SRR14022737'], "$baseDir/test/SRR14022737_T1.scaffolds.fa"], | ||
[[id:'SRR14022754'], "$baseDir/test/SRR14022754_T1.scaffolds.fa"], | ||
[[id:'SRR14022764'], "$baseDir/test/SRR14022764_T1.scaffolds.fa"], | ||
) | ||
input[1] = Channel.fromPath("$baseDir/test/popdb") | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assert workflow.success | ||
assert workflow.out.filtered_genomes.size() == 3 | ||
assert workflow.out.filtered_genomes.toList() == [ | ||
[['id':'SRR14022735'], "$baseDir/test/SRR14022735_T1.scaffolds.fa"], | ||
[['id':'SRR14022754'], "$baseDir/test/SRR14022754_T1.scaffolds.fa"], | ||
[['id':'SRR14022764'], "$baseDir/test/SRR14022764_T1.scaffolds.fa"] | ||
] | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.