# liguowang/cpat architecture

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

- Interactive diagram: https://gitdiagram.com/liguowang/cpat
- Repository: https://github.com/liguowang/cpat

## Overview

CPAT is a command-line bioinformatics tool for assessing RNA coding potential. Its main workflow reads FASTA or BED input, finds candidate ORFs, computes Fickett and hexamer features, applies a logistic-regression model, and writes ORF-level and best-ORF results. The package also exposes commands for preparing hexamer tables and logistic-regression models. The excerpts show the core analysis and scoring calls; some downstream CLI-to-utility wiring is unsampled, so those links are omitted or marked unverified.

Main entry points: [`src/cpmodule/__init__.py`](https://github.com/liguowang/cpat/blob/master/src/cpmodule/__init__.py) (CPAT CLI), [`src/cpmodule/utils.py`](https://github.com/liguowang/cpat/blob/master/src/cpmodule/utils.py) (Model prediction), [`src/cpmodule/FrameKmer.py`](https://github.com/liguowang/cpat/blob/master/src/cpmodule/FrameKmer.py) (FASTA parsing), [`src/cpmodule/ireader.py`](https://github.com/liguowang/cpat/blob/master/src/cpmodule/ireader.py) (Input reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Prediction workflow"]
  node_cli["CPAT CLI<br/>[__init__.py]"]
  node_fasta["FASTA parsing<br/>[FrameKmer.py]"]
  node_reader["Input reader<br/>[ireader.py]"]
  node_bed["BED extraction<br/>[utils.py]"]
  node_orf["ORF finder<br/>[find_orfs.py]"]
end

subgraph group_features["Sequence features"]
  node_fickett["Fickett score<br/>[fickett.py]"]
  node_hexamer["Hexamer score<br/>[FrameKmer.py]"]
end

subgraph group_models["Modeling and outputs"]
  node_prediction["Model prediction<br/>[utils.py]"]
  node_models[("Prebuilt models")]
  node_results["Prediction outputs<br/>[__init__.py]"]
  node_model_tools["Model preparation<br/>[__init__.py]"]
end

node_user(("Analyst"))
node_genome[("Reference genome")]
node_rscript["R runtime"]

node_user -->|"runs"| node_cli
node_cli -->|"reads FASTA"| node_fasta
node_fasta -->|"reads input"| node_reader
node_cli -->|"extracts BED"| node_bed
node_bed -->|"fetches exons"| node_genome
node_cli -->|"finds ORFs"| node_orf
node_cli -->|"scores ORFs"| node_fickett
node_cli -->|"scores ORFs"| node_hexamer
node_prediction -->|"runs script"| node_rscript
node_prediction -->|"loads model"| node_models
node_cli -->|"writes results"| node_results
node_cli -.->|"requests prediction"| node_prediction
node_user -->|"prepares models"| node_model_tools

click node_cli "https://github.com/liguowang/cpat/blob/master/src/cpmodule/__init__.py"
click node_fasta "https://github.com/liguowang/cpat/blob/master/src/cpmodule/FrameKmer.py"
click node_reader "https://github.com/liguowang/cpat/blob/master/src/cpmodule/ireader.py"
click node_bed "https://github.com/liguowang/cpat/blob/master/src/cpmodule/utils.py"
click node_orf "https://github.com/liguowang/cpat/blob/master/src/cpmodule/find_orfs.py"
click node_fickett "https://github.com/liguowang/cpat/blob/master/src/cpmodule/fickett.py"
click node_hexamer "https://github.com/liguowang/cpat/blob/master/src/cpmodule/FrameKmer.py"
click node_prediction "https://github.com/liguowang/cpat/blob/master/src/cpmodule/utils.py"
click node_models "https://github.com/liguowang/cpat/tree/master/prebuilt_models"
click node_results "https://github.com/liguowang/cpat/blob/master/src/cpmodule/__init__.py"
click node_model_tools "https://github.com/liguowang/cpat/blob/master/src/cpmodule/__init__.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_fasta,node_reader,node_bed,node_orf toneBlue
class node_fickett,node_hexamer,node_genome toneAmber
class node_prediction,node_models,node_results,node_model_tools toneMint
class node_user,node_rscript toneIndigo
```

## Components

### Prediction workflow

- [CPAT CLI](https://github.com/liguowang/cpat/blob/master/src/cpmodule/__init__.py): `src/cpmodule/__init__.py`
- [FASTA parsing](https://github.com/liguowang/cpat/blob/master/src/cpmodule/FrameKmer.py): `src/cpmodule/FrameKmer.py`
- [Input reader](https://github.com/liguowang/cpat/blob/master/src/cpmodule/ireader.py): `src/cpmodule/ireader.py`
- [BED extraction](https://github.com/liguowang/cpat/blob/master/src/cpmodule/utils.py): `src/cpmodule/utils.py`
- [ORF finder](https://github.com/liguowang/cpat/blob/master/src/cpmodule/find_orfs.py): `src/cpmodule/find_orfs.py`

### Sequence features

- [Fickett score](https://github.com/liguowang/cpat/blob/master/src/cpmodule/fickett.py): `src/cpmodule/fickett.py`
- [Hexamer score](https://github.com/liguowang/cpat/blob/master/src/cpmodule/FrameKmer.py): `src/cpmodule/FrameKmer.py`

### Modeling and outputs

- [Model prediction](https://github.com/liguowang/cpat/blob/master/src/cpmodule/utils.py): `src/cpmodule/utils.py`
- [Prebuilt models](https://github.com/liguowang/cpat/tree/master/prebuilt_models): `prebuilt_models`
- [Prediction outputs](https://github.com/liguowang/cpat/blob/master/src/cpmodule/__init__.py): `src/cpmodule/__init__.py`
- [Model preparation](https://github.com/liguowang/cpat/blob/master/src/cpmodule/__init__.py): `src/cpmodule/__init__.py`

### Other components

- **Analyst**
- **Reference genome**
- **R runtime**

## Connections

- Analyst → CPAT CLI: runs
- CPAT CLI → FASTA parsing: reads FASTA (evidence: `src/cpmodule/__init__.py`)
- FASTA parsing → Input reader: reads input (evidence: `src/cpmodule/FrameKmer.py`)
- CPAT CLI → BED extraction: extracts BED (evidence: `src/cpmodule/__init__.py`)
- BED extraction → Reference genome: fetches exons (evidence: `src/cpmodule/utils.py`)
- CPAT CLI → ORF finder: finds ORFs (evidence: `src/cpmodule/__init__.py`)
- CPAT CLI → Fickett score: scores ORFs (evidence: `src/cpmodule/__init__.py`)
- CPAT CLI → Hexamer score: scores ORFs (evidence: `src/cpmodule/__init__.py`)
- Model prediction → R runtime: runs script (evidence: `src/cpmodule/utils.py`)
- Model prediction → Prebuilt models: loads model (evidence: `src/cpmodule/utils.py`)
- CPAT CLI → Prediction outputs: writes results (evidence: `src/cpmodule/__init__.py`)
- CPAT CLI → Model prediction: requests prediction (evidence: `src/cpmodule/__init__.py`)
- Analyst → Model preparation: prepares models
