Skip to content

Commit 023eae6

Browse files
committed
update of the readme
1 parent 9e7ccf0 commit 023eae6

File tree

6 files changed

+69
-48
lines changed

6 files changed

+69
-48
lines changed

README.md

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@
88
[BioThings.io](https://biothings.io/) is a platform that provides a network of high-performance biomedical APIs and tools for building FAIR (Findable, Accessible, Interoperable, and Reusable) data services. The platform includes several key components:
99

1010
- **Core BioThings APIs**:
11-
- MyGene.info - Gene Annotation Service
12-
- MyVariant.info - Variant Annotation Service
13-
- MyChem.info - Chemical and Drug Annotation Service
14-
- MyDisease.info - Disease Annotation Service
11+
- [MyGene.info](https://mygene.info/) - Gene Annotation Service
12+
- [MyVariant.info](https://myvariant.info/) - Variant Annotation Service
13+
- [MyChem.info](https://mychem.info/) - Chemical and Drug Annotation Service
14+
- [MyDisease.info](http://mydisease.info/) - Disease Annotation Service
1515
- Taxonomy API - For querying taxonomic information
1616

17-
- **Development Tools**:
18-
- BioThings SDK - A Python-based toolkit for building high-performance data APIs
19-
- BioThings Studio - A pre-configured environment for building and administering BioThings APIs
20-
21-
- **Discovery and Integration Tools**:
22-
- SmartAPI - A registry for semantically annotated APIs
23-
- BioThings Explorer - A tool for exploring biological data through linked API services
24-
2517
This typed client library is built on top of the BioThings ecosystem, providing type-safe access to these services through Python.
2618

2719
## Project Description
@@ -30,11 +22,10 @@ A strongly-typed Python wrapper around the [BioThings Client](https://github.com
3022

3123
## Features
3224

33-
- **Type Safety**: Strongly typed models for all BioThings data using Pydantic
34-
- **IDE Support**: Full autocompletion and type checking in modern IDEs
25+
- **Type Safety & Validation**: Leverages Pydantic models for runtime data validation and type checking.
26+
- **Enhanced IDE Support**: Full autocompletion and static analysis in modern IDEs
3527
- **Synchronous & Asynchronous**: Support for both sync and async operations
3628
- **Helper Methods**: Additional utility methods for common operations
37-
- **Validation**: Runtime type checking and data validation
3829
- **Compatibility**: Maintains full compatibility with the original BioThings client
3930

4031
## Installation
@@ -52,28 +43,34 @@ cd biothings-typed-client
5243
pip install biothings-typed-client
5344
```
5445

55-
### Using UV (Recommended)
46+
#### Setting Up for Development
47+
48+
If you want to contribute to this repository:
5649

57-
[UV](https://github.com/astral-sh/uv) is a fast Python package installer and resolver, written in Rust. It's designed to be a drop-in replacement for pip and pip-tools.
50+
1. Clone the repository (if you haven't already):
51+
```bash
52+
git clone https://github.com/longevity-genie/biothings-typed-client.git
53+
cd biothings-typed-client
54+
```
5855

59-
1. Install UV (if you haven't already):
60-
```bash
61-
curl -LsSf https://astral.sh/uv/install.sh | sh
62-
```
56+
2. Install UV:
57+
```bash
58+
curl -LsSf https://astral.sh/uv/install.sh | sh
59+
```
6360

64-
2. Install the package:
65-
```bash
66-
uv sync
67-
```
61+
3. Create and activate a virtual environment:
62+
```bash
63+
uv venv
64+
source .venv/bin/activate # On Unix/macOS
65+
# or
66+
.venv\Scripts\activate # On Windows
67+
```
6868

69-
3. To create a virtual environment and install dependencies:
70-
```bash
71-
uv venv
72-
source .venv/bin/activate # On Unix/macOS
73-
# or
74-
.venv\Scripts\activate # On Windows
75-
uv install biothings-typed-client
76-
```
69+
4. Install all dependencies, including development tools:
70+
```bash
71+
uv sync --all-extras
72+
```
73+
This command reads the `pyproject.toml` file and installs the package in editable mode along with all its dependencies and optional dependencies (like those needed for testing and development).
7774

7875
## Quick Start
7976

@@ -203,16 +200,15 @@ client = ChemClient()
203200
204201
# Get a single chemical
205202
chem = client.getchem("ZRALSGWEFCBTJO-UHFFFAOYSA-N") # Using InChI key
206-
if chem:
207-
print(f"Chemical ID: {chem.id}")
208-
print(f"Molecular Formula: {chem.pubchem.molecular_formula}")
209-
print(f"SMILES: {chem.pubchem.smiles}")
210-
print(f"Molecular Weight: {chem.pubchem.molecular_weight}")
211-
print(f"XLogP: {chem.pubchem.xlogp}")
212-
print(f"Hydrogen Bond Donors: {chem.pubchem.hydrogen_bond_donor_count}")
213-
print(f"Hydrogen Bond Acceptors: {chem.pubchem.hydrogen_bond_acceptor_count}")
214-
print(f"Rotatable Bonds: {chem.pubchem.rotatable_bond_count}")
215-
print(f"Topological Polar Surface Area: {chem.pubchem.topological_polar_surface_area} Ų")
203+
print(f"Chemical ID: {chem.id}")
204+
print(f"Molecular Formula: {chem.pubchem.molecular_formula}")
205+
print(f"SMILES: {chem.pubchem.smiles}")
206+
print(f"Molecular Weight: {chem.pubchem.molecular_weight}")
207+
print(f"XLogP: {chem.pubchem.xlogp}")
208+
print(f"Hydrogen Bond Donors: {chem.pubchem.hydrogen_bond_donor_count}")
209+
print(f"Hydrogen Bond Acceptors: {chem.pubchem.hydrogen_bond_acceptor_count}")
210+
print(f"Rotatable Bonds: {chem.pubchem.rotatable_bond_count}")
211+
print(f"Topological Polar Surface Area: {chem.pubchem.topological_polar_surface_area} Ų")
216212
217213
# Get multiple chemicals
218214
chems = client.getchems(["ZRALSGWEFCBTJO-UHFFFAOYSA-N", "RRUDCFGSUDOHDG-UHFFFAOYSA-N"])

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "biothings-typed-client"
3-
version = "0.0.2"
4-
description = "Add your description here"
3+
version = "0.0.3"
4+
description = "A strongly-typed Python wrapper around the BioThings Client library, providing type safety and better IDE support through Python's type hints and Pydantic models."
55
readme = "README.md"
66
authors = [
77
{ name = "antonkulaga", email = "antonkulaga@gmail.com" }

src/biothings_typed_client/genes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
class RefSeq(BaseModel):
99
"""RefSeq information for a gene"""
10-
genomic: Optional[List[str]] = Field(default=None, description="Genomic RefSeq IDs")
10+
genomic: Optional[Union[str, List[str]]] = Field(default=None, description="Genomic RefSeq IDs")
1111
protein: Optional[Union[str, List[str]]] = Field(default=None, description="Protein RefSeq IDs")
1212
rna: Optional[Union[str, List[str]]] = Field(default=None, description="RNA RefSeq IDs")
1313
translation: Optional[Union[Dict[str, str], List[Dict[str, str]]]] = Field(default=None, description="Protein-RNA translation pairs")
1414

15-
@field_validator('protein', 'rna', mode='before')
15+
@field_validator('genomic', 'protein', 'rna', mode='before')
1616
@classmethod
1717
def ensure_list(cls, v):
1818
if v is None:

tests/test_genes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,15 @@ def test_metadata_sync(sync_client: GeneClient):
6969
assert metadata is not None
7070
assert "stats" in metadata
7171
assert "total" in metadata["stats"]
72+
73+
def test_getgene_sync_ensembl_string_refseq(sync_client: GeneClient):
74+
"""Test sync gene retrieval for Ensembl ID with single string RefSeq genomic ID."""
75+
ensembl_id = "ENSECAG00000002212" # Known to return string for refseq.genomic
76+
gene = sync_client.getgene(ensembl_id)
77+
assert gene is not None
78+
assert isinstance(gene, GeneResponse)
79+
assert gene.id == "100050481" # MyGene resolves this Ensembl to Entrez ID
80+
assert gene.taxid == 9796 # Cavia porcellus
81+
assert gene.has_refseq()
82+
assert isinstance(gene.refseq.genomic, list) # Validator should ensure it's a list
83+
assert "NC_091700.1" in gene.refseq.genomic

tests/test_genes_async.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,16 @@ async def test_metadata_async(async_client: GeneClientAsync):
6666
assert metadata is not None
6767
assert "stats" in metadata
6868
assert "total" in metadata["stats"]
69+
70+
@pytest.mark.asyncio
71+
async def test_getgene_async_ensembl_string_refseq(async_client: GeneClientAsync):
72+
"""Test async gene retrieval for Ensembl ID with single string RefSeq genomic ID."""
73+
ensembl_id = "ENSECAG00000002212" # Known to return string for refseq.genomic
74+
gene = await async_client.getgene(ensembl_id)
75+
assert gene is not None
76+
assert isinstance(gene, GeneResponse)
77+
assert gene.id == "100050481" # MyGene resolves this Ensembl to Entrez ID
78+
assert gene.taxid == 9796 # Cavia porcellus
79+
assert gene.has_refseq()
80+
assert isinstance(gene.refseq.genomic, list) # Validator should ensure it's a list
81+
assert "NC_091700.1" in gene.refseq.genomic

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)