Advertisement
Guest User

Untitled

a guest
May 5th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.99 KB | None | 0 0
  1. readPATH = params.reads
  2. genome = file(params.genome)
  3. iterations = params.itr
  4. outDir = params.out
  5. single = "no"
  6. runDir = params.runDir
  7.  
  8. genome_base = "${genome.getBaseName()}"
  9. genome_file = "${genome.getName()}"
  10. genome_path = "${genome.getParent()}"
  11.  
  12. fastqFILES = Channel.empty()
  13.  
  14. if (readPATH) {
  15.   readFiles = file(readPATH)
  16.   fastqFILES = extractFastq(readFiles)
  17. }
  18.  
  19. (fastqFILES, readMapping) = fastqFILES.into(2)
  20.  
  21. process index {
  22.     tag { "Genome: $genome_base" }
  23.     publishDir '$outDir', mode:'copy', overwrite: true
  24.     input:
  25.     file fasta from genome
  26.     output:
  27.     file "${outDir}" into index
  28.     shell:
  29.     """
  30.    Refindex.py --itr 1 --ref ${fasta} --out ${outDir}
  31.    """
  32.     }
  33. process mapping {
  34.     tag { "Mapping: $idSample" }
  35.     publishDir "$outDir", mode:'copy', overwrite: true
  36.     input:
  37.     set idSample, file(read1), file(read2) from readMapping
  38.     file genome_index from index
  39.     output:
  40.     file "${outDir}" into mapping
  41.     script:
  42.     """
  43.    ReadMapping.py --itr 1 --r1 ${fastqFile1} --r2 ${fastqFile2} --out ${outDir}
  44.    """
  45.   }
  46. process assembly {
  47.     tag { "Assembly: $idSample" }
  48.     publishDir "$outDir", mode:'copy', overwrite: true
  49.     input:
  50.     file reads from mapping
  51.     output:
  52.     file "${outDir}" into assembly
  53.     script:
  54.     """
  55.    ContigAssembly.py --itr 1 --out ${outDir}
  56.    """
  57.  
  58. def extractFastq(readFiles) {
  59.   return fastqFILES = Channel
  60.     .from(readFiles.readLines())
  61.     .map{line ->
  62.       list       = checkTSV(line.split(),4)
  63.       idSample   = list[0]
  64.       idRun      = list[1]
  65.       fastqFile1 = list[2]
  66.       fastqFile2 = list[3]
  67.       //checkFileExtension(FastqFile1,".fastq.gz")
  68.       //checkFileExtension(FastqFile2,".fastq.gz")
  69.       [idSample, idRun, fastqFile1, fastqFile2]
  70.     }
  71. }
  72.  
  73. def checkTSV(it, number) {
  74.   // Check if TSV has the correct number of items in row
  75.   if (it.size() != number) {
  76.     exit 1, "Malformed row in TSV file: $it, see --help for more information"
  77.   }
  78.   return it
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement