Skip to content

Commit

Permalink
Move tests to cmake and moved edlib into external dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pjotrp committed Apr 9, 2022
1 parent 0669f9d commit a06234b
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/small_test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
run: git submodule update --init --recursive
- name: Build smoothxg
run: cmake -H. -DCMAKE_BUILD_TYPE=Debug -Bbuild && cmake --build build -- -j 2
- name: Run a test on the DRB1-3123 dataset
run: ASAN_OPTIONS=detect_leaks=1:symbolize=1 LSAN_OPTIONS=verbosity=0:log_threads=1 bin/smoothxg -t 2 -g test/data/DRB1-3123.fa.gz.pggb-s3000-p70-n10-a70-K16-k8-w10000-j5000-e5000.seqwish.gfa -w 10K -j 5k -e 5k -l 10k -m test/data/DRB1-3123.fa.gz.pggb-s3000-p70-n10-a70-K16-k8-w10000-j5000-e5000.smooth.maf -C "consensus,10,100:test/data/gi_568815592_32578768-32589835.txt:y,1000:test/data/gi_568815592_32578768-32589835.txt:n,10000" -o test/data/DRB1-3123.fa.gz.pggb-s3000-p70-n10-a70-K16-k8-w10000-j5000-e5000.smooth.gfa
- name: Run tests
run: ctest --test-dir build -E odgi-test --verbose
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
.gdb_history
test/
include
consensus*
47 changes: 35 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# Specify the minimum version for CMake

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.16)

# Project's name
project(smoothxg)

# We build using c++17
set(CMAKE_CXX_STANDARD 17)

find_package(ZLIB REQUIRED)

enable_testing()

# Preload the following libraries before running tests
set(PRELOAD "libasan.so:libjemalloc.so.2")


if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Release Debug Generic." FORCE)
Expand Down Expand Up @@ -38,7 +47,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# assumes clang build
# we can't reliably detect when we're using clang, so for the time being we assume
# TODO: can't we though?

# adapted from https://stackoverflow.com/questions/46414660/macos-cmake-and-openmp
# find_package(OpenMP) does not work reliably on macOS, so we do its work ourselves
set (OpenMP_C "${CMAKE_C_COMPILER}")
Expand All @@ -50,30 +59,28 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (OpenMP_libomp_LIBRARY "omp")
set (OpenMP_libgomp_LIBRARY "gomp")
set (OpenMP_libiomp5_LIBRARY "iomp5")

# and now add the OpenMP parameters to the compile flags
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} -lomp")

elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")

find_package(OpenMP REQUIRED)

# add the flags it detects to the compile flags
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -fopenmp")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -fopenmp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")

endif()

message(STATUS "SMOOTHXG CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "SMOOTHXG CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "SMOOTHXG CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")

find_package(ZLIB REQUIRED)

