A computational pipeline for designing synthetic overlapping gene pairs using dynamic programming, Hidden Markov Models (HMMs), and Potts statistical models.
This pipeline designs overlapping gene sequences where two coding sequences share a common nucleotide region while maintaining proper translation in different reading frames. The approach combines:
- Dynamic Programming: Optimal alignment with customizable gap penalties
- Profile HMMs: Evolutionary constraints from multiple sequence alignments
- Potts Models: Direct coupling analysis for sequence optimization
- Greedy Optimization: Codon-level refinement for improved fitness
bash setup_mac.sh
source activate_release.sh
bash test_pipeline.sh
python scripts/dpalign.py purE hisI 1module load cuda # Load CUDA module first
bash setup_hpc.sh
source activate_release.sh
bash test_pipeline.sh
python scripts/dpalign.py purE hisI 1- Operating System: macOS or Linux (HPC)
- Package Manager: Conda or Mamba (system-level installation required for initial setup)
- Python: 3.11 (installed locally in conda/)
- CUDA (HPC only): For Potts model training with CCMpred
- Disk Space: ~5GB for complete installation
- 2GB: Example gene data (Potts models)
- 3GB: Conda environment with all tools
Fully Self-Contained: All packages, tools, and dependencies are installed within the conda/ directory. No global environment pollution. The entire environment can be transferred by copying just the conda/ directory.
git lfs install
git clone https://github.com/BiosecSFA/PAGODA.git# 1. Install Miniconda if not already installed
# Download from: https://docs.conda.io/en/latest/miniconda.html
# 2. Run setup script
bash setup_mac.sh
# 3. Activate environment
source activate_release.shNote: CCMpred on macOS runs in CPU-only mode (slower than GPU). For faster Potts model generation, use HPC with CUDA. Pre-computed Potts models are included for the example genes.
# 1. Load CUDA module (if available)
module load cuda
# 2. Run setup script
bash setup_hpc.sh
# 3. Activate environment
source activate_release.shThe setup script will:
- Create self-contained conda environment in
conda/directory - Install Python 3.11 and all dependencies locally
- Build HMMER 3.4 from source in
conda/external/hmmer/ - Build CCMpred in
conda/external/ccmpred/(CPU-only on macOS, CUDA on HPC) - Install pycameox and potts packages in
conda/external/ - Configure environment activation script
Note: Everything is installed within the conda/ directory, making it fully portable and self-contained. Simply move or copy the conda/ folder to transfer the entire environment.
Run the test script to validate the installation:
bash test_pipeline.shThis will verify:
- All Python packages are installed correctly
- External tools (HMMER, CCMpred) are available
- Data files exist for example genes
- Scripts can be executed
- Pipeline produces output for a test case
# Requires UniRef90 database (see "Generating Models" below)
bash test_pipeline.sh --fullThis release includes 4 example genes with complete data files:
| Gene | Size | Description |
|---|---|---|
| purE | 169 aa | Small, used in experimental validation (purE_hisI library) |
| hisI | 202 aa | Small-medium, used in experimental validation |
| ilvE | 309 aa | Medium, used in experimental validation (ilvE_gltA library) |
| gltA | 427 aa | Medium-large, used in experimental validation |
Each gene includes:
- Protein sequence (FASTA):
data/split_fasta/{gene}.fasta - CDS sequence (nucleotide):
data/split_cds/{gene}.fastaORdata/cds.fasta - Profile HMM:
data/hmm/{gene}.hmm - Potts model:
data/raw/{gene}.raw
Note on CDS sequences: The pipeline requires individual CDS files in data/split_cds/. You can provide these in two ways:
- Individual files: Place each gene's CDS sequence in
data/split_cds/{gene}.fasta - Combined file: Place all CDS sequences in
data/cds.fastaand extract them:# Extract individual CDS files from combined FASTA cd data for gene in gene1 gene2 gene3; do grep -A1 "^>${gene}$" cds.fasta > split_cds/${gene}.fasta done
# Basic usage
python scripts/dpalign.py purE hisI 1
# With custom parameters
python scripts/dpalign.py ilvE gltA 1 \
--del_penalty 4.0 \
--ins_penalty 1.0 \
--match_weight 0.3 \
--output-dir resultsParameters:
gene1 gene2: Names of genes to overlaprep_number: Replicate number (for tracking multiple runs)--del_penalty: Deletion penalty (higher = fewer deletions, default: 4.0)--ins_penalty: Insertion penalty (higher = fewer insertions, default: 1.0)--match_weight: Wild-type sequence preference (0-1, default: 0.3)--output-dir: Output directory (default: current directory)
Output:
- CSV file:
{output_dir}/{gene1}_{gene2}_del{pdel}_ins{pins}_{wmatch}_rep{rep}.csv - Contains all designed overlapping sequences with scores and properties
# Generate circos plot showing residue couplings
python scripts/plot_ccmpred_circos.py \
data/raw/purE.raw \
purE_circos.png \
--fasta data/split_fasta/purE.fasta \
--label-every 20To prepare models for genes not included in this release, you'll need the UniRef90 database (~50GB).
mkdir -p data/db
cd data/db
wget https://ftp.uniprot.org/pub/databases/uniprot/uniref/uniref90/uniref90.fasta.gz
gunzip uniref90.fasta.gz
cd ../..Before generating models, ensure you have the required input files:
-
Add gene information to
data/gene_info_final_table.tsv:Gene Description Length_aa newgene Description 300 -
Add protein sequence to
data/split_fasta/newgene.fasta:>newgene MKKL... -
Add CDS sequence - Choose one method:
Method A: Individual file in
data/split_cds/newgene.fasta:>newgene ATGAAAAAA...Method B: Add to combined file
data/cds.fasta, then extract:cd data grep -A1 "^>newgene$" cds.fasta > split_cds/newgene.fasta
On macOS (complete models, CCMpred in CPU-only mode):
python scripts/prepare_gene_models.py newgene \
--database data/db/uniref90.fastaNote: CCMpred runs slower on macOS CPU. For large proteins or many genes, use HPC with CUDA.
On HPC/Linux (complete models):
module load cuda
python scripts/prepare_gene_models.py newgene \
--database data/db/uniref90.fastaThis will create:
- MSA (multiple sequence alignment) in data/msa/
- Profile HMM in data/hmm/
- Potts model in data/raw/ (HPC only)
The pipeline generates CSV files with one row per designed overlapping sequence:
| Column | Description |
|---|---|
seqid |
Unique sequence identifier |
gene1, gene2 |
Gene names |
minlen |
Minimum overlap length constraint |
order |
Gene order (12 or 21) |
full_seq |
Complete overlapping nucleotide sequence |
start1, end1 |
Coordinates in gene1 protein (nucleotide positions) |
start2, end2 |
Coordinates in gene2 protein (nucleotide positions) |
overlaplen |
Actual overlap length (amino acids) |
raw1, raw2 |
Initial aligned protein sequences (with gaps -) |
init1, init2 |
Initial protein sequences (no gaps) |
optim1, optim2 |
Optimized protein sequences (after greedy refinement) |
init1_score, init2_score |
Initial Potts model scores |
optim1_score, optim2_score |
Optimized Potts model scores |
CCMpred requires CUDA which is only available for NVIDIA GPUs. macOS does not support NVIDIA GPUs.
Solutions:
- Use pre-computed Potts models (included for example genes)
- Generate MSA and HMM on macOS, then run CCMpred on HPC:
# On macOS python scripts/prepare_gene_models.py gene --database data/db/uniref90.fasta --skip-ccmpred # Transfer data/msa/gene.a3m to HPC # On HPC with GPU module load cuda ccmpred data/msa/gene.a3m data/raw/gene.raw # Transfer data/raw/gene.raw back to macOS
If CCMpred compilation fails:
# Load CUDA module
module avail cuda # Check available versions
module load cuda/11.0 # Or appropriate version
# Rebuild CCMpred
rm -rf external/CCMpred
bash setup_hpc.shRun the test script with verbose output:
bash -x test_pipeline.shCommon issues:
- Import errors: Check that PYTHONPATH is set correctly in activate_release.sh
- HMMER not found: Verify external/hmmer/bin/ is in PATH
- Missing data files: Re-run setup script to rebuild
If source activate_release.sh fails:
# Manually activate the local conda environment
conda activate $(pwd)/conda
# Set paths manually
export PATH="$(pwd)/external/hmmer/bin:$PATH"
export PYTHONPATH="$(pwd):$(pwd)/external/pycameox/src:$(pwd)/external/potts:$PYTHONPATH"The environment is fully self-contained and can be moved to a different location:
# Move the entire directory
mv release /new/location/
# Re-activate (paths are relative)
cd /new/location/release
source activate_release.shAll paths in activate_release.sh are relative to the release directory, so it remains portable.
The conda/ directory contains everything needed:
# Transfer to another system
tar -czf overlap-design-env.tar.gz conda/
# Transfer file, then extract on target system
tar -xzf overlap-design-env.tar.gz
# The conda/ directory now contains:
# - Python 3.11 and all packages
# - HMMER, pycameox, potts
# - CCMpred (if built on HPC)The score matrix S[i,j,k,l] represents:
i: Position in protein 1j: Position in protein 2k: Previous nucleotide (0-4, or deletion state)l: Current nucleotide (0-3)
States: m (match), d (deletion), i1 (insertion seq1), i2 (insertion seq2)
Total score = HMM log-probability + Potts energy
HMM component:
- Match emission probabilities from profile HMM
- Transition probabilities with adjustable penalties
- Insertion/deletion costs
Potts component:
- Single-site terms h(i, a)
- Pairwise coupling terms W(i, a, j, b)
- Wild-type sequence bonus (controlled by
match_weight)
- Initial Design: DP algorithm with HMM constraints finds optimal alignment
- Greedy Refinement: For each codon in overlap, try all synonymous codons and keep changes that improve Potts score while respecting both reading frames
If you use this pipeline, please cite:
[Publication information to be added]
- HMMER: http://hmmer.org/
- CCMpred: https://github.com/soedinglab/CCMpred
- Potts Models: Weigt et al., PNAS 2009; Morcos et al., PNAS 2011
- Profile HMMs: Eddy, Current Opinion in Structural Biology 1996
- pyCameoX: Codon optimization library (BiosecSFA)
- Biotite: Kunzmann & Hamacher, BMC Bioinformatics 2018
MIT License
Chenling Xu: chenlingantelope@gmail.com
This release package includes example genes with experimental validation data from the ilvE/gltA and purE_hisI libraries.