챕터 11 - 최종 Snakefile - 복습과 토론
다음은 네 개의 게놈을 비교하는 최종 Snakefile입니다.
이 Snakemake 워크플로의 특징은 다음과 같습니다:
Snakefile 상단에 접근 번호 목록이 하나 있어, 한 곳만 수정하면 더 많은 게놈을 추가할 수 있습니다. 자세한 내용은
expand로 파일 이름 목록 만들기를 참고하세요.워크플로는 기본 규칙
all을 사용합니다. 이것은 입력 파일만 포함하는 “의사 규칙(pseudo-rule)”으로, 명령줄에서 대상 없이 Snakemake를 실행할 때 기본으로 실행되는 규칙입니다. 대상 및 Snakefile 구조에 대한 내용은 명령줄에서 규칙 실행 및 대상 선택을 참고하세요.워크플로는 하나의 와일드카드 규칙
sketch_genome을 사용하여.fna.gz로 끝나는 여러 게놈 파일을 sourmash 서명 파일로 변환합니다. 와일드카드에 대한 자세한 내용은 와일드카드로 규칙 일반화하기를 참고하세요.compare_genomes규칙은expand를 사용하여sourmash compare실행에 필요한 전체 게놈 서명 목록을 구성합니다. 자세한 내용은expand문서를 참고하세요.마지막 규칙
plot_comparison은compare_genomes의 출력을 받아 제공된 셸 명령을 통해sourmash plot으로 PNG 이미지로 변환합니다.
ACCESSIONS = ["GCF_000017325.1",
"GCF_000020225.1",
"GCF_000021665.1",
"GCF_008423265.1"]
rule all:
input:
"compare.mat.matrix.png"
rule sketch_genome:
input:
"genomes/{accession}.fna.gz",
output:
"{accession}.fna.gz.sig",
shell: """
sourmash sketch dna -p k=31 {input} --name-from-first
"""
rule compare_genomes:
input:
expand("{acc}.fna.gz.sig", acc=ACCESSIONS),
output:
"compare.mat"
shell: """
sourmash compare {input} -o {output}
"""
rule plot_comparison:
message: "sourmash로 모든 입력 게놈을 비교합니다"
input:
"compare.mat"
output:
"compare.mat.matrix.png"
shell: """
sourmash plot {input}
"""이후 섹션에서는 이 Snakefile에서 사용된 Snakemake의 핵심 기능들을 더 자세히 다루고, 좀 더 복잡한 생물정보학 워크플로와 여러 유용한 패턴 및 재사용 가능한 레시피도 소개할 것입니다.