-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0b20dd
commit 2f86c09
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
1. Question: How do you define a process in Nextflow, and what are the key components of a process? | ||
Expected Answer: A process in Nextflow is defined using the process keyword followed by a process name. Key components include input, output, and script. For example: | ||
Groovy | ||
``` | ||
process example { | ||
input: | ||
path 'input_file.txt' | ||
|
||
output: | ||
path 'output_file.txt' | ||
|
||
script: | ||
""" | ||
cat input_file.txt > output_file.txt | ||
""" | ||
} | ||
``` | ||
2. Question: How do channels work in Nextflow, and how are they used to pass data between processes? | ||
Expected Answer: Channels in Nextflow are used to pass data between processes. They can be created using the Channel factory methods and are specified in the input and output directives of processes. For example: | ||
Groovy | ||
``` | ||
Channel.fromPath('input_file.txt').set { input_channel } | ||
|
||
process first_process { | ||
input: | ||
path input_file from input_channel | ||
|
||
output: | ||
path 'intermediate_file.txt' into intermediate_channel | ||
|
||
script: | ||
""" | ||
cp $input_file intermediate_file.txt | ||
""" | ||
} | ||
|
||
process second_process { | ||
input: | ||
path intermediate_file from intermediate_channel | ||
|
||
output: | ||
path 'final_output.txt' | ||
|
||
script: | ||
""" | ||
cp $intermediate_file final_output.txt | ||
""" | ||
} | ||
``` | ||
|
||
3. Question: How does Nextflow enable parallel execution of tasks, and what are some ways to control the parallelism? | ||
Expected Answer: Nextflow enables parallel execution of tasks by default, as each process can run independently. Parallelism can be controlled using the maxForks parameter to limit the number of concurrent tasks, and by specifying resources like cpus and memory in the process definition. For example: | ||
Groovy | ||
``` | ||
process example { | ||
cpus 4 | ||
memory '8 GB' | ||
|
||
input: | ||
path 'input_file.txt' | ||
|
||
output: | ||
path 'output_file.txt' | ||
|
||
script: | ||
""" | ||
cat input_file.txt > output_file.txt | ||
""" | ||
} | ||
|
||
workflow { | ||
example(maxForks: 2) | ||
} | ||
``` |