https://github.com/NCBI-Hackathons/MetagenomicAntibioticResistance.git
630
(doi: 10.12688/f1000research.12781.1)
Antibiotic resistance (AMR) of bacterial pathogens is a growing public health threat around the world. Fast and reliable extraction of antimicrobial resistance genomic signatures from large raw sequencing datasets obtained from human metagenomes is a key task for bioinformatics.
NastyBugs is a versatile workflow for fast extracting of antimicrobial resistance genomic signatures from metagenomic sequencing data.
Objective: Create a reusable, reproducible, scalable, and interoperable workflow to locate antimicrobial resistant genomic signatures in SRA shotgun sequencing (including metagenomics) datasets.
This project was part of the Summer 2017 NCBI Hackathon.
A Docker image complete with all tools and dependencies in project is available.
Install Docker
How to use/run a Docker image from a previous hackathon
From Working Directory - Run nastybugs.sh
# docker pull stevetsa/metagenomicantibioticresistance:latest #update Docker image
docker run -v `pwd`:`pwd` -w `pwd` -i -t stevetsa/metagenomicantibioticresistance:latest
sh /MetagenomicAntibioticResistance/nastybugs.sh id.txt ./hgDir ./cardgene ./cardsnp 16 ./outDir
sh nastybugs.sh [List of SRA runs] [Host Genome Directory] [CARD Gene Database Directory] [CARD Variant Database Directory] [Cores] [Output Directory]

The pipeline use three databases that should be downloaded with the script:
Step 1. Getting host genome and create BLAST db Getting CARD Gene and SNP databases and create BLAST db - https://card.mcmaster.ca/download
wget -P $hostGen ftp://ftp.ncbi.nlm.nih.gov/refseq/H_sapiens/annotation/GRCh37_latest/refseq_identifiers/GRCh37_latest_genomic.fna.gz
gunzip $hostGen/GRCh37_latest_genomic.fna.gz
makeblastdb -in $hostGen/GRCh37_latest_genomic.fna -dbtype nucl -out $hostGen/hg19
wget https://card.mcmaster.ca/download/0/broadstreet-v2.0.0.tar.gz
tar xvf broadstreet-v2.0.0.tar.gz
makeblastdb -in nucleotide_fasta_protein_homolog_model.fasta -dbtype nucl -out cardgenedb
makeblastdb -in nucleotide_fasta_protein_variant_model.fasta -dbtype nucl -out cardsnpdb
Step. 2
Loop Through SRA Accession List (id.txt - one accession per line) First we align to a host so we can subtract host reads by mapping SRA to host genome using magicblast Extract unmapped read and convert to FASTA #Getting unmapped reads (-f 4). For mapped reads, use flag (-F 4)
magicblast -sra $sra -db $hostGen -num_threads $cores -score 50 -penalty -3 -out $outdir/$sra.human.sam
samtools fasta -f 4 $outdir/$sra.human.sam -1 $outdir/${sra}_unmapped_read_one -2 $outdir/${sra}_unmapped_read_two -0 $outdir/${sra}_unmapped_read_zero
Step. 3 Trim FASTA files
fastx_clipper -i $outdir/${sra}_unmapped_read_one -o $outdir/${sra}_unmapped_read_one_trimmed
fastx_clipper -i $outdir/${sra}_unmapped_read_two -o $outdir/${sra}_unmapped_read_two_trimmed
Step. 4
Map FASTA files to CARD gene and variant sequences
magicblast -num_threads $cores -infmt fasta -query $outdir/${sra}_unmapped_read_one_trimmed -query_mate $outdir/${sra}_unmapped_read_two_trimmed -score 50 -penalty -3 -out $outdir/$sra.CARD_gene.sa
m -db $cardgene/cardgenedb
magicblast -num_threads $cores -infmt fasta -query $outdir/${sra}_unmapped_read_one_trimmed -query_mate $outdir/${sra}_unmapped_read_two_trimmed -score 50 -penalty -3 -out $outdir/$sra.CARD_snp.sam
-db $cardsnp/cardsnpdb
Step. 5 Convert the gene_homology aligned SAM to BAM and sort. Delete SAM to save space
samtools view -bS $outdir/$sra.CARD_gene.sam | samtools sort -o $outdir/$sra.CARD_gene.bam
samtools view -bS $outdir/$sra.CARD_snp.sam | samtools sort -o $outdir/$sra.CARD_snp.bam # should we output the unaligned reads to a different bam?
rm -f $outdir/$sra.CARD*.sam
From working directory - Required: id.txt ( List of SRA Accession Numbers - One Acession number per line) Required: Download Human Genome Sequence, e.g. ucsc.hg19.fasta, or other host sequence, and save in ./hgDir sh nastybugs.sh [List of SRA runs] [Host Genome Directory] [CARD Gene Database Directory] [CARD Variant Database Directory] [Cores] [Output Directory]
mkdir hgDir cardgene cardsnp outDir #create directories or use existing directories
cp ucsc.hg19.fasta ./hgDir/.
makeblastdb -in ucsc.hg19.fasta -dbtype nucl -out hg19 #Create BLAST databases for host removal
cd ..
sh nastybugs.sh id.txt ./hgDir/hg19 ./cardgene ./cardsnp 16 ./outDir
Default - SRA accession numbers (ERR or SRR) FASTQ files can be used by modifying magicblast steps.
The NastyBugs workflow was validated using the next SRAs: ERR1600439 and ERR1600437
Software:
Magic-BLAST 1.3.0 is a tool for mapping large next-generation RNA or DNA sequencing runs against a whole genome or transcriptome.
SAMtools 1.7.9 is a suite of programs for interacting with high-throughput sequencing data.
FASTX-Toolkit is a collection of command line tools for Short-Reads FASTA/FASTQ files preprocessing.
sratoolkit.2.9.0 a collection of tools and libraries for using data in the INSDC Sequence Read Archives.
Docker is the leading software container platform.
DBs used for BLAST databases:
NCBI GRCh37/UCSC hg19 human reference genome
CARD (Comprehensive Antibiotic Resistance Database)
Dot plot showing relative abundance of antimicrobial resistance/bacterial species in metagenomic sample.
Pie chart vizualization of bacterial abundance in the given dataset using Krona ([Ondov BD, Bergman NH, and Phillippy AM. Interactive metagenomic visualization in a Web browser. BMC Bioinformatics. $

Tsang H, Moss M, Fedewa G et al. NastyBugs: A simple method for extracting antimicrobial resistance information from metagenomes [version 1; referees: awaiting peer review]. F1000Research 2017, 6:1971 doi: 10.12688/f1000research.12781.1
Follow the instructions on this page.
Feel free to contact authors if you need help.
Tsang H, Moss M, Fedewa G, Farag S, Quang D, Rakov AV, Busby B. NastyBugs: A simple method for extracting antimicrobial resistance information from metagenomes [version 1; referees: awaiting peer review]. F1000Research 2017, 6:1971 doi: 10.12688/f1000research.12781.1
docker pull stevetsa/metagenomicantibioticresistance:latest