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.9.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.9-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple_sams_api-0.1.9.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.9.tar.gz
Algorithm Hash digest
SHA256 baefaf5320552b9f50cc2052b72f3c52cd07deefad462ad9723509e586b49009
MD5 6b728168360989831ceb8f4780bf0edc
BLAKE2b-256 2a1120b0e5ed89d6ba02ab01fc3ab810744102aeb8368ad2351739d8368d5d75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simple_sams_api-0.1.9-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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 482689704b1bf4abd6e409cf6c54643c5fe16b5a10028ac105cea38fb2a9f2f0
MD5 ebf9d82531e99ecf9fd0926421d29e78
BLAKE2b-256 4d839d652f5c1b3d24fdf26cb8eeb8063578cfd52de341423e90a823fc1949d2

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