DNAstack Docs | Command Line Interface

Command Line Interface

Installation

This guide will help you install dnastack-client-library 3.0. If you need to install a specific version, please check out the list of available versions on the release history page.

Install Python 3

First, you need to have

Python 3 for MacOS

MacOS already comes with Python 3. There is no need to do anything.

Python 3 for Linux

Here is how you can do it for Debian, Ubunbu, and some Debian-based Linux distributions with apt.

apt update
apt install python3 python3-pip

Here is how you can do it for RedHat, Fedora, and some RedHat-based Linux distributions with dnf.

dnf update
dnf install python3 python3-pip
Python 3 for Windows 10/11
  1. Download the installer from anaconda.com.
  2. Run the installer to install Python 3.
Install the CLI/library package
Install the package on MacOS/Linux

First, you need to have

  • Python 3.7 or higher,
  • and optionally pip 21.3 or newer are required for ARM-based systems, e.g., ARM-based MacOS machines.

You just need to run the pip command:

pip3 install -U dnastack-client-library

If pip3 is not available on your system, please try pip, python -m pip, or python3 -m pip.

This package will come with the command line tool which is available as:

  • dnastack
  • python3 -m dnastack or python -m dnastack (depending on your Python installation)
Install the package alongside Anaconda 3 on Windows 10/11 with Powershell

Assume that you have Anaconda 3 installed.

To install with Powershell,

  1. Open Anaconda Powershell Prompt. You can do it from the start menu or Anaconda Navigator1.
  2. Then, when the Powershell is ready, run:
pip3 install -U dnastack-client-library

This package will come with the command line tool which is available as:

  • dnastack
  • python -m dnastack

Use the command line tool

Set up with a service registry

You can easily set up your environment by using the dnastack use command. For example, we set up the CLI to work with the service endpoints available at viral.ai.

dnastack use viral.ai
List all collections

You can list all collections with:

dnastack collections list
List items in a particular collection

You can list all items in a particular collection with dnastack collections list-items -c SLUG_NAME where SLUG_NAME is the slug name of the collection. Here is an example.

dnastack collections list-items -c ncbi-sra

where the item can be a blob2 or table3.

Run a query

You can run query like this:

dnastack collections query -c ncbi-sra "SELECT * FROM publisher_data.ncbi_sra.variants LIMIT 10"

Alternatively, you can do this.

dnastack data-connect query --endpoint-id data-connect-ncbi-sra "SELECT * FROM publisher_data.ncbi_sra.variants LIMIT 10"

Although the former method is recommended.

Download blobs

You can run dnastack files download to download blobs with its ID or metadata URL, for example:

dnastack files download drs://viral.ai/faux-blob-id-001 faux-blob-id-002