It uses GTDB-tk to taxonomically annotate your genomes and to build a tree.
Run as follows:
dbdir="databases"
genome_dir="genomes"
snakemake --use-conda --conda-prefix "$dbdir/conda_envs" \ --config database_dir="$dbdir" genome_dir="$genome_dir"
where
dbdir
is the path to a (shared) directory to place the GTDB database and conda envs.
genome_dir
should be the folder containing all genome fastas.
This code was developped as part of metagenome-atlas . Don't forget to cite the GTDB-tk
Code Snippets
28 29 | shell: " wget {GTDB_DATA_URL} -O {output} &> {log} " |
44 45 46 47 | shell: 'tar -xzvf {input} -C "{GTDBTK_DATA_PATH}" --strip 1 2> {log}; ' 'echo "Set the GTDBTK_DATA_PATH environment variable to {GTDBTK_DATA_PATH} " >> {log}; ' "conda env config vars set GTDBTK_DATA_PATH={GTDBTK_DATA_PATH} " |
68 69 70 71 72 73 | shell: "gtdbtk identify " "--genome_dir {input.dir} " " --out_dir {params.outdir} " "--extension {params.extension} " "--cpus {threads} &> {log[0]}" |
91 92 93 | shell: "gtdbtk align --identify_dir {params.outdir} --out_dir {params.outdir} " "--cpus {threads} &> {log[0]}" |
114 115 116 117 118 119 | shell: "gtdbtk classify --genome_dir {input.genome_dir} --align_dir {params.outdir} " "--out_dir {params.outdir} " " --tmpdir {resources.tmpdir} " "--extension {params.extension} " "--cpus {threads} &> {log[0]}" |
130 131 | script: "../scripts/combine_taxonomy.py" |
147 148 149 150 151 152 | shell: "gtdbtk infer --msa_file {input} " " --out_dir {params.outdir} " " --prefix {wildcards.msa} " " --cpus {threads} " "--tmpdir {resources.tmpdir} " |
174 175 | script: "../scripts/root_tree.py" |
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import os, sys import logging, traceback logging.basicConfig( filename=snakemake.log[0], level=logging.INFO, format="%(asctime)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) def handle_exception(exc_type, exc_value, exc_traceback): if issubclass(exc_type, KeyboardInterrupt): sys.__excepthook__(exc_type, exc_value, exc_traceback) return logging.error( "".join( [ "Uncaught exception: ", *traceback.format_exception(exc_type, exc_value, exc_traceback), ] ) ) # Install exception handler sys.excepthook = handle_exception #### Begining of scripts import pandas as pd import numpy as np from utils.taxonomy import tax2table from glob import glob gtdb_classify_folder = snakemake.input.folder taxonomy_files = glob(f"{gtdb_classify_folder}/gtdbtk.*.summary.tsv") N_taxonomy_files = len(taxonomy_files) logging.info(f"Found {N_taxonomy_files} gtdb taxonomy files.") if (0 == N_taxonomy_files) or (N_taxonomy_files > 2): raise Exception( f"Found {N_taxonomy_files} number of taxonomy files 'gtdbtk.*.summary.tsv' in {gtdb_classify_folder} expect 1 or 2." ) DT = pd.concat([pd.read_table(file, index_col=0) for file in taxonomy_files], axis=0) DT.to_csv(snakemake.output.combined) Tax = tax2table(DT.classification, remove_prefix=True) Tax.to_csv(snakemake.output.taxonomy, sep="\t") |
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import sys, os import logging, traceback logging.basicConfig( filename=snakemake.log[0], level=logging.INFO, format="%(asctime)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) def handle_exception(exc_type, exc_value, exc_traceback): if issubclass(exc_type, KeyboardInterrupt): sys.__excepthook__(exc_type, exc_value, exc_traceback) return logging.error( "".join( [ "Uncaught exception: ", *traceback.format_exception(exc_type, exc_value, exc_traceback), ] ) ) # Install exception handler sys.excepthook = handle_exception # start import ete3 T = ete3.Tree(str(snakemake.input.tree), quoted_node_names=False, format=1) try: T.unroot(mode="keep") if len(T) > 2: T.set_outgroup(T.get_midpoint_outgroup()) except Exception as e: logging.error("Failed to root tree, keep unrooted. Reason was:\n\n" + str(e)) T.write(outfile=snakemake.output.tree) |
Support
Do you know this workflow well? If so, you can
request seller status , and start supporting this workflow.
Created: 1yr ago
Updated: 1yr ago
Maitainers:
public
URL:
https://github.com/SilasK/snake_gtdbtk
Name:
snake_gtdbtk
Version:
1
Downloaded:
0
Copyright:
Public Domain
License:
None
Keywords:
- Future updates
Related Workflows

ENCODE pipeline for histone marks developed for the psychENCODE project
psychip pipeline is an improved version of the ENCODE pipeline for histone marks developed for the psychENCODE project.
The o...

Near-real time tracking of SARS-CoV-2 in Connecticut
Repository containing scripts to perform near-real time tracking of SARS-CoV-2 in Connecticut using genomic data. This pipeli...

snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...

ATLAS - Three commands to start analyzing your metagenome data
Metagenome-atlas is a easy-to-use metagenomic pipeline based on snakemake. It handles all steps from QC, Assembly, Binning, t...
raw sequence reads
Genome assembly
Annotation track
checkm2
gunc
prodigal
snakemake-wrapper-utils
MEGAHIT
Atlas
BBMap
Biopython
BioRuby
Bwa-mem2
cd-hit
CheckM
DAS
Diamond
eggNOG-mapper v2
MetaBAT 2
Minimap2
MMseqs
MultiQC
Pandas
Picard
pyfastx
SAMtools
SemiBin
Snakemake
SPAdes
SqueezeMeta
TADpole
VAMB
CONCOCT
ete3
gtdbtk
h5py
networkx
numpy
plotly
psutil
utils
metagenomics

RNA-seq workflow using STAR and DESeq2
This workflow performs a differential gene expression analysis with STAR and Deseq2. The usage of this workflow is described ...

This Snakemake pipeline implements the GATK best-practices workflow
This Snakemake pipeline implements the GATK best-practices workflow for calling small germline variants. The usage of thi...