-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
113 lines (91 loc) · 3.67 KB
/
main.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
// Define parameters for input/output directories and paths
params.tumor_list = null // Path to tumor BAM list (txt file)
params.normal_list = null // Path to normal BAM list (txt file)
params.reference = null // Path to the reference genome (FASTA file)
params.out_dir = "./nanofrag_results" // Directory to save output metrics
params.threads = 12 // Number of threads
params.skip_small_variants = true // Whether to skip small variants (flag)
if (params.help) {
log.info """
Nanofrag Analysis
=============================================
Usage:
nextflow run main.nf --tumor_list <file> --normal_list <file> --reference <file> --out_dir <dir> --threads <number>
Input:
* --tumor_list: path to the text file listing tumor BAM files
* --normal_list: path to the text file listing normal BAM files
* --reference: path to the reference genome (FASTA file)
* --out_dir: output directory. Default [${params.out_dir}]
* --threads: number of threads. Default [${params.threads}]
* --skip_small_variants: flag to skip small variants. Default [${params.skip_small_variants}]
"""
exit 0
}
// Ensure mandatory parameters are provided
if (!params.tumor_list || !params.normal_list || !params.reference) {
throw new IllegalArgumentException("Missing required parameters: --tumor_list, --normal_list, or --reference")
}
// Ensure the output directory exists
if (!new File(params.out_dir).exists()) {
new File(params.out_dir).mkdirs()
}
// Create channels for inputs
tumor_list = Channel.fromPath(params.tumor_list)
normal_list = Channel.fromPath(params.normal_list)
reference = Channel.fromPath(params.reference)
process runNanofrag {
tag "nanofrag"
memory '12 GB'
cpus params.threads
conda params.conda_yaml
input:
path tumor_list
path normal_list
path reference
output:
script:
"""
echo "Running Nanofrag with tumor list ${tumor_list}, normal list ${normal_list}, and reference genome ${reference}..."
python3 ${projectDir}/bin/nanofrag/nanofrag.py \\
--tumor_list ${tumor_list} \\
--normal_list ${normal_list} \\
--reference ${reference} \\
--output_dir . \\
--threads ${params.threads} \\
${params.skip_small_variants ? '--skip_small_variants' : ''}
"""
}
// Workflow definition
workflow {
runNanofrag(tumor_list, normal_list, reference)
}
workflow.onComplete {
println "Nanofrag analysis completed successfully. Results are saved in '${params.out_dir}'."
}
// process fragmentExtractor {
// tag "${bam_file.simpleName}" // Tag the process with the BAM filename
// memory '2 GB'
// input:
// path bed_file
// path bam_file
// path bai_file
// output:
// path "${bam_file.simpleName}_fragments.bed" // Output BED file
// path "${bam_file.simpleName}_fragments.wig" // Output WIG file
// script:
// """
// echo "Processing ${bam_file} with ${bed_file}..."
// fragment_extractor ${bam_file} ${bed_file} \
// ${bam_file.simpleName}_fragments.bed \
// ${bam_file.simpleName}_fragments.wig
// """
// }
// // Workflow definition
// workflow {
// results = fragmentExtractor(windows_bed, bam_files, bai_files)
// }
// workflow.onComplete {
// println "Workflow execution completed successfully. Fragmentation metrics are saved in the '${params.out_dir}' directory."
// }