Skip to content
Snippets Groups Projects
Select Git revision
  • 1f25c4c5c3615e919c1fda528d26f2458e96b7b6
  • master default protected
  • dev
  • v2.0.0
  • v0.4.0
  • v0.3.0
  • v0.2.9
  • v0.2.8
  • v0.2.7
  • v0.2.6
  • v0.1.0
  • v0.2.5
  • v0.2.4
  • v0.2.3
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.2
18 results

quantification_single.nf

Blame
  • Laurent Modolo's avatar
    Laurent Modolo authored
    099b8b5e
    History
    quantification_single.nf 1.44 KiB
    params.fastq = "$baseDir/data/fastq/*.fastq"
    params.index = "$baseDir/data/index/*.index*"
    params.mean = 200
    params.sd = 100
    
    log.info "fastq files : ${params.fastq}"
    log.info "index files : ${params.index}"
    log.info "mean read size: ${params.mean}"
    log.info "sd read size: ${params.sd}"
    
    Channel
      .fromPath( params.fastq )
      .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" }
      .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
      .set { fastq_files }
    Channel
      .fromPath( params.index )
      .ifEmpty { error "Cannot find any index files matching: ${params.index}" }
      .set { index_files }
    
    process mapping_fastq {
      tag "$file_id"
      publishDir "results/mapping/quantification/", mode: 'copy'
    
      input:
      set file_id, file(reads) from fastq_files
      file index from index_files.collect()
    
      output:
      file "*" into count_files
    
      script:
      index_id = index[0]
      for (index_file in index) {
        if (index_file =~ /.*\.1\.bt2/ && !(index_file =~ /.*\.rev\.1\.bt2/)) {
            index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1]
        }
      }
    """
    rsem-calculate-expression --bowtie2 \
    --bowtie2-path \$(which bowtie2 | sed 's/bowtie2\$//g') \
    --bowtie2-sensitivity-level "very_sensitive" \
    --fragment-length-mean ${params.mean} --fragment-length-sd ${params.sd} \
    --output-genome-bam -p ${task.cpus} \
    ${reads} ${index_id} ${file_id} \
    2> ${file_id}_rsem_bowtie2_report.txt
    
    if grep -q "Error" ${file_id}_rsem_bowtie2_report.txt; then
      exit 1
    fi
    """
    }