-
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
c1a4e80
commit e0b20dd
Showing
1 changed file
with
38 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,38 @@ | ||
1. Question: How do you define a rule in Snakemake, and what are the essential components of a rule? | ||
|
||
Expected Answer: A rule in Snakemake is defined using the rule keyword followed by a rule name. Essential components include input, output, and shell or script. For example: | ||
Python | ||
``` | ||
rule example: | ||
input: "input_file.txt" | ||
output: "output_file.txt" | ||
shell: "cat {input} > {output}" | ||
``` | ||
|
||
2. Question: How does Snakemake handle dependencies between rules, and how can you specify that one rule depends on the output of another? | ||
|
||
Expected Answer: Snakemake handles dependencies by specifying the output of one rule as the input of another. This creates a directed acyclic graph (DAG) of jobs. For example: | ||
Python | ||
``` | ||
rule first_rule: | ||
output: "intermediate_file.txt" | ||
shell: "echo 'data' > {output}" | ||
|
||
rule second_rule: | ||
input: "intermediate_file.txt" | ||
output: "final_output.txt" | ||
shell: "cat {input} > {output}" | ||
``` | ||
|
||
3. Question: What are wildcards in Snakemake, and how are they used in rule definitions? | ||
Expected Answer: Wildcards in Snakemake are placeholders that match parts of filenames and allow for flexible rule definitions. They are enclosed in curly braces {}. For example: | ||
Python | ||
``` | ||
rule all: | ||
input: expand("results/{sample}.txt", sample=["sample1", "sample2"]) | ||
|
||
rule process: | ||
input: "data/{sample}.txt" | ||
output: "results/{sample}.txt" | ||
shell: "cp {input} {output}" | ||
``` |