Skip to main content

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_sams_api-0.1.10.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_sams_api-0.1.10-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file simple_sams_api-0.1.10.tar.gz.

File metadata

  • Download URL: simple_sams_api-0.1.10.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for simple_sams_api-0.1.10.tar.gz
Algorithm Hash digest
SHA256 5b795be7b8cdcd01248df1c152e7e5c98b5a849ac8a8f2958e4865c5b63482c1
MD5 beb54743dd6daa9bf8d42946dd52e84b
BLAKE2b-256 592ca9a84f2af78b53e82caca654cbcfacc58c7ba417516658fccc35abef8d90

See more details on using hashes here.

File details

Details for the file simple_sams_api-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: simple_sams_api-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for simple_sams_api-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 43a1deda198840788106731438a389590c3e64df9c2334c5e74bceb97728e616
MD5 00aa4f92df7199b73a29edc280cc18ab
BLAKE2b-256 dc8c5011ffbe7600f2f6f34a2f42060217a5ec804846876bd61f3277ff7cd94b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page