Hello, I'm sorry if this is poorly written, it's my first time writing code with Snakemake, and my professor has given no instructions on how to deal with troubleshooting! I haven't found much help online because we're writing in Python, not Bash. I am getting an error code Expecting rule keyword, comment or docstrings inside a rule definition
with the line genotypes= pd.read_table(str(input))
that my professor wrote! Any help would be appreciated
import pandas as pd
PEOPLE = ["X", "M"]
rule all:
input: expand("snaketest/{person}_homozygous.txt", person=PEOPLE)
rule create_genotype_counts:
input: "/local-scratch/course_files/MBB110/fixed_genotypes/{person}_genotypes.txt"
output: "snaketest/{person}_counts.txt"
run:
genotypes= pd.read_table(str(input)) |
[genotypes.chromosome.isin(["X", "Y", "MT"])] |
[genotypes.genotype.isin(["--"])] |
table1=genotypes.genotype.value_counts()
out = open(str(output),"w")
out.write(table1)
out.close()
I believe you want
genotypes= pd.read_table(str({input}))
, perhaps? The curly brackets mean to take the Snakemake directive setting in that context. Without that curly bracket, it would use what Python has as theinput
object. In a pure Python contextinput
is a function to get user input from the command line. (Probably, a similar things for a later line involvingout =
. ) Your professor may have been hurriedly writing that and just forgot. (Or there is more instruction that you aren't sharing here as in that is a sketch of pseudocode and you are meant to make it work.) In the future, consult with your professor. You'll be programming with no safety net soon enough. For now take advantage of the resources you have to help you learn. "my professor has given no instructions on how to deal with troubleshooting! " usually means they assume you'll be consulting with them to troubleshoot.my professor says " We are using python now, so instead of using the "shell:" part of the pipeline, we will be using "run:" . NOTE: when you use "run:", you do not have to use the curly brackets ({ and }) around input and output, BUT we do have a weird issue with snakemake in that we have to convert out input and output filenames to strings. I have provided the first line for this rule that shows you how to do this:"
Then, it's the example in my file! I don't see any examples like this here, lecture material, or in the documentation, so I am very confused about what to do! Unfortunately, my professor is unavailable until this is due (they are very absent from this course, and we only have limited time to talk with the TA)! If you point me to some non-bash resources, I would be very grateful!