Package: ncbi.datasets.openapi

Native python client library for NCBI Datasets OpenApi

This code is auto-generated by the openapi-generator based on the definition in the NCBI Datasets OpenAPI specification .

Example use:

from typing import List

from ncbi.datasets.openapi import ApiClient as DatasetsApiClient
from ncbi.datasets.openapi import ApiException as DatasetsApiException
from ncbi.datasets.openapi import GeneApi as DatasetsGeneApi

# Provide your own gene ids as a list of integers
input_gene_ids: List[int] = [1, 2, 3, 9, 10, 11, 12, 13, 14, 15, 16, 17]


def example_usage_of_api(gene_ids: List[int]):
    if len(gene_ids) == 0:
        print("Please provide at least one gene-id")
        return

    with DatasetsApiClient() as api_client:
        gene_api = DatasetsGeneApi(api_client)

        # Get just metadata
        try:
            gene_reply = gene_api.gene_metadata_by_id(gene_ids)
            for gene in gene_reply.genes:
                print(gene.gene.gene_id)
        except DatasetsApiException as e:
            print(f"Exception when calling GeneApi: {e}\n")

        # Or, download a data package with FASTA files
        try:
            print("Begin download of data package ...")
            gene_ds_download = gene_api.download_gene_package(
                gene_ids, include_annotation_type=["FASTA_GENE"], _preload_content=False
            )
            gene_reply = gene_api.gene_metadata_by_id(gene_ids)
            zipfile_name = "gene_ds.zip"

            with open(zipfile_name, "wb") as f:
                f.write(gene_ds_download.data)
            print(f"Download completed -- see {zipfile_name}")

        except DatasetsApiException as e:
            print(f"Exception when calling GeneApi: {e}\n")


Package: ncbi.datasets.openapi.api

Client library definitions of HTTP endpoints.

Module: ncbi.datasets.openapi.api_client

NCBI Datasets API

Module: ncbi.datasets.openapi.apis

Python API: ncbi.datasets.openapi.apis

Module: ncbi.datasets.openapi.configuration

NCBI Datasets API

Module: ncbi.datasets.openapi.exceptions

NCBI Datasets API

Module: ncbi.datasets.openapi.model_utils

NCBI Datasets API

Module: OpenAPI Models

OpenAPI generated models

Module: OpenAPI Models

OpenAPI generated models

Module: ncbi.datasets.openapi.rest

NCBI Datasets API

Generated November 19, 2021