forked from andreiaamaral/wgs_analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPopulation_genomics_nextflow
78 lines (59 loc) · 1.88 KB
/
Population_genomics_nextflow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* WGS Analysis Pipeline
* Usage: Hackathon 2, BovReg- Nextflow workshop 17-20 Nov 2020
* Author: All hackathon participants
*
*/
// Setting some defaults here,
// can be overridden in config or via command line
params.reads="/home/ec2-user/environment/data/ggal/*_{1,2}.*fq"
params.ref="/home/ec2-user/environment/data/ggal/transcriptome.fa"
params.outdir="/home/ec2-user/environment/result_alignment"
params.out = "${params.outdir}/out"
//params.tmpdir = "${params.outdir}/gatk_temp"
//params.snpeff_data = "${params.outdir}/snpeff_data"
// Print some stuff here
println "reads: $params.reads"
println "ref: $params.ref"
println "output: $params.out"
//println "gatk temp dir: $params.tmpdir"
//println "snpeff db: $params.snpeff_db"
//println "snpeff data: $params.snpeff_data"
// Setup the reference file
ref = file(params.ref)
/* Prepare the fastq read pairs for input.
* While doing this, count number of input samples
*/
num_samples = 0
Channel
.fromFilePairs( params.reads )
.ifEmpty { error "Cannot find any reads matching: ${params.reads}" }
.tap { read_pairs_ch }
.subscribe({ num_samples += 1 })
//read_pairs_ch.view()
process index {
input:
file transcriptome from ref
output:
//path 'index' into index_ch
file("*") into index_ch
script:
"""
bwa index ${transcriptome}
"""
}
//index_ch.view()
process align {
cpus 1
publishDir "${params.out}/aligned_reads", mode:'copy' // tells the output of the chanel it is created automatically by nextflow
input:
set pair_id, file(reads) from read_pairs_ch //the chanel creates the pair ids
file(index) from index_ch
output:
set val(pair_id), file("${pair_id}_aligned_reads.sam") \
into aligned_reads_ch
script:
"""
bwa mem ${ref} ${reads} > ${pair_id}_aligned_reads.sam
"""
}
aligned_reads_ch.view()