bashawkanacondanextflow

2 processes but not related in nextflow pipeline


i have 2 processes but it is not related to the next one here: FASTQC_check and FASTQC_1 this means I don't care about the input of FASTQC_1 but I want FASTQC_check to run after FASTQC_1 completes (i want to print the screen when everything done)! what should I do? I tried the.out but it can solve my problem!

workflow {
  read_pairs_ch = Channel.fromFilePairs(params.reads)
  fastqc= FASTQC(read_pairs_ch)
  trimmomatic(read_pairs_ch)
  **FASTQC_1**(trimmomatic.out)
  **FASTQC_check**(FASTQC_1.out)
  if (FASTQC_check.out) {
    Channel
      .fromPath('/home/dungnguyen/genepanel/bin/data3.txt')  
      .splitText()
      .view { 
        println it 
      }

  }

Solution

  • My initial thought was that you could use the state dependency pattern for this, but I think you could just as easily pass down the sample names to the FASTQC_check process, for example:

    process FASTQC_1 {
    
        tag { sample }
    
        input:
        tuple val(sample), path(fastq)
    
        output:
        tuple val(sample), path "*_fastqc.{zip,html}"
    
        """
        fastqc -q "${fastq}"
        """
    }
    
    process FASTQC_check {
    
        tag { sample }
    
        input:
        val sample
    
        """
        # do something
        """
    }
    
    workflow {
    
        read_pairs_ch = Channel.fromFilePairs(params.reads)
    
        FASTQC(read_pairs_ch)
        trimmomatic(read_pairs_ch)
        FASTQC_1(trimmomatic.out)
    
        FASTQC_1.out
            .map { sample, fastqc -> sample }
            .set { ready_ch }
    
        FASTQC_check(ready_ch)
    }
    

    If FASTQC_check should run after all instances of FASTQC_1, you could call collect to produce a ready signal for example:

    process FASTQC_check {
    
        input:
        val ready
    
        """
        # do something
        """
    }
    
    workflow {
    
        ...
    
        FASTQC_1.out
            .map { sample, fastqc -> sample }
            .collect()
            .set { ready_ch }
    
        FASTQC_check(ready_ch)
    }