-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from HKU-BAL/r11
update version to v0.1-r11
- Loading branch information
Showing
33 changed files
with
4,974 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
OS := $(shell uname) | ||
ARCH := $(shell arch) | ||
|
||
PYTHON ?= python3 | ||
|
||
all : libhts.a longphase libclair3.so | ||
clean : clean_htslib clean_longphase clean_libclair3 | ||
|
||
SAMVER = 1.10 | ||
LPVER = 1.0 | ||
GCC ?= gcc | ||
GXX ?= g++ | ||
PREFIX ?= ${CONDA_PREFIX} | ||
LDFLAGS = -L ${PREFIX}/lib | ||
CFLAGS = -fpic -std=c99 -O3 -I ${PREFIX}/include -L ${PREFIX}/lib | ||
CPPFLAGS = -std=c++11 -Wall -O3 -I ${PREFIX}/include -L ${PREFIX}/lib -Wl,-rpath=${PREFIX}/lib | ||
LP_CPPFLAGS = -std=c++11 -Wall -g -O3 -I ${PREFIX}/include -L ${PREFIX}/lib -Wl,-rpath=${PREFIX}/lib | ||
|
||
samtools-$(SAMVER)/Makefile: | ||
curl -L -o samtools-${SAMVER}.tar.bz2 https://github.com/samtools/samtools/releases/download/${SAMVER}/samtools-${SAMVER}.tar.bz2; \ | ||
tar -xjf samtools-${SAMVER}.tar.bz2; \ | ||
rm samtools-${SAMVER}.tar.bz2 | ||
|
||
libhts.a: samtools-$(SAMVER)/Makefile | ||
# this is required only to add in -fpic so we can build python module | ||
@echo "\x1b[1;33mMaking $(@F)\x1b[0m" | ||
cd samtools-${SAMVER}/htslib-${SAMVER}; CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure; make CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" | ||
cp samtools-${SAMVER}/htslib-${SAMVER}/$@ $@ | ||
|
||
|
||
longphase-$(LPVER)/Makefile: | ||
curl -L -o longphase-${LPVER}.tar.gz https://github.com/twolinin/longphase/archive/refs/tags/v${LPVER}.tar.gz; \ | ||
tar -zxvf longphase-${LPVER}.tar.gz; \ | ||
rm longphase-${LPVER}.tar.gz | ||
|
||
longphase: longphase-$(LPVER)/Makefile | ||
@echo "\x1b[1;33mMaking $(@F)\x1b[0m" | ||
cd longphase-${LPVER}; autoreconf -i; CPPFLAGS="${CPPFLAGS}" ./configure; make CC=${GCC} CXX=${GXX} CPPFLAGS="${CPPFLAGS}" | ||
cp longphase-${LPVER}/$@ $@ | ||
|
||
|
||
libclair3.so: samtools-${SAMVER}/htslib-${SAMVER} | ||
${PYTHON} build.py | ||
|
||
|
||
.PHONY: clean_htslib | ||
clean_htslib: | ||
cd samtools-${SAMVER} && make clean || exit 0 | ||
cd samtools-${SAMVER}/htslib-${SAMVER} && make clean || exit 0 | ||
rm libhts.a | ||
|
||
.PHONY: clean_longphase | ||
clean_longphase: | ||
cd longphase-${LPVER} && make clean || exit 0 | ||
rm longphase | ||
|
||
.PHONY: clean_libclair3 | ||
clean_libclair3: | ||
rm libclair3.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import itertools | ||
import os | ||
import platform | ||
from subprocess import run | ||
from cffi import FFI | ||
|
||
samver = "1.10" | ||
file_directory = os.path.dirname(os.path.realpath(__file__)) | ||
htslib_dir = os.path.join(file_directory, 'samtools-{}'.format(samver), 'htslib-{}'.format(samver)) | ||
|
||
libraries = ['m', 'z', 'lzma', 'bz2', 'pthread', 'curl', 'crypto'] | ||
extra_link_args = [] | ||
library_dirs = [htslib_dir] | ||
src_dir = os.path.join(file_directory, 'src') | ||
|
||
extra_compile_args = ['-std=c99', '-O3'] | ||
if platform.machine() in {"aarch64", "arm64"}: | ||
if platform.system() == "Darwin": | ||
pass | ||
else: | ||
extra_compile_args.append("-march=armv8-a+simd") | ||
else: | ||
extra_compile_args.append("-mtune=haswell") | ||
libraries.append('deflate') | ||
try: | ||
conda_path = os.environ['CONDA_PREFIX'] | ||
extra_link_args = ['-Wl,-rpath={}/lib'.format(conda_path)] | ||
except: | ||
print("[WARNING] Conda prefix not found, please activate clair3 conda environment first!") | ||
|
||
ffibuilder = FFI() | ||
ffibuilder.set_source("libclair3", | ||
r""" | ||
#include "kvec.h" | ||
#include "khash.h" | ||
#include "levenshtein.h" | ||
#include "medaka_bamiter.h" | ||
#include "medaka_common.h" | ||
#include "medaka_khcounter.h" | ||
#include "clair3_pileup.h" | ||
#include "clair3_full_alignment.h" | ||
""", | ||
libraries=libraries, | ||
library_dirs=library_dirs, | ||
include_dirs=[src_dir, htslib_dir], | ||
sources=[ | ||
os.path.join(src_dir, x) for x in ( | ||
'levenshtein.c', | ||
'medaka_bamiter.c', | ||
'medaka_common.c', | ||
'medaka_khcounter.c', | ||
'clair3_pileup.c', | ||
'clair3_full_alignment.c')], | ||
extra_compile_args=extra_compile_args, | ||
extra_link_args=extra_link_args, | ||
extra_objects=['libhts.a'] | ||
) | ||
|
||
cdef = [ | ||
"typedef struct { ...; } bam_fset;" | ||
"bam_fset* create_bam_fset(char* fname);" | ||
"void destroy_bam_fset(bam_fset* fset);" | ||
] | ||
for header in ('clair3_pileup.h', 'clair3_full_alignment.h'): | ||
with open(os.path.join(src_dir, header), 'r') as fh: | ||
# remove directives | ||
lines = ''.join(x for x in fh.readlines() if not x.startswith('#')) | ||
cdef.append(lines) | ||
|
||
ffibuilder.cdef('\n\n'.join(cdef)) | ||
|
||
|
||
if __name__ == "__main__": | ||
ffibuilder.compile(verbose=True) | ||
run("cp {}/libclair3*.so {}/libclair3.so".format(file_directory, file_directory), shell=True) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.