Thanks for the help, I have modified the script and this specific problem has been solved:
import os
import snakemake.io
import glob
import pandas as pd
# Config file
configfile: "config/config.yaml"
# Load the samples table:
table=pd.read_csv("config/samples_reads.tsv", delim_whitespace=True)
# Use the samples table to make lists of samples names/lists:
SAMPLES=table['sample'].to_list()
R1=table['fq1'].to_list()
R2=table['fq2'].to_list()
# The first rule (here rule all) specifies the files that you would like to create during your snakemake workflow.
rule all:
input:
expand("mapped/{sample}.bam", sample=SAMPLES)
rule bwa_mem:
input:
reads=[expand("reads/{read1}", read1=R1 ), expand("reads/{read2}", read2=R2)],
idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"),
output:
expand("mapped/{sample}.bam", sample=SAMPLES),
log:
expand("logs/bwa_mem/{sample}.log", sample=SAMPLES),
params:
extra=r"-R '@RG\tID:{sample}\tSM:{sample}'",
sorting="none", # Can be 'none', 'samtools' or 'picard'.
sort_order="queryname", # Can be 'queryname' or 'coordinate'.
sort_extra="", # Extra args for samtools/picard.
threads: 8
wrapper:
"v2.6.0/bio/bwa/mem"
However, this method to input samples and reads with different names does not work, it seems Snakemake does not like when samples and reads names differ.
Building DAG of jobs...
MissingInputException in rule bwa_mem in file /mnt/shared/scratch/usr/comp_baits_pseudo-chr/baits/workflow/Snakefile, line 31:
Missing input files for rule bwa_mem:
output: mapped/A.bam, mapped/B.bam, mapped/C.bam
affected files:
reads/110802_0249_AD0CM0ABXX_3_SA-PE-022.1.fq.gz
reads/110627_0240_AC0254ABXX_2_SA-PE-001.2.fq.gz
reads/110627_0240_AC0254ABXX_2_SA-PE-001.1.fq.gz
reads/110802_0249_AD0CM0ABXX_3_SA-PE-022.2.fq.gz
reads/110627_0240_AC0254ABXX_2_SA-PE-002.2.fq.gz
reads/110627_0240_AC0254ABXX_2_SA-PE-002.1.fq.gz
If anyone has a way around it, I would be interested in.