Skip to content

Commit 0a9e47d

Browse files
deeenesclaude
andcommitted
Refresh docs for relations API and lookup/related/fresh; bump 0.3.1
Update README, quickstart, index, the database vignette, and the API reference to reflect the renamed export endpoints (relations / annotations) and to introduce the new high-level helpers (lookup, related), the cache-control helpers (cache_clear, fresh), and the friendly id-type / participant-type aliases. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 70444ac commit 0a9e47d

8 files changed

Lines changed: 411 additions & 78 deletions

File tree

README.md

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ prior-knowledge web API.
1212

1313
## Features
1414

15-
- Export **entities**, **interactions**, and **associations** (complexes,
16-
pathways, reactions) as DataFrames
15+
- One-call **`lookup()`** and **`related()`** helpers that resolve
16+
free-text queries, fetch the matching entities/relations, and pivot
17+
identifiers into named columns — no manual primary-key juggling
18+
- Friendly id-type aliases (`name`, `chebi`, `hmdb`, `uniprot`,
19+
`genesymbol`, `kegg`, …) and participant-type aliases
20+
(`protein`, `small_molecule`, …) that hide the MI/OM ontology codes
21+
- Lower-level primitives: export **entities**, **relations**, and
22+
**annotations** as DataFrames; resolve free-text identifiers; slice
23+
with paging
1724
- **Ontology** term lookup, search, and hierarchy trees
1825
- Multi-backend output: [polars](https://pola.rs/) (default),
1926
[pandas](https://pandas.pydata.org/), or
2027
[pyarrow](https://arrow.apache.org/docs/python/)
2128
- Optional graph conversion to [annnet](https://github.com/saezlab/annnet)
2229
objects
2330
- Query validation against the API schema
24-
- Caching via [download-manager](https://github.com/saezlab/download-manager)
31+
- Caching via [download-manager](https://github.com/saezlab/download-manager),
32+
with a `fresh()` context manager for first-touch refresh
2533

2634
## Installation
2735

@@ -37,20 +45,57 @@ pip install omnipath-client polars
3745

3846
## Quick start
3947

48+
The two high-level helpers, `lookup()` and `related()`, cover most use
49+
cases in a single call:
50+
4051
```python
4152
import omnipath_client as op
4253

43-
# All interactions as a polars DataFrame
44-
df = op.interactions()
54+
# Resolve names and pivot identifiers into named columns
55+
op.lookup(
56+
['caffeine', 'metformin', 'TP53'],
57+
id_types=['name', 'chebi', 'hmdb', 'uniprot', 'genesymbol'],
58+
)
59+
60+
# Compounds reported in strawberry (FooDB), as a wide joined table
61+
op.related(
62+
subject='Strawberry',
63+
sources=['foodb'],
64+
id_types=['name', 'chebi', 'hmdb'],
65+
)
66+
67+
# Drug targets for caffeine (positional arg matches either side)
68+
op.related(
69+
'caffeine',
70+
sources=['bindingdb'],
71+
id_types=['name', 'uniprot', 'genesymbol'],
72+
)
73+
74+
# Pathway members from WikiPathways and Reactome at once
75+
op.related(
76+
object=['WP253', 'R-HSA-70171'],
77+
sources=['wikipathways', 'reactome'],
78+
relation_categories=['annotation'],
79+
id_types=['name', 'uniprot', 'chebi'],
80+
group_by='object_name',
81+
)
82+
```
4583

46-
# Directed interactions only
47-
df = op.interactions(direction='directed')
84+
The lower-level primitives are still available for paged scans, raw
85+
parquet, or graph export:
86+
87+
```python
88+
# All relations as a polars DataFrame
89+
df = op.relations()
90+
91+
# Resolve free-text identifiers to entity primary keys
92+
op.resolve(['caffeine', 'TP53'])
4893

4994
# Human entities
5095
df = op.entities(taxonomy_ids=['9606'])
5196

52-
# Interactions as an annnet graph
53-
g = op.interactions(as_graph=True)
97+
# Relations as an annnet graph
98+
g = op.relations(as_graph=True)
5499

55100
# Ontology term lookup
56101
result = op.ontology_terms(['GO:0006915', 'MI:0326'])
@@ -59,6 +104,17 @@ result = op.ontology_terms(['GO:0006915', 'MI:0326'])
59104
df = op.entities(backend='pandas')
60105
```
61106

107+
Cache control:
108+
109+
```python
110+
# Force a one-shot refresh for everything touched in the block
111+
with op.fresh():
112+
df = op.related('caffeine', sources=['bindingdb'])
113+
114+
# Wipe the entire on-disk cache (e.g. after a server redeploy)
115+
op.cache_clear()
116+
```
117+
62118
For more examples, see the [quickstart guide](https://saezlab.github.io/omnipath-client/quickstart/).
63119

64120
## OmniPath Utils

docs/index.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,35 @@ orthology_translate(['TP53', 'EGFR'], source=9606, target=10090)
5353
```python
5454
import omnipath_client as op
5555

56-
df = op.interactions(entity_ids=['Q9Y6K9'])
56+
# One-call helper: caffeine drug targets with UniProt + gene symbols
57+
op.related(
58+
'caffeine',
59+
sources=['bindingdb'],
60+
id_types=['name', 'uniprot', 'genesymbol'],
61+
)
62+
63+
# Or the lower-level primitive
64+
df = op.relations(entity_pks=['2119890'])
65+
```
66+
67+
### Resolve and enrich identifiers
68+
69+
```python
70+
op.lookup(
71+
['caffeine', 'metformin', 'TP53'],
72+
id_types=['name', 'chebi', 'hmdb', 'uniprot', 'genesymbol'],
73+
)
5774
```
5875

5976
### Explore the API
6077

6178
```python
6279
import omnipath_client as op
6380

64-
op.endpoints() # all endpoints
65-
op.params('exports/interactions') # available filters
66-
op.values('exports/interactions', 'entity_types') # allowed values
81+
op.endpoints() # all endpoints
82+
op.params('exports/relations/parquet') # available filters
83+
op.values('exports/entities/parquet', 'entity_types') # allowed values
84+
op.resources() # source catalog
6785
```
6886

6987
## Learn more

0 commit comments

Comments
 (0)