-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtable_annovar.nf
86 lines (72 loc) · 3.17 KB
/
table_annovar.nf
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
79
80
81
82
83
84
85
86
params.help = null
params.output_folder = "."
params.table_extension = "tsv"
params.cpu = 1
params.annovar_db = "Annovar_db/"
params.mem = 4
params.buildver = "hg38"
params.annovar_params = "--codingarg includesnp -protocol ensGene,exac03nontcga,esp6500siv2_all,1000g2015aug_all,gnomad211_genome,gnomad211_exome,clinvar_20190305,revel,dbnsfp35a,dbnsfp31a_interpro,intervar_20180118,cosmic84_coding,cosmic84_noncoding,avsnp150,phastConsElements100way,wgRna -operation g,f,f,f,f,f,f,f,f,f,f,f,f,f,r,r -otherinfo "
if (params.help) {
log.info ''
log.info '--------------------------------------------------------------'
log.info 'table_annovar-nf 1.1.1: Nextflow pipeline to run TABLE ANNOVAR'
log.info '--------------------------------------------------------------'
log.info ''
log.info 'Usage: '
log.info 'nextflow run table_annovar.nf --table_folder myinputfolder'
log.info ''
log.info 'Mandatory arguments:'
log.info ' --table_folder FOLDER Folder containing tables to process.'
log.info 'Optional arguments:'
log.info ' --cpu INTEGER Number of cpu used by annovar (default: 1).'
log.info ' --mem INTEGER Size of memory (in GB) (default: 4).'
log.info ' --output_folder FOLDER Folder where output is written.'
log.info ' --table_extension STRING Extension of input tables (default: tsv).'
log.info ' --annovar_db FOLDER Folder with annovar databases (default: Annovar_db)'
log.info ' --buildver STRING Version of genome build (default: hg38)'
log.info ' --annovar_params STRING Parameters given to table_annovar.pl (default: multiple databases--see README)'
log.info ''
exit 0
}
log.info "table_folder=${params.table_folder}"
tables = Channel.fromPath( params.table_folder+'/*.'+params.table_extension)
.ifEmpty { error "empty table folder, please verify your input." }
annodb = file( params.annovar_db )
process annovar {
cpus params.cpu
memory params.mem+'G'
tag { file_name }
input:
file table from tables
file annodb
output:
file "*multianno*.txt" into output_annovar_txt
file "*multianno*.vcf" optional true into output_annovar_vcf
file "*.fa" optional true into coding_changes_fasta
publishDir params.output_folder, mode: 'copy', pattern: '{*.txt}'
publishDir "${params.output_folder}/coding_changes", mode: 'copy', pattern: '{*.fa}'
shell:
if(params.table_extension=="vcf"|params.table_extension=="vcf.gz"){
vcf="--vcfinput -nastring ."
}else{
vcf="-nastring NA "
}
file_name = table.baseName
'''
table_annovar.pl -buildver !{params.buildver} --thread !{params.cpu} --onetranscript !{vcf} !{params.annovar_params} !{table} !{annodb} -out !{file_name}
'''
}
process CompressAndIndex {
tag { vcf_name }
input:
file(vcf) from output_annovar_vcf
output:
set file("*.vcf.gz"), file("*.vcf.gz.tbi") into output_annovar_vcfgztbi
publishDir params.output_folder, mode: 'copy'
shell:
vcf_name = vcf.baseName
'''
bcftools view -O z !{vcf} > !{vcf_name}.vcf.gz
bcftools index -t !{vcf_name}.vcf.gz
'''
}