Metadata-Version: 2.5
Name: xwalk
Version: 0.0.1
Summary: Resolve protein identifiers to pinned, quality-tiered structures with cross-references and provenance
Project-URL: Homepage, https://xwalk.bio
Project-URL: Repository, https://github.com/xwalkbio/xwalk
Project-URL: Issues, https://github.com/xwalkbio/xwalk/issues
Author-email: Xwalk Bio <hello@xwalk.bio>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: alphafold,bioinformatics,crosswalk,docking,identifier,mcp,pdb,protein,structure,uniprot
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.12
Requires-Dist: duckdb>=2.0.0
Requires-Dist: fastapi>=0.162
Requires-Dist: httpx2>=2.16
Requires-Dist: mcp-types>=2.3
Requires-Dist: mcp>=2.3
Requires-Dist: obstore>=0.12.0
Requires-Dist: pydantic>=2.14
Requires-Dist: starlette>=1.10
Requires-Dist: uvicorn>=0.54
Provides-Extra: dev
Requires-Dist: jsonschema>=4; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown

# Xwalk

Xwalk resolves any protein identifier (gene name, UniProt accession, PDB entry or chain, AlphaFold ID, raw sequence) to one pinned, quality-tiered structure with a stable ID, cross-references to AlphaFold DB, PDB, UniProt/UniParc and ESM Atlas, and full provenance. It is delivered agent-first as a hosted MCP server with bundled skills, with a REST API underneath and the ID grammar available as a Python package.

**Status: pre-alpha; 0.0.1 is a name reservation.** The hosted service is not deployed yet.

```
pip install xwalk
```

