# meglecz/mkcoinr architecture

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

- Interactive diagram: https://gitdiagram.com/meglecz/mkcoinr
- Repository: https://github.com/meglecz/mkcoinr

## Overview

mkCOInr is a Perl toolkit for building the COInr COI reference database and deriving custom databases from it. The documented workflow gathers sequences and taxonomy from NCBI and BOLD, harmonizes taxonomic identifiers and lineages, and produces database files; users can then select regions or taxa, set taxonomic resolution, add custom sequences, and export to several formats. The README documents these capabilities but no source excerpts were provided, so the graph shows only those documented relationships, not unverified internal calls or a precise execution order.

Main entry points: [`scripts/mkdb.pm`](https://github.com/meglecz/mkcoinr/blob/main/scripts/mkdb.pm) (COInr database files), [`scripts/download_bold.pl`](https://github.com/meglecz/mkcoinr/blob/main/scripts/download_bold.pl) (Sequence downloads), [`scripts/add_taxids.pl`](https://github.com/meglecz/mkcoinr/blob/main/scripts/add_taxids.pl) (TaxID completion), [`scripts/select_region.pl`](https://github.com/meglecz/mkcoinr/blob/main/scripts/select_region.pl) (Custom database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sources["Data acquisition"]
  node_sequence_download["Sequence downloads<br/>[download_bold.pl]"]
  node_taxonomy_download["Taxonomy downloads"]
  node_ncbi_format["NCBI formatting<br/>[format_ncbi.pl]"]
  node_bold_format["BOLD formatting<br/>[format_bold.pl]"]
end

subgraph group_taxonomy["Taxonomy handling"]
  node_taxid_harmonize["TaxID completion<br/>[add_taxids.pl]"]
  node_taxonomy_selection["Taxon selection<br/>[select_taxa.pl]"]
  node_custom_sequences["Custom sequences<br/>[format_custom.pl]"]
end

subgraph group_customize["Database customization"]
  node_custom_db["Custom database<br/>[select_region.pl]"]
  node_region_selection["Region selection<br/>[select_region.pl]"]
  node_taxon_resolution["Resolution selection<br/>[select_taxa.pl]"]
  node_demultiplexing["Taxonomic demultiplexing"]
end

subgraph group_formats["Database outputs"]
  node_db_outputs[("COInr database files<br/>[mkdb.pm]")]
  node_format_qiime["QIIME format<br/>[format_db.pl]"]
  node_format_rdp["RDP format<br/>[format_rdp.pl]"]
  node_format_blast["BLAST format<br/>[format_db.pl]"]
  node_format_full["Full TSV format<br/>[format_db.pl]"]
end

node_user(("Database builder"))
node_ncbi[("NCBI nucleotide")]
node_bold[("BOLD")]

node_user -->|"builds from"| node_sequence_download
node_ncbi -->|"provides sequences"| node_sequence_download
node_bold -->|"provides sequences"| node_sequence_download
node_ncbi -->|"provides taxonomy"| node_taxonomy_download
node_bold -->|"provides taxonomy"| node_taxonomy_download
node_sequence_download -->|"formats sequences"| node_ncbi_format
node_sequence_download -->|"formats sequences"| node_bold_format
node_taxonomy_download -->|"supports lineage completion"| node_taxid_harmonize
node_ncbi_format -->|"uses TaxIDs"| node_taxid_harmonize
node_bold_format -->|"uses TaxIDs"| node_taxid_harmonize
node_taxid_harmonize -->|"builds taxonomy"| node_db_outputs
node_user -->|"adds sequences"| node_custom_sequences
node_custom_sequences -->|"matches lineages"| node_taxid_harmonize
node_db_outputs -->|"customizes"| node_custom_db
node_user -->|"selects region"| node_region_selection
node_user -->|"selects taxa"| node_taxonomy_selection
node_user -->|"sets resolution"| node_taxon_resolution
node_custom_db -->|"supports"| node_demultiplexing
node_custom_db -->|"produces database"| node_db_outputs
node_db_outputs -->|"formats as"| node_format_qiime
node_db_outputs -->|"formats as"| node_format_rdp
node_db_outputs -->|"formats as"| node_format_blast
node_db_outputs -->|"formats as"| node_format_full

click node_sequence_download "https://github.com/meglecz/mkcoinr/blob/main/scripts/download_bold.pl"
click node_taxonomy_download "https://github.com/meglecz/mkcoinr/blob/main/scripts/download_taxonomy.pl"
click node_ncbi_format "https://github.com/meglecz/mkcoinr/blob/main/scripts/format_ncbi.pl"
click node_bold_format "https://github.com/meglecz/mkcoinr/blob/main/scripts/format_bold.pl"
click node_taxid_harmonize "https://github.com/meglecz/mkcoinr/blob/main/scripts/add_taxids.pl"
click node_taxonomy_selection "https://github.com/meglecz/mkcoinr/blob/main/scripts/select_taxa.pl"
click node_custom_sequences "https://github.com/meglecz/mkcoinr/blob/main/scripts/format_custom.pl"
click node_custom_db "https://github.com/meglecz/mkcoinr/blob/main/scripts/select_region.pl"
click node_region_selection "https://github.com/meglecz/mkcoinr/blob/main/scripts/select_region.pl"
click node_taxon_resolution "https://github.com/meglecz/mkcoinr/blob/main/scripts/select_taxa.pl"
click node_demultiplexing "https://github.com/meglecz/mkcoinr/blob/main/scripts/pool_and_dereplicate.pl"
click node_db_outputs "https://github.com/meglecz/mkcoinr/blob/main/scripts/mkdb.pm"
click node_format_qiime "https://github.com/meglecz/mkcoinr/blob/main/scripts/format_db.pl"
click node_format_rdp "https://github.com/meglecz/mkcoinr/blob/main/scripts/format_rdp.pl"
click node_format_blast "https://github.com/meglecz/mkcoinr/blob/main/scripts/format_db.pl"
click node_format_full "https://github.com/meglecz/mkcoinr/blob/main/scripts/format_db.pl"

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_sequence_download,node_taxonomy_download,node_ncbi_format,node_bold_format toneBlue
class node_taxid_harmonize,node_taxonomy_selection,node_custom_sequences,node_user,node_ncbi,node_bold toneAmber
class node_custom_db,node_region_selection,node_taxon_resolution,node_demultiplexing toneMint
class node_db_outputs,node_format_qiime,node_format_rdp,node_format_blast,node_format_full toneRose
```

## Components

### Data acquisition

- [Sequence downloads](https://github.com/meglecz/mkcoinr/blob/main/scripts/download_bold.pl): `scripts/download_bold.pl`
- [Taxonomy downloads](https://github.com/meglecz/mkcoinr/blob/main/scripts/download_taxonomy.pl): `scripts/download_taxonomy.pl`
- [NCBI formatting](https://github.com/meglecz/mkcoinr/blob/main/scripts/format_ncbi.pl): `scripts/format_ncbi.pl`
- [BOLD formatting](https://github.com/meglecz/mkcoinr/blob/main/scripts/format_bold.pl): `scripts/format_bold.pl`

### Taxonomy handling

- [TaxID completion](https://github.com/meglecz/mkcoinr/blob/main/scripts/add_taxids.pl): `scripts/add_taxids.pl`
- [Taxon selection](https://github.com/meglecz/mkcoinr/blob/main/scripts/select_taxa.pl): `scripts/select_taxa.pl`
- [Custom sequences](https://github.com/meglecz/mkcoinr/blob/main/scripts/format_custom.pl): `scripts/format_custom.pl`

### Database customization

- [Custom database](https://github.com/meglecz/mkcoinr/blob/main/scripts/select_region.pl): `scripts/select_region.pl`
- [Region selection](https://github.com/meglecz/mkcoinr/blob/main/scripts/select_region.pl): `scripts/select_region.pl`
- [Resolution selection](https://github.com/meglecz/mkcoinr/blob/main/scripts/select_taxa.pl): `scripts/select_taxa.pl`
- [Taxonomic demultiplexing](https://github.com/meglecz/mkcoinr/blob/main/scripts/pool_and_dereplicate.pl): `scripts/pool_and_dereplicate.pl`

### Database outputs

- [COInr database files](https://github.com/meglecz/mkcoinr/blob/main/scripts/mkdb.pm): `scripts/mkdb.pm`
- [QIIME format](https://github.com/meglecz/mkcoinr/blob/main/scripts/format_db.pl): `scripts/format_db.pl`
- [RDP format](https://github.com/meglecz/mkcoinr/blob/main/scripts/format_rdp.pl): `scripts/format_rdp.pl`
- [BLAST format](https://github.com/meglecz/mkcoinr/blob/main/scripts/format_db.pl): `scripts/format_db.pl`
- [Full TSV format](https://github.com/meglecz/mkcoinr/blob/main/scripts/format_db.pl): `scripts/format_db.pl`

### Other components

- **Database builder**
- **NCBI nucleotide**
- **BOLD**

## Connections

- Database builder → Sequence downloads: builds from (evidence: `README.md`)
- NCBI nucleotide → Sequence downloads: provides sequences (evidence: `README.md`)
- BOLD → Sequence downloads: provides sequences (evidence: `README.md`)
- NCBI nucleotide → Taxonomy downloads: provides taxonomy (evidence: `README.md`)
- BOLD → Taxonomy downloads: provides taxonomy (evidence: `README.md`)
- Sequence downloads → NCBI formatting: formats sequences (evidence: `README.md`)
- Sequence downloads → BOLD formatting: formats sequences (evidence: `README.md`)
- Taxonomy downloads → TaxID completion: supports lineage completion (evidence: `README.md`)
- NCBI formatting → TaxID completion: uses TaxIDs (evidence: `README.md`)
- BOLD formatting → TaxID completion: uses TaxIDs (evidence: `README.md`)
- TaxID completion → COInr database files: builds taxonomy (evidence: `README.md`)
- Database builder → Custom sequences: adds sequences (evidence: `README.md`)
- Custom sequences → TaxID completion: matches lineages (evidence: `README.md`)
- COInr database files → Custom database: customizes (evidence: `README.md`)
- Database builder → Region selection: selects region (evidence: `README.md`)
- Database builder → Taxon selection: selects taxa (evidence: `README.md`)
- Database builder → Resolution selection: sets resolution (evidence: `README.md`)
- Custom database → Taxonomic demultiplexing: supports (evidence: `README.md`)
- Custom database → COInr database files: produces database (evidence: `README.md`)
- COInr database files → QIIME format: formats as (evidence: `README.md`)
- COInr database files → RDP format: formats as (evidence: `README.md`)
- COInr database files → BLAST format: formats as (evidence: `README.md`)
- COInr database files → Full TSV format: formats as (evidence: `README.md`)
