# krishnan-rama/defensome architecture

> Architecture diagram of the GitHub repository krishnan-rama/defensome, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krishnan-rama/defensome
- Repository: https://github.com/krishnan-rama/defensome

## Overview

This repository is a research pipeline for comparing detoxification (“defensome”) gene families across Lepidoptera and outgroups. Its documented workflow annotates protein sequences, maps domain hits to families, aggregates species-level calls, assigns CYP clan membership, and performs per-clan phylogenetics. Separate scripts extract family sequences and join defensome calls to OrthoFinder orthogroups for evolutionary summaries. The README describes capabilities beyond the sampled implementation; those links are shown as documented, while implementation details for unsampled stages remain unverified.

Main entry points: [`workflow_scripts/workflow/parse_interpro_defensome.py`](https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/workflow/parse_interpro_defensome.py) (Defensome calls), [`3-postprocess.slurm`](https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm) (Clan alignments and trees), [`workflow_scripts/parse_interpro_defensome.py`](https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/parse_interpro_defensome.py) (Domain call parser), [`orthofinder_analysis/join_defensome_orthofinder.py`](https://github.com/krishnan-rama/defensome/blob/main/orthofinder_analysis/join_defensome_orthofinder.py) (Orthogroup join)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_annotation["Annotation and calls"]
  node_parser["Domain call parser"]
  node_family_fasta["Family FASTA extraction"]
  node_calls["Defensome calls"]
end

subgraph group_comparative["Comparative analysis"]
  node_aggregation["Species aggregation"]
  node_clan["CYP clan assignment"]
  node_orthofinder["Orthogroup join"]
  node_og_summary["Orthogroup summary"]
end

subgraph group_phylogeny["CYP phylogenetics"]
  node_align_tree["Clan alignments and trees"]
end

subgraph group_presentation["Results and interface"]
  node_outputs["Analysis outputs"]
  node_dashboard["Results dashboard"]
  node_deploy["Dashboard deployment"]
end

node_researcher(("Researcher"))
node_proteomes["Species proteomes"]
node_pfam[("Pfam database")]
node_interpro["InterProScan results"]
node_hmm_tools["HMMER"]
node_mafft["MAFFT"]
node_iqtree["IQ-TREE2"]
node_orthogroup_data["OrthoFinder groups"]

node_researcher -->|"provides input"| node_proteomes
node_proteomes -->|"supplies sequences"| node_parser
node_pfam -->|"maps signatures"| node_parser
node_interpro -->|"provides hits"| node_parser
node_parser -.->|"writes calls"| node_calls
node_calls -->|"selects proteins"| node_family_fasta
node_calls -.->|"aggregates counts"| node_aggregation
node_aggregation -.->|"assigns clans"| node_clan
node_clan -.->|"scans sequences"| node_hmm_tools
node_clan -.->|"selects clans"| node_align_tree
node_align_tree -.->|"aligns sequences"| node_mafft
node_align_tree -.->|"infers trees"| node_iqtree
node_aggregation -.->|"writes summaries"| node_outputs
node_align_tree -.->|"writes phylogenies"| node_outputs
node_outputs -.->|"presents results"| node_dashboard
node_dashboard -.->|"can be deployed"| node_deploy
node_calls -->|"joins protein calls"| node_orthofinder
node_orthogroup_data -->|"maps gene IDs"| node_orthofinder
node_orthofinder -->|"summarizes orthogroups"| node_og_summary

click node_parser "https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/parse_interpro_defensome.py"
click node_family_fasta "https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/extract_family_fastas.py"
click node_calls "https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/workflow/parse_interpro_defensome.py"
click node_aggregation "https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm"
click node_clan "https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm"
click node_orthofinder "https://github.com/krishnan-rama/defensome/blob/main/orthofinder_analysis/join_defensome_orthofinder.py"
click node_og_summary "https://github.com/krishnan-rama/defensome/blob/main/orthofinder_analysis/summarize_defensome_by_og.py"
click node_align_tree "https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm"
click node_outputs "https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm"
click node_dashboard "https://github.com/krishnan-rama/defensome/blob/main/defensome_dashboard_v2.html"
click node_deploy "https://github.com/krishnan-rama/defensome/blob/main/deploy_defensome.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_parser,node_family_fasta,node_calls toneBlue
class node_aggregation,node_clan,node_orthofinder,node_og_summary,node_pfam toneAmber
class node_align_tree toneMint
class node_outputs,node_dashboard,node_deploy toneRose
class node_researcher,node_proteomes,node_interpro,node_hmm_tools,node_mafft,node_iqtree,node_orthogroup_data toneIndigo
```

## Components

### Annotation and calls

- [Domain call parser](https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/parse_interpro_defensome.py): `workflow_scripts/parse_interpro_defensome.py`
- [Family FASTA extraction](https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/extract_family_fastas.py): `workflow_scripts/extract_family_fastas.py`
- [Defensome calls](https://github.com/krishnan-rama/defensome/blob/main/workflow_scripts/workflow/parse_interpro_defensome.py): `workflow_scripts/workflow/parse_interpro_defensome.py`

### Comparative analysis

- [Species aggregation](https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm): `3-postprocess.slurm`
- [CYP clan assignment](https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm): `3-postprocess.slurm`
- [Orthogroup join](https://github.com/krishnan-rama/defensome/blob/main/orthofinder_analysis/join_defensome_orthofinder.py): `orthofinder_analysis/join_defensome_orthofinder.py`
- [Orthogroup summary](https://github.com/krishnan-rama/defensome/blob/main/orthofinder_analysis/summarize_defensome_by_og.py): `orthofinder_analysis/summarize_defensome_by_og.py`

### CYP phylogenetics

- [Clan alignments and trees](https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm): `3-postprocess.slurm`

### Results and interface

- [Analysis outputs](https://github.com/krishnan-rama/defensome/blob/main/3-postprocess.slurm): `3-postprocess.slurm`
- [Results dashboard](https://github.com/krishnan-rama/defensome/blob/main/defensome_dashboard_v2.html): `defensome_dashboard_v2.html`
- [Dashboard deployment](https://github.com/krishnan-rama/defensome/blob/main/deploy_defensome.sh): `deploy_defensome.sh`

### Other components

- **Researcher**
- **Species proteomes**
- **Pfam database**
- **InterProScan results**
- **HMMER**
- **MAFFT**
- **IQ-TREE2**
- **OrthoFinder groups**

## Connections

- Researcher → Species proteomes: provides input (evidence: `README.md`)
- Species proteomes → Domain call parser: supplies sequences (evidence: `workflow_scripts/parse_interpro_defensome.py`)
- Pfam database → Domain call parser: maps signatures (evidence: `workflow_scripts/parse_interpro_defensome.py`)
- InterProScan results → Domain call parser: provides hits (evidence: `workflow_scripts/parse_interpro_defensome.py`)
- Domain call parser → Defensome calls: writes calls
- Defensome calls → Family FASTA extraction: selects proteins (evidence: `workflow_scripts/extract_family_fastas.py`)
- Defensome calls → Species aggregation: aggregates counts (evidence: `README.md`)
- Species aggregation → CYP clan assignment: assigns clans (evidence: `README.md`)
- CYP clan assignment → HMMER: scans sequences (evidence: `README.md`)
- CYP clan assignment → Clan alignments and trees: selects clans (evidence: `README.md`)
- Clan alignments and trees → MAFFT: aligns sequences (evidence: `README.md`)
- Clan alignments and trees → IQ-TREE2: infers trees (evidence: `README.md`)
- Species aggregation → Analysis outputs: writes summaries (evidence: `README.md`)
- Clan alignments and trees → Analysis outputs: writes phylogenies (evidence: `README.md`)
- Analysis outputs → Results dashboard: presents results
- Results dashboard → Dashboard deployment: can be deployed
- Defensome calls → Orthogroup join: joins protein calls (evidence: `orthofinder_analysis/join_defensome_orthofinder.py`)
- OrthoFinder groups → Orthogroup join: maps gene IDs (evidence: `orthofinder_analysis/join_defensome_orthofinder.py`)
- Orthogroup join → Orthogroup summary: summarizes orthogroups (evidence: `orthofinder_analysis/summarize_defensome_by_og.py`)
