Skip to main content

sgd-rest


Saccharomyces Genome Database (SGD) REST API wrapper. Refer to the SGD REST page for information about API usage and terms of service.

Python 3.8+ pypiv Licence tests

Installation

pip install sgd-rest --upgrade

Quick start

Get GO (gene ontology) details for gene ARO1.

import sgd

aro1 = sgd.gene("ARO1")
aro1.go_details.json()

# >>> [{'id': 9761727, 'annotation_type': 'computational', 'date_created': '2024-10-14', 'qualifier': 'enables', 'locus': {'display_name': 'ARO1', 'link': '/locus/S000002534', 'id': 1284912, 'format_name': 'YDR127W'}, 'go': {'display_name': 'lyase activity', 'link': '/go/GO:0016829', 'go_id': 'GO:0016829', 'go_aspect': 'molecular function', 'id': 291052}, ...]

Background

Easily navigate the SGD REST API with Python.

Classes

Class Description Example
locus Query SGD REST using locus ID. locus("S000002534")
gene Query SGD REST using gene name. gene("ARO1")
phenotype Query SGD REST using phenotype name. phenotype("increased_chemical_compound_accumulation")
go Query SGD REST using GO ID. go("GO:0000001")

Instantiate the SGD class prior to working with subclasses:

import sgd

aro1 = sgd.gene("ARO1")

Subclasses

Use the endpoints attribute to display subclasses of a class:

import sgd

print(sgd.gene.endpoints)
Class Subclass Description
locus & gene details Gets basic information about a locus.
locus & gene go_details Gets GO (gene ontology) annotations and the references used to make them.
locus & gene interaction_details Gets interaction annotations and the references used to make them.
locus & gene literature_details Gets references which refer to a gene, organized by subject of relevance.
locus & gene neighbor_sequence_details Gets get sequences for neighboring loci in the strains for which they are available.
locus & gene phenotype_details Gets phenotype annotations and the references used to make them.
locus & gene posttranslational_details Gets posttranslational protein data.
locus & gene protein_domain_details Gets protein domains, their sources, and their positions relative to protein sequence.
locus & gene protein_experiment_details Gets metadata and data values for protein experiments.
locus & gene regulation_details Gets regulation annotations and the references used to make them.
locus & gene sequence_details Gets sequence for genomic, coding, protein, and +/- 1KB sequence.
phenotype details Gets basic information about a phenotype.
phenotype locus_details Gets a list of genes annotated to a phenotype with some information about the experiment and strain background.
go details Gets basic information about a GO term.
go locus_details Gets a list of genes annotated to a GO term.

Use a subclass to retrieve the endpoint's response. This library utilizes the requests library, returning a requests.models.Response instance. Use this instance to define how the REST API content should be processed.

For example, for gene ARO1, get GO details as JSON and literature details as text:

import sgd

aro1 = sgd.gene("ARO1")
aro1.go_details.json()
aro1.literature_details.text

Advanced

Just like a subclass returns a requests.models.Response instance, the user can pass keyword arguments directly to the requests.get method during class instantiation. For example, you can add a header to prevent server-side caching and parse the locus details response as text:

import sgd

go_0000001 = sgd.go("GO:0000001", headers={"Cache-Control": "no-cache", "Pragma": "no-cache"})
go_0000001.locus_details.text

Additional attributes

  • url: Gets the endpoint's URL. Available for all classes.
  • locus_id: Gets the endpoint's locus ID. Avaialble for locus and gene classes.
import sgd

tor2 = sgd.gene("TOR2")

# 1 
print(tor2.url)
# >>> 'https://www.yeastgenome.org/backend/locus/S000001686'

# 2
print(tor2.locus_id)
# >>> 'S000001686'

Exceptions

  • InvalidGene: An invalid gene was queried.
import sgd
from sgd.exceptions import InvalidGene

try:
    bad_gene = sgd.gene("BadGene")
except InvalidGene:
    print("Whoops, an invalid gene was queried.")

Contribute

Support

If you are having issues or would like to propose a new feature, please use the issues tracker.

License

This project is licensed under the MIT license.

Metadata

Release files for sgd-rest 0.2.1

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

Source distribution (sdist)

Source distribution for sgd-rest 0.2.1
File Size Uploaded Provenance
sgd_rest-0.2.1.tar.gz 91.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sgd-rest 0.2.1
File Interpreter ABI Platform
sgd_rest-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 180.0 kB

Release files / sgd_rest-0.2.1.tar.gz

Download URL sgd_rest-0.2.1.tar.gz
Size 91.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d02b98b438e63d1cec27624f55e088e8eff2917a835dd2b25e9df01ffb10e2ce
BLAKE2b-256 checksum
How to use checksums
7ea763f5c94929f60eb9554966d04f6edf5588ea8295ef28a82b2d96329aefe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / sgd_rest-0.2.1-py3-none-any.whl

Download URL sgd_rest-0.2.1-py3-none-any.whl
Size 88.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07358d15a3705779aec90348fe5743e860c07bb4f25b002ebc58755000b33216
BLAKE2b-256 checksum
How to use checksums
ff1072730790ba128b448948c097841f28d036e92a2579f33a5377e1ef7f127c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Security for sgd-rest 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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