Skip to main content

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.

Full documentation is available here: https://kuechlero.github.io/simple_sams_api/.

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

The package can be installed via pip:

pip install simple_sams_api

Example

from simple_sams_api.base import SAMSapi, extract_HPO_terms_from_phenopacket

# Initialize API
api = SAMSapi()
# Initialize with a custom SAMS URL if needed:
api2 = SAMSapi(sams_url="https://example.org/sams-cgi")

# Login with username and password
api.login_with_username('your_email', 'your_password')
# Alternatively, you can use a credentials file:
api.login_with_credentials_file('path/to/credentials.txt')

# 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.

Release files for simple_sams_api 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple_sams_api 0.1.10
File Size Uploaded
simple_sams_api-0.1.10.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simple_sams_api 0.1.10
File Interpreter ABI Platform
simple_sams_api-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / simple_sams_api-0.1.10.tar.gz

Download URL simple_sams_api-0.1.10.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5b795be7b8cdcd01248df1c152e7e5c98b5a849ac8a8f2958e4865c5b63482c1
BLAKE2b-256 checksum
How to use checksums
592ca9a84f2af78b53e82caca654cbcfacc58c7ba417516658fccc35abef8d90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}

Release files / simple_sams_api-0.1.10-py3-none-any.whl

Download URL simple_sams_api-0.1.10-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43a1deda198840788106731438a389590c3e64df9c2334c5e74bceb97728e616
BLAKE2b-256 checksum
How to use checksums
dc8c5011ffbe7600f2f6f34a2f42060217a5ec804846876bd61f3277ff7cd94b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.7

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page