Skip to content

Commit

Permalink
Merge branch 'jts:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeborja authored May 13, 2022
2 parents fd1b797 + 748ce04 commit 1b2d82d
Show file tree
Hide file tree
Showing 31 changed files with 780 additions and 1,841 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "htslib"]
path = htslib
url = https://github.com/samtools/htslib
[submodule "fast5"]
path = fast5
url = https://github.com/mateidavid/fast5
[submodule "minimap2"]
path = minimap2
url = https://github.com/lh3/minimap2
Expand Down
54 changes: 39 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#

# Sub directories containing source code, except for the main programs
SUBDIRS := src src/hmm src/thirdparty src/thirdparty/scrappie src/common src/alignment src/pore_model src/io
SUBDIRS := src src/hmm src/thirdparty src/thirdparty/scrappie src/common src/alignment src/pore_model src/io src/basemods

#
# Set libraries, paths, flags and options
Expand All @@ -10,7 +10,7 @@ SUBDIRS := src src/hmm src/thirdparty src/thirdparty/scrappie src/common src/ali
#Basic flags every build needs
LIBS = -lz
CXXFLAGS ?= -g -O3
CXXFLAGS += -std=c++11 -fopenmp -fsigned-char -D_FILE_OFFSET_BITS=64 #D_FILE_OFFSET_BITS=64 makes nanopolish work in 32 bit systems
CXXFLAGS += -std=c++11 -fopenmp -fsigned-char -D_FILE_OFFSET_BITS=64
CFLAGS ?= -O3 -std=c99 -fsigned-char -D_FILE_OFFSET_BITS=64
LDFLAGS ?=
CXX ?= g++
Expand All @@ -27,7 +27,35 @@ HTS ?= install
MINIMAP2 ?= install
SLOW5LIB ?= install

HDF5_VERSION ?= 1.8.14
MACHINE := $(shell gcc -dumpmachine)

# when building on MacOS we only support gcc, but need to set some paths
ifneq (,$(findstring apple,$(MACHINE)))
SDK := $(shell xcrun --sdk macosx --show-sdk-path)
MAC_FLAGS = -isysroot $(SDK) -L/usr/lib
MAC=1
CXXFLAGS += $(MAC_FLAGS)
CFLAGS += $(MAC_FLAGS)
endif

ARM=0

# set an ARM-specific flag
ifneq (,$(findstring arm64,$(MACHINE)))
ARM=1
endif

# set an ARM-specific flag
ifneq (,$(findstring aarch64,$(MACHINE)))
ARM=1
endif

ifeq ($(MAC), 1)
HDF5_VERSION ?= 1.13.0
else
HDF5_VERSION ?= 1.8.14
endif

EIGEN_VERSION ?= 3.3.7

# Check operating system, OSX doesn't have -lrt
Expand Down Expand Up @@ -80,26 +108,21 @@ else
LIBS += -lminimap2
endif

# Default to build and link the libhts submodule
# Default to build and link slow5 submodule
ifeq ($(SLOW5LIB), install)
SLOW5LIB_LIB = ./slow5lib/lib/libslow5.a
SLOW5LIB_INCLUDE = -I./slow5lib/include/
endif

ifeq ($(ARM), 1)
MINIMAP2_OPT=arm_neon=1
else
MINIMAP2_OPT=
MINIMAP2_OPT += arm_neon=1
endif

# Include the header-only fast5 library
FAST5_INCLUDE = -I./fast5/include

# Include the src subdirectories
NP_INCLUDE = $(addprefix -I./, $(SUBDIRS))

# Add include flags
CPPFLAGS += $(H5_INCLUDE) $(HTS_INCLUDE) $(MINIMAP2_INCLUDE) $(FAST5_INCLUDE) $(NP_INCLUDE) $(EIGEN_INCLUDE) $(SLOW5LIB_INCLUDE)
CPPFLAGS += $(H5_INCLUDE) $(HTS_INCLUDE) $(MINIMAP2_INCLUDE) $(NP_INCLUDE) $(EIGEN_INCLUDE) $(SLOW5LIB_INCLUDE)

# Main programs to build
PROGRAM = nanopolish
Expand All @@ -112,13 +135,14 @@ all: depend $(PROGRAM)
# Build libhts
#
htslib/libhts.a:
$(MAKE) -C htslib htslib_default_libs="-lz -lm -lbz2" || exit 255
cp etc/htslib_config.h htslib/config.h
$(MAKE) -C htslib CFLAGS="$(MAC_FLAGS) -g -Wall -O2 -fvisibility=hidden" LDFLAGS="$(MAC_FLAGS) -fvisibility=hidden" htslib_default_libs="-lz -lm -lbz2" NONCONFIGURE_OBJS="" || exit 255

minimap2/libminimap2.a:
$(MAKE) -C minimap2 $(MINIMAP2_OPT) libminimap2.a || exit 255
$(MAKE) -C minimap2 $(MINIMAP2_OPT) CFLAGS="$(MAC_FLAGS) -g -Wall -O2 -Wc++-compat" libminimap2.a || exit 255

