Я хотел бы объединить результаты нескольких файлов CSV из программы ABRICATE (github.com/tseemann/abricate) в один файл CSV.
Следующий snakefile запускает папку с файлами fasta, создавая отдельные csv для каждого fast. Я хотел бы объединить эти результаты в один CSV-файл, но не уверен, как создать «все правила».
Есть предложения?
Ниже мой рабочий файл змеи. Спасибо
########################### snakefile making dictionary
import os
import yaml
file_list = []
### location assumes that data is in results_fasta/ folder
for entry in os.scandir("results_fasta/"):
if entry.is_file():
file_list.append(entry.name)
#### this tells split the file for use in dictionary creation
config_dict = {"samples":{i.split(".")[0]:"results_fasta/"+i for i in file_list}}
with open("config_abricate_resfinder.yaml","w") as handle:
yaml.dump(config_dict,handle)
###### dictionary created using all files located in results_fasta folder
configfile: "config_abricate_resfinder.yaml"
##### not needed but used to say what is currently running
print("Starting abricate workflow")
##### rule all is a general rule that says this is the results we are lookin for in the end.
rule all:
input:
expand("abricate_resfinder/{sample}_abricate_resfinder.csv", sample = config["samples"])
##### Abricate resfinder
rule resfinder:
input:
lambda wildcards: config["samples"][wildcards.sample]
params:
db_resfinder = "leaveblank", ### for resfinder DB is default so leave blank
type = "csv"
output:
res = "abricate_resfinder/{sample}_abricate_resfinder.csv",
######## log file is empty. need to print stdout to log
log:
"logs/{sample}_resfinder.log"
shell:
"abricate {input} --{params.type} > {output.res}"