This repo walks the hemoglobin beta Glu6Val (E6V) story from primary sequence through structural context. It keeps the focus on the actual biology, the steps needed to reproduce the analysis, and the files you get at the end.
- Objective: Detect and explain the beta6 Glu->Val substitution using curated sequences, alignments, substitution matrices, BLAST confirmation, and structural context.
- Stack: Python 3.11+, Biopython (alignments, BLOSUM, PDB parsing), Matplotlib (figures), EMBOSS/BLAST+ (documented), py3Dmol-ready for future rendering.
- Scientific scope: Educational reproduction of a known variant; no novelty or clinical claims.
- Prompt: Determine whether an unknown beta-globin sequence corresponds to the sickle-cell variant (E6V) by interrogating sequence QC, alignments, substitution scoring, BLAST hits, and structural context.
- Key readouts: percent identity vs canonical HBB, BLOSUM penalty for E->V, BLAST hit table, residue-6 contact environment in 4HHB vs 2HBS.
Environment files shipped in this repo
pyproject.toml– the list of Python dependencies used byuv.uv syncreads this file (and generates a localuv.lockthe first time you run it).environment/environment.yml– the conda recipe that includes Python 3.11, Biopython, Matplotlib, NumPy, EMBOSS, BLAST+, and the two small pip add-ons (py3Dmol,pypdf).requirements-smoke.txt– the lean requirements list used by CI; it is handy if you just want to mimic the automated smoke test with plainpip.uv.lock– not committed yet because network-free environments cannot regenerate it. When you runuv synclocally it will create one for you inside the repo.
Need a slower walkthrough? See docs/setup_for_beginners.md.
- With Git:
Git keeps the history, so this is the easiest option if you plan to contribute changes.
git clone https://github.com/<your-account>/hemoglobin-e6v-case-study.git
- Without Git:
Download the ZIP from GitHub (Code▸Download ZIP), unzip it, and a folder with all the files will appear.
Use cd to move into the folder you just cloned or unzipped (for example cd hemoglobin-e6v-case-study). Every command below assumes you are inside this folder so the scripts and data paths resolve correctly.
- Install
uvif you do not already have it (pip install uvor follow uv’s install guide). - Run:
uv sync
uv syncreadspyproject.toml(anduv.lockif present), downloads the pinned packages, and creates a.venv/folder inside the repo. The first run will also generate a localuv.lock. You do not need to activate anything manually—every command can be prefixed withuv run.
- Make sure Anaconda/Miniconda/Mamba is installed.
- Run:
That command reads the YAML file in
conda env create -f environment/environment.yml
environment/, builds an environment namedhemoglobin-e6v, and installs Python plus BLAST/EMBOSS extras that live on conda-forge. - Activate it before running scripts:
conda activate hemoglobin-e6v
If you only want the minimal packages used by CI, you can also run pip install -r requirements-smoke.txt in any Python 3.11 environment; it installs Biopython, Matplotlib, and NumPy (you would still need to supply BLAST+ yourself for online runs).
- uv path:
uv run python scripts/sequence_summary.py - conda path:
python scripts/sequence_summary.py(because the environment is already active)
The script reads the versioned FASTA files under data/raw/{uniprot,secret_sequences}/, then writes two outputs:
data/processed/sequence_summary.tsvreports/sequence_summary.md
Verify that both files appear and mention the secret alpha/beta records. Once that works, you can run the remaining steps.
The commands below assume you are either using uv run python ... or, if you activated the conda environment, simply python ....
- Sequence summary –
uv run python scripts/sequence_summary.py
Parses all FASTA files and regeneratesdata/processed/sequence_summary.tsvandreports/sequence_summary.md. - Pairwise alignments –
uv run python scripts/run_alignments.py --gap-open 10 --gap-extend 0.5
Runs the BRCA1↔53BP1 calibration plus hemoglobin vs secret alignments; writesdata/processed/alignment_summary.tsvand plain-text alignments indata/processed/alignments/. - QC figures –
uv run python scripts/make_figures.py
Regeneratesfigures/fig01_sequence_characteristics.pngandfigures/fig06_blosum_penalty.png. - Dotplots –
uv run python scripts/make_dotplots.py
Outputs the BRCA1 calibration (figures/fig03_dotplots_brca1_53bp1.png) and the two hemoglobin vs secret dotplots (figures/fig04a/b). - Canonical vs secret beta illustration –
uv run python scripts/make_alignment_figure.py
Producesfigures/fig05_beta_variant_alignment.pngwith the E6V site labeled. - Structural contacts –
uv run python scripts/analyze_structure.py --radius 5.0
Counts residue classes within 5 Å around beta6 and writesdata/processed/structure_contacts.csvplusreports/structure_summary.md. - Structure figure –
uv run python scripts/make_structure_figure.py
Generatesfigures/fig08_structure_comparison.png. - BLAST artifacts –
uv run python scripts/run_blastp.py
Createsdata/processed/blast/secret_beta_query.fasta, refreshes (or copies)data/processed/blast/secret_beta_blast.xml, and logs instructions inreports/blast_protocol.md. Use--offlineif BLAST+ or network access is unavailable. - BLAST hit visualization –
uv run python scripts/make_blast_figure.py
Converts the cached or freshly generated BLAST XML intofigures/fig07_blast_hits.pngand updatesreports/blast_summary.md.
Outputs land under data/processed/, reports/, and figures/. BRCA1 vs 53BP1 remains as a "tool calibration" checkpoint; it shows how gap penalties behave on low-identity sequences before trusting the hemoglobin alignments. BLAST defaults to the cached XML if neither local BLAST+ nor outbound network is available; the cached artifact lives under data/raw/reference/blast/. Interaction-database interpretation is captured separately as a supporting note (see Supporting Notes & Provenance).
- Do I need Git? No. Git makes updates easier, but downloading the ZIP from GitHub gives you the exact same files; you just need to unzip them and use
cdto enter the folder. - What does
uv syncread? It readspyproject.toml(anduv.lockif it exists) to learn which Python packages and versions to install. If the repo does not ship a lockfile yet,uv syncwill create one locally after it resolves the dependencies. - What does
conda env create -f environment/environment.ymlread? It reads the YAML file stored in theenvironment/folder. That file already lists the environment name (hemoglobin-e6v), channels (conda-forge), and packages (Python, Biopython, Matplotlib, NumPy, EMBOSS, BLAST, plus two pip extras). - Why do I need to activate an environment? Activation tells your shell which Python interpreter and site-packages folder to use. Without
conda activate hemoglobin-e6v,pythonwould try to run with whatever packages happen to be installed globally, and the scripts would fail.uv runwraps activation for you, which is why it does not require a separate step.
flowchart LR
A[Canonical sequences]
B[Secret bundle]
C[Alignments & dotplots]
D[BLOSUM context]
E[BLAST identity]
F[Structure contacts]
A --> C
B --> C
C --> D --> E --> F
- Canonical sequence retrieval: pull P69905 (alpha) and P68871 (beta) from UniProt for clean references.
- Secret sequence comparison: parse the curated FASTA bundle and align headers/metadata to the canonical set.
- Alignment: run BRCA1<->53BP1 as a harsh control, then quantify alpha/beta identity and dotplots for the secret chains.
- BLOSUM interpretation: visualize the E6V penalty relative to the canonical E->E match to ground the substitution impact.
- BLAST identification: confirm the secret beta chain's nearest neighbors (HbS/Hb Monza) via reproducible BLAST XML + summary plots.
- Structure/function explanation: map beta6 contacts and visualize the hydrophobic patch introduced in 2HBS vs 4HHB.
| Step | Status | Notes |
|---|---|---|
| Sequence QC & metadata (scripts/sequence_summary.py) | automated | Produces TSV + Markdown summary with length, hydrophobicity, and charge ratios. |
| Pairwise alignments (scripts/run_alignments.py) | automated | Uses Biopython pairwise2 (warned for future deprecation) with BLOSUM62; includes the BRCA1<->53BP1 calibration run. |
| QC figures (scripts/make_figures.py) | automated | Regenerates fig01 (length/hydrophobicity) and fig06 (BLOSUM penalty). |
| Canonical vs secret beta alignment (scripts/make_alignment_figure.py) | automated | Generates fig05 with residue numbering + E6V annotation directly from the tracked FASTA files. |
| Dotplots (scripts/make_dotplots.py) | automated | Produces deterministic BRCA1 calibration plots plus hemoglobin vs secret dotplots (fig03-fig04b). |
| Structural context (scripts/analyze_structure.py) | automated | Counts residue classes within 5 Angstroms of beta6 in 4HHB vs 2HBS using downloaded PDBs. |
| Structural visualization (scripts/make_structure_figure.py) | automated | Produces fig08 by plotting beta6-centered contact clouds for 4HHB vs 2HBS. |
| BLAST identification (scripts/run_blastp.py) | partially automated | Script writes the exact CLI command + query FASTA; running BLAST requires local BLAST+. Falls back to cached XML if BLAST+/network unavailable. |
| BLAST hit visualization (scripts/make_blast_figure.py) | automated (depends on XML) | Renders fig07 from data/processed/blast/secret_beta_blast.xml; accuracy limited by the cached BLAST snapshot. |
| Interaction-database interpretation note | manual (documented) | BioGRID vs IntAct partner counts captured once to highlight database-dependent evidence; scripting deferred (see Supporting Notes & Provenance). |
| Artifact | Location |
|---|---|
| Sequence metrics table | data/processed/sequence_summary.tsv, reports/sequence_summary.md |
| Alignment text + summary | data/processed/alignments/*.txt, data/processed/alignment_summary.tsv, reports/alignment_summary.md (includes the BRCA1<->53BP1 calibration run) |
| Figures | listed above (see figures/README.md for captions and scripts) |
| Interaction-database interpretation note | documented manually; see Supporting Notes & Provenance |
| Structural contacts | data/processed/structure_contacts.csv, reports/structure_summary.md |
| BLAST artifacts | reports/blast_protocol.md, data/processed/blast/secret_beta_query.fasta, data/processed/blast/secret_beta_blast.xml, reports/blast_summary.md |
- Beta-chain alignment reports 99.32% identity with a single mismatch at position 7 (beta6), matching the E6V mutation seen in BLAST hits.
- BLOSUM62 comparison shows the canonical E->E self-match (+5) vs the E->V penalty (-2), visualized in
figures/fig06_blosum_penalty.png. - Structural contact analysis shows beta6 surrounded by ~1.3-1.4 Angstrom hydrophobic/polar contacts in 4HHB and 2HBS, underscoring how Val6 introduces a surface hydrophobic patch (
reports/structure_summary.md). - For a deeper narrative (why the mutation matters, how to read each output, what conclusions are fair), see
docs/08_biological_interpretation.md,docs/09_results_and_discussion.md, anddocs/05_common_misconceptions.md.
- Sequence, alignment, and structure scripts produce tracked TSV/MD outputs.
- BLAST wrapper documents the exact command, caches the query sequence, and ships a fallback XML + summary for offline environments.
- Generate dotplots via scripts (legacy screenshots removed).
- Add CI smoke tests (see
.github/workflows/smoke.yml). - Replace interaction network screenshots with scripted exports (BioGRID/IntAct APIs).
.github/workflows/smoke.yml installs a lightweight Python stack (Biopython + Matplotlib) and reruns scripts/sequence_summary.py, scripts/run_alignments.py, scripts/make_figures.py, scripts/make_dotplots.py, and scripts/analyze_structure.py on every push/PR targeting main/master.
- Interaction evidence: one-time manual BioGRID vs IntAct comparison retained as a database interpretation note; scripting is on the roadmap.
- Source materials: original briefing, solution write-up, and the untouched FASTA bundle live under
docs/archive/ComputationalBio_Directives.pdf,docs/archive/ComputationalBio_solutions.pdf, anddocs/archive/ComputationalBio_secret_sequences_original.fasta. - Derived docs: layered documentation lives in
docs/01_project_at_a_glance.mdthroughdocs/10_limitations_and_future_work.md, plusdocs/project_brief.{md,pdf}(public summary) andreports/workflow_report.md(execution log). - References:
docs/references/references.bib(e.g., Suhail 2024; Donkor et al. 2023); Biopython pairwise2 emits a deprecation warning—migrate toBio.Align.PairwiseAlignerwhen time permits.
- Archive layer (
docs/archive/) - preserve original identifiers to keep provenance explicit. - Working layer (
docs/,reports/,figures/) - use role-based names (project_brief,workflow_report,analysis_summary,blast_protocol) for immediate context. - Data/outputs -
data/{raw,processed}/<descriptive>.extaligning 1:1 with the generating script; figures followfigNN_description.pngand are cataloged infigures/README.md.