This is not the unrelated [`crosswalk`](https://pypi.org/project/crosswalk/) package on PyPI.

The ID grammar works offline with no index or server:

```python
from xwalk.ids import seq_record, parse_any

rec = seq_record("MEEPQSDPSVEPPLSQETFSDLWKLLPENNVLSPLPSQAMDDLMLSPDDIEQWFTEDPGP")
print(rec.id)      # seq:sha256:402be4a45a1bc894a76bf88d1006824586c9ba09af81c1beffc08cbff970a7e2
print(rec.crc64)   # C7EAE751240F0562 (UniParc checksum of the same sequence)
print(parse_any("str:pdb:1TUP"))   # str:pdb:1TUP, pinned to a file version once resolved
```

The resolver, REST API and MCP server in the same package need a built crosswalk index; see [Development](#development). The v1 design lives in [`docs/crosswalk_spec.md`](docs/crosswalk_spec.md).

## Status

Built and tested locally: the ID grammar, the crosswalk index (all of PDB and Swiss-Prot; AlphaFold DB for the demo targets), quality tiers, the REST API with keys, rate limits and call log, the MCP server, both skills, the plugin manifests, the container image, and Terraform for GCP and AWS. The 20-target demo passes through the container: 18/20 resolve with no clarifying question and 20/20 with one, p95 is 348 ms for `resolve_target` and 325 ms for `get_structure`, and every response validates against the schema.

Not deployed yet: no cloud URL exists, so `<api-host>` and `<mcp-url>` below are placeholders, and the plugin's default MCP URL is `https://mcp.xwalk.invalid/mcp` until the first deploy.

## What v1 provides

- **Resolve** gene names, UniProt accessions, PDB entries/chains, AlphaFold IDs or raw sequences to pinned IDs in one call.
- **Pinned IDs** at three levels: sequence (`seq:sha256:…`), structure (`str:<source>:<native>@<version>`), and derived object (`obj:…`).
- **Quality tiers** (A/B/C) on every structure, each with a reason string, so callers never interpret pLDDT or resolution themselves.
- **Provenance** on every response: crosswalk snapshot, upstream release versions, licenses and attribution. The same input against the same snapshot returns the same bytes.
- **Two interfaces over one backend:** a remote MCP server with three tools (`resolve_target`, `get_structure`, `get_annotations`) and a REST API (`/v1/resolve`, `/v1/structure/{id}`, `/v1/annotations/{id}`).
- **Skills:** `prepare-docking-target` and `resolve-ambiguous-id`.
- **Runs on GCP and AWS** from the same container and Terraform.

Every call needs an API key issued to your organization, sent as `Authorization: Bearer <key>`.

## Install the plugin

**Claude Code:**

```
/plugin install xwalk --marketplace xwalkbio/xwalk
```

Claude Code asks for your API key when the plugin is enabled and keeps it in the system keychain. The MCP server URL has a default; change it only if you were given another.

**Codex, Cursor, GitHub Copilot, VS Code and other [Agent Plugins](https://agent-plugins.org) clients:** install from this repository with your client's plugin command. Agent Plugins 1.0 has no way for a plugin to carry a credential, so add the header `Authorization: Bearer <key>` to the `xwalk` MCP server in your client's own MCP settings.

## REST API

Three calls that show the shape. Responses are trimmed here; every real response also carries `xrefs[]` and a full `provenance` block.

**1. A name that matches several organisms.** `ambiguous` lists up to 10 candidates and names the one field that separates them.

```
curl -sG https://<api-host>/v1/resolve -H "Authorization: Bearer $KEY" --data-urlencode q=p53
```

```json
{"status":"ambiguous","disambiguate_by":"organism","candidates_total":19,
 "candidates":[{"seq_id":"seq:sha256:e3ca60f1…","accession":"P04637","organism":"Homo sapiens (Human)","taxid":9606},
               {"seq_id":"seq:sha256:e95b3ae4…","accession":"P02340","organism":"Mus musculus (Mouse)","taxid":10090}, …],
 "hint":"…"}
```

Pass `organism=9606` and the same call returns `resolved`, with the pinned `seq_id`, the UniProt entries and isoforms, and the candidate structures tiered against the full length.

**2. The best structure for docking into a domain.** `get_structure` takes the `seq:` ID from `resolve_target` and picks one structure for a region and purpose.

```
curl -sG "https://<api-host>/v1/structure/seq:sha256:dbb4583267ad40a7dfd854ee3c44ce4be38e137d0570e3eb76cf1854a74e7246" \
    -H "Authorization: Bearer $KEY" --data-urlencode "region=Protein kinase" --data-urlencode want=docking
```

```json
{"status":"resolved","id":"str:pdb:9WR8@1.0","tier":"A",
 "reason":"tier A: 2.33 Å X-ray, 100% coverage, no unresolved gaps",
 "method":"X-RAY DIFFRACTION","resolution":2.33,"ligand_bound":true,
 "chains":[{"label_asym_id":"A","auth_asym_id":"A","seq_id":"seq:sha256:1b5cf51f…","uniprot_accessions":["P00533"]}],
 "file_url":"https://files-versioned.wwpdb.org/pdb_versioned/data/entries/wr/pdb_00009wr8/pdb_00009wr8_xyz_v1-0.cif.gz",
 "composition_hash":"sha256:0581d7d6…","annotations":{}, …}
```

Cite `str:pdb:9WR8@1.0`: the version pins the exact file.

**3. A predicted model by its AlphaFold ID, then the file.** The service returns the upstream file URL, not the file.

```
curl -sG https://<api-host>/v1/structure/str:afdb:AF-P00533-F1 -H "Authorization: Bearer $KEY"
```

```json
{"status":"resolved","id":"str:afdb:AF-P00533-F1@v6","tier":"C",
 "reason":"tier C: predicted, mean pLDDT 75.9 < 85, 100% coverage",
 "file_url":"https://alphafold.ebi.ac.uk/files/AF-P00533-F1-model_v6.cif", …}
```

```
curl -s -A "acme-docking/1.0 (ops@acme.example)" -O https://alphafold.ebi.ac.uk/files/AF-P00533-F1-model_v6.cif
```

alphafold.ebi.ac.uk answers 403 to curl's default User-Agent; send a descriptive one.

Errors are `{"error":{"code","message","hint"}}` with HTTP 400, 401 or 429. Outcomes (`resolved`, `ambiguous`, `not_found`, `not_available`) are HTTP 200 with `status` in the body. Rate limits come back as `X-RateLimit-{Limit,Remaining}-{Minute,Day}` headers. The response JSON Schema is at `/v1/schema.json`.

## In Claude Code

"Set up CDK2 for docking", with the plugin installed. In brief:

1. The `prepare-docking-target` skill loads.
2. `resolve_target(q="CDK2", organism=9606)` returns `resolved`, P24941.
3. `get_structure(id=<seq_id>, region="Protein kinase", want="docking")` returns `str:pdb:11GV@1.0`, tier A (1.59 Å X-ray, 100% coverage of the kinase domain), ligand-bound.
4. The skill's script fetches the file, keeps chain A, removes waters and hetero groups, and computes the pocket center from the bound inhibitor A1DEQ: (-17.13, -25.90, 22.61) Å.

## Development

The Python source is in `server/src/xwalk` (the `xwalk` package, also the distribution name on PyPI). `pyproject.toml` is at the repo root and the project uses `uv` (Python ≥ 3.12): `uv sync --extra dev` then `uv run pytest`. Commands for index builds, local serving and the demo check are in [`CLAUDE.md`](CLAUDE.md).

## Deployment

One image (`server/Dockerfile`, `serve.sh api|mcp`) runs on Cloud Run and ECS Fargate. Terraform is in `deploy/terraform/{gcp,aws}`; both call `deploy/terraform/common` for the shared names, sizes and environment. Steps, keys, snapshots and the usage rollup are in [`deploy/README.md`](deploy/README.md).

## Data sources

The service hosts an index, not structure files. Raw structures stay on their upstream hosts. AlphaFold DB, PDB, UniProt and ESM Atlas data are used under their respective open licenses (CC-BY, CC0 or equivalent), with attribution returned in each response.

## License

Apache License 2.0, copyright 2026 Xwalk Bio. See [LICENSE](LICENSE). Upstream data keeps its own terms (see [Data sources](#data-sources)).
