Skip to content

misialq/ncbi-datasets-pyclient

Repository files navigation

ncbi-datasets-pyclient

NCBI Datasets is a resource that lets you easily gather data from NCBI.

The Datasets version 2 API is still in alpha, and we're updating it often to add new functionality, iron out bugs and enhance usability. For some larger downloads, you may want to download a dehydrated zip archive, and retrieve the individual data files at a later time.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: v2
  • Package version: v18.4.0
  • Generator version: 7.12.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://www.ncbi.nlm.nih.gov/datasets

Requirements.

Python 3.8+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/misialq/ncbi-datasets-pyclient.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/misialq/ncbi-datasets-pyclient.git)

Then import the package:

import ncbi.datasets.openapi

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import ncbi.datasets.openapi

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import ncbi.datasets.openapi
from ncbi.datasets.openapi.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.ncbi.nlm.nih.gov/datasets/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = ncbi.datasets.openapi.Configuration(
    host = "https://api.ncbi.nlm.nih.gov/datasets/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuthHeader
configuration.api_key['ApiKeyAuthHeader'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuthHeader'] = 'Bearer'


# Enter a context with an instance of the API client
with ncbi.datasets.openapi.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ncbi.datasets.openapi.BioSampleApi(api_client)
    accessions = ['[\"SAMN15960293\"]'] # List[str] | 

    try:
        # Get BioSample dataset reports by accession(s)
        api_response = api_instance.bio_sample_dataset_report(accessions)
        print("The response of BioSampleApi->bio_sample_dataset_report:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling BioSampleApi->bio_sample_dataset_report: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.ncbi.nlm.nih.gov/datasets/v2

Class Method HTTP request Description
BioSampleApi bio_sample_dataset_report GET /biosample/accession/{accessions}/biosample_report Get BioSample dataset reports by accession(s)
GeneApi download_gene_package GET /gene/id/{gene_ids}/download Get a gene dataset by gene ID
GeneApi download_gene_package_post POST /gene/download Get a gene dataset by POST
GeneApi gene_chromosome_summary GET /gene/taxon/{taxon}/annotation/{annotation_name}/chromosome_summary Get summary of chromosomes for a particular taxon's annotation
GeneApi gene_counts_for_taxon GET /gene/taxon/{taxon}/counts Get gene counts by taxonomic identifier
GeneApi gene_counts_for_taxon_by_post POST /gene/taxon/counts Get gene counts by taxonomic identifier
GeneApi gene_dataset_report POST /gene/dataset_report Get gene dataset report as JSON
GeneApi gene_dataset_report_by_accession GET /gene/accession/{accessions}/dataset_report Get dataset reports by accession IDs
GeneApi gene_dataset_report_by_tax_and_symbol GET /gene/symbol/{symbols}/taxon/{taxon}/dataset_report Get dataset reports by taxons.
GeneApi gene_dataset_reports_by_id GET /gene/id/{gene_ids}/dataset_report Get dataset reports by gene IDs.
GeneApi gene_dataset_reports_by_locus_tag GET /gene/locus_tag/{locus_tags}/dataset_report Get gene dataset reports by locus tag
GeneApi gene_dataset_reports_by_taxon GET /gene/taxon/{taxon}/dataset_report Get gene dataset reports by taxonomic identifier
GeneApi gene_download_summary_by_id GET /gene/id/{gene_ids}/download_summary Get gene download summary by GeneID
GeneApi gene_download_summary_by_post POST /gene/download_summary Get gene download summary
GeneApi gene_links_by_id GET /gene/id/{gene_ids}/links Get gene links by gene ID
GeneApi gene_links_by_id_by_post POST /gene/links Get gene links by gene ID
GeneApi gene_metadata_by_accession GET /gene/accession/{accessions} Get gene metadata by RefSeq Accession
GeneApi gene_metadata_by_post POST /gene Get gene metadata as JSON
GeneApi gene_metadata_by_tax_and_symbol GET /gene/symbol/{symbols}/taxon/{taxon} Get gene metadata by gene symbol
GeneApi gene_orthologs_by_id GET /gene/id/{gene_id}/orthologs Get gene orthologs by gene ID
GeneApi gene_orthologs_by_post POST /gene/orthologs Get gene orthologs by gene ID
GeneApi gene_product_report POST /gene/product_report Get gene product reports as JSON
GeneApi gene_product_report_by_accession GET /gene/accession/{accessions}/product_report Get gene product reports by accession IDs
GeneApi gene_product_report_by_tax_and_symbol GET /gene/symbol/{symbols}/taxon/{taxon}/product_report Get product reports by taxon.
GeneApi gene_product_reports_by_id GET /gene/id/{gene_ids}/product_report Get gene product reports by gene IDs.
GeneApi gene_product_reports_by_locus_tags GET /gene/locus_tag/{locus_tags}/product_report Get gene product reports by locus tags
GeneApi gene_product_reports_by_taxon GET /gene/taxon/{taxon}/product_report Get gene product reports by taxonomic identifier
GeneApi gene_reports_by_id GET /gene/id/{gene_ids} Get gene reports by GeneID
GeneApi gene_reports_by_taxon GET /gene/taxon/{taxon} Get gene reports by taxonomic identifier
GenomeApi annotation_report_facets_by_accession GET /genome/accession/{accession}/annotation_summary Get genome annotation report summary information
GenomeApi annotation_report_facets_by_post POST /genome/annotation_summary Get genome annotation report summary information
GenomeApi assembly_accessions_for_sequence_accession GET /genome/sequence_accession/{accession}/sequence_assemblies Get assembly accessions for a sequence accession
GenomeApi assembly_accessions_for_sequence_accession_by_post POST /genome/sequence_assemblies Get assembly accessions for a sequence accession
GenomeApi assembly_revision_history_by_get GET /genome/accession/{accession}/revision_history Get revision history for assembly by accession
GenomeApi assembly_revision_history_by_post POST /genome/revision_history Get revision history for assembly by accession
GenomeApi check_assembly_availability GET /genome/accession/{accessions}/check Check the validity of genome accessions
GenomeApi check_assembly_availability_post POST /genome/check Check the validity of many genome accessions in a single request
GenomeApi checkm_histogram_by_taxon GET /genome/taxon/{species_taxon}/checkm_histogram Get CheckM histogram by species taxon
GenomeApi checkm_histogram_by_taxon_by_post POST /genome/checkm_histogram Get CheckM histogram by species taxon
GenomeApi download_assembly_package GET /genome/accession/{accessions}/download Get a genome dataset by accession
GenomeApi download_assembly_package_post POST /genome/download Get a genome dataset by post
GenomeApi download_genome_annotation_package GET /genome/accession/{accession}/annotation_report/download Get an annotation report dataset by accession
GenomeApi download_genome_annotation_package_by_post POST /genome/annotation_report/download Get an annotation report dataset by accession
GenomeApi genome_annotation_download_summary GET /genome/accession/{accession}/annotation_report/download_summary Preview feature dataset download
GenomeApi genome_annotation_download_summary_by_post POST /genome/annotation_report/download_summary Preview feature download by POST
GenomeApi genome_annotation_report GET /genome/accession/{accession}/annotation_report Get genome annotation reports by genome accession
GenomeApi genome_annotation_report_by_post POST /genome/annotation_report Get genome annotation reports by genome accession
GenomeApi genome_dataset_report GET /genome/accession/{accessions}/dataset_report Get dataset reports by accessions
GenomeApi genome_dataset_report_by_post POST /genome/dataset_report Get dataset reports by accessions
GenomeApi genome_dataset_reports_by_assembly_name GET /genome/assembly_name/{assembly_names}/dataset_report Get dataset reports by assembly name (exact)
GenomeApi genome_dataset_reports_by_bioproject GET /genome/bioproject/{bioprojects}/dataset_report Get dataset reports by bioproject
GenomeApi genome_dataset_reports_by_biosample_id GET /genome/biosample/{biosample_ids}/dataset_report Get dataset reports by biosample id
GenomeApi genome_dataset_reports_by_taxon GET /genome/taxon/{taxons}/dataset_report Get dataset reports by taxons
GenomeApi genome_dataset_reports_by_wgs GET /genome/wgs/{wgs_accessions}/dataset_report Get dataset reports by wgs accession
GenomeApi genome_download_summary GET /genome/accession/{accessions}/download_summary Preview genome dataset download
GenomeApi genome_download_summary_by_post POST /genome/download_summary Preview genome dataset download by POST
GenomeApi genome_links_by_accession GET /genome/accession/{accessions}/links Get assembly links by accessions
GenomeApi genome_links_by_accession_by_post POST /genome/links Get assembly links by accessions
GenomeApi genome_sequence_report GET /genome/accession/{accession}/sequence_reports Get sequence reports by accessions
GenomeApi genome_sequence_report_by_post POST /genome/sequence_reports Get sequence reports by accessions
OrganelleApi download_organelle_package GET /organelle/accession/{accessions}/download Get a organelle data package by accesions
OrganelleApi download_organelle_package_by_post POST /organelle/download Get a organelle data package by post
OrganelleApi organelle_datareport_by_accession GET /organelle/accessions/{accessions}/dataset_report Get Organelle dataset report by accession
OrganelleApi organelle_datareport_by_post POST /organelle/dataset_report Get Organelle dataset report by http post
OrganelleApi organelle_datareport_by_taxon GET /organelle/taxon/{taxons}/dataset_report Get Organelle dataset report by taxons
ProkaryoteApi download_prokaryote_gene_package GET /protein/accession/{accessions}/download Get a prokaryote gene dataset by RefSeq protein accession
ProkaryoteApi download_prokaryote_gene_package_post POST /protein/accession/download Get a prokaryote gene dataset by RefSeq protein accession by POST
TaxonomyApi download_taxonomy_package GET /taxonomy/taxon/{tax_ids}/download Get a taxonomy data package by tax ID
TaxonomyApi download_taxonomy_package_by_post POST /taxonomy/download Get a taxonomy data package by tax_id
TaxonomyApi tax_name_query GET /taxonomy/taxon_suggest/{taxon_query} Get a list of taxonomy names and IDs given a partial taxonomic name
TaxonomyApi tax_name_query_by_post POST /taxonomy/taxon_suggest Get a list of taxonomy names and IDs given a partial taxonomic name
TaxonomyApi taxonomy_data_report GET /taxonomy/taxon/{taxons}/dataset_report Use taxonomic identifiers to get taxonomic data report
TaxonomyApi taxonomy_data_report_post POST /taxonomy/dataset_report Use taxonomic identifiers to get taxonomic names data report by post
TaxonomyApi taxonomy_filtered_subtree GET /taxonomy/taxon/{taxons}/filtered_subtree Use taxonomic identifiers to get a filtered taxonomic subtree
TaxonomyApi taxonomy_filtered_subtree_post POST /taxonomy/filtered_subtree Use taxonomic identifiers to get a filtered taxonomic subtree by post
TaxonomyApi taxonomy_image GET /taxonomy/taxon/{taxon}/image Retrieve image associated with a taxonomic identifier
TaxonomyApi taxonomy_image_metadata GET /taxonomy/taxon/{taxon}/image/metadata Retrieve image metadata associated with a taxonomic identifier
TaxonomyApi taxonomy_image_metadata_post POST /taxonomy/image/metadata Retrieve image metadata associated with a taxonomic identifier by post
TaxonomyApi taxonomy_image_post POST /taxonomy/image Retrieve image associated with a taxonomic identifier by post
TaxonomyApi taxonomy_links GET /taxonomy/taxon/{taxon}/links Retrieve external links associated with a taxonomic identifier.
TaxonomyApi taxonomy_links_by_post POST /taxonomy/links Retrieve external links associated with a taxonomic identifier.
TaxonomyApi taxonomy_metadata GET /taxonomy/taxon/{taxons} Use taxonomic identifiers to get taxonomic metadata
TaxonomyApi taxonomy_metadata_post POST /taxonomy Use taxonomic identifiers to get taxonomic metadata by post
TaxonomyApi taxonomy_names GET /taxonomy/taxon/{taxons}/name_report Use taxonomic identifiers to get taxonomic names data report
TaxonomyApi taxonomy_names_post POST /taxonomy/name_report Use taxonomic identifiers to get taxonomic names data report by post
TaxonomyApi taxonomy_related_ids GET /taxonomy/taxon/{tax_id}/related_ids Use taxonomic identifier to get related taxonomic identifiers, such as children
TaxonomyApi taxonomy_related_ids_post POST /taxonomy/related_ids Use taxonomic identifier to get related taxonomic identifiers, such as children
VersionApi version GET /version Retrieve service version
VirusApi sars2_protein_download GET /virus/taxon/sars2/protein/{proteins}/download Download SARS-CoV-2 protein and CDS datasets by protein name
VirusApi sars2_protein_download_post POST /virus/taxon/sars2/protein/download Download SARS-CoV-2 protein and CDS datasets by protein name by POST request
VirusApi sars2_protein_summary GET /virus/taxon/sars2/protein/{proteins} Summary of SARS-CoV-2 protein and CDS datasets by protein name
VirusApi sars2_protein_summary_by_post POST /virus/taxon/sars2/protein Summary of SARS-CoV-2 protein and CDS datasets by protein name
VirusApi sars2_protein_table GET /virus/taxon/sars2/protein/{proteins}/table Get SARS-CoV-2 protein metadata in a tabular format.
VirusApi virus_accession_availability GET /virus/accession/{accessions}/check Check available viruses by accession
VirusApi virus_accession_availability_post POST /virus/check Check available viruses by accession
VirusApi virus_annotation_reports_by_acessions GET /virus/accession/{accessions}/annotation_report Get virus annotation report by accession
VirusApi virus_annotation_reports_by_post POST /virus/annotation_report Get virus annotation report by POST
VirusApi virus_annotation_reports_by_taxon GET /virus/taxon/{taxon}/annotation_report Get virus annotation report by taxon
VirusApi virus_genome_download GET /virus/taxon/{taxon}/genome/download Download a virus genome dataset by taxon
VirusApi virus_genome_download_accession GET /virus/accession/{accessions}/genome/download Download a virus genome dataset by accession
VirusApi virus_genome_download_post POST /virus/genome/download Get a virus genome dataset by post
VirusApi virus_genome_summary GET /virus/taxon/{taxon}/genome Get summary data for virus genomes by taxon
VirusApi virus_genome_summary_by_post POST /virus/genome Get summary data for virus genomes by post
VirusApi virus_genome_table GET /virus/taxon/{taxon}/genome/table Get virus genome metadata in a tabular format.
VirusApi virus_reports_by_acessions GET /virus/accession/{accessions}/dataset_report Get virus metadata by accession
VirusApi virus_reports_by_post POST /virus Get virus metadata by POST
VirusApi virus_reports_by_taxon GET /virus/taxon/{taxon}/dataset_report Get virus metadata by taxon

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

ApiKeyAuth

  • Type: API key
  • API key parameter name: api_key
  • Location: URL query string

ApiKeyAuthHeader

  • Type: API key
  • API key parameter name: api-key
  • Location: HTTP header

Author

[email protected]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published