Skip to content

Building and Installing from Source

Anatoly Boshkin edited this page Feb 3, 2022 · 5 revisions

Quick instructions for building and installing sra-tools from source.

  1. Dependencies:
    sra-tools will attempt to utilize 3rd party libraries and development headers from your system if they can be located:
    libxml2 (needed for many loaders)
    libmagic (needed for copycat)
    libhdf5 (needed for pacbio-load)
    If any of these libraries cannot be located, their functionality will be missing from our library, and some tools may not be built.

  2. Create an ncbi source directory if needed.
    While this is not strictly required, our configuration scripts will benefit by being able to locate related projects without asking for explicit paths:
    $ mkdir ncbi

  3. Check out the sources:
    $ cd ncbi
    $ git clone https://github.com/ncbi/sra-tools.git

  4. If you have not yet installed ngs and/or ncbi-vdb, please do so now:
    $ git clone https://github.com/ncbi/ngs.git
    $ git clone https://github.com/ncbi/ncbi-vdb.git
    and follow directions at https://github.com/ncbi/ngs/wiki/Building-and-Installing-from-Source and https://github.com/ncbi/ncbi-vdb/wiki/Building-and-Installing-from-Source respectively.

  5. Configure the build:
    $ cd sra-tools
    $ ./configure
    By default, configure will select a build-output directory under your $HOME and will install under /usr/local/sra-tools on Linux. The default settings can be changed, of course. For all options, you can run:
    $ ./configure --help

  6. Make the tools:
    $ make

  7. Install the tools and configuration as admin (you may be asked for a password):
    $ sudo make install

At this point, the installation should be complete, although you will probably have to login again before all changes take place. If the installation is successful, you should find library code installed and an update to shell variables (only AFTER logging in again). To verify update of your environment:
$ echo $PATH # should now have the path to your installed sra-tools, and
$ which fastq-dump # should return the location of this utility.

UPCOMING CHANGES

Starting with Release 3.0.0:

How To Build From Source

To build from source, you need one of the supported operating systems (Linux, Windows, macOS) and CMake (minimum version 3.16). On Linux and macOS you need the GNU C/C++ toolchain (On macOS, you may also use CMake to generate an Xcode project), on Windows a set of MS Build Tools for Visual Studio 2017 or 2019.

As a prerequisite, you need a set of libraries and headers from the NCBI SRA SDK (https://github.com/ncbi/ncbi-vdb). The easiest way to build the toolkit from the sources is to checkout the SDK and the toolkit side-by-side (ncbi-vdb/ and sra-tools/ under a common parent directory) and run configure/make first in ncbi-vdb/ and then in sra-tools/, as described below.

Linux, macOS (gmake)

  1. Checkout and build the SDK. For instructions, see README.md in https://github.com/ncbi/ncbi-vdb

  2. In the root of the sra-tools checkout, run:

./configure

Use ./configure -h for the list of available optins

If the SDK is checked out side-by-side with the toolkit (i.e. ncbi-vdb/ and sra-tools/ share a common parent directory), the configuration step will locate it and set the internal variables to point to its headers and libraries. Otherwise, you would need to specify their location using the configuration option --with-ncbi-vdb-prefix=<path-to-sdk> If you do not specify the --with-ncbi-vdb-prefix and there is no ncbi-vdb/ checked out side-by-side with sra-tools, the configuration script will look for a copy of the SDK installed into the system location, /usr/local/ncbi/ncbi-vdb.

  1. Once the configuration script has successfully finished, run:
make

This will invoke a Makefile that performs the following sequence:

  • retrieve all the settings saved by the configuration script
  • pass the settings to CMake
  • if this is the first time CMake is invoked, it will generate a project tree. The project tree will be located underneath the directory specified in the --build-prefix option of the configuration. The location can be displayed by running make config or make help inside the source tree.
  • build the CMake-generated project

Running make from any directory inside the source tree will invoke the same sequence but limit the scope of the build to the sub-tree with the current directory as the root.

The make command inside the source tree supports several additional targets; run make help for the list and short descriptions.

macOS (Xcode)

To generate an Xcode project, you will need to first checkout and build ncbi-vdb, then check out sra-tools and run the standard CMake out-of-source build. For that, run CMake GUI and point it at the checkout directory. Click "Configure", then edit the entries for VDB_BINDIR and VDB_INCDIR to contain the paths for the CMake build directory for ncbi-vdb and the interfaces directory in the ncbi-vdb source directory, respectively. Choose "Xcode" as the generator and click "Configure" and then "Generate". Once the CMake generation succeeds, there will be an Xcode project file sra-tools.xcodeproj in the build's binary directory. You can open it with Xcode and build from the IDE.

Alternatively, you can configure and build from the command line, in which case you would need to provide the 2 paths to the SDK's libraries and headers:

cmake <path-to-sra-tools> -G Xcode -DVDB_BINDIR=<path-to-sdk-build> -DVDB_INCDIR=<path-to-sdk-headers>
cmake --build . --config Debug      # or Release

Windows (Visual Studio)

To generate an MS Visual Studio solution, you will need to first checkout and build ncbi-vdb, then check out sra-tools and run the standard CMake out-of-source build. For that, run CMake GUI and point it at the checkout directory. Click "Configure", then edit the entries for VDB_BINDIR and VDB_INCDIR to contain the paths for the CMake build directory for ncbi-vdb and the interfaces directory in the ncbi-vdb source directory, respectively. Now, choose one of the supported Visual Studio generators (see NOTE below) and a 64-bit generator, and click "Configure" and then "Generate". Once the CMake generation succeeds, there will be an MS VS solution file sra-tools.sln in the build's binary directory. You can open it with the Visual Studio and build from the IDE.

NOTE: This release supports generators Visual Studio 15 2017 and Visual Studio 16 2019, only for 64 bit platforms.

Alternatively, you can configure and build from the command line (assuming the correct MSVS Build Tools are in the %PATH%), in which case you would need to provide the 2 paths to the SDK's libraries and headers:

cmake <path-to-sra-tools> -G "Visual Studio 16 2019" -A x64 -DVDB_BINDIR=<path-to-sdk-build> -DVDB_INCDIR=<path-to-sdk-headers>
cmake --build . --config Debug      # or Release