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.

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


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.7.tar.gz (6.5 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.7-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple_sams_api-0.1.7.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

Hashes for simple_sams_api-0.1.7.tar.gz
Algorithm Hash digest
SHA256 7dfcccd9d0e73c28828a35b05c8181d538f3deb718b45fadfd6739c75f84abb7
MD5 8f9e7a3eb85101a63369ccd45fb914e7
BLAKE2b-256 aec72bac2f8b59084a4fd5e5d4f58e31461ff46a92578373933defc5665771c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simple_sams_api-0.1.7-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

Hashes for simple_sams_api-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8c0651876448a4ef7e6ea630603030a5963631ea39861eaa5e9a2113ec55f124
MD5 ce2741c0b8ad8a813d76f801a2301aca
BLAKE2b-256 4b6e29d0cfaa9088430c7e1eb166a65180e1e635b50888f3dc84d0f9a44e7dec

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