How lucian-ilie/e-score works
Purpose and Entry Points
E-score is a Python protein-sequence alignment toolkit that replaces fixed substitution matrices with context-dependent cosine similarity between per-residue protein-language-model embeddings. It supports local, global-regular, and semi-global dynamic-programming alignments.
Primary entry points:
• e_score_quick_start.py — aligns one sequence pair.
• full_test_example/testing_code.py — batch-runs alignment examples and persists per-test alignments plus aggregate distances.
• distances_and_extracting_local_alignments.py — derives distances and extracts local-alignment results.
Embedding Model Boundary
Model initialization and embedding extraction are isolated in initalizing_models_and_getting_embs.py. This is the boundary between raw protein strings and residue-vector matrices consumed by scoring/alignment logic.
The repository targets Ankh primarily and documents compatibility with ProtT5, ProstT5, ProtBert, ProtAlbert, ProtXLNet, ESM1b, and ESM2. These are expected to be available locally from Hugging Face rather than downloaded at runtime; model inference is the material compute/memory dependency (recommended Python 3.10 and 24 GB RAM).
Paths:
• initalizing_models_and_getting_embs.py
• requirement.txt
Alignment and Scoring Core
e_score_quick_start.py is the user-facing orchestration layer: it accepts two sequences, embedding model/tokenizer, gap-open and gap-extension penalties, an integer cosine-score shift, and alignment mode. It returns aligned sequence strings and optimal DP score.
The scoring boundary is embedding-derived cosine similarity; the alignment boundary is classical DP with affine-style gap controls. This separation enables the same alignment flow to run against different embedding models and parameterizations.
Paths:
• e_score_quick_start.py
• average_of_two_embedding_models.py
Batch Experiment Pipeline
The batch runner reads an examples CSV and parameter CSV, initializes a selected model, then processes examples sequentially. Each test emits an alignment text file; a shared distances CSV aggregates test-level distance results. The checked-in cd01068 run demonstrates the expected artifact layout and naming convention, including model and scoring parameters in filenames.
Paths:
• full_test_example/testing_code.py
• full_test_example/parms.csv
• full_test_example/cd01068_tests_example_output/cd01068_distances/cd01068_Ankh_0.00000_-1.00000_-0.10000_distances.csv
Inputs and Dataset Boundary
Inputs are file-based rather than database- or service-backed: curated local examples are packaged as ZIP archives, while global examples are supplied as BB/CDD archives and can be built from sequence pairs in an MSA. Batch input schemas are represented by the example CSVs and parameters CSV.
Paths:
• example_data_local/1_CDD_natural.zip
• example_data_global/BB_example_files.zip
• full_test_example/cd01068_examples.csv
Result Aggregation and Statistical Analysis
Post-processing operates on emitted CSV distance files. combining_distance_files.py consolidates result sets; averages_and_pvals.py computes comparative summaries/significance statistics. Notebooks and stored CSVs support method comparisons, sliding-window views, win ratios, and dot plots across Ankh, BLOSUM45, and US-alignment baselines.
Paths:
• analyzing_results/combining_distance_files.py
• analyzing_results/averages_and_pvals.py
• analyzing_results/all_methods_compared_plots/sliding_window_plot.ipynb
Execution and Infrastructure
This is a local/server-oriented Python workflow, with no deployable application or persistent backend represented in the tree. Batch-scale execution is supported by shell launch scripts, while local model files are the principal external asset. The referenced E-score web server is external to this repository.
Paths:
• full_test_example/job.sh
• full_test_example/over_extensions_calculation/extension.sh
Main entry points: testing_code.py Batch alignment runner · initalizing_models_and_getting_embs.py Embedding extraction · cd01068_examples.csv Batch examples · cd01068_Ankh_0.00000_-1.00000_-0.10000_distances.csv Distance results
Components 20
Input Data
- Local curated examples
example_data_local/1_CDD_natural.zip - Global BB/CDD examples
example_data_global/BB_example_files.zip - Batch examples
full_test_example/cd01068_examples.csv - Alignment parameters
full_test_example/parms.csv
Embedding & Alignment Core
- Single-pair alignment · Accepts sequences, model settings, penalties, and alignment mode.
e_score_quick_start.py - Embedding extraction · Converts protein strings into per-residue embedding matrices.
initalizing_models_and_getting_embs.py - Local protein language models · Ankh is primary; compatible Hugging Face models are loaded locally.
- Two-model embedding average
average_of_two_embedding_models.py - Cosine similarity scoring · Uses shifted cosine similarity between residue embeddings.
- Affine-gap DP alignment · Supports local, global-regular, and semi-global modes.
- Python dependencies · Defines the local Python environment dependencies.
requirement.txt
Batch Execution
- Batch alignment runner · Sequentially runs examples and writes per-test outputs.
full_test_example/testing_code.py - Batch job launcher
full_test_example/job.sh - Extension sweep launcher
full_test_example/over_extensions_calculation/extension.sh - Per-test alignments · Filenames encode model and scoring parameters.
- Distance results
full_test_example/cd01068_tests_example_output/cd01068_distances/cd01068_Ankh_0.00000_-1.00000_-0.10000_distances.csv - Distance & local extraction · Derives distances and local-alignment results.
distances_and_extracting_local_alignments.py
Result Analysis
- Distance consolidation
analyzing_results/combining_distance_files.py - Comparative statistics · Computes summaries and significance statistics.
analyzing_results/averages_and_pvals.py - Comparison visualizations · Supports sliding-window and method-comparison views.
analyzing_results/all_methods_compared_plots/sliding_window_plot.ipynb
Connections 23
- Local protein language models → Embedding extraction: loaded by
- Embedding extraction → Two-model embedding average: optional model outputs
- Embedding extraction → Cosine similarity scoring: residue vectors
- Two-model embedding average → Cosine similarity scoring: averaged vectors
- Cosine similarity scoring → Affine-gap DP alignment: substitution scores
- Single-pair alignment → Embedding extraction: embeds sequences
- Single-pair alignment → Affine-gap DP alignment: runs alignment
- Local curated examples → Batch examples: curated examples source
- Global BB/CDD examples → Batch examples: global examples source
- Batch examples → Batch alignment runner: sequence pairs
- Alignment parameters → Batch alignment runner: run settings
- Batch job launcher → Batch alignment runner: launches
- Extension sweep launcher → Batch alignment runner: sweeps extensions
- Batch alignment runner → Embedding extraction: initializes and embeds
- Batch alignment runner → Affine-gap DP alignment: aligns each test
- Batch alignment runner → Per-test alignments: writes
- Batch alignment runner → Distance results: aggregates
- Per-test alignments → Distance & local extraction: alignment results
- Distance & local extraction → Distance results: derived distances
- Distance results → Distance consolidation: result files
- Distance consolidation → Comparative statistics: consolidated data
- Comparative statistics → Comparison visualizations: comparison metrics
- Python dependencies → Embedding extraction: runtime dependencies