Skip to main content

sgd

Project description

sgd-rest

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

pypiv Python 3.7+ continuous-integration Licence

Installation

pip install sgd-rest

Quick start

Get GO (gene ontology) information for gene ARO1.

import sgd

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

Background

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")

First, instantiate an SGD class prior to working with subclasses:

import sgd

aro1 = sgd.gene("ARO1")

Subclasses

Use the endpoints attribute to search a class's subclasses:

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 the desired processing of the REST API content.

For example, for the 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.

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

sgd_rest-0.0.3.tar.gz (92.5 kB view details)

Uploaded Source

Built Distribution

sgd_rest-0.0.3-py3-none-any.whl (87.9 kB view details)

Uploaded Python 3

File details

Details for the file sgd_rest-0.0.3.tar.gz.

File metadata

  • Download URL: sgd_rest-0.0.3.tar.gz
  • Upload date:
  • Size: 92.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for sgd_rest-0.0.3.tar.gz
Algorithm Hash digest
SHA256 4f09d8d7bc5675fd27e44fcf20a0d4cdde7d7729b88047606a17cfce9d2843af
MD5 58baefde1b79c90be7d7eeb044177274
BLAKE2b-256 8b215b758bd5e1c565050d7c81e9f09c03d8602bb6157b282c6298bb824bbe61

See more details on using hashes here.

File details

Details for the file sgd_rest-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sgd_rest-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 87.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for sgd_rest-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 791443fb0d860d19d1c6904317e92f3af3eb4a4e78380f15ccc929c3a713eb76
MD5 98452c82844ed2bc6774c7bdbdae4bc4
BLAKE2b-256 71cfdd1795d8e060479866fc9873151caf0d01fdba004a4bb509ca54a77551f8

See more details on using hashes here.

Supported by

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