A simple Python API for interacting with the SAMS system
Project description
Simple SAMS API
This module provides a Python interface for interacting with the SAMS (Symptom Annotation Made Simple) web service, allowing you to authenticate, retrieve phenopacket data, and extract relevant medical terms for downstream analysis.
Features
- Authentication: Login to SAMS using username/password or credentials file.
- Phenopacket Retrieval: Download all phenopackets or a specific phenopacket by patient ID.
- HPO Term Extraction: Extract Human Phenotype Ontology (HPO) terms from phenopacket data.
- Disease Term Extraction: Extract disease terms (OMIM, ORPHANET) from phenopacket data.
- Onset Filtering: Filter phenopacket features and diseases by onset timestamp.
Usage
Installation
Simply copy the module into your project and install the required dependencies:
pip install requests
Example
from simple_sams_api.base import SAMSapi, extract_HPO_terms_from_phenopacket
# Initialize API and login
api = SAMSapi()
api.login_with_username('your_email', 'your_password')
# Retrieve all phenopackets
phenopackets = api.get_phenopackets()
# Extract HPO terms from a phenopacket
hpo_terms = extract_HPO_terms_from_phenopacket(phenopackets[0])
print(hpo_terms)
# Example output: "HP:0000001 - Phenotype 1; HP:0000002 - Phenotype 2; ..."
API Reference
Class: SAMSapi
login_with_username(username, password): Login using username and password.login_with_credentials_file(credentials_file): Login using a credentials file (first line: username, second line: password).get_phenopackets(): Retrieve all phenopackets for the current user.get_phenopacket(patient_id): Retrieve a phenopacket for a specific patient.loggedIn: Property indicating login status.
Functions
extract_HPO_terms_from_phenopacket(phenopacket, ignore_excluded=True): Extract HPO terms from a phenopacket.extract_disease_terms_from_phenopacket(phenopacket, ignore_excluded=True): Extract disease terms from a phenopacket.filter_phenopacket_by_onset(phenopacket, input_onset_timestamp): Filter phenopacket features and diseases by onset timestamp ("earliest", "latest", or specific timestamp).
Testing
Run python -m unittest tests/test_base.py.
License
MIT License
Author
Oliver Küchler
Notes
- Make sure you have access to the SAMS web service and valid credentials.
- For more details, see the docstrings in the source code.
- The GitHub Actions workflow is based on: Using uv in GitHub Actions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_sams_api-0.1.0.tar.gz.
File metadata
- Download URL: simple_sams_api-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28c42ba13ec57f0c5a053161facf2a9f356ac76a109671d72c75b867e71fa3ec
|
|
| MD5 |
6dea2e8e151ceb584815c5486ed069fe
|
|
| BLAKE2b-256 |
244bc480b2f9f0f85d7f824bb6a6a84c64bdb7ed9002217b11dcdb36ae74941f
|
File details
Details for the file simple_sams_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simple_sams_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35e53b19934a10462939f64a86d929431cf0b75d98dd746f7c8af36fbb612fd2
|
|
| MD5 |
bda71a535763db8224bd5467f633c647
|
|
| BLAKE2b-256 |
6fd2b82b042a2f7b15d39dc00c00f85c449e1fcbb94e2ebd88660e92c4e20713
|