# tprodanov/parascopy architecture

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

- Interactive diagram: https://gitdiagram.com/tprodanov/parascopy
- Repository: https://github.com/tprodanov/parascopy

## Overview

Parascopy analyzes whole-genome sequencing data in duplicated genomic regions to estimate aggregate and paralog-specific copy number, and can call variants using an existing copy-number analysis. Its documented workflow builds or loads a homology table, calculates background depth, runs copy-number analysis, then optionally calls variants. The graph also preserves documented read pooling, PSV discovery, multiple-alignment, and table-inspection capabilities. Several implementation links are based on the SOURCE INDEX rather than complete excerpts; those links are cited only where the index or README supports them.

Main entry points: [`src/parascopy/entry_point.py`](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/entry_point.py) (Command dispatcher), [`src/parascopy/detect_cn.py`](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/detect_cn.py) (Copy-number analysis), [`src/parascopy/inner/genome.py`](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/genome.py) (Genome intervals), [`src/parascopy/call_variants.py`](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/call_variants.py) (Variant calling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_table["Homology tables"]
  node_pretable["Preliminary table<br/>[pretable.py]"]
  node_tablebuild["Homology table builder<br/>[combine_table.py]"]
  node_homology["Homology table"]
  node_tableview["Table viewer<br/>[view.py]"]
  node_duplexamine["Duplication inspection<br/>[examine_dupl.py]"]
end

subgraph group_cn["Copy number"]
  node_depth["Background depth<br/>[depth.py]"]
  node_readpool["Read pooling<br/>[pool_reads.py]"]
  node_cnest["Copy-number analysis<br/>[detect_cn.py]"]
  node_model["Model parameters<br/>[model_params.py]"]
  node_hmm["Copy-number HMM<br/>[cn_hmm.py]"]
  node_paralogcn["Paralog copy number<br/>[paralog_cn.py]"]
  node_cnresults["CN results"]
end

subgraph group_variants["Variant analysis"]
  node_psvdiscovery["PSV discovery<br/>[psvs.py]"]
  node_variantcall["Variant calling<br/>[call_variants.py]"]
  node_variantlogic["Variant evidence<br/>[variants.py]"]
  node_variantpool["Variant pooling<br/>[pool_variants.py]"]
  node_variantresults["Variant results"]
  node_msa["Multiple alignment<br/>[msa.py]"]
end

subgraph group_core["Shared genomic engine"]
  node_genome["Genome intervals<br/>[genome.py]"]
  node_duplication["Duplication model<br/>[duplication.py]"]
  node_alignment["Alignment utilities<br/>[alignment.py]"]
  node_cigar["CIGAR utilities<br/>[cigar.py]"]
  node_intervals["Interval indexing<br/>[itree.py]"]
end

node_user(("Analyst"))
node_cli["Command dispatcher<br/>[entry_point.py]"]

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches"| node_pretable
node_cli -->|"dispatches"| node_tablebuild
node_cli -->|"dispatches"| node_depth
node_cli -->|"dispatches"| node_cnest
node_cli -->|"dispatches"| node_variantcall
node_cli -->|"dispatches"| node_readpool
node_cli -->|"dispatches"| node_variantpool
node_cli -->|"dispatches"| node_psvdiscovery
node_cli -->|"dispatches"| node_msa
node_cli -->|"dispatches"| node_tableview
node_cli -->|"dispatches"| node_duplexamine
node_pretable -->|"supplies input"| node_tablebuild
node_tablebuild -->|"creates"| node_homology
node_homology -.->|"guides regions"| node_depth
node_homology -->|"provides regions"| node_cnest
node_homology -->|"filters or views"| node_tableview
node_homology -.->|"examines duplications"| node_duplexamine
node_depth -->|"provides background"| node_cnest
node_readpool -.->|"supplies pooled reads"| node_cnest
node_cnest -->|"loads or fits"| node_model
node_cnest -->|"uses inference"| node_hmm
node_cnest -->|"calculates copy number"| node_paralogcn
node_cnest -->|"finds reliable PSVs"| node_psvdiscovery
node_cnest -->|"writes"| node_cnresults
node_model -->|"provides parameters"| node_paralogcn
node_hmm -->|"supports inference"| node_paralogcn
node_cnresults -->|"anchors calling"| node_variantcall
node_variantcall -->|"uses genotype logic"| node_variantlogic
node_variantcall -->|"writes VCF"| node_variantresults
node_variantpool -->|"reuses read pooling"| node_readpool
node_variantpool -->|"uses CN analysis"| node_cnest
node_variantpool -->|"uses PSV data"| node_psvdiscovery
node_msa -->|"uses duplication table"| node_homology
node_pretable -->|"uses reference"| node_genome
node_tablebuild -->|"uses reference"| node_genome
node_depth -->|"uses intervals"| node_genome
node_cnest -->|"uses intervals"| node_genome
node_variantcall -->|"uses reference"| node_genome
node_genome -->|"defines coordinates"| node_duplication
node_duplication -->|"aligns reads"| node_alignment
node_alignment -->|"uses operations"| node_cigar
node_duplication -->|"uses operations"| node_cigar
node_variantlogic -->|"indexes positions"| node_intervals
node_paralogcn -->|"indexes regions"| node_intervals

click node_cli "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/entry_point.py"
click node_pretable "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/pretable.py"
click node_tablebuild "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/combine_table.py"
click node_tableview "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/view.py"
click node_depth "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/depth.py"
click node_readpool "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/pool_reads.py"
click node_cnest "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/detect_cn.py"
click node_model "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/model_params.py"
click node_hmm "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/cn_hmm.py"
click node_paralogcn "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/paralog_cn.py"
click node_psvdiscovery "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/psvs.py"
click node_variantcall "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/call_variants.py"
click node_variantlogic "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/variants.py"
click node_variantpool "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/pool_variants.py"
click node_msa "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/msa.py"
click node_duplexamine "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/examine_dupl.py"
click node_genome "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/genome.py"
click node_duplication "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/duplication.py"
click node_alignment "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/alignment.py"
click node_cigar "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/cigar.py"
click node_intervals "https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/itree.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_pretable,node_tablebuild,node_homology,node_tableview,node_duplexamine toneBlue
class node_depth,node_readpool,node_cnest,node_model,node_hmm,node_paralogcn,node_cnresults toneAmber
class node_psvdiscovery,node_variantcall,node_variantlogic,node_variantpool,node_variantresults,node_msa toneMint
class node_genome,node_duplication,node_alignment,node_cigar,node_intervals toneRose
class node_user toneIndigo
class node_cli toneTeal
```

## Components

### Homology tables

- [Preliminary table](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/pretable.py): `src/parascopy/pretable.py`
- [Homology table builder](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/combine_table.py): `src/parascopy/combine_table.py`
- **Homology table**
- [Table viewer](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/view.py): `src/parascopy/view.py`
- [Duplication inspection](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/examine_dupl.py): `src/parascopy/examine_dupl.py`

### Copy number

- [Background depth](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/depth.py): `src/parascopy/depth.py`
- [Read pooling](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/pool_reads.py): `src/parascopy/pool_reads.py`
- [Copy-number analysis](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/detect_cn.py): `src/parascopy/detect_cn.py`
- [Model parameters](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/model_params.py): `src/parascopy/inner/model_params.py`
- [Copy-number HMM](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/cn_hmm.py): `src/parascopy/inner/cn_hmm.py`
- [Paralog copy number](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/paralog_cn.py): `src/parascopy/inner/paralog_cn.py`
- **CN results**

### Variant analysis

- [PSV discovery](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/psvs.py): `src/parascopy/psvs.py`
- [Variant calling](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/call_variants.py): `src/parascopy/call_variants.py`
- [Variant evidence](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/variants.py): `src/parascopy/inner/variants.py`
- [Variant pooling](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/pool_variants.py): `src/parascopy/pool_variants.py`
- **Variant results**
- [Multiple alignment](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/msa.py): `src/parascopy/msa.py`

### Shared genomic engine

- [Genome intervals](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/genome.py): `src/parascopy/inner/genome.py`
- [Duplication model](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/duplication.py): `src/parascopy/inner/duplication.py`
- [Alignment utilities](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/alignment.py): `src/parascopy/inner/alignment.py`
- [CIGAR utilities](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/cigar.py): `src/parascopy/inner/cigar.py`
- [Interval indexing](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/inner/itree.py): `src/parascopy/inner/itree.py`

### Other components

- **Analyst**
- [Command dispatcher](https://github.com/tprodanov/parascopy/blob/main/src/parascopy/entry_point.py): `src/parascopy/entry_point.py`

## Connections

- Analyst → Command dispatcher: runs commands (evidence: `README.md`)
- Command dispatcher → Preliminary table: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Homology table builder: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Background depth: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Copy-number analysis: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Variant calling: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Read pooling: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Variant pooling: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → PSV discovery: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Multiple alignment: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Table viewer: dispatches (evidence: `src/parascopy/entry_point.py`)
- Command dispatcher → Duplication inspection: dispatches (evidence: `src/parascopy/entry_point.py`)
- Preliminary table → Homology table builder: supplies input (evidence: `README.md`)
- Homology table builder → Homology table: creates (evidence: `README.md`)
- Homology table → Background depth: guides regions
- Homology table → Copy-number analysis: provides regions (evidence: `README.md`)
- Homology table → Table viewer: filters or views (evidence: `src/parascopy/view.py`)
- Homology table → Duplication inspection: examines duplications
- Background depth → Copy-number analysis: provides background (evidence: `README.md`)
- Read pooling → Copy-number analysis: supplies pooled reads (evidence: `src/parascopy/detect_cn.py`)
- Copy-number analysis → Model parameters: loads or fits (evidence: `src/parascopy/detect_cn.py`)
- Copy-number analysis → Copy-number HMM: uses inference (evidence: `src/parascopy/detect_cn.py`)
- Copy-number analysis → Paralog copy number: calculates copy number (evidence: `src/parascopy/detect_cn.py`)
- Copy-number analysis → PSV discovery: finds reliable PSVs (evidence: `README.md`)
- Copy-number analysis → CN results: writes (evidence: `README.md`)
- Model parameters → Paralog copy number: provides parameters (evidence: `src/parascopy/inner/model_params.py`)
- Copy-number HMM → Paralog copy number: supports inference (evidence: `src/parascopy/inner/paralog_cn.py`)
- CN results → Variant calling: anchors calling (evidence: `README.md`)
- Variant calling → Variant evidence: uses genotype logic (evidence: `src/parascopy/call_variants.py`)
- Variant calling → Variant results: writes VCF (evidence: `README.md`)
- Variant pooling → Read pooling: reuses read pooling (evidence: `src/parascopy/pool_variants.py`)
- Variant pooling → Copy-number analysis: uses CN analysis (evidence: `src/parascopy/pool_variants.py`)
- Variant pooling → PSV discovery: uses PSV data (evidence: `src/parascopy/pool_variants.py`)
- Multiple alignment → Homology table: uses duplication table (evidence: `src/parascopy/msa.py`)
- Preliminary table → Genome intervals: uses reference (evidence: `src/parascopy/pretable.py`)
- Homology table builder → Genome intervals: uses reference (evidence: `src/parascopy/combine_table.py`)
- Background depth → Genome intervals: uses intervals (evidence: `src/parascopy/depth.py`)
- Copy-number analysis → Genome intervals: uses intervals (evidence: `src/parascopy/detect_cn.py`)
- Variant calling → Genome intervals: uses reference (evidence: `src/parascopy/call_variants.py`)
- Genome intervals → Duplication model: defines coordinates (evidence: `src/parascopy/inner/duplication.py`)
- Duplication model → Alignment utilities: aligns reads (evidence: `src/parascopy/inner/duplication.py`)
- Alignment utilities → CIGAR utilities: uses operations (evidence: `src/parascopy/inner/alignment.py`)
- Duplication model → CIGAR utilities: uses operations (evidence: `src/parascopy/inner/duplication.py`)
- Variant evidence → Interval indexing: indexes positions (evidence: `src/parascopy/inner/variants.py`)
- Paralog copy number → Interval indexing: indexes regions (evidence: `src/parascopy/inner/paralog_cn.py`)