# Set the output folder where your program will be created
# Set the output folder
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
Expand Down Expand Up @@ -265,7 +272,16 @@ ExternalProject_Add(mkmh
ExternalProject_Get_property(mkmh SOURCE_DIR)
set(mkmh_INCLUDE "${SOURCE_DIR}")

add_subdirectory(deps/edlib EXCLUDE_FROM_ALL)
ExternalProject_Add(edlib
SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/edlib"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_COMMAND ""
TEST_COMMAND ""
CONFIGURE_COMMAND "")
ExternalProject_Get_property(edlib SOURCE_DIR)
set(edlib_INCLUDE "${SOURCE_DIR}/edlib/include")

add_subdirectory(deps/WFA EXCLUDE_FROM_ALL)

add_library(smoothxg_objs OBJECT
Expand Down Expand Up @@ -354,7 +370,7 @@ set(smoothxg_INCLUDES
"${abPOA_src_INCLUDE}"
"${bbhash_INCLUDE}"
"${mkmh_INCLUDE}"
"deps/edlib/edlib/include"
"${edlib_INCLUDE}"
"deps/WFA"
"deps/patchmap")

Expand All @@ -377,7 +393,7 @@ add_executable(smoothxg
${CMAKE_SOURCE_DIR}/src/main.cpp)
target_link_libraries(smoothxg spoa)
target_link_libraries(smoothxg ${smoothxg_LIBS})
target_link_libraries(smoothxg edlib)
# target_link_libraries(smoothxg edlib)

# -lz is needed for abPOA, as indicated in the example.c
# https://github.com/yangao07/abPOA/blob/17d7b287b905bcd0e684ca5015a78e5a73a40798/example.c#L3
Expand Down Expand Up @@ -405,6 +421,13 @@ install(TARGETS smoothxg DESTINATION bin)
#install(TARGETS libsmoothxg_static ARCHIVE DESTINATION lib LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/smoothxg)
#install(TARGETS libsmoothxg_shared ARCHIVE DESTINATION lib LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/smoothxg)


add_test(
NAME smoothxg-test
COMMAND bin/smoothxg -t 2 -g test/data/DRB1-3123.fa.gz.pggb-s3000-p70-n10-a70-K16-k8-w10000-j5000-e5000.seqwish.gfa -w 10K -j 5k -e 5k -l 10k -m test/data/DRB1-3123.fa.gz.pggb-s3000-p70-n10-a70-K16-k8-w10000-j5000-e5000.smooth.maf -C "consensus,10,100:test/data/gi_568815592_32578768-32589835.txt:y,1000:test/data/gi_568815592_32578768-32589835.txt:n,10000" -o test/data/DRB1-3123.fa.gz.pggb-s3000-p70-n10-a70-K16-k8-w10000-j5000-e5000.smooth.gfa
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_tests_properties(smoothxg-test PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_leaks=1:symbolize=1;LSAN_OPTIONS=verbosity=0:log_threads=1;LD_LIBRARY_PATH=$ENV{LIBRARY_PATH};LD_PRELOAD=${PRELOAD}")

if (APPLE)
elseif (TRUE)
if (BUILD_STATIC)
Expand Down
112 changes: 112 additions & 0 deletions guix.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
;; To use this file to build HEAD of smoothxg:
;;
;; guix build -f guix.scm
;;
;; To do a cross compilation build for ARM64
;;
;; guix build -f guix.scm --target=aarch64-linux
;;
;; To get a development container (inside emacs shell will work)
;;
;; guix shell -C -D -f guix.scm -- bash --init-file <(echo "ln -s /bin/sh /bin/bash")
;;
;; and build
;;
;; find -name CMakeCache.txt|xargs rm -v
;; cd build
;; cmake -DCMAKE_BUILD_TYPE=Debug ..
;; cmake --build . --verbose -- -j 14 && ctest . --verbose
;;
;; For the tests you may need /usr/bin/env. In a container create it with
;;
;; mkdir -p /usr/bin ; ln -s $GUIX_ENVIRONMENT/bin/env /usr/bin/env
;;

(use-modules
(ice-9 popen)
(ice-9 rdelim)
((guix licenses) #:prefix license:)
(guix gexp)
(guix packages)
(guix download)
(guix git-download)
(guix build-system cmake)
(guix utils)
(gnu packages base)
(gnu packages compression)
(gnu packages bioinformatics)
(gnu packages build-tools)
(gnu packages commencement) ; gcc-toolchain
(gnu packages curl)
(gnu packages datastructures)
(gnu packages gdb)
(gnu packages gcc)
(gnu packages jemalloc)
(gnu packages libffi)
(gnu packages mpi)
(gnu packages python)
(gnu packages python-xyz)
(gnu packages pkg-config)
(gnu packages tls)
(gnu packages version-control)
)

(define %source-dir (dirname (current-filename)))

(define %git-commit
(read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ)))

(define-public smoothxg-git
(package
(name "smoothxg-git")
(version (git-version "0.3.3" "HEAD" %git-commit))
(source (local-file %source-dir #:recursive? #t))
(build-system cmake-build-system)
(inputs
`(
("coreutils" ,coreutils)
; ("cpp-httplib" ,cpp-httplib) later!
("pybind11" ,pybind11) ;; see libstd++ note in remarks above
; ("intervaltree" ,intervaltree) later!
("jemalloc" ,jemalloc)
("gcc" ,gcc-11)
("gcc-lib" ,gcc-11 "lib")
("gcc-toolchain" ,gcc-toolchain)
("gdb" ,gdb)
("git" ,git) ; pulls in perl which does not do RISV-V cross builds yet
; ("lodepng" ,lodepng) later!
("openmpi" ,openmpi)
("python" ,python)
("sdsl-lite" ,sdsl-lite)
("libdivsufsort" ,libdivsufsort)
("zlib" ,zlib)
("zstd-lib" ,zstd "lib")
))
(native-inputs
`(("pkg-config" ,pkg-config)
))
(arguments
`(#:phases
(modify-phases
%standard-phases
;; This stashes our build version in the executable
(add-after 'unpack 'set-version
(lambda _
(mkdir-p "include")
(with-output-to-file "include/smoothxg_git_version.hpp"
(lambda ()
(format #t "#define ODGI_GIT_VERSION \"~a\"~%" version)))
#t))
;; (delete 'check)
)
;; #:make-flags (list ,(string-append "CC=" (cc-for-target)))))
))
(synopsis "odgi pangenome optimized dynamic sequence graph implementation")
(description
"odgi pangenome graph tooling provides an efficient, succinct dynamic
DNA sequence graph model, as well as a host of algorithms that allow
the use of such graphs.")
(home-page "https://github.com/vgteam/odgi")
(license license:expat)))

smoothxg-git

0 comments on commit a06234b

Please sign in to comment.