Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 2.08 KB | None | 0 0
  1. #!/usr/bin/env nextflow
  2.  
  3. // INPUT_FOLDER = "data/fastq_small"
  4. // REFERENCE = "data/cuc_reference.fasta"
  5. // PREFIX = "NLSOCC"
  6. // NLSOCC18-1459-A02_S2_L001_R2_001.fastq.gz
  7. params.reads = "$baseDir/data/fastq_small/*_R{1,2}_001.fastq.gz"
  8. params.genome = "$baseDir/data/cuc_reference.fasta"
  9.  
  10.  
  11. genome_file = file(params.genome)
  12. /*
  13.  * Create the `read_pairs` channel that emits tuples containing three elements:
  14.  * the pair ID, the first read-pair file and the second read-pair file
  15.  */
  16. Channel
  17.     .fromFilePairs( params.reads )
  18.     .ifEmpty { error "Cannot find any reads matching: ${params.reads}" }
  19. .set { read_pairs }
  20.  
  21. /*
  22.  * Step 1. Builds the genome index required by the mapping process
  23.  */
  24. process buildIndex {
  25.     publishDir 'results'
  26.     tag "$genome_file.baseName"
  27.    
  28.  
  29.     input:
  30.     file genome from genome_file
  31.      
  32.     output:
  33.     file genome_file.fileName + ".*" into genome_index
  34.        
  35.     """
  36.    bwa index ${genome} -p ${genome_file.fileName}
  37.    """
  38. }
  39.  
  40. /*
  41.  * Step 2. Maps each read-pair by using BWA
  42.  */
  43.  process mapping {
  44.     tag "$pair_id"
  45.     publishDir 'results'
  46.    
  47.     input:
  48.     file genome from genome_file
  49.     file index from genome_index
  50.     set pair_id, file(reads) from read_pairs
  51.  
  52.     output:
  53.     set pair_id, "*.bam" into bam
  54.  
  55.     """
  56.    bwa mem ${genome.fileName} ${reads[0]} ${reads[1]} | samtools view -b -q 20 > ${pair_id}.bam
  57.    """
  58. }
  59.  
  60.  
  61.  
  62. // process trim_reads {
  63. //   publishDir 'results'
  64.  
  65. //   tag "sampleId"
  66. //   input:
  67. //     set sampleId, file(reads) from read_pairs
  68. //   output:
  69. //     set sampleId, file '*.fastq.gz' into trimmed
  70. //   script:
  71. //   """
  72. //     echo cutadapt -a AGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGT -A AGATCGGAAGAGCGGTTCAGCAGGAATGCCGAG -q 20 -m 50 -o $sampleid"_R1.fastq.gz" -p $sampleid"_R2.fastq.gz" ${reads[0]} ${reads[1]}
  73. //   """
  74. // }
  75.  
  76. // process map_reads {
  77. //   publishDir 'results'
  78. //   input:
  79. //     set sampleId, file(reads) from trimmed
  80. //   output:
  81. //     file "*.bam" into mapped
  82. //   script:
  83. //   """
  84. //     echo bowtie2 $reads > $sampleId".aligned.bam"
  85. //   """
  86. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement