I have been trying to write a simple alignment pipeline with Snakemake. Unfortunately, I have a hard time understanding the error messages. In the example below, the message " 'str' object has no attribute 'name' " is a bit cryptic. Does it means that the expression {input.r1} is incorrect?
import os
import snakemake.io
import glob
(SAMPLES,READS,) = glob_wildcards("{sample}_{read}.fastq.gz")
READS=["1","2"]
rule all:
input: expand("{sample}.bam",sample=SAMPLES)
rule bwa_map:
input:
ref="path/to/ref.fasta",
r1="{sample}_1.fastq.gz",
r2="{sample}_2.fastq.gz"
output: "{sample}.bam"
shell: "bwa mem {input.ref} {input.r1} {input.r2} | samtools view -Sbh - > {output}"
snakemake -n
Building DAG of jobs...
Traceback (most recent call last):
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/snakemake/__init__.py", line 701, in snakemake
success = workflow.execute(
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/snakemake/workflow.py", line 1066, in execute
logger.run_info("\n".join(dag.stats()))
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/snakemake/dag.py", line 2191, in stats
yield tabulate(rows, headers="keys")
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/tabulate/__init__.py", line 2048, in tabulate
list_of_lists, headers = _normalize_tabular_data(
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/tabulate/__init__.py", line 1471, in _normalize_tabular_data
rows = list(map(lambda r: r if _is_separating_line(r) else list(r), rows))
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/tabulate/__init__.py", line 1471, in <lambda>
rows = list(map(lambda r: r if _is_separating_line(r) else list(r), rows))
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/tabulate/__init__.py", line 107, in _is_separating_line
(len(row) >= 1 and row[0] == SEPARATING_LINE)
File "/mnt/shared/scratch/usr/apps/conda/lib/python3.8/site-packages/snakemake/rules.py", line 1138, in __eq__
return self.name == other.name and self.output == other.output
AttributeError: 'str' object has no attribute 'name'
It is working, the same error did not show up. Another error show up ("Missing input files for rule all:"), but I think it is more linked to my dataset.
I don't understand the logic of it. The output: and shell: lines are included in the rule bwa_map:, why not indenting them??