# metagenopolis/crocodeel architecture

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

- Interactive diagram: https://gitdiagram.com/metagenopolis/crocodeel
- Repository: https://github.com/metagenopolis/crocodeel
- Video tour (about a minute): https://gitdiagram.com/metagenopolis/crocodeel/video

## Overview

CroCoDeEL is a command-line tool for detecting and estimating cross-sample contamination in metagenomic species-abundance tables. Its main workflow reads and preprocesses abundance data, evaluates sample pairs, writes contamination events, and can generate review plots. Separate capabilities include training a custom classifier and running a self-test. The sampled CLI and module references support the main dispatch relationships; some implementation details, including self-test internals, were not sampled.

Main entry points: [`crocodeel/crocodeel.py`](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/crocodeel.py) (Command-line app), [`crocodeel/search_conta.py`](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/search_conta.py) (Contamination search), [`crocodeel/conta_features.py`](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/conta_features.py) (Pair features), [`crocodeel/conta_event.py`](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/conta_event.py) (Event data and TSV)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["CLI workflow"]
  node_cli["Command-line app<br/>[crocodeel.py]"]
  node_ab_table["Table preprocessing<br/>[ab_table_utils.py]"]
  node_execution["Run metadata"]
end

subgraph group_analysis["Detection analysis"]
  node_search["Contamination search<br/>[search_conta.py]"]
  node_features["Pair features<br/>[conta_features.py]"]
  node_ransac["Contamination-line fit<br/>[ransac.py]"]
end

subgraph group_outputs["Results and review"]
  node_events["Event data and TSV<br/>[conta_event.py]"]
  node_plots["Scatterplot report<br/>[plot_conta.py]"]
end

subgraph group_support["Model and validation"]
  node_trainer["Model training<br/>[train_model.py]"]
  node_self_test["Self-test<br/>[self_test.py]"]
  node_utils["Shared utilities<br/>[utils.py]"]
end

node_user(("Researcher"))
node_input_table["Abundance TSV"]
node_event_tsv["Events TSV"]
node_report_pdf["Review PDF"]

node_user -->|"runs command"| node_cli
node_input_table -->|"provides input"| node_cli
node_cli -->|"preprocesses table"| node_ab_table
node_cli -->|"dispatches search"| node_search
node_search -->|"extracts features"| node_features
node_features -->|"fits line"| node_ransac
node_search -->|"creates events"| node_events
node_cli -->|"writes events"| node_events
node_events -->|"serializes to"| node_event_tsv
node_cli -->|"dispatches plotting"| node_plots
node_plots -->|"generates report"| node_report_pdf
node_cli -->|"records parameters"| node_execution
node_cli -->|"dispatches training"| node_trainer
node_trainer -->|"extracts features"| node_features
node_cli -->|"dispatches test"| node_self_test
node_ab_table -->|"formats names"| node_utils

click node_cli "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/crocodeel.py"
click node_ab_table "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/ab_table_utils.py"
click node_execution "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/execution_description.py"
click node_search "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/search_conta.py"
click node_features "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/conta_features.py"
click node_ransac "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/ransac.py"
click node_events "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/conta_event.py"
click node_plots "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/plot_conta.py"
click node_trainer "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/train_model.py"
click node_self_test "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/self_test.py"
click node_utils "https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/utils.py"

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_cli,node_ab_table,node_execution,node_report_pdf toneBlue
class node_search,node_features,node_ransac toneAmber
class node_events,node_plots toneMint
class node_trainer,node_self_test,node_utils toneRose
class node_user,node_input_table,node_event_tsv toneIndigo
```

## Components

### CLI workflow

- [Command-line app](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/crocodeel.py): `crocodeel/crocodeel.py`
- [Table preprocessing](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/ab_table_utils.py): `crocodeel/ab_table_utils.py`
- [Run metadata](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/execution_description.py): `crocodeel/execution_description.py`

### Detection analysis

- [Contamination search](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/search_conta.py): `crocodeel/search_conta.py`
- [Pair features](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/conta_features.py): `crocodeel/conta_features.py`
- [Contamination-line fit](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/ransac.py): `crocodeel/ransac.py`

### Results and review

- [Event data and TSV](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/conta_event.py): `crocodeel/conta_event.py`
- [Scatterplot report](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/plot_conta.py): `crocodeel/plot_conta.py`

### Model and validation

- [Model training](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/train_model.py): `crocodeel/train_model.py`
- [Self-test](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/self_test.py): `crocodeel/self_test.py`
- [Shared utilities](https://github.com/metagenopolis/crocodeel/blob/main/crocodeel/utils.py): `crocodeel/utils.py`

### Other components

- **Researcher**
- **Abundance TSV**
- **Events TSV**
- **Review PDF**

## Connections

- Researcher → Command-line app: runs command (evidence: `README.md`)
- Abundance TSV → Command-line app: provides input (evidence: `README.md`)
- Command-line app → Table preprocessing: preprocesses table (evidence: `crocodeel/crocodeel.py`)
- Command-line app → Contamination search: dispatches search (evidence: `crocodeel/crocodeel.py`)
- Contamination search → Pair features: extracts features (evidence: `crocodeel/search_conta.py`)
- Pair features → Contamination-line fit: fits line (evidence: `crocodeel/conta_features.py`)
- Contamination search → Event data and TSV: creates events (evidence: `crocodeel/search_conta.py`)
- Command-line app → Event data and TSV: writes events (evidence: `crocodeel/crocodeel.py`)
- Event data and TSV → Events TSV: serializes to (evidence: `README.md`)
- Command-line app → Scatterplot report: dispatches plotting (evidence: `crocodeel/crocodeel.py`)
- Scatterplot report → Review PDF: generates report (evidence: `README.md`)
- Command-line app → Run metadata: records parameters (evidence: `crocodeel/crocodeel.py`)
- Command-line app → Model training: dispatches training (evidence: `crocodeel/crocodeel.py`)
- Model training → Pair features: extracts features (evidence: `crocodeel/train_model.py`)
- Command-line app → Self-test: dispatches test (evidence: `crocodeel/crocodeel.py`)
- Table preprocessing → Shared utilities: formats names (evidence: `crocodeel/ab_table_utils.py`)
