Skip to content

Commit

Permalink
feat: Add filtering based on N50
Browse files Browse the repository at this point in the history
- Static initially
  • Loading branch information
jvfe committed Sep 4, 2023
1 parent 59bfa75 commit 4e8649e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
20 changes: 20 additions & 0 deletions subworkflows/local/assemblyqc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,27 @@ workflow CHECK_ASSEMBLIES {
ch_software_versions = ch_software_versions.mix(QUAST.out.versions.ifEmpty(null))
ch_multiqc_files = ch_multiqc_files.mix(QUAST.out.tsv.collect())

filtered_assemblies = assemblies

if (params.apply_filtering) {
println 'WARNING: Your assemblies are being filtered \n(--apply_filtering is true)'

QUAST.out.transposed_report
.splitCsv(header: true, sep: '\t')
.filter { row -> row.N50.toFloat() > 100000}
.map { row -> row.Assembly }
.set { to_keep }

filtered_assemblies
.combine (to_keep.collect().map { [it] })
.filter { meta, path, to_keep -> (path.getSimpleName() in to_keep) }
.map { it[0, 1] }
.set { filtered_assemblies }

}

emit:
filtered_assemblies
quast_report = QUAST.out.transposed_report
assemblyqc_software = ch_software_versions
multiqc = ch_multiqc_files
Expand Down
12 changes: 11 additions & 1 deletion workflows/arete.nf
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ workflow ARETE {
)
ch_software_versions = ch_software_versions.mix(CHECK_ASSEMBLIES.out.assemblyqc_software)

if (params.apply_filtering) {
CHECK_ASSEMBLIES.out.filtered_assemblies
.set { assemblies }
}

if (db_cache) {
/////////////////// ANNOTATION ///////////////////////////
ANNOTATE_ASSEMBLIES(
Expand Down Expand Up @@ -365,14 +370,19 @@ workflow ANNOTATION {

ANNOTATION_INPUT_CHECK.out.genomes.set { assemblies }

if (params.run_recombination) {
if (params.run_recombination || params.apply_filtering) {
CHECK_ASSEMBLIES(
assemblies,
ch_reference_genome,
use_reference_genome
)
ch_software_versions = ch_software_versions.mix(CHECK_ASSEMBLIES.out.assemblyqc_software)
ch_multiqc_files = ch_multiqc_files.mix(CHECK_ASSEMBLIES.out.multiqc)

if (params.apply_filtering) {
CHECK_ASSEMBLIES.out.filtered_assemblies
.set { assemblies }
}
}


Expand Down

0 comments on commit 4e8649e

Please sign in to comment.