# lhatsk/alphalink architecture

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

- Interactive diagram: https://gitdiagram.com/lhatsk/alphalink
- Repository: https://github.com/lhatsk/alphalink

## Overview

AlphaLink extends OpenFold to predict protein structures from a sequence plus experimental crosslink restraints, including contact-threshold and distogram inputs. Its main workflow is restraint preparation, sequence/MSA/template feature generation, model inference with restraint-aware embeddings, and structure output with optional relaxation. The repository also includes OpenFold training and IHM deposition paths. Relationships below rely on the README and SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`predict_with_crosslinks.py`](https://github.com/lhatsk/alphalink/blob/main/predict_with_crosslinks.py) (Crosslink inference), [`openfold/model/model.py`](https://github.com/lhatsk/alphalink/blob/main/openfold/model/model.py) (AlphaLink model), [`openfold/data/data_pipeline.py`](https://github.com/lhatsk/alphalink/blob/main/openfold/data/data_pipeline.py) (Raw feature assembly), [`openfold/np/protein.py`](https://github.com/lhatsk/alphalink/blob/main/openfold/np/protein.py) (Protein structure encoding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Restraints and inputs"]
  node_seq_restraint["Sequence and restraints"]
  node_distribution_prep["Distogram conversion"]
end

subgraph group_features["Feature preparation"]
  node_alignment["MSA search<br/>[data_pipeline.py]"]
  node_search_tools["Search tools"]
  node_template["Template features<br/>[templates.py]"]
  node_raw_features["Raw feature assembly<br/>[data_pipeline.py]"]
  node_feature_pipeline["Tensor features"]
end

subgraph group_modeling["Structure prediction"]
  node_predict_cli["Crosslink inference"]
  node_model["AlphaLink model<br/>[model.py]"]
  node_embedders["Input and restraint embedding<br/>[embedders.py]"]
  node_evoformer["Evoformer trunk<br/>[evoformer.py]"]
  node_structure_module["Structure module"]
  node_model_heads["Prediction heads<br/>[heads.py]"]
end

subgraph group_outputs["Structure outputs"]
  node_protein_codec["Protein structure encoding<br/>[protein.py]"]
  node_relax["Structure relaxation<br/>[relax.py]"]
  node_structure_file["Predicted structure"]
end

subgraph group_other["Training and deposition"]
  node_training["Model training<br/>[train_openfold.py]"]
  node_ihm["IHM deposition writer<br/>[make_ihm.py]"]
end

node_user(("Researcher"))
node_mmcif["mmCIF model"]

node_user -->|"provides"| node_seq_restraint
node_seq_restraint -->|"converts distributions"| node_distribution_prep
node_seq_restraint -->|"supplies inputs"| node_predict_cli
node_distribution_prep -->|"prepares distograms"| node_predict_cli
node_predict_cli -->|"runs or loads alignments"| node_alignment
node_alignment -->|"invokes search tools"| node_search_tools
node_predict_cli -->|"assembles features"| node_raw_features
node_raw_features -->|"uses template featurizer"| node_template
node_predict_cli -->|"processes features"| node_feature_pipeline
node_feature_pipeline -->|"transforms raw features"| node_raw_features
node_predict_cli -->|"runs inference"| node_model
node_model -->|"embeds inputs"| node_embedders
node_model -->|"updates representations"| node_evoformer
node_model -->|"generates coordinates"| node_structure_module
node_model -->|"computes predictions"| node_model_heads
node_predict_cli -->|"serializes structure"| node_protein_codec
node_predict_cli -->|"optionally relaxes"| node_relax
node_relax -->|"uses protein representation"| node_protein_codec
node_protein_codec -.->|"writes structure"| node_structure_file
node_user -->|"trains model"| node_training
node_user -->|"requests deposition file"| node_ihm
node_mmcif -->|"provides model input"| node_ihm

click node_distribution_prep "https://github.com/lhatsk/alphalink/blob/main/preprocessing_distributions.py"
click node_predict_cli "https://github.com/lhatsk/alphalink/blob/main/predict_with_crosslinks.py"
click node_alignment "https://github.com/lhatsk/alphalink/blob/main/openfold/data/data_pipeline.py"
click node_search_tools "https://github.com/lhatsk/alphalink/tree/main/openfold/data/tools"
click node_template "https://github.com/lhatsk/alphalink/blob/main/openfold/data/templates.py"
click node_raw_features "https://github.com/lhatsk/alphalink/blob/main/openfold/data/data_pipeline.py"
click node_feature_pipeline "https://github.com/lhatsk/alphalink/blob/main/openfold/data/feature_pipeline.py"
click node_model "https://github.com/lhatsk/alphalink/blob/main/openfold/model/model.py"
click node_embedders "https://github.com/lhatsk/alphalink/blob/main/openfold/model/embedders.py"
click node_evoformer "https://github.com/lhatsk/alphalink/blob/main/openfold/model/evoformer.py"
click node_structure_module "https://github.com/lhatsk/alphalink/blob/main/openfold/model/structure_module.py"
click node_model_heads "https://github.com/lhatsk/alphalink/blob/main/openfold/model/heads.py"
click node_protein_codec "https://github.com/lhatsk/alphalink/blob/main/openfold/np/protein.py"
click node_relax "https://github.com/lhatsk/alphalink/blob/main/openfold/np/relax/relax.py"
click node_training "https://github.com/lhatsk/alphalink/blob/main/train_openfold.py"
click node_ihm "https://github.com/lhatsk/alphalink/blob/main/make_ihm.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_seq_restraint,node_distribution_prep toneBlue
class node_alignment,node_search_tools,node_template,node_raw_features,node_feature_pipeline toneAmber
class node_predict_cli,node_model,node_embedders,node_evoformer,node_structure_module,node_model_heads toneMint
class node_protein_codec,node_relax,node_structure_file toneRose
class node_training,node_ihm,node_user,node_mmcif toneIndigo
```

## Components

### Restraints and inputs

- **Sequence and restraints**
- [Distogram conversion](https://github.com/lhatsk/alphalink/blob/main/preprocessing_distributions.py): `preprocessing_distributions.py`

### Feature preparation

- [MSA search](https://github.com/lhatsk/alphalink/blob/main/openfold/data/data_pipeline.py): `openfold/data/data_pipeline.py`
- [Search tools](https://github.com/lhatsk/alphalink/tree/main/openfold/data/tools): `openfold/data/tools`
- [Template features](https://github.com/lhatsk/alphalink/blob/main/openfold/data/templates.py): `openfold/data/templates.py`
- [Raw feature assembly](https://github.com/lhatsk/alphalink/blob/main/openfold/data/data_pipeline.py): `openfold/data/data_pipeline.py`
- [Tensor features](https://github.com/lhatsk/alphalink/blob/main/openfold/data/feature_pipeline.py): `openfold/data/feature_pipeline.py`

### Structure prediction

- [Crosslink inference](https://github.com/lhatsk/alphalink/blob/main/predict_with_crosslinks.py): `predict_with_crosslinks.py`
- [AlphaLink model](https://github.com/lhatsk/alphalink/blob/main/openfold/model/model.py): `openfold/model/model.py`
- [Input and restraint embedding](https://github.com/lhatsk/alphalink/blob/main/openfold/model/embedders.py): `openfold/model/embedders.py`
- [Evoformer trunk](https://github.com/lhatsk/alphalink/blob/main/openfold/model/evoformer.py): `openfold/model/evoformer.py`
- [Structure module](https://github.com/lhatsk/alphalink/blob/main/openfold/model/structure_module.py): `openfold/model/structure_module.py`
- [Prediction heads](https://github.com/lhatsk/alphalink/blob/main/openfold/model/heads.py): `openfold/model/heads.py`

### Structure outputs

- [Protein structure encoding](https://github.com/lhatsk/alphalink/blob/main/openfold/np/protein.py): `openfold/np/protein.py`
- [Structure relaxation](https://github.com/lhatsk/alphalink/blob/main/openfold/np/relax/relax.py): `openfold/np/relax/relax.py`
- **Predicted structure**

### Training and deposition

- [Model training](https://github.com/lhatsk/alphalink/blob/main/train_openfold.py): `train_openfold.py`
- [IHM deposition writer](https://github.com/lhatsk/alphalink/blob/main/make_ihm.py): `make_ihm.py`

### Other components

- **Researcher**
- **mmCIF model**

## Connections

- Researcher → Sequence and restraints: provides
- Sequence and restraints → Distogram conversion: converts distributions
- Sequence and restraints → Crosslink inference: supplies inputs
- Distogram conversion → Crosslink inference: prepares distograms
- Crosslink inference → MSA search: runs or loads alignments (evidence: `predict_with_crosslinks.py`)
- MSA search → Search tools: invokes search tools (evidence: `openfold/data/data_pipeline.py`)
- Crosslink inference → Raw feature assembly: assembles features (evidence: `predict_with_crosslinks.py`)
- Raw feature assembly → Template features: uses template featurizer (evidence: `openfold/data/data_pipeline.py`)
- Crosslink inference → Tensor features: processes features (evidence: `predict_with_crosslinks.py`)
- Tensor features → Raw feature assembly: transforms raw features (evidence: `openfold/data/feature_pipeline.py`)
- Crosslink inference → AlphaLink model: runs inference (evidence: `predict_with_crosslinks.py`)
- AlphaLink model → Input and restraint embedding: embeds inputs (evidence: `openfold/model/model.py`)
- AlphaLink model → Evoformer trunk: updates representations (evidence: `openfold/model/model.py`)
- AlphaLink model → Structure module: generates coordinates (evidence: `openfold/model/model.py`)
- AlphaLink model → Prediction heads: computes predictions (evidence: `openfold/model/model.py`)
- Crosslink inference → Protein structure encoding: serializes structure (evidence: `predict_with_crosslinks.py`)
- Crosslink inference → Structure relaxation: optionally relaxes (evidence: `predict_with_crosslinks.py`)
- Structure relaxation → Protein structure encoding: uses protein representation (evidence: `openfold/np/relax/relax.py`)
- Protein structure encoding → Predicted structure: writes structure
- Researcher → Model training: trains model (evidence: `train_openfold.py`)
- Researcher → IHM deposition writer: requests deposition file
- mmCIF model → IHM deposition writer: provides model input
