Resources chevron_right Protocols chevron_right DefenseFinder
Protocol // Defense Systems

DefenseFinder

Identification of Defense Systems in bacterial and archaeal genomes from annotated protein sequences.

Defense Systems codeGitHub languageWebsite menu_bookPaper scheduleMarch 28, 2026

Installation

Create a conda environment:

conda create -n Defensefinder python=3.7

Activate the environment:

conda activate Defensefinder

Install:

pip install mdmparis-defense-finder

Update the models:

macsydata install -U -u --org mdmparis defense-finder-models

To update the tool:

defense-finder update

Run

for i in *.faa; do defense-finder run $i -o /home/Genomes/$i -w 20 --preserve-raw; done
info

Sometimes after the run some of the outputs are not generated. Make sure you have it for all your genomes. In case you don't, run the program individually for these genomes.

Output

One folder for each analyzed genome will be created. Each folder contains 3 files (and another folder):

File Description
defense_finder_genes.tsv Information of the genes found that belong to a complete defense system in this genome
defense_finder_system.tsv Information of the complete defense systems found in this genome
defense_finder_hmmer.tsv List of all genes associated with defense systems (complete or not) found in this genome

The files have the same name in each folder. Add the folder name to the files before putting them together using this script:

#!/usr/bin/env python3
import shutil
import os
import sys

dr = sys.argv[1]

for root, dirs, files in os.walk(dr):
    for f in files:
        shutil.move(root+"/"+f, root+"/"+root.split("/")[-1]+f)

Run the script in a loop for all folders inside the directory with your output folders:

for i in . ; do ./foldername2file.sh $i; done

To have the information of which genome each defense system comes from, add a new column with the genome information:

for f in *.tsv; do awk -v name="$f" 'BEGIN{FS=OFS="\t"} NR==1{$(NF+1)="filename"} NR>1{$(NF+1)=name}1' "$f" > tmp && mv tmp "$f"; done

Organize outputs by type into separate folders:

mkdir Genes
mv **/*_genes.tsv Genes

mkdir Systems
mv **/*_systems.tsv Systems

mkdir Hmmer
mv **/*_hmmer.tsv Hmmer