|
| 1 | +/* |
| 2 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 3 | + VALIDATE INPUTS |
| 4 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 5 | +*/ |
| 6 | + |
| 7 | +def summary_params = NfcoreSchema.paramsSummaryMap(workflow, params) |
| 8 | + |
| 9 | +// Validate input parameters |
| 10 | +WorkflowViroprofiler.initialise(params, log) |
| 11 | + |
| 12 | +// TODO nf-core: Add all file path parameters for the pipeline to the list below |
| 13 | +// Check input path parameters to see if they exist |
| 14 | +def checkPathParamList = [ params.multiqc_config ] |
| 15 | +for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } } |
| 16 | + |
| 17 | + |
| 18 | +/* |
| 19 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 20 | + CONFIG FILES |
| 21 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 22 | +*/ |
| 23 | + |
| 24 | +ch_multiqc_config = file("$projectDir/assets/multiqc_config.yml", checkIfExists: true) |
| 25 | +ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config) : Channel.empty() |
| 26 | + |
| 27 | +/* |
| 28 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 29 | + IMPORT LOCAL MODULES/SUBWORKFLOWS |
| 30 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 31 | +*/ |
| 32 | + |
| 33 | +// |
| 34 | +// SUBWORKFLOW: Consisting of a mix of local and nf-core/modules |
| 35 | +// |
| 36 | +include { INPUT_CHECK } from '../subworkflows/local/input_check' |
| 37 | +include { vMAG_PHAMB; vMAG_VRHYME } from '../subworkflows/local/vMAG' |
| 38 | +include { SETUP } from '../subworkflows/local/init' |
| 39 | + |
| 40 | +/* |
| 41 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 42 | + IMPORT NF-CORE MODULES/SUBWORKFLOWS |
| 43 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 44 | +*/ |
| 45 | + |
| 46 | +// |
| 47 | +// MODULE: Installed directly from nf-core/modules |
| 48 | +// |
| 49 | + |
| 50 | + |
| 51 | +include { FASTQC } from '../modules/nf-core/modules/fastqc/main' |
| 52 | +include { MULTIQC } from '../modules/nf-core/modules/multiqc/main' |
| 53 | +include { CUSTOM_DUMPSOFTWAREVERSIONS } from '../modules/nf-core/modules/custom/dumpsoftwareversions/main' |
| 54 | +include { FASTP } from '../modules/nf-core/modules/fastp/main' |
| 55 | +include { SPADES } from '../modules/nf-core/modules/spades/main' |
| 56 | +include { BBMAP_ALIGN } from '../modules/nf-core/modules/bbmap/align/main' |
| 57 | +// local modules |
| 58 | +include { DECONTAM } from '../modules/local/decontam' |
| 59 | +include { CONTIGLIB; CONTIGLIB_CLUSTER } from '../modules/local/contig_library' |
| 60 | +include { MAPPING2CONTIGS; CONTIGINDEX; MAPPING2CONTIGS2; ABUNDANCE } from '../modules/local/abundance' |
| 61 | +include { BRACKEN_DB; BRACKEN; BRACKEN_COMBINEBRACKENOUTPUTS } from '../modules/local/bracken' |
| 62 | +include { DRAMV; EMAPPER; ABRICATE } from '../modules/local/annotation' |
| 63 | +include { VIRALHOST_IPHOP } from '../modules/local/viral_host' |
| 64 | +include { BACPHLIP; REPLIDEC } from '../modules/local/replicyc' |
| 65 | +include { CHECKV; VIRSORTER2; DVF; VIRCONTIGS_PRE; VIBRANT } from '../modules/local/viral_detection' |
| 66 | +include { GENEPRED as GENEPRED4CTG; NRSEQS as NRPROT; NRSEQS as NRGENE } from '../modules/local/gene_library' |
| 67 | +include { TAXONOMY_VCONTACT; TAXONOMY_MMSEQS; TAXONOMY_MERGE } from '../modules/local/taxonomy' |
| 68 | +include { RESULTS_TSE } from '../modules/local/base' |
| 69 | + |
| 70 | +/* |
| 71 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 72 | + RUN MAIN WORKFLOW |
| 73 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 74 | +*/ |
| 75 | + |
| 76 | +// Info required for completion email and summary |
| 77 | +def multiqc_report = [] |
| 78 | + |
| 79 | +workflow CONTIGANNO { |
| 80 | + ch_cclib = Channel.fromPath("${params.input_contigs}", checkIfExists: true).first() |
| 81 | + // MODULE: CheckV |
| 82 | + CHECKV(ch_cclib) |
| 83 | + clean_cclib_long = CHECKV.out.checkv_qc_ch |
| 84 | + ch_nrclib = clean_cclib_long |
| 85 | + |
| 86 | + // Gene library |
| 87 | + GENEPRED4CTG (clean_cclib_long, "ccclib_long") |
| 88 | + ch_prot_all = GENEPRED4CTG.out.prot_ch |
| 89 | + ch_gene_all = GENEPRED4CTG.out.gene_fna_ch |
| 90 | + |
| 91 | + // Non-redundant gene library |
| 92 | + NRPROT (ch_prot_all, "prot", params.prot_cluster_min_similarity, params.prot_cluster_min_coverage) |
| 93 | + ch_nr_prot = NRPROT.out.cluster_rep_ch |
| 94 | + NRGENE (ch_gene_all, "gene", params.gene_cluster_min_similarity, params.gene_cluster_min_coverage) |
| 95 | + ch_nr_gene = NRGENE.out.cluster_rep_ch |
| 96 | + |
| 97 | + // Gene/Protein annotation |
| 98 | + if (params.use_eggnog) { |
| 99 | + EMAPPER (ch_nr_prot) |
| 100 | + } |
| 101 | + if (params.use_abricate) { |
| 102 | + ABRICATE (ch_nr_gene) |
| 103 | + } |
| 104 | + |
| 105 | + |
| 106 | + // Viral detection: DVF + CheckV MQ, HQ, Complete + VirSorter2 + VIBRANT |
| 107 | + VIBRANT(ch_nrclib) |
| 108 | + DVF(ch_nrclib) |
| 109 | + ch_dvfscore = DVF.out.dvfscore_ch |
| 110 | + ch_dvfseq = DVF.out.dvfseq_ch |
| 111 | + ch_dvflist = DVF.out.dvflist_ch |
| 112 | + |
| 113 | + VIRCONTIGS_PRE(ch_nrclib, ch_dvflist, CHECKV.out.checkv2vContigs_ch, VIBRANT.out.vibrant_ch) |
| 114 | + ch_putative_vList = VIRCONTIGS_PRE.out.putative_vList_ch |
| 115 | + ch_putative_vContigs = VIRCONTIGS_PRE.out.putative_vContigs_ch |
| 116 | + vContigs_and_vMAGs = ch_putative_vContigs |
| 117 | + |
| 118 | + VIRSORTER2(ch_nrclib) // for DRAM-v gene annotation and AMG detection |
| 119 | + ch_vs2contigs = VIRSORTER2.out.vs2_contigs_ch |
| 120 | + |
| 121 | + // ANNOTATION (AMG) |
| 122 | + if ( params.use_dram ) { |
| 123 | + DRAMV (ch_vs2contigs, VIRSORTER2.out.vs2_affi_ch) |
| 124 | + } |
| 125 | + |
| 126 | + // Taxonomy |
| 127 | + TAXONOMY_VCONTACT(ch_nrclib) |
| 128 | + TAXONOMY_MMSEQS(ch_nrclib) |
| 129 | + TAXONOMY_MERGE(TAXONOMY_VCONTACT.out.taxa_vc_ch, TAXONOMY_MMSEQS.out.taxa_mmseqs_ch) |
| 130 | + |
| 131 | + // Viral host |
| 132 | + if ( params.use_iphop ) { |
| 133 | + VIRALHOST_IPHOP(ch_nrclib) |
| 134 | + } |
| 135 | + |
| 136 | + // Replication cycle |
| 137 | + BACPHLIP (ch_nrclib) |
| 138 | + ch_replicyc = BACPHLIP.out.bacphlip_ch |
| 139 | + |
| 140 | + // |
| 141 | + // MODULE: MultiQC |
| 142 | + // |
| 143 | + workflow_summary = WorkflowViroprofiler.paramsSummaryMultiqc(workflow, summary_params) |
| 144 | + ch_workflow_summary = Channel.value(workflow_summary) |
| 145 | +} |
| 146 | + |
| 147 | +/* |
| 148 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 149 | + COMPLETION EMAIL AND SUMMARY |
| 150 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 151 | +*/ |
| 152 | + |
| 153 | +workflow.onComplete { |
| 154 | + if (params.email || params.email_on_fail) { |
| 155 | + NfcoreTemplate.email(workflow, params, summary_params, projectDir, log, multiqc_report) |
| 156 | + } |
| 157 | + NfcoreTemplate.summary(workflow, params, log) |
| 158 | +} |
| 159 | + |
| 160 | +/* |
| 161 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 162 | + THE END |
| 163 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 164 | +*/ |
0 commit comments