<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Bacterial Comparative Genomics Pipeline Bash Script]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/44733/bacterial-comparative-genomics-pipeline-bash-script?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/44733/bacterial-comparative-genomics-pipeline-bash-script?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44733/bacterial-comparative-genomics-pipeline-bash-script</guid>
	<pubDate>Sat, 14 Dec 2024 12:34:57 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44733/bacterial-comparative-genomics-pipeline-bash-script</link>
	<title><![CDATA[Bacterial Comparative Genomics Pipeline Bash Script]]></title>
	<description><![CDATA[<code>#!/bin/bash

# Bacterial Comparative Genomics Pipeline Script
# This script automates key steps in bacterial comparative genomics using popular bioinformatics tools.

# Ensure the script stops on error
set -e

# Define paths
WORKDIR=&quot;./bacterial_genomics_pipeline&quot;
INPUT_FASTA_DIR=&quot;./input_genomes&quot;
OUTPUT_DIR=&quot;./output&quot;
CORE_PAN_DIR=&quot;$OUTPUT_DIR/core_pan_analysis&quot;
PHYLOGENY_DIR=&quot;$OUTPUT_DIR/phylogeny&quot;
ALIGNMENT_DIR=&quot;$OUTPUT_DIR/genome_alignment&quot;
RESISTANCE_DIR=&quot;$OUTPUT_DIR/antibiotic_resistance&quot;
SYNTENY_DIR=&quot;$OUTPUT_DIR/synteny_analysis&quot;

# Create directories if they do not exist
mkdir -p $WORKDIR $OUTPUT_DIR $CORE_PAN_DIR $PHYLOGENY_DIR $ALIGNMENT_DIR $RESISTANCE_DIR $SYNTENY_DIR

# Tools required
PROKKA=&quot;prokka&quot;
ROARY=&quot;roary&quot;
MAUVE=&quot;progressiveMauve&quot;
IQTREE=&quot;iqtree&quot;
ABRICATE=&quot;abricate&quot;
MCSCANX=&quot;mcscanx&quot;

# Step 1: Genome Annotation using Prokka
annotate_genomes() {
  echo &quot;\n=== Annotating Genomes with Prokka ===&quot;
  for fasta in $INPUT_FASTA_DIR/*.fasta; do
    basename=$(basename $fasta .fasta)
    output_path=&quot;$OUTPUT_DIR/annotation_$basename&quot;
    echo &quot;Annotating $basename...&quot;
    $PROKKA --outdir $output_path --prefix $basename $fasta
  done
}

# Step 2: Core and Pan-genome Analysis using Roary
core_pan_analysis() {
  echo &quot;\n=== Performing Core and Pan-genome Analysis with Roary ===&quot;
  gff_files=$(find $OUTPUT_DIR -name &quot;*.gff&quot;)
  roary_output=&quot;$CORE_PAN_DIR/pan_genome_analysis&quot;
  mkdir -p $roary_output
  $ROARY -e -n -v -p 8 -o $roary_output $gff_files
}

# Step 3: Whole Genome Alignment using Mauve
align_genomes() {
  echo &quot;\n=== Aligning Genomes with Mauve ===&quot;
  alignment_output=&quot;$ALIGNMENT_DIR/aligned_genomes.xmfa&quot;
  echo &quot;Running Mauve on input genomes...&quot;
  $MAUVE --output=$alignment_output $(find $INPUT_FASTA_DIR -name &quot;*.fasta&quot;)
  echo &quot;Alignment saved to $alignment_output&quot;
}

# Step 4: Phylogenetic Tree Construction using IQ-TREE
construct_phylogeny() {
  echo &quot;\n=== Constructing Phylogenetic Tree with IQ-TREE ===&quot;
  alignment=&quot;$ALIGNMENT_DIR/aligned_genomes.xmfa&quot;
  phylo_output=&quot;$PHYLOGENY_DIR/phylogeny_tree&quot;
  iqtree_output=&quot;$phylo_output.treefile&quot;

  echo &quot;Running IQ-TREE on aligned genomes...&quot;
  $IQTREE -s $alignment -m GTR+G -nt AUTO -pre $phylo_output
  echo &quot;Phylogenetic tree saved to $iqtree_output&quot;
}

# Step 5: Antibiotic Resistance Gene Identification using ABRicate
identify_resistance_genes() {
  echo &quot;\n=== Identifying Antibiotic Resistance Genes with ABRicate ===&quot;
  for fasta in $INPUT_FASTA_DIR/*.fasta; do
    basename=$(basename $fasta .fasta)
    output_path=&quot;$RESISTANCE_DIR/${basename}_resistance.txt&quot;
    echo &quot;Analyzing $basename for resistance genes...&quot;
    abricate $fasta &gt; $output_path
  done
}

# Step 6: Synteny Analysis using MCScanX
synteny_analysis() {
  echo &quot;\n=== Performing Synteny Analysis with MCScanX ===&quot;
  synteny_output=&quot;$SYNTENY_DIR/synteny_results&quot;
  mkdir -p $synteny_output
  echo &quot;Running MCScanX on annotated genomes...&quot;
  MCScanX $OUTPUT_DIR &gt; &quot;$synteny_output/results.txt&quot;
  echo &quot;Synteny analysis results saved to $synteny_output&quot;
}

# Main workflow
annotate_genomes
core_pan_analysis
align_genomes
construct_phylogeny
identify_resistance_genes
synteny_analysis

echo &quot;\n=== Bacterial Comparative Genomics Pipeline Complete ===&quot;
echo &quot;Results saved in $OUTPUT_DIR&quot;</code>]]></description>
	<dc:creator>LEGE</dc:creator>
</item>

</channel>
</rss>