slow5lib/lib/libslow5.a:
$(MAKE) -C slow5lib || exit 255
$(MAKE) -C slow5lib CFLAGS="$(MAC_FLAGS) -g -Wall -O2 -std=c99"|| exit 255
#
# If this library is a dependency the user wants HDF5 to be downloaded and built.
#
Expand All @@ -130,7 +154,7 @@ lib/libhdf5.a:

tar -xzf hdf5-$(HDF5_VERSION).tar.gz || exit 255
cd hdf5-$(HDF5_VERSION) && \
./configure --enable-threadsafe --disable-hl --libdir=`pwd`/../lib --includedir=`pwd`/../include --prefix=`pwd`/.. || exit 255
./configure CFLAGS="$(MAC_FLAGS)" CPPFLAGS="$(MAC_FLAGS)" --enable-threadsafe --disable-hl --libdir=`pwd`/../lib --includedir=`pwd`/../include --prefix=`pwd`/.. || exit 255
$(MAKE) -C hdf5-$(HDF5_VERSION) && $(MAKE) -C hdf5-$(HDF5_VERSION) install

# Download and install eigen if not already downloaded
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Software package for signal-level analysis of Oxford Nanopore sequencing data. Nanopolish can calculate an improved consensus sequence for a draft genome assembly, detect base modifications, call SNPs and indels with respect to a reference genome and more (see Nanopolish modules, below).

## Release notes
* 0.14.0: support modification bam files, compile on M1 apple hardware, support [SLOW5](https://github.com/hasindu2008/slow5lib) files

* 0.13.3: fix conda build issues, better handling of VBZ-compressed files, integration of module for [nano-COP](https://www.nature.com/articles/s41596-020-00469-y)

Expand Down Expand Up @@ -42,8 +43,9 @@ By default, nanopolish will download and compile all of its required dependencie

* [libhdf5-1.8.14](http://www.hdfgroup.org/HDF5/release/obtain5.html) compiled with multi-threading support `--enable-threadsafe`
* [eigen-3.2.5](http://eigen.tuxfamily.org)
* [htslib-1.4](http://github.com/samtools/htslib)
* [minimap2-d2de282](http://github.com/lh3/minimap2)
* [htslib-1.15.1](http://github.com/samtools/htslib)
* [minimap2-fe35e67](http://github.com/lh3/minimap2)
* [slow5lib-3680e17](https://github.com/hasindu2008/slow5lib)

In order to use the additional python3 scripts within `/scripts`, install the dependencies via

Expand Down Expand Up @@ -93,11 +95,12 @@ nanopolish eventalign: align signal-level events to k-mers of a reference genome
Nanopolish needs access to the signal-level data measured by the nanopore sequencer. The first step of any nanopolish workflow is to prepare the input data by telling nanopolish where to find the signal files. If you ran Albacore 2.0 on your data you should run `nanopolish index` on your input reads (-d can be specified more than once if using multiple runs):

```
# Index the output of the albacore basecaller
nanopolish index -d /path/to/raw_fast5s/ -s sequencing_summary.txt albacore_output.fastq
# Index the output of the basecaller
nanopolish index -d /path/to/raw_fast5s/ -s sequencing_summary.txt basecalled_output.fastq # for FAST5 inout
nanopolish index basecalled_output.fastq --slow5 signals.blow5 # for SLOW5 input
```

The `-s` option tells nanopolish to read the `sequencing_summary.txt` file from Albacore to speed up indexing. Without this option `nanopolish index` is extremely slow as it needs to read every fast5 file individually. If you basecalled your run in parallel, so you have multiple `sequencing_summary.txt` files, you can use the `-f` option to pass in a file containing the paths to the sequencing summary files (one per line).
The `-s` option tells nanopolish to read the `sequencing_summary.txt` file from Albacore to speed up indexing. Without this option `nanopolish index` is extremely slow as it needs to read every fast5 file individually. If you basecalled your run in parallel, so you have multiple `sequencing_summary.txt` files, you can use the `-f` option to pass in a file containing the paths to the sequencing summary files (one per line). When using SLOW5 files as the input (FAST5 can be converted to SLOW5 using [slow5tools](https://github.com/hasindu2008/slow5tools)), `-s` option is not required and does not affect indexing performance.

### Computing a new consensus sequence for a draft assembly

Expand Down
6 changes: 6 additions & 0 deletions etc/htslib_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Nanopolish-specific config */
//#define HAVE_LIBBZ2 1
//#define HAVE_LIBLZMA 1
//#define HAVE_LZMA_H 1
#define HAVE_FSEEKO 1
#define HAVE_DRAND48 1
1 change: 0 additions & 1 deletion fast5
Submodule fast5 deleted from 18d6e3
2 changes: 1 addition & 1 deletion htslib
Submodule htslib updated 357 files
2 changes: 1 addition & 1 deletion minimap2
Loading

0 comments on commit 1b2d82d

Please sign in to comment.