diff --git a/BamDeal.cpp b/BamDeal.cpp new file mode 100644 index 0000000..08e22f3 --- /dev/null +++ b/BamDeal.cpp @@ -0,0 +1,79 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/convert/covert.h" +#include "src/modify/modify.h" +#include "src/statistics/statistics.h" +#include "src/visualize/visualize.h" + +using namespace std; + +int convert_main(int argc, char *argv[]) ; +int modify_main(int argc, char *argv[]); +int statistics_main(int argc, char *argv[]); +int visualize_main(int argc, char *argv[]); + +static int AllTools_usage () +{ + cerr <<"Program: BamDeal\nVersion: 0.27\thewm2008@gmail.com\t"<<__DATE__<=1.12) had done ( http://www.htslib.org/download/) + b. gcc/g++ ver >= 4.8 // support Flag [ --std=c++11 ] + +############################# +Only two step : + +1 ./configure + # you can usr the usr the LDFLAGS to find the htslib library and CXXFLAGS and CFLAGS to find the htslib header + # ./configure LDFLAGS=-L/usr/lib/ CFLAGS="-I/usr/include/" CXXFLAGS="-I/usr/include/" + # Export LIBRARY/CFLAGS/CXXFLAGS environment variables to set the htslib path also can be a way to compile, such : export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH + +2 make + + +Note if it can't work . follow below B1-B6 or use the static Compiled [BamDeal_Linux ] + +############################################ + #autoscan ./ + #cp configure.scan configure.ac + +# if can't work, follow below 6 commands +B1: aclocal #// src/automake-1.9/aclocal +B2: autoconf #// src/automake-1.9/autoconf +B3: autoheader #// src/automake-1.9/autoheader +B4: automake --add-missing #// src/automake-1.9/automake --add-missing +B5: ./configure +B6: make +############################################# +#swimming in the sky & flying in the sea# + + + diff --git a/LICENSE b/LICENSE index 8527ff4..4b8712f 100644 --- a/LICENSE +++ b/LICENSE @@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2df8e4b --- /dev/null +++ b/Makefile @@ -0,0 +1,620 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + + +pkgdatadir = $(datadir)/BamDeal +pkgincludedir = $(includedir)/BamDeal +pkglibdir = $(libdir)/BamDeal +pkglibexecdir = $(libexecdir)/BamDeal +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = BamDeal$(EXEEXT) +subdir = . +DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure depcomp install-sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_BamDeal_OBJECTS = BamDeal.$(OBJEXT) +BamDeal_OBJECTS = $(am_BamDeal_OBJECTS) +BamDeal_DEPENDENCIES = +BamDeal_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(BamDeal_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(BamDeal_SOURCES) +DIST_SOURCES = $(BamDeal_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d "$(distdir)" \ + || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr "$(distdir)"; }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = ${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run aclocal-1.11 +AMTAR = ${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run tar +AUTOCONF = ${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run autoconf +AUTOHEADER = ${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run autoheader +AUTOMAKE = ${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run automake-1.11 +AWK = gawk +CC = gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/ +CPP = gcc -E +CPPFLAGS = --std=c++11 +CXX = g++ +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/ +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +GREP = /bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LDFLAGS = -L/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/lib/ +LIBOBJS = ${LIBOBJDIR}malloc$U.o ${LIBOBJDIR}realloc$U.o +LIBS = -lhts -lz +LN_S = ln -s +LTLIBOBJS = ${LIBOBJDIR}malloc$U.lo ${LIBOBJDIR}realloc$U.lo +MAKEINFO = ${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run makeinfo +MKDIR_P = /bin/mkdir -p +OBJEXT = o +PACKAGE = BamDeal +PACKAGE_BUGREPORT = hewm2008@qq.com +PACKAGE_NAME = BamDeal +PACKAGE_STRING = BamDeal 0.27 +PACKAGE_TARNAME = bamdeal +PACKAGE_URL = +PACKAGE_VERSION = 0.27 +PATH_SEPARATOR = : +RANLIB = ranlib +SET_MAKE = +SHELL = /bin/sh +STRIP = +VERSION = 0.27 +abs_builddir = /ifswh1/BC_PS/heweiming/BamDeal-0.27 +abs_srcdir = /ifswh1/BC_PS/heweiming/BamDeal-0.27 +abs_top_builddir = /ifswh1/BC_PS/heweiming/BamDeal-0.27 +abs_top_srcdir = /ifswh1/BC_PS/heweiming/BamDeal-0.27 +ac_ct_CC = gcc +ac_ct_CXX = g++ +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build_alias = +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host_alias = +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = ${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target_alias = +top_build_prefix = +top_builddir = . +top_srcdir = . +AUTOMAKE_OPTIONS = foreign +BamDeal_SOURCES = BamDeal.cpp +BamDeal_LDFLAGS = --std=c++11 +BamDeal_LDADD = -lhts +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) && echo chmod 755 bin/\* >> $(top_srcdir)/configure +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +BamDeal$(EXEEXT): $(BamDeal_OBJECTS) $(BamDeal_DEPENDENCIES) + @rm -f BamDeal$(EXEEXT) + $(BamDeal_LINK) $(BamDeal_OBJECTS) $(BamDeal_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/BamDeal.Po + +.cpp.o: + $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: + $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r "$(distdir)" +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod u+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @$(am__cd) '$(distuninstallcheck_dir)' \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) config.h +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: all install-am install-strip + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ + clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ + dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ + distcheck distclean distclean-compile distclean-generic \ + distclean-hdr distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..6ad038c --- /dev/null +++ b/Makefile.am @@ -0,0 +1,7 @@ +AUTOMAKE_OPTIONS = foreign +bin_PROGRAMS = BamDeal +BamDeal_SOURCES = BamDeal.cpp +BamDeal_LDFLAGS = --std=c++11 +BamDeal_LDADD = -lhts +CPPFLAGS = --std=c++11 + diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..201a52c --- /dev/null +++ b/Makefile.in @@ -0,0 +1,620 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = BamDeal$(EXEEXT) +subdir = . +DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure depcomp install-sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_BamDeal_OBJECTS = BamDeal.$(OBJEXT) +BamDeal_OBJECTS = $(am_BamDeal_OBJECTS) +BamDeal_DEPENDENCIES = +BamDeal_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(BamDeal_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(BamDeal_SOURCES) +DIST_SOURCES = $(BamDeal_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d "$(distdir)" \ + || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr "$(distdir)"; }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = --std=c++11 +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign +BamDeal_SOURCES = BamDeal.cpp +BamDeal_LDFLAGS = --std=c++11 +BamDeal_LDADD = -lhts +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +BamDeal$(EXEEXT): $(BamDeal_OBJECTS) $(BamDeal_DEPENDENCIES) + @rm -f BamDeal$(EXEEXT) + $(BamDeal_LINK) $(BamDeal_OBJECTS) $(BamDeal_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BamDeal.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r "$(distdir)" +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod u+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @$(am__cd) '$(distuninstallcheck_dir)' \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) config.h +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: all install-am install-strip + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ + clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ + dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ + distcheck distclean distclean-compile distclean-generic \ + distclean-hdr distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/README.md b/README.md index 4a2af02..6a4ceeb 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,45 @@ + # BamDeal BamDeal: a comprehensive toolkit for bam manipulation -

BamDeal is a full-featured toolkit for comprehensive analysis of bam file, - -BamDeal is implemented in C/C++ language, available for Linux and Mac OS X operating system. +
BamDeal is a full-featured toolkit for comprehensive analysis of bam file, +BamDeal is implemented in C/C++ language, available for Linux and Mac OS X operating system. ### 1) Download and Install ------------ - [Download](https://github.com/BGI-shenzhen/BamDeal/raw/master/BamDeal-0.19.tar.gz) -
 
Pre-installations of 3 libraries are required before installing BamDeal -  
1 htslib: [samtools-1.6/htslib-1.6](https://sourceforge.net/projects/samtools/files/samtools)) -  
2 g++ with [--std=c++11](https://gcc.gnu.org/) > 4.8 is recommended -  
3 zlib : [zlib](https://zlib.net/) > 1.2.3 is recommended -  
4 R : [R](https://www.r-project.org/) is recommended +The new version will be updated and maintained in [hewm2008/BamDeal](https://github.com/hewm2008/BamDeal), please click below Link to download the latest version +

[hewm2008/BamDeal](https://github.com/hewm2008/BamDeal)

+ + [Download](https://github.com/hewm2008/BamDeal/archive/v0.27.tar.gz) +

+For linux/Unix static +
you can use the statically compiled programs directly +
+             chmod 755 ./bin/BamDeal_Linux
+             ./bin/BamDeal_Linux       # mv BamDeal_Linux    BamDeal
+
+
+ +For linux/Unix and macOS compile +
 
Pre-installations of 4 libraries or softs are required before installing BamDeal +  
1 htslib: [samtools-1.12/htslib-1.12](https://sourceforge.net/projects/samtools/files/samtools) htslib >=1.12 +  
2 g++ : g++ with [--std=c++11](https://gcc.gnu.org/) > 4.8+ is recommended +  
3 zlib : [zlib](https://zlib.net/) > 1.2.3 is recommended +  
4 R : [R](https://www.r-project.org/) with [ggplot](http://ggplot.yhathq.com/) is recommended - To compile BamDeal, do [ ./configure] first, then [make] - Final software can be found in the direcoty [bin/BamDeal] - - For linux /Unix and macOS
         tar -zxvf  BamDeal-XXX.tar.gz
-        cd BamDeal-XXX;                             
-        ./configure	   
-        make ;                        
-        ./bin/BamDeal                             
+        cd BamDeal-XXX;
+        chmod 755  configure;      ./configure
+        make;
+        mv BamDeal bin/;   ./bin/BamDeal 
 
-**Note:** If fail in [./configure], to find library ***_htslib_**, you can add LDFLAGS to find the htslib library and CPPFLAGS to find the htslib header [ ./configure LDFLAGS=-L/usr/lib/ CPPFLAGS=-I/usr/include/] + +**Note1:** If fail in [./configure], to find library **_htslib_**, you can add LDFLAGS to find the htslib library and CXXFLAGS and CFLAGS to find the htslib header [ ./configure LDFLAGS=-L/usr/lib/ CXXFLAGS=-I/usr/include/ CFLAGS=-I/usr/include/]; +
export 'LIBRARY/CFLAGS/CXXFLAGS' environment variables to set the htslib path also can be a way to compile, such : export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH; + +**Note2:** you can use the statically compiled programs directly [chmod 755 ./bin/BamDeal_Linux; ./bin/BamDeal_Linux] ### 2) Features @@ -34,7 +49,7 @@ BamDeal is implemented in C/C++ language, available for Linux and Mac OS X opera ```php Program: BamDeal -Version: 0.19 hewm2008@gmail.com Apr 12 2018 +Version: 0.27 hewm2008@gmail.com 2021-12-02 Usage: @@ -65,30 +80,33 @@ Version: 0.19 hewm2008@gmail.com Apr 12 2018 |Summary| | | | |bamFilter |filter low quality read in bam | | |bamSplit |split single/muti-Bam by chr | +| |bamAssign |split single/muti-Bam by assign chr | | |bamCat |Merge/Cat diff header muti bam to one bam | | |bamRand |random out partly of bam read | +| |bamSubChr |get/remove some chr form bam | | |bamShiftQ |modify seq phred quality in bam | - +| |bamLimit |Limit big bam to muti subbam by fix line | #### statistics |Module | Function | Description | |:-----:|:--------------|:-----------------------------------------------------------------| |Summary| | | -| |Coverage |Calculate Genome Coverage/Depth/GC Dis based Bam | -| |DeteCNV |detect CNV/Deletion Region by merge Depth info based Bam | +| |Coverage |Calculate Genome Coverage/Depth/GC Dis based Bam (v1.32) | +| |BasesCount |Calculate Genome every Site's four base Depth | +| |DeteCNV |Detect CNV/Deletion Region by merge Depth info based Bam | +| |DeteSV |Detect SV by Pair End Read insert size in Bam | | |LowDepth |GiveOut bed file of low Depth Region(may BigDeletion) | -| | | | -| | | | +| |SiteRead |Extract the read (with base) covering the SNP site | #### visualize |Module | Function | Description | |:-----:|:--------------|:-----------------------------------------------------------------| |Summary| | | -| |StatCheck |Basic Statistics and qualty control,Show result Fig | +| |StatQC |Basic Stat and qualty control,Show gc-depth... result Fig | | |DepthCov |Show pdf Fig of Depth Dis & Depth~Coverage | -| |DepthGC |Show pdf Fig of Depth~GC | +| |DepthGC |Show pdf Fig of Depth~RefGC | | |DepthSlide |Show Manhattan Fig of Depth sliding Windows along genome | @@ -133,8 +151,6 @@ Version: 0.19 hewm2008@gmail.com Apr 12 2018 ./BamDeal visualize DepthCov -InList -OutPut ``` - - see more other Usage in the Documentation ### 4) Format @@ -142,14 +158,15 @@ see more other Usage in the Documentation Format Introduction * [sam/bam format](https://samtools.github.io/hts-specs/SAMv1.pdf) -* [soap format](http://soap.genomics.org.cn/soapaligner.html) +* [soap format](http://soap.genomics.org.cn/soapaligner.html) [chinese soap introduction](http://blog.sina.com.cn/s/blog_70b2b6020101b609.html) -### 5)Discussing +### 5) Discussing ------------ -- [:email:](https://github.com/BGI-shenzhen/BamDeal) hewm2008@gmail.com / hewm2008@qq.com +- [:email:](https://github.com/hewm2008/BamDeal) hewm2008@gmail.com / hewm2008@qq.com - join the QQ Group : 125293663 ######################swimming in the sky and flying in the sea ########################### ## + diff --git a/Temp/static_make.sh b/Temp/static_make.sh new file mode 100644 index 0000000..011f987 --- /dev/null +++ b/Temp/static_make.sh @@ -0,0 +1,9 @@ +#!/bin/sh +#$ -S /bin/sh +#Version1.0 P_bc_rd@genomics.org.cn 2020-06-05 +echo Start Time : +date +#/share/app/gcc-5.2.0/bin/g++ --std=c++11 -g -O3 -I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/ -L/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/lib/ -o BamDeal_Linux BamDeal.cpp -lhts -lncurses -lm -lpthread -lboost_thread -lz -lrt -static -llzma -lbz2 -I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/ -L/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/lib/ +../gcc-6.4.0/bin/g++ --std=c++11 -g -O3 -I /home/BCadmin/03.Soft_ALL/Dele/samtools-1.12/include/ -L /home/BCadmin/03.Soft_ALL/Dele/samtools-1.12/lib/ -o BamDeal_Linux BamDeal.cpp -lhts -lm -lpthread -lz -static -L/data/storage05/BC_PUB/Software/03.Soft_ALL/curl-7.77.0/lib -L /data/storage05/BC_PUB/Software/01.Usr/lib/ -L /usr/lib/ -L/data/storage05/BC_PUB/Software/03.Soft_ALL/curl-7.77.0/lib -lcurl -lcrypto -lboost_thread -lrt -ldl -llzma -lbz2 -lcares +echo End Time : +date diff --git a/Temp/yy.sh b/Temp/yy.sh new file mode 100644 index 0000000..9e656b8 --- /dev/null +++ b/Temp/yy.sh @@ -0,0 +1,8 @@ +#!/bin/sh +#$ -S /bin/sh +#Version1.0 hewm@genomics.org.cn 2022-12-14 +echo Start Time : +date +/share/app/gcc-5.2.0/bin/g++ --std=c++11 -g -O3 BamDeal.cpp -lcurl -lncurses -lhts -lm -lpthread -lboost_thread -lz -lrt -static -llzma -lbz2 -I /home/heweiming/PS/dede/include/ -L /home/heweiming/PS/dede/lib/ -lcurl -lcrypto -ldl -L /home/heweiming/PS/dede/Lib/ -o BamDeal_Linux +echo End Time : +date diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..65f291f --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,951 @@ +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.11' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.11.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.11.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 10 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 5 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 16 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.62])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl +]) + +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 6 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/bin/BamDeal_Linux b/bin/BamDeal_Linux new file mode 100644 index 0000000..d1c8166 Binary files /dev/null and b/bin/BamDeal_Linux differ diff --git a/bin/misc/GC_Depth_Plot.pl b/bin/misc/GC_Depth_Plot.pl new file mode 100644 index 0000000..8c43403 --- /dev/null +++ b/bin/misc/GC_Depth_Plot.pl @@ -0,0 +1,112 @@ +#!/usr/bin/perl -w +use FindBin qw($Bin); +use strict; +#explanation:this program is edited to +#edit by hewm; Mon Jan 26 14:37:33 CST 2015 +#Version 1.0 hewm@genomics.org.cn + +die "Version 1.0\t2015-01-26;\nUsage: $0 \n" unless (@ARGV ==3); + +#############Befor Start , open the files #################### + +######################swimming in the sky and flying in the sea ########################### +my $file= $ARGV[0] ; + +if ($file =~s/\.gz$/\.gz/) +{ + open FIN,"gzip -cd $file | " || die "input file can't open $!" ; +} +else +{ + open FIN,"$file" || die "input file can't open $!" ; +} + + +open (OAtmp , ">$ARGV[2].tmp") || die " output file can't open $!"; +open (OAR , ">$ARGV[2].r") || die " output file can't open $!"; + + +my %DD=(); +while ($_=) +{ + chomp ; + next if ($_=~s/#/#/g); + next if ($_=~s/NA/NA/g); + my @inf=split ; + if ($inf[1]>$ARGV[1]) + { + $inf[1]=$ARGV[1]; + } + $DD{$inf[-1]}{$inf[1]}++; +} +close FIN ; + + +print OAtmp "GC_ratio\tDepth\tNumbers\n"; +foreach my $k1 ( sort {$a<=>$b} keys %DD) +{ + my $sedH=$DD{$k1}; + foreach my $k2 ( sort {$a<=>$b} keys %$sedH) + { + print OAtmp "$k1\t$k2\t$DD{$k1}{$k2}\n"; + } +} +close OAtmp ; + + +my $Pit = <tab; +GC_ratio<-tab[,1] +Depth<-tab[,2] +Numbers<-tab[,3] + +pdf("$ARGV[2].pdf"); + +df <- data.frame(GC_ratio , Depth ) +p <- ggplot(df, aes(GC_ratio, Depth,colour=Numbers)) + geom_point(size=1.5) + theme_classic() +ggExtra::ggMarginal(p, type = "histogram") + + +dev.off(); + +png("$ARGV[2].png"); + +df <- data.frame(GC_ratio , Depth ) +p <- ggplot(df, aes(GC_ratio, Depth,colour=Numbers)) + geom_point(size=1.5) + theme_classic() +ggExtra::ggMarginal(p, type = "histogram") + + +dev.off(); +PIG +print OAR $Pit ; +close OAR ; +my $Rscript="/usr/bin/Rscript"; +if ( !(-e $Rscript) ) +{ + $Rscript="/ifswh1/BC_PUB/biosoft/BC_NQ/01.Soft/03.Soft_ALL/R-3.4.1/bin/Rscript"; + if ( !(-e $Rscript) ) + { + $Rscript=`which Rscript`;chomp $Rscript; + } +} + + + + +if ( !(-e $Rscript) ) +{ + print "Can't find the [ Rscript ] bin, You shoud install the R First,then:\n"; + print " Rscript $ARGV[2].r \n"; + exit(1); +} + + +system (" $Rscript $ARGV[2].r "); +system (" rm -rf $ARGV[2].tmp $ARGV[2].r ") ; + diff --git a/config.h b/config.h new file mode 100644 index 0000000..9487c02 --- /dev/null +++ b/config.h @@ -0,0 +1,140 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#define HAVE_HTSLIB_KSEQ_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_HTSLIB_KSTRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_HTSLIB_SAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `hts' library (-lhts). */ +#define HAVE_LIBHTS 1 + +/* Define to 1 if you have the `z' library (-lz). */ +#define HAVE_LIBZ 1 + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#define HAVE_MALLOC 0 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#define HAVE_REALLOC 0 + +/* Define to 1 if you have the `regcomp' function. */ +#define HAVE_REGCOMP 1 + +/* Define to 1 if you have the `sqrt' function. */ +#define HAVE_SQRT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ZLIB_H 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Name of package */ +#define PACKAGE "BamDeal" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "hewm2008@qq.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "BamDeal" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "BamDeal 0.27" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "bamdeal" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.27" + +/* Define to 1 if you have the ANSI C header files. */ +/* #undef STDC_HEADERS */ + +/* Version number of package */ +#define VERSION "0.27" + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to rpl_malloc if the replacement function should be used. */ +#define malloc rpl_malloc + +/* Define to rpl_realloc if the replacement function should be used. */ +#define realloc rpl_realloc + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..11b2806 --- /dev/null +++ b/config.h.in @@ -0,0 +1,139 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_HTSLIB_KSEQ_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_HTSLIB_KSTRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_HTSLIB_SAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `hts' library (-lhts). */ +#undef HAVE_LIBHTS + +/* Define to 1 if you have the `z' library (-lz). */ +#undef HAVE_LIBZ + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#undef HAVE_REALLOC + +/* Define to 1 if you have the `regcomp' function. */ +#undef HAVE_REGCOMP + +/* Define to 1 if you have the `sqrt' function. */ +#undef HAVE_SQRT + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ZLIB_H + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT8_T + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef int32_t + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to rpl_realloc if the replacement function should be used. */ +#undef realloc + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +#undef uint8_t diff --git a/config.log b/config.log new file mode 100644 index 0000000..951536a --- /dev/null +++ b/config.log @@ -0,0 +1,403 @@ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by BamDeal configure 0.27, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ ./configure + +## --------- ## +## Platform. ## +## --------- ## + +hostname = masterSrv +uname -m = x86_64 +uname -r = 3.10.0-957.27.2.el7.x86_64 +uname -s = Linux +uname -v = #1 SMP Mon Jul 29 17:46:05 UTC 2019 + +/usr/bin/uname -p = x86_64 +/bin/uname -X = unknown + +/bin/arch = x86_64 +/usr/bin/arch -k = unknown +/usr/convex/getsysinfo = unknown +/usr/bin/hostinfo = unknown +/bin/machine = unknown +/usr/bin/oslevel = unknown +/bin/universe = unknown + +PATH: /home/BCadmin/03.Soft_ALL/gcc-6.4.0/bin +PATH: /data/storage05/BC_PUB/Software/01.Usr//bin +PATH: /home/BCadmin/perl5/bin +PATH: /usr/local/bin +PATH: /usr/bin +PATH: /usr/local/sbin +PATH: /usr/sbin + + +## ----------- ## +## Core tests. ## +## ----------- ## + +configure:2413: checking for a BSD-compatible install +configure:2481: result: /usr/bin/install -c +configure:2492: checking whether build environment is sane +configure:2542: result: yes +configure:2683: checking for a thread-safe mkdir -p +configure:2722: result: /usr/bin/mkdir -p +configure:2735: checking for gawk +configure:2751: found /usr/bin/gawk +configure:2762: result: gawk +configure:2773: checking whether make sets $(MAKE) +configure:2795: result: yes +configure:2883: checking for gawk +configure:2910: result: gawk +configure:2979: checking for g++ +configure:2995: found /home/BCadmin/03.Soft_ALL/gcc-6.4.0/bin/g++ +configure:3006: result: g++ +configure:3033: checking for C++ compiler version +configure:3042: g++ --version >&5 +g++ (GCC) 6.4.0 +Copyright (C) 2017 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:3053: $? = 0 +configure:3042: g++ -v >&5 +Using built-in specs. +COLLECT_GCC=g++ +COLLECT_LTO_WRAPPER=/data/storage05/BC_PUB/Software/03.Soft_ALL/gcc-6.4.0/libexec/gcc/x86_64-pc-linux-gnu/6.4.0/lto-wrapper +Target: x86_64-pc-linux-gnu +Configured with: ./configure --prefix=/data/storage05/BC_PUB/Software/03.Soft_ALL/gcc-6.4.0/ --enable-threads=posix --enable-languages=c,c++,fortran,go,objc,obj-c++,java --with-gmp=/data/storage05/BC_PUB/Software/01.Usr --with-mpc=/data/storage05/BC_PUB/Software/01.Usr --with-mpfr=/data/storage05/BC_PUB/Software/01.Usr --disable-checking --disable-multilib --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions--enable-gnu-unique-object --enable-java-awt=gtk --disable-dssi -enable-libgcj-multifile --enable-java-maintainer-mode --with-ppl --with-cloog --with-tune=generic +Thread model: posix +gcc version 6.4.0 (GCC) +configure:3053: $? = 0 +configure:3042: g++ -V >&5 +g++: error: unrecognized command line option '-V' +g++: fatal error: no input files +compilation terminated. +configure:3053: $? = 1 +configure:3042: g++ -qversion >&5 +g++: error: unrecognized command line option '-qversion'; did you mean '--version'? +g++: fatal error: no input files +compilation terminated. +configure:3053: $? = 1 +configure:3073: checking whether the C++ compiler works +configure:3095: g++ -L/home/BCadmin/03.Soft_ALL/gcc-6.4.0/lib conftest.cpp >&5 +configure:3099: $? = 0 +configure:3147: result: yes +configure:3150: checking for C++ compiler default output file name +configure:3152: result: a.out +configure:3158: checking for suffix of executables +configure:3165: g++ -o conftest -L/home/BCadmin/03.Soft_ALL/gcc-6.4.0/lib conftest.cpp >&5 +configure:3169: $? = 0 +configure:3191: result: +configure:3213: checking whether we are cross compiling +configure:3221: g++ -o conftest -L/home/BCadmin/03.Soft_ALL/gcc-6.4.0/lib conftest.cpp >&5 +configure:3225: $? = 0 +configure:3232: ./conftest +configure:3236: $? = 0 +configure:3251: result: no +configure:3256: checking for suffix of object files +configure:3278: g++ -c conftest.cpp >&5 +configure:3282: $? = 0 +configure:3303: result: o +configure:3307: checking whether we are using the GNU C++ compiler +configure:3326: g++ -c conftest.cpp >&5 +configure:3326: $? = 0 +configure:3335: result: yes +configure:3344: checking whether g++ accepts -g +configure:3364: g++ -c -g conftest.cpp >&5 +configure:3364: $? = 0 +configure:3405: result: yes +configure:3439: checking for style of include used by make +configure:3467: result: GNU +configure:3492: checking dependency style of g++ +configure:3602: result: gcc3 +configure:3671: checking for gcc +configure:3687: found /home/BCadmin/03.Soft_ALL/gcc-6.4.0/bin/gcc +configure:3698: result: gcc +configure:3729: checking for C compiler version +configure:3738: gcc --version >&5 +gcc (GCC) 6.4.0 +Copyright (C) 2017 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +configure:3749: $? = 0 +configure:3738: gcc -v >&5 +Using built-in specs. +COLLECT_GCC=gcc +COLLECT_LTO_WRAPPER=/data/storage05/BC_PUB/Software/03.Soft_ALL/gcc-6.4.0/libexec/gcc/x86_64-pc-linux-gnu/6.4.0/lto-wrapper +Target: x86_64-pc-linux-gnu +Configured with: ./configure --prefix=/data/storage05/BC_PUB/Software/03.Soft_ALL/gcc-6.4.0/ --enable-threads=posix --enable-languages=c,c++,fortran,go,objc,obj-c++,java --with-gmp=/data/storage05/BC_PUB/Software/01.Usr --with-mpc=/data/storage05/BC_PUB/Software/01.Usr --with-mpfr=/data/storage05/BC_PUB/Software/01.Usr --disable-checking --disable-multilib --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions--enable-gnu-unique-object --enable-java-awt=gtk --disable-dssi -enable-libgcj-multifile --enable-java-maintainer-mode --with-ppl --with-cloog --with-tune=generic +Thread model: posix +gcc version 6.4.0 (GCC) +configure:3749: $? = 0 +configure:3738: gcc -V >&5 +gcc: error: unrecognized command line option '-V' +gcc: fatal error: no input files +compilation terminated. +configure:3749: $? = 1 +configure:3738: gcc -qversion >&5 +gcc: error: unrecognized command line option '-qversion'; did you mean '--version'? +gcc: fatal error: no input files +compilation terminated. +configure:3749: $? = 1 +configure:3753: checking whether we are using the GNU C compiler +configure:3772: gcc -c -I/home/BCadmin/03.Soft_ALL/gcc-6.4.0/include conftest.c >&5 +configure:3772: $? = 0 +configure:3781: result: yes +configure:3790: checking whether gcc accepts -g +configure:3810: gcc -c -g conftest.c >&5 +configure:3810: $? = 0 +configure:3851: result: yes +configure:3868: checking for gcc option to accept ISO C89 +configure:3931: gcc -c -I/home/BCadmin/03.Soft_ALL/gcc-6.4.0/include conftest.c >&5 +configure:3931: $? = 0 +configure:3944: result: none needed +configure:3966: checking dependency style of gcc +configure:4076: result: gcc3 +configure:4096: checking how to run the C preprocessor +configure:4127: gcc -E conftest.c +configure:4127: $? = 0 +configure:4141: gcc -E conftest.c +conftest.c:11:28: fatal error: ac_nonexistent.h: No such file or directory + #include + ^ +compilation terminated. +configure:4141: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "BamDeal" +| #define PACKAGE_TARNAME "bamdeal" +| #define PACKAGE_VERSION "0.27" +| #define PACKAGE_STRING "BamDeal 0.27" +| #define PACKAGE_BUGREPORT "hewm2008@qq.com" +| #define PACKAGE_URL "" +| #define PACKAGE "BamDeal" +| #define VERSION "0.27" +| /* end confdefs.h. */ +| #include +configure:4166: result: gcc -E +configure:4186: gcc -E conftest.c +configure:4186: $? = 0 +configure:4200: gcc -E conftest.c +conftest.c:11:28: fatal error: ac_nonexistent.h: No such file or directory + #include + ^ +compilation terminated. +configure:4200: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "BamDeal" +| #define PACKAGE_TARNAME "bamdeal" +| #define PACKAGE_VERSION "0.27" +| #define PACKAGE_STRING "BamDeal 0.27" +| #define PACKAGE_BUGREPORT "hewm2008@qq.com" +| #define PACKAGE_URL "" +| #define PACKAGE "BamDeal" +| #define VERSION "0.27" +| /* end confdefs.h. */ +| #include +configure:4228: checking whether ln -s works +configure:4232: result: yes +configure:4239: checking whether make sets $(MAKE) +configure:4261: result: yes +configure:4313: checking for ranlib +configure:4329: found /usr/bin/ranlib +configure:4340: result: ranlib +configure:4366: checking for main in -lz +configure:4385: gcc -o conftest -I/home/BCadmin/03.Soft_ALL/gcc-6.4.0/include -L/home/BCadmin/03.Soft_ALL/gcc-6.4.0/lib conftest.c -lz >&5 +configure:4385: $? = 0 +configure:4394: result: yes +configure:4409: checking for main in -lhts +configure:4428: gcc -o conftest -I/home/BCadmin/03.Soft_ALL/gcc-6.4.0/include -L/home/BCadmin/03.Soft_ALL/gcc-6.4.0/lib conftest.c -lhts -lz >&5 +/usr/bin/ld: cannot find -lhts +collect2: error: ld returned 1 exit status +configure:4428: $? = 1 +configure: failed program was: +| /* confdefs.h */ +| #define PACKAGE_NAME "BamDeal" +| #define PACKAGE_TARNAME "bamdeal" +| #define PACKAGE_VERSION "0.27" +| #define PACKAGE_STRING "BamDeal 0.27" +| #define PACKAGE_BUGREPORT "hewm2008@qq.com" +| #define PACKAGE_URL "" +| #define PACKAGE "BamDeal" +| #define VERSION "0.27" +| #define HAVE_LIBZ 1 +| /* end confdefs.h. */ +| +| +| int +| main () +| { +| return main (); +| ; +| return 0; +| } +configure:4437: result: no +configure:4447: error: You need Pre-install Library libhts samtools/htslib >= 1.12 to build BamDeal + +## ---------------- ## +## Cache variables. ## +## ---------------- ## + +ac_cv_c_compiler_gnu=yes +ac_cv_cxx_compiler_gnu=yes +ac_cv_env_CCC_set= +ac_cv_env_CCC_value= +ac_cv_env_CC_set= +ac_cv_env_CC_value= +ac_cv_env_CFLAGS_set=set +ac_cv_env_CFLAGS_value=-I/home/BCadmin/03.Soft_ALL/gcc-6.4.0/include +ac_cv_env_CPPFLAGS_set= +ac_cv_env_CPPFLAGS_value= +ac_cv_env_CPP_set= +ac_cv_env_CPP_value= +ac_cv_env_CXXFLAGS_set= +ac_cv_env_CXXFLAGS_value= +ac_cv_env_CXX_set= +ac_cv_env_CXX_value= +ac_cv_env_LDFLAGS_set=set +ac_cv_env_LDFLAGS_value=-L/home/BCadmin/03.Soft_ALL/gcc-6.4.0/lib +ac_cv_env_LIBS_set= +ac_cv_env_LIBS_value= +ac_cv_env_build_alias_set= +ac_cv_env_build_alias_value= +ac_cv_env_host_alias_set= +ac_cv_env_host_alias_value= +ac_cv_env_target_alias_set= +ac_cv_env_target_alias_value= +ac_cv_lib_hts_main=no +ac_cv_lib_z_main=yes +ac_cv_objext=o +ac_cv_path_install='/usr/bin/install -c' +ac_cv_path_mkdir=/usr/bin/mkdir +ac_cv_prog_AWK=gawk +ac_cv_prog_CPP='gcc -E' +ac_cv_prog_ac_ct_CC=gcc +ac_cv_prog_ac_ct_CXX=g++ +ac_cv_prog_ac_ct_RANLIB=ranlib +ac_cv_prog_cc_c89= +ac_cv_prog_cc_g=yes +ac_cv_prog_cxx_g=yes +ac_cv_prog_make_make_set=yes +am_cv_CC_dependencies_compiler_type=gcc3 +am_cv_CXX_dependencies_compiler_type=gcc3 + +## ----------------- ## +## Output variables. ## +## ----------------- ## + +ACLOCAL='${SHELL} /software/03.Soft_ALL/BamDeal-0.27/missing --run aclocal-1.11' +AMDEPBACKSLASH='\' +AMDEP_FALSE='#' +AMDEP_TRUE='' +AMTAR='${SHELL} /software/03.Soft_ALL/BamDeal-0.27/missing --run tar' +AUTOCONF='${SHELL} /software/03.Soft_ALL/BamDeal-0.27/missing --run autoconf' +AUTOHEADER='${SHELL} /software/03.Soft_ALL/BamDeal-0.27/missing --run autoheader' +AUTOMAKE='${SHELL} /software/03.Soft_ALL/BamDeal-0.27/missing --run automake-1.11' +AWK='gawk' +CC='gcc' +CCDEPMODE='depmode=gcc3' +CFLAGS='-I/home/BCadmin/03.Soft_ALL/gcc-6.4.0/include' +CPP='gcc -E' +CPPFLAGS='' +CXX='g++' +CXXDEPMODE='depmode=gcc3' +CXXFLAGS='-g -O2' +CYGPATH_W='echo' +DEFS='' +DEPDIR='.deps' +ECHO_C='' +ECHO_N='-n' +ECHO_T='' +EGREP='' +EXEEXT='' +GREP='' +INSTALL_DATA='${INSTALL} -m 644' +INSTALL_PROGRAM='${INSTALL}' +INSTALL_SCRIPT='${INSTALL}' +INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' +LDFLAGS='-L/home/BCadmin/03.Soft_ALL/gcc-6.4.0/lib' +LIBOBJS='' +LIBS='-lz ' +LN_S='ln -s' +LTLIBOBJS='' +MAKEINFO='${SHELL} /software/03.Soft_ALL/BamDeal-0.27/missing --run makeinfo' +MKDIR_P='/usr/bin/mkdir -p' +OBJEXT='o' +PACKAGE='BamDeal' +PACKAGE_BUGREPORT='hewm2008@qq.com' +PACKAGE_NAME='BamDeal' +PACKAGE_STRING='BamDeal 0.27' +PACKAGE_TARNAME='bamdeal' +PACKAGE_URL='' +PACKAGE_VERSION='0.27' +PATH_SEPARATOR=':' +RANLIB='ranlib' +SET_MAKE='' +SHELL='/bin/sh' +STRIP='' +VERSION='0.27' +ac_ct_CC='gcc' +ac_ct_CXX='g++' +am__EXEEXT_FALSE='' +am__EXEEXT_TRUE='' +am__fastdepCC_FALSE='#' +am__fastdepCC_TRUE='' +am__fastdepCXX_FALSE='#' +am__fastdepCXX_TRUE='' +am__include='include' +am__isrc='' +am__leading_dot='.' +am__quote='' +am__tar='${AMTAR} chof - "$$tardir"' +am__untar='${AMTAR} xf -' +bindir='${exec_prefix}/bin' +build_alias='' +datadir='${datarootdir}' +datarootdir='${prefix}/share' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +dvidir='${docdir}' +exec_prefix='NONE' +host_alias='' +htmldir='${docdir}' +includedir='${prefix}/include' +infodir='${datarootdir}/info' +install_sh='${SHELL} /software/03.Soft_ALL/BamDeal-0.27/install-sh' +libdir='${exec_prefix}/lib' +libexecdir='${exec_prefix}/libexec' +localedir='${datarootdir}/locale' +localstatedir='${prefix}/var' +mandir='${datarootdir}/man' +mkdir_p='/usr/bin/mkdir -p' +oldincludedir='/usr/include' +pdfdir='${docdir}' +prefix='NONE' +program_transform_name='s,x,x,' +psdir='${docdir}' +sbindir='${exec_prefix}/sbin' +sharedstatedir='${prefix}/com' +sysconfdir='${prefix}/etc' +target_alias='' + +## ----------- ## +## confdefs.h. ## +## ----------- ## + +/* confdefs.h */ +#define PACKAGE_NAME "BamDeal" +#define PACKAGE_TARNAME "bamdeal" +#define PACKAGE_VERSION "0.27" +#define PACKAGE_STRING "BamDeal 0.27" +#define PACKAGE_BUGREPORT "hewm2008@qq.com" +#define PACKAGE_URL "" +#define PACKAGE "BamDeal" +#define VERSION "0.27" +#define HAVE_LIBZ 1 + +configure: exit 1 diff --git a/config.status b/config.status new file mode 100644 index 0000000..c662286 --- /dev/null +++ b/config.status @@ -0,0 +1,1216 @@ +#! /bin/sh +# Generated by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by BamDeal $as_me 0.27, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +# Files that config.status was made for. +config_files=" Makefile" +config_headers=" config.h" +config_commands=" depfiles" + +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +ac_cs_config="'LDFLAGS=-L/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/lib/' 'CXXFLAGS=-I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/' 'CFLAGS=-I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/'" +ac_cs_version="\ +BamDeal config.status 0.27 +configured by ./configure, generated by GNU Autoconf 2.69, + with options \"$ac_cs_config\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='/ifswh1/BC_PS/heweiming/BamDeal-0.27' +srcdir='.' +INSTALL='/usr/bin/install -c' +MKDIR_P='/bin/mkdir -p' +AWK='gawk' +test -n "$AWK" || AWK=awk +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +if $ac_cs_recheck; then + set X /bin/sh './configure' 'LDFLAGS=-L/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/lib/' 'CXXFLAGS=-I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/' 'CFLAGS=-I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/' $ac_configure_extra_args --no-create --no-recursion + shift + $as_echo "running CONFIG_SHELL=/bin/sh $*" >&6 + CONFIG_SHELL='/bin/sh' + export CONFIG_SHELL + exec "$@" +fi + +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +# +# INIT-COMMANDS +# +AMDEP_TRUE="" ac_aux_dir="." + + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +cat >>"$ac_tmp/subs1.awk" <<\_ACAWK && +S["am__EXEEXT_FALSE"]="" +S["am__EXEEXT_TRUE"]="#" +S["LTLIBOBJS"]=" ${LIBOBJDIR}malloc$U.lo ${LIBOBJDIR}realloc$U.lo" +S["LIBOBJS"]=" ${LIBOBJDIR}malloc$U.o ${LIBOBJDIR}realloc$U.o" +S["EGREP"]="/bin/grep -E" +S["GREP"]="/bin/grep" +S["RANLIB"]="ranlib" +S["LN_S"]="ln -s" +S["CPP"]="gcc -E" +S["am__fastdepCC_FALSE"]="#" +S["am__fastdepCC_TRUE"]="" +S["CCDEPMODE"]="depmode=gcc3" +S["ac_ct_CC"]="gcc" +S["CFLAGS"]="-I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/" +S["CC"]="gcc" +S["am__fastdepCXX_FALSE"]="#" +S["am__fastdepCXX_TRUE"]="" +S["CXXDEPMODE"]="depmode=gcc3" +S["AMDEPBACKSLASH"]="\\" +S["AMDEP_FALSE"]="#" +S["AMDEP_TRUE"]="" +S["am__quote"]="" +S["am__include"]="include" +S["DEPDIR"]=".deps" +S["OBJEXT"]="o" +S["EXEEXT"]="" +S["ac_ct_CXX"]="g++" +S["CPPFLAGS"]="" +S["LDFLAGS"]="-L/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/lib/" +S["CXXFLAGS"]="-I/hwfswh2/BC_PUB/Software/06.Develop/02.SpeUsr/include/" +S["CXX"]="g++" +S["am__untar"]="${AMTAR} xf -" +S["am__tar"]="${AMTAR} chof - \"$$tardir\"" +S["AMTAR"]="${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run tar" +S["am__leading_dot"]="." +S["SET_MAKE"]="" +S["AWK"]="gawk" +S["mkdir_p"]="/bin/mkdir -p" +S["MKDIR_P"]="/bin/mkdir -p" +S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s" +S["STRIP"]="" +S["install_sh"]="${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/install-sh" +S["MAKEINFO"]="${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run makeinfo" +S["AUTOHEADER"]="${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run autoheader" +S["AUTOMAKE"]="${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run automake-1.11" +S["AUTOCONF"]="${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run autoconf" +S["ACLOCAL"]="${SHELL} /ifswh1/BC_PS/heweiming/BamDeal-0.27/missing --run aclocal-1.11" +S["VERSION"]="0.27" +S["PACKAGE"]="BamDeal" +S["CYGPATH_W"]="echo" +S["am__isrc"]="" +S["INSTALL_DATA"]="${INSTALL} -m 644" +S["INSTALL_SCRIPT"]="${INSTALL}" +S["INSTALL_PROGRAM"]="${INSTALL}" +S["target_alias"]="" +S["host_alias"]="" +S["build_alias"]="" +S["LIBS"]="-lhts -lz " +S["ECHO_T"]="" +S["ECHO_N"]="-n" +S["ECHO_C"]="" +S["DEFS"]="-DHAVE_CONFIG_H" +S["mandir"]="${datarootdir}/man" +S["localedir"]="${datarootdir}/locale" +S["libdir"]="${exec_prefix}/lib" +S["psdir"]="${docdir}" +S["pdfdir"]="${docdir}" +S["dvidir"]="${docdir}" +S["htmldir"]="${docdir}" +S["infodir"]="${datarootdir}/info" +S["docdir"]="${datarootdir}/doc/${PACKAGE_TARNAME}" +S["oldincludedir"]="/usr/include" +S["includedir"]="${prefix}/include" +S["localstatedir"]="${prefix}/var" +S["sharedstatedir"]="${prefix}/com" +S["sysconfdir"]="${prefix}/etc" +S["datadir"]="${datarootdir}" +S["datarootdir"]="${prefix}/share" +S["libexecdir"]="${exec_prefix}/libexec" +S["sbindir"]="${exec_prefix}/sbin" +S["bindir"]="${exec_prefix}/bin" +S["program_transform_name"]="s,x,x," +S["prefix"]="/usr/local" +S["exec_prefix"]="${prefix}" +S["PACKAGE_URL"]="" +S["PACKAGE_BUGREPORT"]="hewm2008@qq.com" +S["PACKAGE_STRING"]="BamDeal 0.27" +S["PACKAGE_VERSION"]="0.27" +S["PACKAGE_TARNAME"]="bamdeal" +S["PACKAGE_NAME"]="BamDeal" +S["PATH_SEPARATOR"]=":" +S["SHELL"]="/bin/sh" +_ACAWK +cat >>"$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +D["PACKAGE_NAME"]=" \"BamDeal\"" +D["PACKAGE_TARNAME"]=" \"bamdeal\"" +D["PACKAGE_VERSION"]=" \"0.27\"" +D["PACKAGE_STRING"]=" \"BamDeal 0.27\"" +D["PACKAGE_BUGREPORT"]=" \"hewm2008@qq.com\"" +D["PACKAGE_URL"]=" \"\"" +D["PACKAGE"]=" \"BamDeal\"" +D["VERSION"]=" \"0.27\"" +D["HAVE_LIBZ"]=" 1" +D["HAVE_LIBHTS"]=" 1" +D["HAVE_SYS_TYPES_H"]=" 1" +D["HAVE_SYS_STAT_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_STRING_H"]=" 1" +D["HAVE_MEMORY_H"]=" 1" +D["HAVE_STRINGS_H"]=" 1" +D["HAVE_INTTYPES_H"]=" 1" +D["HAVE_STDINT_H"]=" 1" +D["HAVE_UNISTD_H"]=" 1" +D["HAVE_ZLIB_H"]=" 1" +D["HAVE_HTSLIB_SAM_H"]=" 1" +D["HAVE_HTSLIB_KSEQ_H"]=" 1" +D["HAVE_ZLIB_H"]=" 1" +D["HAVE_HTSLIB_KSTRING_H"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_STRING_H"]=" 1" +D["HAVE_UNISTD_H"]=" 1" +D["HAVE_HTSLIB_KSEQ_H"]=" 1" +D["HAVE_HTSLIB_SAM_H"]=" 1" +D["HAVE_HTSLIB_KSTRING_H"]=" 1" +D["HAVE__BOOL"]=" 1" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_MALLOC"]=" 0" +D["malloc"]=" rpl_malloc" +D["HAVE_STDLIB_H"]=" 1" +D["HAVE_REALLOC"]=" 0" +D["realloc"]=" rpl_realloc" +D["HAVE_MEMSET"]=" 1" +D["HAVE_REGCOMP"]=" 1" +D["HAVE_SQRT"]=" 1" +D["HAVE_STRDUP"]=" 1" +D["HAVE_STRNCASECMP"]=" 1" +D["HAVE_STRTOL"]=" 1" + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ { + line = $ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + ac_datarootdir_hack=' + s&@datadir@&${datarootdir}&g + s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g + s&@infodir@&${datarootdir}/info&g + s&@localedir@&${datarootdir}/locale&g + s&@mandir@&${datarootdir}/man&g + s&\${datarootdir}&${prefix}/share&g' ;; +esac +ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +} + +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 diff --git a/configure b/configure new file mode 100644 index 0000000..67cefd3 --- /dev/null +++ b/configure @@ -0,0 +1,6590 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for BamDeal 0.27. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## +chmod 755 bin/* +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and hewm2008@qq.com +$0: about your system, including any error possibly output +$0: before this message. Then install a modern shell, or +$0: manually run the script under such a shell if you do +$0: have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='BamDeal' +PACKAGE_TARNAME='bamdeal' +PACKAGE_VERSION='0.27' +PACKAGE_STRING='BamDeal 0.27' +PACKAGE_BUGREPORT='hewm2008@qq.com' +PACKAGE_URL='' + +ac_unique_file="BamDeal.cpp" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +EGREP +GREP +RANLIB +LN_S +CPP +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +ac_ct_CC +CFLAGS +CC +am__fastdepCXX_FALSE +am__fastdepCXX_TRUE +CXXDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CXX +CPPFLAGS +LDFLAGS +CXXFLAGS +CXX +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_dependency_tracking +' + ac_precious_vars='build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures BamDeal 0.27 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/bamdeal] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of BamDeal 0.27:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + +Some influential environment variables: + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CC C compiler command + CFLAGS C compiler flags + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +BamDeal configure 0.27 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------ ## +## Report this to hewm2008@qq.com ## +## ------------------------------ ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_find_intX_t LINENO BITS VAR +# ----------------------------------- +# Finds a signed integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_intX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 +$as_echo_n "checking for int$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in int$2_t 'int' 'long int' \ + 'long long int' 'short int' 'signed char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) + < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + case $ac_type in #( + int$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_intX_t + +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_uintX_t + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by BamDeal $as_me 0.27, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +am__api_version='1.11' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=BamDeal + VERSION=0.27 + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + +ac_config_headers="$ac_config_headers config.h" + +# Checks for programs +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 +$as_echo_n "checking whether the C++ compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C++ compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 +$as_echo_n "checking for C++ compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CXX_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in gcc + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in gcc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lz': + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lz" >&5 +$as_echo_n "checking for main in -lz... " >&6; } +if ${ac_cv_lib_z_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_z_main=yes +else + ac_cv_lib_z_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_main" >&5 +$as_echo "$ac_cv_lib_z_main" >&6; } +if test "x$ac_cv_lib_z_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +else + as_fn_error $? "You need zlib >= 1.2.3 to build $PACKAGE" "$LINENO" 5 +fi + + +# FIXME: Replace `main' with a function in `-lhts': +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lhts" >&5 +$as_echo_n "checking for main in -lhts... " >&6; } +if ${ac_cv_lib_hts_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lhts $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_hts_main=yes +else + ac_cv_lib_hts_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hts_main" >&5 +$as_echo "$ac_cv_lib_hts_main" >&6; } +if test "x$ac_cv_lib_hts_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBHTS 1 +_ACEOF + + LIBS="-lhts $LIBS" + +else + as_fn_error $? "You need Pre-install Library libhts samtools/htslib >= 1.12 to build $PACKAGE" "$LINENO" 5 +fi + + + +# Checks for header files. + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in zlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ZLIB_H 1 +_ACEOF + +else + as_fn_error $? "You need include htslib/zlib.h to build $PACKAGE" "$LINENO" 5 +fi + +done + +for ac_header in htslib/sam.h htslib/kseq.h zlib.h htslib/kstring.h stdlib.h string.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in htslib/kseq.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "htslib/kseq.h" "ac_cv_header_htslib_kseq_h" "$ac_includes_default" +if test "x$ac_cv_header_htslib_kseq_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_HTSLIB_KSEQ_H 1 +_ACEOF + +else + as_fn_error $? "You need include htslib/kseq.h to build $PACKAGE" "$LINENO" 5 +fi + +done + +for ac_header in htslib/sam.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "htslib/sam.h" "ac_cv_header_htslib_sam_h" "$ac_includes_default" +if test "x$ac_cv_header_htslib_sam_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_HTSLIB_SAM_H 1 +_ACEOF + +else + as_fn_error $? "You need include htslib/sam.h to build $PACKAGE" "$LINENO" 5 +fi + +done + +for ac_header in htslib/kstring.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "htslib/kstring.h" "ac_cv_header_htslib_kstring_h" "$ac_includes_default" +if test "x$ac_cv_header_htslib_kstring_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_HTSLIB_KSTRING_H 1 +_ACEOF + +else + as_fn_error $? "You need include htslib/kstring.h to build $PACKAGE" "$LINENO" 5 +fi + +done + + + +# Checks for typedefs, structures, and compiler characteristics. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 +$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } +if ${ac_cv_header_stdbool_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + /* See body of main program for 'e'. */ + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + +int +main () +{ + + bool e = &s; + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdbool_h=yes +else + ac_cv_header_stdbool_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 +$as_echo "$ac_cv_header_stdbool_h" >&6; } + ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" +if test "x$ac_cv_type__Bool" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if ${ac_cv_c_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" +case $ac_cv_c_int32_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int32_t $ac_cv_c_int32_t +_ACEOF +;; +esac + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" +case $ac_cv_c_uint8_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT8_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint8_t $ac_cv_c_uint8_t +_ACEOF +;; + esac + + + + +# Checks for library functions. +for ac_header in stdlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STDLIB_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 +$as_echo_n "checking for GNU libc compatible malloc... " >&6; } +if ${ac_cv_func_malloc_0_nonnull+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_malloc_0_nonnull=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *malloc (); +#endif + +int +main () +{ +return ! malloc (0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_malloc_0_nonnull=yes +else + ac_cv_func_malloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } +if test $ac_cv_func_malloc_0_nonnull = yes; then : + +$as_echo "#define HAVE_MALLOC 1" >>confdefs.h + +else + $as_echo "#define HAVE_MALLOC 0" >>confdefs.h + + case " $LIBOBJS " in + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" + ;; +esac + + +$as_echo "#define malloc rpl_malloc" >>confdefs.h + +fi + + +for ac_header in stdlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STDLIB_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 +$as_echo_n "checking for GNU libc compatible realloc... " >&6; } +if ${ac_cv_func_realloc_0_nonnull+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_realloc_0_nonnull=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *realloc (); +#endif + +int +main () +{ +return ! realloc (0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_realloc_0_nonnull=yes +else + ac_cv_func_realloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } +if test $ac_cv_func_realloc_0_nonnull = yes; then : + +$as_echo "#define HAVE_REALLOC 1" >>confdefs.h + +else + $as_echo "#define HAVE_REALLOC 0" >>confdefs.h + + case " $LIBOBJS " in + *" realloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS realloc.$ac_objext" + ;; +esac + + +$as_echo "#define realloc rpl_realloc" >>confdefs.h + +fi + + +for ac_func in memset regcomp sqrt strdup strncasecmp strtol +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + +ac_config_files="$ac_config_files Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by BamDeal $as_me 0.27, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +BamDeal config.status 0.27 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + +sed 's#\$(AUTOCONF)#\$(AUTOCONF) \&\& echo chmod 755 bin/\\\* \>\> \$(top_srcdir)/configure #' Makefile > Makefile.tmp +mv Makefile.tmp Makefile +chmod 755 bin/* +echo Detection system platform is +if [ "$(uname)" == "Darwin" ];then + echo MacOS + sed 's/libboost_thread/libboost_thread-mt/g' Makefile > Makefile.tmp + mv Makefile.tmp Makefile + sed 's/\/\/SSSS/#include /' ./src/statistics/Bmath/pnorm.c > ./src/statistics/Bmath/pnorm.c.tmp + mv ./src/statistics/Bmath/pnorm.c.tmp ./src/statistics/Bmath/pnorm.c + # Mac OS +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ];then + echo Linux + # GNU/Linux +elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ];then + echo windows sys no run this +# Windows NT +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..df7965b --- /dev/null +++ b/configure.ac @@ -0,0 +1,54 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.69) +AC_INIT(BamDeal, 0.27, hewm2008@qq.com) +AM_INIT_AUTOMAKE(BamDeal,0.27) +AC_CONFIG_SRCDIR([BamDeal.cpp]) +AC_CONFIG_HEADER([config.h]) +# Checks for programs +AC_PROG_AWK +AC_PROG_CXX([g++]) +AC_PROG_CC([gcc]) +AC_PROG_CPP +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_RANLIB + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lz': +AC_CHECK_LIB([z], [main],,AC_MSG_ERROR([You need zlib >= 1.2.3 to build $PACKAGE])) + +# FIXME: Replace `main' with a function in `-lhts': +AC_CHECK_LIB([hts], [main],,AC_MSG_ERROR([You need Pre-install Library libhts samtools/htslib >= 1.12 to build $PACKAGE])) + + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([zlib.h],[],[AC_MSG_ERROR([You need include htslib/zlib.h to build $PACKAGE])],[]) +AC_CHECK_HEADERS([htslib/sam.h htslib/kseq.h zlib.h htslib/kstring.h stdlib.h string.h unistd.h]) +AC_CHECK_HEADERS([htslib/kseq.h],[],[AC_MSG_ERROR([You need include htslib/kseq.h to build $PACKAGE])],[]) +AC_CHECK_HEADERS([htslib/sam.h],[],[AC_MSG_ERROR([You need include htslib/sam.h to build $PACKAGE])],[]) +AC_CHECK_HEADERS([htslib/kstring.h],[],[AC_MSG_ERROR([You need include htslib/kstring.h to build $PACKAGE])],[]) + + +# Checks for typedefs, structures, and compiler characteristics. +AC_CHECK_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_INT32_T +AC_TYPE_SIZE_T +AC_TYPE_UINT32_T +AC_TYPE_UINT8_T + + + +# Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([memset regcomp sqrt strdup strncasecmp strtol]) + + + + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/depcomp b/depcomp new file mode 100644 index 0000000..df8eea7 --- /dev/null +++ b/depcomp @@ -0,0 +1,630 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2009-04-28.21; # UTC + +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free +# Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u="sed s,\\\\\\\\,/,g" + depmode=msvisualcpp +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> "$depfile" + echo >> "$depfile" + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mechanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/help_Doc.docx b/help_Doc.docx new file mode 100644 index 0000000..76c49bd Binary files /dev/null and b/help_Doc.docx differ diff --git a/install-sh b/install-sh new file mode 100644 index 0000000..6781b98 --- /dev/null +++ b/install-sh @@ -0,0 +1,520 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2009-04-28.21; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/missing b/missing new file mode 100644 index 0000000..28055d2 --- /dev/null +++ b/missing @@ -0,0 +1,376 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2009-04-28.21; # UTC + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, +# 2008, 2009 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and +\`g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# normalize program name to check for. +program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). This is about non-GNU programs, so use $1 not +# $program. +case $1 in + lex*|yacc*) + # Not GNU programs, they don't have --version. + ;; + + tar*) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $program in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te*) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison*|yacc*) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex*|flex*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit $? + fi + ;; + + makeinfo*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar*) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case $firstarg in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case $firstarg in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/ALL/DataClass.h b/src/ALL/DataClass.h new file mode 100644 index 0000000..66373ed --- /dev/null +++ b/src/ALL/DataClass.h @@ -0,0 +1,140 @@ + +////////////////////////swimming in the sea & flying in the sky ////////////////// + + +/* + * DataClass.h + * + * Created on: 2011-11-21 + * Author: hewm@genomics.org.cn + */ + +#ifndef DataClass_H_ +#define DataClass_H_ + +#include +#include +#include +#include +#include "comm.h" + +using namespace std; + + +///////////////// q_seq for site //////// + + +class In3str1v { + public: + bool TF ; + int InInt ; + int InInt2 ; + bool TF2 ; + double InF ; + string InStr1 ; + string InStr2 ; + string InStr3 ; + vector List ; + In3str1v() + { + InStr1=""; + InStr2=""; + InStr3=""; + TF=true ; + TF2=true ; + InInt=0 ; + InInt2=0; + InF=0.0; + } +}; + + + +class Para_Formt01 { + public: + string input_file ; + string OutSamFile ; + string OutBamFile ; + int PE ; + int sort ; + int shiftQ ; + string Dict ; + Para_Formt01() + { + input_file="" ; + OutSamFile="" ; + OutBamFile="" ; + Dict=""; + PE=0 ; + sort=0; + shiftQ=0; + } +}; + +class SamLine +{ + public: + string RID; + int Flag ; + string seq; + string Qseq; + string cigar; + string chr; + llong position ; + int mapQ ; + string NM_i ; + string MD ; + bool IF ; + int isize ; + llong coor ; + string XorD ; + void copy( SamLine * B ) + { + RID=B->RID; Flag=B->Flag; seq=B->seq ; + Qseq=B->Qseq; cigar=B->cigar; chr=B->chr; + position=B->position ; mapQ=B->mapQ; IF=B->IF; + NM_i=B->NM_i ;MD=B->MD ; isize=B->isize; + coor=B->coor; XorD=B->XorD; + } + SamLine() + { + RID=""; seq=""; Qseq=""; cigar=""; chr =""; + Flag=0 ; position=0; mapQ =0 ; IF=false; + NM_i=""; MD=""; + isize=0; coor=0; XorD="*"; + } + void rm () + { + RID=""; seq=""; Qseq=""; cigar=""; chr =""; + Flag=0 ; position=0; mapQ =0 ; IF=false; + NM_i=""; MD=""; + isize=0; coor=0; XorD="*"; + //return 1 ; + } + void Print(ogzstream & OUT ) + { + OUT< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gzstream/gzstream.c" + + +/*/// +#ifndef DBL_AMANT_ADIG +#define DBL_AMANT_ADIG 35 +#endif + +#define MAX_AFILE_ALIST_ALEN 512 +#define MAX_ALIST_ANAME_ALEN 1024 +#define MAX_ACHR_ANAME_ALEN 128 +///*//// +/*/// + const char decode[16] = {'N','A','C','N','G','N','N','N','T','N','N','N','N','N','N','N'}; + const int code[10] = {0,5,15,10,1,3,2,7,6,11}; + const int rev_Acode[16] = {0,4,6,5,4,1,8,7,6,8,3,9,5,7,9,2}; + const char abbv[17] = {'A','M','W','R','M','C','Y','S','W','Y','T','K','R','S','K','G','N'}; + +//*/ + +using namespace std; + +typedef long long llong ; +typedef unsigned long long ubit64_t; + +KSEQ_INIT(gzFile, gzread) + + /* + template < class TT > + string Int2Str ( TT A ) + { + stringstream sstrm ; + sstrm << A ; + return sstrm.str(); + } + */ + +int ReadList (string soaplist , vector & Soap_AStat ) +{ + igzstream LIST (soaplist.c_str(),ifstream::in); // igzstream + int soapfilecout=0 ; + if (!LIST.good()) + { + cerr << "open List error: "<& tokens, const string& delimiters = " ") +{ + string::size_type lastPos = str.find_first_not_of(delimiters, 0); + string::size_type pos = str.find_first_of(delimiters, lastPos); + while (string::npos != pos || string::npos != lastPos) + { + tokens.push_back(str.substr(lastPos, pos - lastPos)); + lastPos = str.find_first_not_of(delimiters, pos); + pos = str.find_first_of(delimiters, lastPos); + } +} + + +string Int2Str (size_t A ) +{ + stringstream sstrm ; + sstrm << A ; + return sstrm.str(); +} + +string Int2Str (int A ) +{ + stringstream sstrm ; + sstrm << A ; + return sstrm.str(); +} + +string Int2Str (llong A ) +{ + stringstream sstrm ; + sstrm << A ; + return sstrm.str(); +} + +inline void Swap ( int & x ,int & y) +{ + int tmp=y; + y=x; + x=tmp; +} + + +int stat_str_base(string str , llong * Map , llong Leng ) +{ + for(llong ix=0 ; ix & MisMatch ) +{ + string mis1 = str.substr(str.rfind('\t')==string::npos ?str.length():str.rfind('\t') + 1); + string::size_type s_Aend =mis1.size(); + llong ATGC=0 ; + for(string::size_type ix=0 ; ix & ChrLeng , map & Seq) +{ + gzFile fp; + kseq_t *seq; + fp = gzopen(RefFile.c_str(), "r"); + seq = kseq_init(fp); + int l=0, File_Acount=0 ; + while ( (l = kseq_read(seq)) >= 0 ) + { + string chr=seq->name.s; + ubit64_t length_chr=ubit64_t(seq->seq.l); + ChrLeng[chr]=length_chr; + Seq[chr]=(seq->seq.s); + File_Acount++; + } + kseq_destroy(seq); + gzclose(fp); + return File_Acount ; +} + +void Display( string seq , string ID , int linecut=100 ) +{ + long sumleng=seq.length(); + int Endline=int(sumleng/linecut); + cout<<">"< AA ) + { + cout<"< AA ) + { + OUT< AA ) + { + OUT<1000) + { + linecut=100 ; + } + else + { + linecut=tmplinecut; + } + + return linecut ; + +} + + +/* +void Write_Sam_head (string InHead , ogzstream & OUT ) +{ + + igzstream DD (InHead.c_str(),ifstream::in); + + if(!DD.good()) + { + cerr << "open InputFile error: "<tmp[i]) + { + minQ=tmp[i]; + } + if(maxQ= 33 && minQ <= 78 && maxQ >= 33 && maxQ <=78 ) + { + return 33; + } + else if (minQ >= 64 && minQ <= 108 && maxQ >= 64 && maxQ <= 108) + { + return 64; + } + else + { + return 64 ; + } +} + + +int GetShiftQSoap ( string SOAPPath ,int row ) +{ + igzstream INSOAP ((SOAPPath).c_str(),ifstream::in); + if (INSOAP.fail()) + { + cerr << "open File error: "<<(SOAPPath)< inf; + split(line,inf," \t"); + + string::size_type SeqQLength =(inf[row]).size(); + for(int i=0 ; i(inf[row])[i]) + { + minQ=(inf[row])[i]; + } + if(maxQ<(inf[row])[i]) + { + maxQ=(inf[row])[i]; + } + } + } + INSOAP.close(); + if(minQ >= 33 && minQ <= 76 && maxQ >= 33 && maxQ <=76 ) + { + return 33; + } + else if (minQ >= 64 && minQ <= 107 && maxQ >= 64 && maxQ <= 107) + { + return 64; + } + else + { + return 64 ; + } +} + +#endif // comm_H_ ; + diff --git a/src/ALL/dealfun.cpp b/src/ALL/dealfun.cpp new file mode 100644 index 0000000..97b3b3a --- /dev/null +++ b/src/ALL/dealfun.cpp @@ -0,0 +1,563 @@ + +#ifndef sameFun_H_ +#define sameFun_H_ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../ALL/msort/msort.h" +#include "../ALL/msort/sort_funs.c" +#include "../ALL/msort/stdhashc.cc" +#include "../ALL/msort/msort_h.h" +#include "../ALL/comm.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef UINT32_MAX + +#else + #define UINT32_MAX (4294967295U) +#endif + + +//KSEQ_INIT(gzFile, gzread) + + +void Write_Sam_head (string InHead , ogzstream & OUT ) +{ + + igzstream DD (InHead.c_str(),ifstream::in); + + if(!DD.good()) + { + cerr << "open InputFile error: "<l_text == 0) + return h; + + uint32_t i, lnum = 0; + char *cp = h->text, last = '\n'; + for (i = 0; i < h->l_text; i++) { + if (cp[i] == 0) + break; + + if (last == '\n') { + lnum++; + if (cp[i] != '@') { + hts_log_error("Malformed SAM header at line %u", lnum); + bam_hdr_destroy(h); + return NULL; + } + } + + last = cp[i]; + } + + if (i < h->l_text) { // Early nul found. Complain if not just padding. + uint32_t j = i; + while (j < h->l_text && cp[j] == '\0') j++; + if (j < h->l_text) + hts_log_warning("Unexpected NUL character in header. Possibly truncated"); + } + if (last != '\n') { + hts_log_warning("Missing trailing newline on SAM header. Possibly truncated"); + + if (h->l_text == UINT32_MAX) { + hts_log_error("No room for extra newline"); + bam_hdr_destroy(h); + return NULL; + } + + if (i >= h->l_text - 1) { + cp = (char*) (realloc(h->text, (size_t) h->l_text+2)); + if (!cp) { + bam_hdr_destroy(h); + return NULL; + } + h->text = cp; + } + cp[i++] = '\n'; + + if (h->l_text < i) + h->l_text = i; + cp[h->l_text] = '\0'; + } + + return h; +} +////*/ + +void Get_BamInfo ( string InFile , int & MaxRL) +{ + bam_hdr_t *header; + bam1_t *aln = bam_init1(); + samFile *in = sam_open(InFile.c_str(), "r"); + header = sam_hdr_read(in); + int Count=0; + uint8_t MaxPhredQ=0; + uint8_t MinPhredQ=250; + MaxRL=0; + while ( (sam_read1(in, header, aln) >= 0) && (Count<16888) ) + { + if ( (aln->core).qual < 10 ) + { + continue ; + } + if ((aln->core).l_qseq> MaxRL ) + { + MaxRL=(aln->core).l_qseq ; + } + } + + sam_close(in); + bam_hdr_destroy(header); + bam_destroy1(aln); + +} + + + + +int Get_qual_Data ( string InFile) +{ + + bam_hdr_t *header; + bam1_t *aln = bam_init1(); + samFile *in = sam_open(InFile.c_str(), "r"); + header = sam_hdr_read(in); + + int Count=0; + uint8_t MaxPhredQ=0; + uint8_t MinPhredQ=250; + while ( (sam_read1(in, header, aln) >= 0) && (Count<16888) ) + { + if ( (aln->core).qual < 10 ) + { + continue ; + } + if ((aln->core).l_qseq < 10 ) + { + continue ; + } + uint8_t * seqQ=bam_get_qual(aln); + Count++; + for(int i=0; i < (aln->core).l_qseq ; i++) + { + if (MinPhredQ > seqQ[i]) + { + MinPhredQ= seqQ[i] ; + } + if (MaxPhredQ < seqQ[i]) + { + MaxPhredQ = seqQ[i] ; + } + } + } + + sam_close(in); + bam_hdr_destroy(header); + bam_destroy1(aln); + + int ASCII_raw=0; + + if(MinPhredQ >= 0 && MinPhredQ <= 42 && MaxPhredQ >= 0 && MaxPhredQ <= 42) + { + } + else if (MinPhredQ >= 31 && MinPhredQ <= 73 && MaxPhredQ >= 31 && MaxPhredQ <=73) + { + ASCII_raw=31 ; + } + return ASCII_raw ; +} + + + +bam_hdr_t *Fa_hdr_read( string RefPath) +{ + gzFile fp; + kseq_t *seq; + bam_hdr_t *h = NULL; + + kstring_t str = { 0, 0, NULL }; + + int l; + fp = gzopen(RefPath.c_str(), "r"); + seq = kseq_init(fp); + + while ((l = kseq_read(seq)) >= 0) + { + stringstream sstrm; + sstrm << (seq->seq.l); + + kputs("@SQ\tSN:", &str); + kputs(seq->name.s, &str); + kputs("\tLN:", &str); + kputl(seq->seq.l, &str); + kputc('\n', &str); + } + + if (str.l == 0) kputsn("", 0, &str); + h = sam_hdr_parse(str.l, str.s); + h->l_text = str.l; h->text = str.s; + + kseq_destroy(seq); + gzclose(fp); + + return sam_hdr_sanitise(h); +} + + + +int sam2bam2( kstring_t str , bam_hdr_t *h, bam1_t *b) +{ + int ret; + ret = sam_parse1(&str, h, b); + if (ret < 0) { + cerr<<"same the wrong at this "< inf; + split(line,inf,"->"); + if (inf.size()<2) + { + return 0 ; + } + else + { + Base=inf[0]; + int L=inf[1].length(); + int i=0 ; + for ( i=0; i(\d+)/i); +} + +//*// +int mating ( SamLine * A , SamLine * B ) +{ + int Insert=0; + if ( (A->chr) != "*" && ( (A->chr) ==(B->chr)) ) //# then calculate $isize + { + llong x1=( (A->Flag) & 0x10 ) ? (A->position)+((A->seq).length()) : (A->position); + llong x2=( (B->Flag) & 0x10 ) ? (B->position)+((B->seq).length()) : (B->position); + Insert=x2-x1; + } + //# update mate coordinate + if ( (B->chr) != "*" ) + { + A->coor=B->position; + A->isize=Insert; + A->XorD= ((B->chr) == (A->chr)) ? "=" : (B->chr) ; + if ((B->Flag) & 0x10 ) + { + A->Flag |= 0x20 ; + } + } + else + { + A->Flag |= 0x8; + } + + if ( (A->chr) != "*" ) + { + B->coor=A->position; + B->isize=0-Insert; + B->XorD= ((A->chr) == (B->chr)) ? "=" : (A->chr) ; + if ((A->Flag) & 0x10 ) + { + B->Flag |= 0x20 ; + } + } + else + { + B->Flag |= 0x8; + } + return 1; +} + + + +int soap2sam(string line , Para_Formt01 * para_Formt01 , SamLine *sam ) +{ + vector inf; + split(line,inf," \t"); + int Length=inf.size(); + if ( Length < 9 || (inf[0].empty()) ) + { + return 0 ; + } + sam->rm(); + int A=inf[3][0]; + if ( A>57 || A<48 ) // fix SOAP-2.1.x bugs + { + vector tmp (Length-1); + tmp[0]=inf[0]; tmp[1]=inf[1]; tmp[2]=inf[2]; + for(int ii=4 ; iiRID=getID(inf[0]); + //* + sam->RID=(inf[0]); + if ( RID_length >2 ) + { + if ( inf[0][RID_length-2]== '/' && ( (inf[0][RID_length-1]== '1') || (inf[0][RID_length-1]== '2') )) + { + sam->RID=inf[0].substr(0, RID_length-2); + } + } + ///*/// + + // initial flag (will be updated later) + sam->Flag =0 ; + + (sam->Flag) |= 1 | 1<<(inf[4] == "a" ? 6 : 7); + if (para_Formt01->PE) + { + (sam->Flag) |= 2; + } + if (inf[6] == "-" ) + { + (sam->Flag) |= 0x10 ; + } + + // # read & quality + sam->seq=inf[1]; + int RLength=inf[1].length(); + int QLength=inf[2].length(); + sam->Qseq = (QLength> RLength ) ? inf[2].substr(0,RLength): inf[2] ; + //*///// + QLength=(sam->Qseq).length(); + for(string::size_type ix=0; ixQseq)[ix]-=(para_Formt01->shiftQ) ; ////// chang the "#" Quli to "B" Quli + } + ///*//// + // cigar + sam->cigar= Int2Str(RLength)+"M"; + + // # coor + sam->chr = inf[7]; sam->position = atoi(inf[8].c_str()); + + // mapQ + sam->mapQ = (inf[3] == "1" ) ? 30 : 0; + + // # mate coordinate + //$s->[6] = '*'; $s->[7] = $s->[8] = 0; + + // # aux + sam->NM_i="NM:i:"+inf[9]; + sam->MD=""; + A=atoi(inf[9].c_str()); + if (A) + { + string Base ; + int data ; + map MAP ; + for (int ii=10 ; ii :: value_type (data,Base)); + } + } + int a=0; + map :: iterator it=MAP.begin(); + for(it=MAP.begin() ; it!=MAP.end(); it++) + { + int c =(it->first) - a ; + (sam->MD) += Int2Str(c) + (it->second); + a += (c + 1); + } + (sam->MD) += Int2Str(RLength-a); + } + else + { + (sam->MD)=Int2Str(RLength); + } + (sam->MD)="MD:Z:"+(sam->MD); + sam->IF=true ; + return 1; +} +/////////////////// + + + + +//* +int soap2samQ(string line , Para_Formt01 * para_Formt01 , SamLine *sam ) +{ + vector inf; + split(line,inf," \t"); + int Length=inf.size(); + if ( Length < 9 || (inf[0].empty()) ) + { + return 0 ; + } + sam->rm(); + int A=inf[3][0]; + if ( A>57 || A<48 ) // fix SOAP-2.1.x bugs + { + vector tmp (Length-1); + tmp[0]=inf[0]; tmp[1]=inf[1]; tmp[2]=inf[2]; + for(int ii=4 ; iiRID=getID(inf[0]); + //* + sam->RID=(inf[0]); + if ( RID_length >2 ) + { + if ( inf[0][RID_length-2]== '/' && ( (inf[0][RID_length-1]== '1') || (inf[0][RID_length-1]== '2') )) + { + sam->RID=inf[0].substr(0, RID_length-2); + } + } + ///*/// + + // initial flag (will be updated later) + sam->Flag =0 ; + + (sam->Flag) |= 1 | 1<<(inf[4] == "a" ? 6 : 7); + if (para_Formt01->PE) + { + (sam->Flag) |= 2; + } + if (inf[6] == "-" ) + { + (sam->Flag) |= 0x10 ; + } + + // # read & quality + sam->seq=inf[1]; + int RLength=inf[1].length(); + int QLength=inf[2].length(); + sam->Qseq = (QLength> RLength ) ? inf[2].substr(0,RLength): inf[2] ; + + + // cigar + sam->cigar= Int2Str(RLength)+"M"; + + // # coor + sam->chr = inf[7]; sam->position = atoi(inf[8].c_str()); + + // mapQ + sam->mapQ = (inf[3] == "1" ) ? 30 : 0; + + // # mate coordinate + //$s->[6] = '*'; $s->[7] = $s->[8] = 0; + + // # aux + sam->NM_i="NM:i:"+inf[9]; + sam->MD=""; + A=atoi(inf[9].c_str()); + if (A) + { + string Base ; + int data ; + map MAP ; + for (int ii=10 ; ii :: value_type (data,Base)); + } + } + int a=0; + map :: iterator it=MAP.begin(); + for(it=MAP.begin() ; it!=MAP.end(); it++) + { + int c =(it->first) - a ; + (sam->MD) += Int2Str(c) + (it->second); + a += (c + 1); + } + (sam->MD) += Int2Str(RLength-a); + } + else + { + (sam->MD)=Int2Str(RLength); + } + (sam->MD)="MD:Z:"+(sam->MD); + sam->IF=true ; + return 1; +} +/////////////////// + + + + + +#endif +///////// swimming in the sky and flying in the sea //////////// + + diff --git a/src/ALL/gzstream/gzstream.c b/src/ALL/gzstream/gzstream.c new file mode 100644 index 0000000..bbb4ba8 --- /dev/null +++ b/src/ALL/gzstream/gzstream.c @@ -0,0 +1,165 @@ +// ============================================================================ +// gzstream, C++ iostream classes wrapping the zlib compression library. +// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// ============================================================================ +// +// File : gzstream.C +// Revision : $Revision: 1.7 $ +// Revision_date : $Date: 2003/01/08 14:41:27 $ +// Author(s) : Deepak Bandyopadhyay, Lutz Kettner +// +// Standard streambuf implementation following Nicolai Josuttis, "The +// Standard C++ Library". +// ============================================================================ + +#include "gzstream.h" +#include +#include // for memcpy + +#ifdef GZSTREAM_NAMESPACE +namespace GZSTREAM_NAMESPACE { +#endif + +// ---------------------------------------------------------------------------- +// Internal classes to implement gzstream. See header file for user classes. +// ---------------------------------------------------------------------------- + +// -------------------------------------- +// class gzstreambuf: +// -------------------------------------- + +gzstreambuf* gzstreambuf::open( const char* name, int open_mode) { + if ( is_open()) + return (gzstreambuf*)0; + mode = open_mode; + // no append nor read/write mode + if ((mode & std::ios::ate) || (mode & std::ios::app) + || ((mode & std::ios::in) && (mode & std::ios::out))) + return (gzstreambuf*)0; + char fmode[10]; + char* fmodeptr = fmode; + if ( mode & std::ios::in) + *fmodeptr++ = 'r'; + else if ( mode & std::ios::out) + *fmodeptr++ = 'w'; + *fmodeptr++ = 'b'; + *fmodeptr = '\0'; + file = gzopen( name, fmode); + if (file == 0) + return (gzstreambuf*)0; + opened = 1; + return this; +} + +gzstreambuf * gzstreambuf::close() { + if ( is_open()) { + sync(); + opened = 0; + if ( gzclose( file) == Z_OK) + return this; + } + return (gzstreambuf*)0; +} + +int gzstreambuf::underflow() { // used for input buffer only + if ( gptr() && ( gptr() < egptr())) + return * reinterpret_cast( gptr()); + + if ( ! (mode & std::ios::in) || ! opened) + return EOF; + // Josuttis' implementation of inbuf + int n_putback = gptr() - eback(); + if ( n_putback > 4) + n_putback = 4; + memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback); + + int num = gzread( file, buffer+4, bufferSize-4); + if (num <= 0) // ERROR or EOF + return EOF; + + // reset buffer pointers + setg( buffer + (4 - n_putback), // beginning of putback area + buffer + 4, // read position + buffer + 4 + num); // end of buffer + + // return next character + return * reinterpret_cast( gptr()); +} + +int gzstreambuf::flush_buffer() { + // Separate the writing of the buffer from overflow() and + // sync() operation. + int w = pptr() - pbase(); + if ( gzwrite( file, pbase(), w) != w) + return EOF; + pbump( -w); + return w; +} + +int gzstreambuf::overflow( int c) { // used for output buffer only + if ( ! ( mode & std::ios::out) || ! opened) + return EOF; + if (c != EOF) { + *pptr() = c; + pbump(1); + } + if ( flush_buffer() == EOF) + return EOF; + return c; +} + +int gzstreambuf::sync() { + // Changed to use flush_buffer() instead of overflow( EOF) + // which caused improper behavior with std::endl and flush(), + // bug reported by Vincent Ricard. + if ( pptr() && pptr() > pbase()) { + if ( flush_buffer() == EOF) + return -1; + } + return 0; +} + +// -------------------------------------- +// class gzstreambase: +// -------------------------------------- + +gzstreambase::gzstreambase( const char* name, int mode) { + init( &buf); + open( name, mode); +} + +gzstreambase::~gzstreambase() { + buf.close(); +} + +void gzstreambase::open( const char* name, int open_mode) { + if ( ! buf.open( name, open_mode)) + clear( rdstate() | std::ios::badbit); +} + +void gzstreambase::close() { + if ( buf.is_open()) + if ( ! buf.close()) + clear( rdstate() | std::ios::badbit); +} + +#ifdef GZSTREAM_NAMESPACE +} // namespace GZSTREAM_NAMESPACE +#endif + +// ============================================================================ +// EOF // diff --git a/src/ALL/gzstream/gzstream.h b/src/ALL/gzstream/gzstream.h new file mode 100644 index 0000000..861653f --- /dev/null +++ b/src/ALL/gzstream/gzstream.h @@ -0,0 +1,121 @@ +// ============================================================================ +// gzstream, C++ iostream classes wrapping the zlib compression library. +// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// ============================================================================ +// +// File : gzstream.h +// Revision : $Revision: 1.5 $ +// Revision_date : $Date: 2002/04/26 23:30:15 $ +// Author(s) : Deepak Bandyopadhyay, Lutz Kettner +// +// Standard streambuf implementation following Nicolai Josuttis, "The +// Standard C++ Library". +// ============================================================================ + +#ifndef GZSTREAM_H +#define GZSTREAM_H 1 + +// standard C++ with new header file names and std:: namespace +#include +#include +#include + +#ifdef GZSTREAM_NAMESPACE +namespace GZSTREAM_NAMESPACE { +#endif + +// ---------------------------------------------------------------------------- +// Internal classes to implement gzstream. See below for user classes. +// ---------------------------------------------------------------------------- + +class gzstreambuf : public std::streambuf { +private: + static const int bufferSize = 47+256; // size of data buff + // totals 512 bytes under g++ for igzstream at the end. + + gzFile file; // file handle for compressed file + char buffer[bufferSize]; // data buffer + char opened; // open/close state of stream + int mode; // I/O mode + + int flush_buffer(); +public: + gzstreambuf() : opened(0) { + setp( buffer, buffer + (bufferSize-1)); + setg( buffer + 4, // beginning of putback area + buffer + 4, // read position + buffer + 4); // end position + // ASSERT: both input & output capabilities will not be used together + } + int is_open() { return opened; } + gzstreambuf* open( const char* name, int open_mode); + gzstreambuf* close(); + ~gzstreambuf() { close(); } + + virtual int overflow( int c = EOF); + virtual int underflow(); + virtual int sync(); +}; + +class gzstreambase : virtual public std::ios { +protected: + gzstreambuf buf; +public: + gzstreambase() { init(&buf); } + gzstreambase( const char* name, int open_mode); + ~gzstreambase(); + void open( const char* name, int open_mode); + void close(); + gzstreambuf* rdbuf() { return &buf; } +}; + +// ---------------------------------------------------------------------------- +// User classes. Use igzstream and ogzstream analogously to ifstream and +// ofstream respectively. They read and write files based on the gz* +// function interface of the zlib. Files are compatible with gzip compression. +// ---------------------------------------------------------------------------- + +class igzstream : public gzstreambase, public std::istream { +public: + igzstream() : std::istream( &buf) {} + igzstream( const char* name, int open_mode = std::ios::in) + : gzstreambase( name, open_mode), std::istream( &buf) {} + gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } + void open( const char* name, int open_mode = std::ios::in) { + gzstreambase::open( name, open_mode); + } +}; + +class ogzstream : public gzstreambase, public std::ostream { +public: + ogzstream() : std::ostream( &buf) {} + ogzstream( const char* name, int mode = std::ios::out) + : gzstreambase( name, mode), std::ostream( &buf) {} + gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } + void open( const char* name, int open_mode = std::ios::out) { + gzstreambase::open( name, open_mode); + } +}; + +#ifdef GZSTREAM_NAMESPACE +} // namespace GZSTREAM_NAMESPACE +#endif + +#endif // GZSTREAM_H +// ============================================================================ +// EOF // + diff --git a/src/ALL/msort/msort.h b/src/ALL/msort/msort.h new file mode 100644 index 0000000..0de5a0d --- /dev/null +++ b/src/ALL/msort/msort.h @@ -0,0 +1,132 @@ +#ifndef __MSORT_H_RJ +#define __MSORT_H_RJ + +#include +#include +#include +#include +#include +#include "stdhashc.h" + +#define COL_TYPE_STR 0 +#define COL_TYPE_NUM 1 +#define COL_TYPE_MIX 2 +#define COL_TYPE_ENUM 3 + +#define ORDER_ASC 0 +#define ORDER_DSC 1 + +#define STR_CASE_YES 1 +#define STR_CASE_NO 0 + +#define MAX_COLS 1024 + +typedef int (*cmp_fun)(const void *a, const void *b); + +#define CMP_STR_ASC 1 +#define CMP_STR_DSC 2 +#define CMP_STR_CASE_ASC 3 +#define CMP_STR_CASE_DSC 4 +#define CMP_NUM_ASC 5 +#define CMP_NUM_DSC 6 +#define CMP_MIX_ASC 7 +#define CMP_MIX_DSC 8 +#define CMP_MIX_CASE_ASC 9 +#define CMP_MIX_CASE_DSC 10 +#define CMP_ENUM_ASC 11 +#define CMP_ENUM_DSC 12 +#define CMP_ENUM_CASE_ASC 13 +#define CMP_ENUM_CASE_DSC 14 + +static inline int my_strncmp(char *s1, char *s2, double l1, double l2){ + int ret; + size_t AL1=int(l1); + size_t AL2=int(l2); + if(l1 == l2){ + return strncmp(s1, s2, AL1); + } else if(l1 < l2){ + if((ret = strncmp(s1, s2, AL1)) == 0){ + return -1; + } else return ret; + } else { + if((ret = strncmp(s1, s2, AL2)) == 0){ + return 1; + } else return ret; + } +} + + +static inline int my_strncasecmp(char *s1, char *s2, double l1, double l2){ + int ret; + size_t AL1=int(l1); + size_t AL2=int(l2); + if(l1 == l2){ + return strncasecmp(s1, s2, AL1); + } else if(l1 < l2){ + if((ret = strncasecmp(s1, s2, AL1)) == 0){ + return -1; + } else return ret; + } else { + if((ret = strncasecmp(s1, s2, AL2)) == 0){ + return 1; + } else return ret; + } +} + +typedef struct { + int *col_idxs; + int *col_orders; + cmp_fun *cmp_funs; + int *cmp_ops; + int size; + int cap; +} sort_param; + +typedef struct { + double num_val; + char *str_val; +} sortkey_t; + +typedef struct { + int line_num; + char *str; + int str_len; +} line_t; + +typedef struct { + char *text; + long long file_size; + long long file_cap; + line_t *lines; + int line_size; + int line_cap; + sortkey_t *keys; + int key_size; + int key_cap; + sort_param param; + int col_map[MAX_COLS]; +} file_t; + +int cmp_str_asc(const void *key1, const void *key2); +int cmp_str_dsc(const void *key1, const void *key2); +int cmp_str_case_asc(const void *key1, const void *key2); +int cmp_str_case_dsc(const void *key1, const void *key2); +int cmp_num_asc(const void *key1, const void *key2); +int cmp_num_dsc(const void *key1, const void *key2); +int cmp_mix_asc(const void *key1, const void *key2); +int cmp_mix_dsc(const void *key1, const void *key2); +int cmp_mix_case_asc(const void *key1, const void *key2); +int cmp_mix_case_dsc(const void *key1, const void *key2); + +// static file_t *file_db = NULL; //hewm + +file_t* load_file_lines(FILE *in, int block_rows, int *line_breaker_table, int *col_breaker_table, + int *col_idxs, int *col_starts, int *col_lends, int *col_types, hashci_t **enums, int *orders, int *str_cases, int col_size); + +void sort_file_lines(file_t *db); + +void print_file_lines(file_t *db); + +void free_file_lines(file_t *db); + +#endif diff --git a/src/ALL/msort/msort_h.h b/src/ALL/msort/msort_h.h new file mode 100644 index 0000000..7d9b955 --- /dev/null +++ b/src/ALL/msort/msort_h.h @@ -0,0 +1,830 @@ +#ifndef Msort_H_ +#define Msort_H_ + +#include +#include +#include "msort.h" +#include +#include +#include +#include "../gzstream/gzstream.h" +#include +using namespace std; +static file_t *file_db = NULL; + +file_t* load_file_lines(FILE *in, int block_rows, int *line_breaker_table, int *col_breaker_table, + int *col_idxs, int *col_starts, int *col_ends, int *col_types, hashci_t **enums, + int *orders, int *str_cases, int col_size){ + file_t *db; + line_t *line; + sortkey_t *key; + int default_order, default_case, default_type; + long long i, j, m, n, k, b; + int offset, flag; +#define BUFFER_SIZE (32 * 1024) + char buffer[BUFFER_SIZE], *ptr, str[1024]; + db = (file_t*)malloc(sizeof(file_t)); + memset(db, 0, sizeof(file_t)); + db->file_size = 0; + db->file_cap = BUFFER_SIZE; + db->text = (char*)malloc(db->file_cap + 1); + while((n = fread(buffer, 1, BUFFER_SIZE, in)) > 0){ + if(db->file_size + n >= db->file_cap){ + db->file_cap = db->file_size + 64 * 1024 * 1024LLU + n; + db->text = (char*)realloc(db->text, db->file_cap + 1LLU); + } + memcpy(db->text + db->file_size, buffer, n); + db->file_size += n; + } + if(db->file_size < db->file_cap) db->text = (char*)realloc(db->text, db->file_size + 1); + db->file_cap = db->file_size; + db->text[db->file_size] = 0; + db->line_size = 0; + db->line_cap = 1024; + db->lines = (line_t*)malloc(sizeof(line_t) * db->line_cap); + i = 0; + while(ifile_size){ + j = i; + b = block_rows; + while(j < db->file_size && b > 0){ + k = j; + while(j < db->file_size && !line_breaker_table[(int)db->text[j]]){ + if(db->text[j] <= 0){ + db->text[j] = '*'; + } + j ++; + } + if(j == k && b == block_rows){ + } else { + b --; + } + j ++; + } + if(b == block_rows) break; + j --; + db->text[j] = 0; + if(db->line_size == db->line_cap){ + db->line_cap = (size_t)(db->line_cap * 1.2) + 32; + db->lines = (line_t*)realloc(db->lines, sizeof(line_t) * db->line_cap); + } + db->lines[db->line_size].line_num = db->line_size; + db->lines[db->line_size].str = db->text + i; + db->lines[db->line_size].str_len = j - i; + db->line_size ++; + i = j + 1; + } + if(db->line_size < db->line_cap) db->lines = (line_t*)realloc(db->lines, sizeof(line_t) * db->line_size); + db->line_cap = db->line_size; + if(db->line_size < 1){ + db->key_size = 0; + db->key_cap = 0; + db->keys = NULL; + db->param.size = 0; + return db; + } + if(col_size <= 0){ + default_order = orders[0]; + default_case = str_cases[0]; + default_type = col_types[0]; + col_size = 0; + j = 0; + for(i=0;ilines[0].str_len+1;i++){ + if(col_breaker_table[(int)db->lines[0].str[i]]){ + if(i > j){ + col_idxs[col_size] = col_size; + col_types[col_size] = default_type; + str_cases[col_size] = default_case; + orders[col_size] = default_order; + col_size ++; + } + j = i + 1; + } + } + } + for(i=0;icol_map[i] = -1; + for(i=0;i= MAX_COLS){ + fprintf(stderr, " -- Sort columns bigger than %d in %s -- %s:%d --\n", MAX_COLS, __FUNCTION__, __FILE__, __LINE__); + exit(0); + } + db->col_map[col_idxs[i]] = i; + } + db->param.size = col_size; + db->param.cap = col_size; + db->param.col_idxs = (int*)malloc(sizeof(int) * col_size); + memcpy(db->param.col_idxs, col_idxs, sizeof(int) * col_size); + db->param.col_orders = (int*)malloc(sizeof(int) * col_size); + memcpy(db->param.col_orders, orders, sizeof(int) * col_size); + db->param.cmp_funs = (cmp_fun*)malloc(sizeof(cmp_fun) * col_size); + db->param.cmp_ops = (int*)malloc(sizeof(int) * col_size); + for(i=0;iparam.cmp_funs[i] = (cmp_fun)cmp_str_asc; + db->param.cmp_ops[i] = CMP_STR_ASC; + } else { + db->param.cmp_funs[i] = (cmp_fun)cmp_str_case_asc; + db->param.cmp_ops[i] = CMP_STR_CASE_ASC; + } + } else { + if(str_cases[i] == STR_CASE_YES){ + db->param.cmp_funs[i] = (cmp_fun)cmp_str_dsc; + db->param.cmp_ops[i] = CMP_STR_DSC; + } else { + db->param.cmp_funs[i] = (cmp_fun)cmp_str_case_dsc; + db->param.cmp_ops[i] = CMP_STR_CASE_DSC; + } + } + break; + case COL_TYPE_ENUM: + case COL_TYPE_NUM: + if(orders[i] == ORDER_ASC){ + db->param.cmp_funs[i] = (cmp_fun)cmp_num_asc; + db->param.cmp_ops[i] = CMP_NUM_ASC; + } else { + db->param.cmp_funs[i] = (cmp_fun)cmp_num_dsc; + db->param.cmp_ops[i] = CMP_NUM_DSC; + } + break; + case COL_TYPE_MIX: + if(orders[i] == ORDER_ASC){ + if(str_cases[i] == STR_CASE_YES){ + db->param.cmp_funs[i] = (cmp_fun)cmp_mix_asc; + db->param.cmp_ops[i] = CMP_MIX_ASC; + } else { + db->param.cmp_funs[i] = (cmp_fun)cmp_mix_case_asc; + db->param.cmp_ops[i] = CMP_MIX_CASE_ASC; + } + } else { + if(str_cases[i] == STR_CASE_YES){ + db->param.cmp_funs[i] = (cmp_fun)cmp_mix_dsc; + db->param.cmp_ops[i] = CMP_MIX_DSC; + } else { + db->param.cmp_funs[i] = (cmp_fun)cmp_mix_case_dsc; + db->param.cmp_ops[i] = CMP_MIX_CASE_DSC; + } + } + } + } + db->key_size = 0; + db->key_cap = db->line_size * col_size; + db->keys = (sortkey_t*)malloc(sizeof(sortkey_t) * db->key_cap); + memset(db->keys, 0, sizeof(sortkey_t) * db->key_cap); + for(i=0;iline_size;i++){ + line = db->lines + i; + n = 0; + m = 0; + k = 0; + for(j=0;jstr_len+1;j++){ + if(col_breaker_table[(int)line->str[j]]){ + if(j > n){ + k = db->col_map[m]; + if(k >= 0){ + key = db->keys + i * col_size + k; + offset = (col_starts && col_starts[k])? col_starts[k]:0; + key->str_val = line->str + n + offset; + if(col_ends && col_ends[k]){ + if(j - n < col_ends[k]){ + key->num_val = j - n - offset; + } else { + key->num_val = col_ends[k] - offset; + } + } else { + key->num_val = j - n - offset; + } + switch(col_types[k]){ + case COL_TYPE_STR: + break; + case COL_TYPE_NUM: + memcpy(str, key->str_val, (size_t)key->num_val); + str[(int)key->num_val] = 0; + key->num_val = atof(str); + break; + case COL_TYPE_MIX: + ptr = key->str_val; + flag = 1; + while(ptr < key->str_val + (int)key->num_val){ + if(*ptr >= '0' && *ptr <= '9'){ + } else { + flag = 0; + break; + } + ptr ++; + } + if(flag){ + memcpy(str, key->str_val, (size_t)key->num_val); + str[(int)key->num_val] = 0; + key->num_val = atof(str); + key->str_val = NULL; + } + break; + case COL_TYPE_ENUM: + memcpy(str, key->str_val, (size_t)key->num_val); + str[(int)key->num_val] = 0; + if(str_cases[k] == STR_CASE_NO){ + ptr = str; + while(*ptr){ + if(*ptr >= 'a' && *ptr <= 'z'){ + *ptr = *ptr + 'A' - 'a'; + } + ptr ++; + } + } + if(hci_get(enums[k], str, &offset)){ + key->num_val = offset; + } else { + key->num_val = 0; + } + break; + } + } + m ++; + } + n = j + 1; + } + } + } + return db; +} + +void free_file_lines(file_t *db){ + free(db->text); + free(db->lines); + free(db->keys); + if(db->param.size){ + free(db->param.col_idxs); + free(db->param.cmp_funs); + free(db->param.col_orders); + } + free(db); +} + +int _old_cmp_lines(const void *e1, const void *e2){ + line_t *line1, *line2; + sortkey_t *key1, *key2; + int i, ret; + line1 = (line_t*)e1; + line2 = (line_t*)e2; + ret = 0; + for(i=0;iparam.size;i++){ + key1 = file_db->keys + line1->line_num * file_db->param.size + i; + key2 = file_db->keys + line2->line_num * file_db->param.size + i; + if(key1->num_val == 0){ + if(key2->num_val == 0){ + return 0; + } else { + return (file_db->param.col_orders[i] == ORDER_ASC)? -1:1; + } + } else if(key2->num_val == 0){ + return (file_db->param.col_orders[i] == ORDER_ASC)? 1:-1; + } + ret = ((cmp_fun)(file_db->param.cmp_funs[i]))(key1, key2); + if(ret == 0) continue; + return ret; + } + return ret; +} + +int cmp_lines(const void *e1, const void *e2){ + line_t *line1, *line2; + sortkey_t *key1, *key2; + int i, ret; + line1 = (line_t*)e1; + line2 = (line_t*)e2; + ret = 0; + for(i=0;iparam.size;i++){ + key1 = file_db->keys + line1->line_num * file_db->param.size + i; + key2 = file_db->keys + line2->line_num * file_db->param.size + i; + /* + if(key1->num_val == 0){ + if(key2->num_val == 0){ + return 0; + } else { + return (file_db->param.col_orders[i] == ORDER_ASC)? -1:1; + } + } else if(key2->num_val == 0){ + return (file_db->param.col_orders[i] == ORDER_ASC)? 1:-1; + } + */ + switch(file_db->param.cmp_ops[i]){ + case CMP_STR_ASC: + ret = my_strncmp(key1->str_val, key2->str_val, key1->num_val, key2->num_val); + break; + case CMP_STR_DSC: + ret = my_strncmp(key2->str_val, key1->str_val, key2->num_val, key1->num_val); + break; + case CMP_STR_CASE_ASC: + ret = my_strncasecmp(key1->str_val, key2->str_val, key1->num_val, key2->num_val); + break; + case CMP_STR_CASE_DSC: + ret = my_strncasecmp(key2->str_val, key1->str_val, key2->num_val, key2->num_val); + break; + case CMP_NUM_ASC: + if(key1->num_val == key2->num_val){ + ret = 0; + } else if(key1->num_val < key2->num_val){ + return -1;; + } else { + return 1;; + } + break; + case CMP_NUM_DSC: + if(key1->num_val == key2->num_val){ + ret = 0; + } else if(key1->num_val < key2->num_val){ + return 1;; + } else { + return -1;; + } + break; + case CMP_MIX_ASC: + if(key1->str_val){ + if(key2->str_val){ + ret = my_strncmp(key1->str_val, key2->str_val, key1->num_val, key2->num_val); + } else { + return 1;; + } + } else { + if(key2->str_val){ + return -1;; + } else { + if(key1->num_val == key2->num_val){ + ret = 0; + } else if(key1->num_val < key2->num_val){ + return -1;; + } else { + return 1;; + } + } + } + break; + case CMP_MIX_DSC: + if(key1->str_val){ + if(key2->str_val){ + ret = my_strncmp(key2->str_val, key1->str_val, key1->num_val, key2->num_val); + } else { + return -1;; + } + } else { + if(key2->str_val){ + return 1;; + } else { + if(key1->num_val == key2->num_val){ + ret = 0; + } else if(key1->num_val < key2->num_val){ + return 1;; + } else { + return -1;; + } + } + } + break; + case CMP_MIX_CASE_ASC: + if(key1->str_val){ + if(key2->str_val){ + ret = my_strncasecmp(key1->str_val, key2->str_val, key1->num_val, key2->num_val); + } else { + return 1;; + } + } else { + if(key2->str_val){ + return -1;; + } else { + if(key1->num_val == key2->num_val){ + ret = 0; + } else if(key1->num_val < key2->num_val){ + return -1;; + } else { + return 1;; + } + } + } + break; + case CMP_MIX_CASE_DSC: + if(key1->str_val){ + if(key2->str_val){ + ret = my_strncasecmp(key2->str_val, key1->str_val, key1->num_val, key2->num_val); + } else { + return -1;; + } + } else { + if(key2->str_val){ + return 1;; + } else { + if(key1->num_val == key2->num_val){ + ret = 0; + } else if(key1->num_val < key2->num_val){ + return 1;; + } else { + return -1;; + } + } + } + break; + default: + ret = ((cmp_fun)(file_db->param.cmp_funs[i]))(key1, key2); + } + if(ret == 0) continue; + return ret; + } + return ret; +} + +void sort_file_lines(file_t *db){ + file_db = db; + qsort(db->lines, db->line_size, sizeof(line_t), cmp_lines); +} + +/* + void print_file_lines(file_t *db){ + int i; + for(i=0;iline_size;i++){ + printf("%s\n", db->lines[i].str); + } + } + */ + +int PrintFileLines ( file_t *db , string outPut ) +{ + if (outPut.empty() ) + { + for(int i=0;iline_size;i++) + { + cout<lines[i].str<line_size;i++) + { + OUT<lines[i].str<line_size;i++) + { + OUT<lines[i].str<\n" + " msort -k8 -kn9 In.soap -o Out.soap.gz\n" + "Usage: %s [-hrfn] [-t ] [-k [rfmneb][start-end]{enum1,...},...] []\n" + "Options:\n" + " -h display this document\n" + " -l specify line brokers, you can define more than one characters\n" + " defaultly, they are \n" + " -L treat N line as a block, defaultly N = 1\n" + " -t specify field separators, you can define more than one characters\n" + " defaultly, they are , \n" + " -r reverse sort, it will be overwritten if fileds are specified\n" + " -f ignore character`s case, ...\n" + " -n treat fileds as number, ...\n" + " -m treat fileds as number or string, ...\n" + " -o OutPut the files[#.gz or not],Otherwise to STDOUT\n" + " -k specify fileds to be sorted, eg.\n" + " rn10[2-6]: reverse sort 2-6 (include 6) of column 10, treat it as number\n" + " n11: sort column 11, treat it as number\n" + " f2[6-]: sort 6-end of column 2, treat it as string, ignore case\n" + " rfm3: reverse sort column 3, treat it as string or number, ignore string case\n" + " f3{red green blue}: sort column 3 , treat it as enum, ignore string case\n" + " b3: sort column 3, treat it as build-in enum, such as chromosomes\n" + " \t\tRuan Jue \tmodify:hewm\n",prog + ); + exit(0); +} + +file_t * ReadParaAnd (int argc, char **argv , string & outPut ) { + //int main(int argc, char **argv){ + if (argc<2) {usage(argv[0]) ;} //hewem + file_t *db; + int col_idxs[MAX_COLS]; + int col_starts[MAX_COLS]; + int col_ends[MAX_COLS]; + int col_types[MAX_COLS]; + int orders[MAX_COLS]; + int str_cases[MAX_COLS]; + hashci_t *enums[MAX_COLS]; + int i, j, m, n, c, col_size, col, start, end, block_rows, default_order, default_type, default_case; + int memlimit; + int col_breaker_table[256]; + int line_breaker_table[256]; + char *ptr, msg[1024]; + FILE *in; + regex_t regex; + regmatch_t matches[120]; + default_order = ORDER_ASC; + default_type = COL_TYPE_STR; + default_case = STR_CASE_YES; + memset(col_starts, 0, MAX_COLS * sizeof(int)); + memset(col_ends, 0, MAX_COLS * sizeof(int)); + memset(enums, 0, sizeof(hashci_t*) * MAX_COLS); + col_size = 0; + memset(col_breaker_table, 0, sizeof(int) * 256); + memset(line_breaker_table, 0, sizeof(int) * 256); + col_breaker_table[' '] = 1; + col_breaker_table['\t'] = 1; + line_breaker_table['\n'] = 1; + line_breaker_table['\r'] = 1; + block_rows = 1; + memlimit = 2040; + regcomp(®ex, "([rnmfeb]*)([0-9]+)(\\[([0-9]+)(-([0-9]+)?)?\\])?(\\{([^}]+)\\})?", REG_EXTENDED); + while((c = getopt(argc, argv, "hrmnfdM:t:l:L:k:o:")) != -1){ + switch(c){ + case 'h': + usage(argv[0]); + break; + case 'o': + outPut =optarg ; + break; + case 'r': + default_order = ORDER_DSC; + break; + case 'm': + default_type = COL_TYPE_MIX; + break; + case 'f': + default_case = STR_CASE_NO; + break; + case 'n': + default_type = COL_TYPE_NUM; + break; + case 'M': + memlimit = atoi(optarg); + case 't': + j = 0; + memset(col_breaker_table, 0, sizeof(int) * 256); + for(i=0;i<(int)strlen(optarg);i++){ + if(optarg[i] == '\\'){ + if(j){ + col_breaker_table['\\'] = 1; + j = 0; + } else { + j = 1; + } + } else { + if(j){ + switch(optarg[i]){ + case 't': + col_breaker_table['\t'] = 1; + break; + case 'n': + col_breaker_table['\n'] = 1; + break; + case 'r': + col_breaker_table['\r'] = 1; + break; + default: + col_breaker_table[(int)optarg[i]] = 1; + } + } else { + col_breaker_table[(int)optarg[i]] = 1; + } + } + } + break; + case 'l': + j = 0; + memset(line_breaker_table, 0, sizeof(int) * 256); + for(i=0;i<(int)strlen(optarg);i++){ + if(optarg[i] == '\\'){ + if(j){ + line_breaker_table['\\'] = 1; + j = 0; + } else { + j = 1; + } + } else { + if(j){ + switch(optarg[i]){ + case 't': + line_breaker_table['\t'] = 1; + break; + case 'n': + line_breaker_table['\n'] = 1; + break; + case 'r': + line_breaker_table['\r'] = 1; + break; + default: + line_breaker_table[(int)optarg[i]] = 1; + } + } else { + line_breaker_table[(int)optarg[i]] = 1; + } + } + } + break; + case 'L': + block_rows = atoi(optarg); + assert(block_rows >= 1); + break; + case 'k': + j = 0; + for(i=0;i<(int)strlen(optarg)+1;i++){ + if(optarg[i] == ',' || i == (int)strlen(optarg)){ + start = end = 0; + int errcode; + if((errcode = regexec(®ex, optarg + j, 120, matches, 0))){ + regerror(errcode, ®ex, msg, 1023); + fprintf(stderr, " -- bad field format '%s' %s\n", optarg + j, msg); + j = i + 1; + continue; + } + ptr = optarg + j + matches[2].rm_eo; + col = strtol(optarg + j + matches[2].rm_so, &ptr, 10); + if(col < 1){ + fprintf(stderr, " -- Error column number is 1 based, but find %d in %s -- %s:%d --\n", col, __FUNCTION__, __FILE__, __LINE__); + usage(argv[0]); + } + if(matches[4].rm_eo > matches[4].rm_so){ + ptr = optarg + j + matches[4].rm_eo; + start = strtol(optarg + j + matches[4].rm_so, &ptr, 10); + } + if(matches[6].rm_eo > matches[6].rm_so){ + ptr = optarg + j + matches[6].rm_eo; + end = strtol(optarg + j + matches[6].rm_so, &ptr, 10); + } + if(start > 0) start --; + else if(start < 0) start = 0; + if(end && end < start) end = start; + col_idxs[col_size] = col - 1; + col_starts[col_size] = start; + col_ends[col_size] = end; + col_types[col_size] = COL_TYPE_STR; + orders[col_size] = ORDER_ASC; + str_cases[col_size] = STR_CASE_NO; + for(col=matches[1].rm_so;col= 'a' && *ptr <= 'z'){ + *ptr = *ptr + 'A' - 'a'; + } + ptr ++; + } + } + col ++; + hci_put(enums[col_size], msg, col); + n = m + 1; + } + } + } + col_size ++; + j = i + 1; + } + } + break; + } + } + regfree(®ex); + if(col_size == 0){ + col_types[0] = default_type; + orders[0] = default_order; + str_cases[0] = default_case; + } + col_breaker_table[0] = 1; + if(argc > optind){ + if(strcmp(argv[optind], "-") == 0){ + in = stdin; + } else { + if ( strlen(argv[optind]) > 3 && strcmp(argv[optind] + strlen(argv[optind]) - 3, ".gz") == 0) + { + char *cmd; + cmd = (char*)malloc(strlen(argv[optind]) + 20); + sprintf(cmd, "gzip -dc %s", argv[optind]); + in = popen(cmd, "r"); + free(cmd); + } + else + { + in = fopen(argv[optind], "r"); + } + if(in == NULL){ + perror("open file"); + return NULL ; + } + } + } else { + in = stdin; + } + db = load_file_lines(in, block_rows, line_breaker_table, col_breaker_table, col_idxs, col_starts, col_ends, col_types, enums, orders, str_cases, col_size); + if(db == NULL){ + fprintf(stderr, "Please report below message to me \n"); + fprintf(stderr, "-----------------------------------------\n"); + fprintf(stderr, " -- Error in %s -- %s:%d --\n", __FUNCTION__, __FILE__, __LINE__); + fprintf(stderr, "-----------------------------------------\n"); + exit(1); + } + for(i=0;istr_val, key2->str_val, key1->num_val, key2->num_val); +} + +int cmp_str_case_asc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + return my_strncasecmp(key1->str_val, key2->str_val, key1->num_val, key2->num_val); +} + +int cmp_str_dsc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + return my_strncmp(key2->str_val, key1->str_val, key2->num_val, key1->num_val); +} + +int cmp_str_case_dsc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + return my_strncasecmp(key2->str_val, key1->str_val, key2->num_val, key1->num_val); +} + +int cmp_num_asc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + if(key1->num_val == key2->num_val){ + return 0; + } else if(key1->num_val < key2->num_val){ + return -1; + } else { + return 1; + } +} + +int cmp_num_dsc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + if(key1->num_val == key2->num_val){ + return 0; + } else if(key1->num_val < key2->num_val){ + return 1; + } else { + return -1; + } +} + +int cmp_mix_asc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + if(key1->str_val){ + if(key2->str_val){ + return my_strncmp(key1->str_val, key2->str_val, key1->num_val, key2->num_val); + } else { + return 1; + } + } else { + if(key2->str_val){ + return -1; + } else { + if(key1->num_val == key2->num_val){ + return 0; + } else if(key1->num_val < key2->num_val){ + return -1; + } else { + return 1; + } + } + } +} + +int cmp_mix_dsc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + if(key1->str_val){ + if(key2->str_val){ + return my_strncmp(key2->str_val, key1->str_val, key2->num_val, key1->num_val); + } else { + return -1; + } + } else { + if(key2->str_val){ + return 1; + } else { + if(key1->num_val == key2->num_val){ + return 0; + } else if(key1->num_val < key2->num_val){ + return 1; + } else { + return -1; + } + } + } +} + +int cmp_mix_case_asc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + if(key1->str_val){ + if(key2->str_val){ + return my_strncasecmp(key1->str_val, key2->str_val, key1->num_val, key2->num_val); + } else { + return 1; + } + } else { + if(key2->str_val){ + return -1; + } else { + if(key1->num_val == key2->num_val){ + return 0; + } else if(key1->num_val < key2->num_val){ + return -1; + } else { + return 1; + } + } + } +} + +int cmp_mix_case_dsc(const void *e1, const void *e2){ + sortkey_t *key1, *key2; + key1 = (sortkey_t*)e1; + key2 = (sortkey_t*)e2; + if(key1->str_val){ + if(key2->str_val){ + return my_strncasecmp(key2->str_val, key1->str_val, key2->num_val, key1->num_val); + } else { + return -1; + } + } else { + if(key2->str_val){ + return 1; + } else { + if(key1->num_val == key2->num_val){ + return 0; + } else if(key1->num_val < key2->num_val){ + return 1; + } else { + return -1; + } + } + } +} + diff --git a/src/ALL/msort/stdhash.hh b/src/ALL/msort/stdhash.hh new file mode 100644 index 0000000..732afee --- /dev/null +++ b/src/ALL/msort/stdhash.hh @@ -0,0 +1,684 @@ +/* + stdhash -- standalone hash library + + Copyright (c) 2006, Heng Li + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/** + Standalone hash library is a free C++ template library for hash tables. + It implements open-address hashing with the "double hashing" technique, + which makes this library different from most of other implementations, + such as STL and TR1 hash based classes, which are all based on chained + hashing. However, fewer implementations do not mean open-address hashing + is less efficient. As a matter of fact, this hash library is at least as + efficient, in terms of both time and space, as STL and TR1 libraries, and + in some cases outperforms others. + */ + +/* + 2007-07-18, 1.9.2: fixed a bug in hash_*_char when an element is erased. + */ + +#ifndef LH3_STDHASH_H_ +#define LH3_STDHASH_H_ + +#include +#include + +#define LH3_STDHASH_VERSION "1.9.2" + +typedef unsigned int bit32_t; +typedef unsigned long long bit64_t; +typedef unsigned short bit16_t; +// even on 64-bit systems, hashint_t should be bit32_t +typedef bit32_t hashint_t; + +/* + * Hash functions + */ +// Do a web search "g_str_hash X31_HASH" for more information. +/** hash function for strings (char*) */ +inline bit32_t __lh3_X31_hash_string(const char *s) +{ + bit32_t h = 0; + for ( ; *s; s++) + h = (h << 5) - h + *s; + return h; +} +/** Jenkins' hash function for 32-bit integers. Not used in this library. */ +inline bit32_t __lh3_Jenkins_hash_int(bit32_t key) +{ + key += (key << 12); + key ^= (key >> 22); + key += (key << 4); + key ^= (key >> 9); + key += (key << 10); + key ^= (key >> 2); + key += (key << 7); + key ^= (key >> 12); + return key; +} +/** Jenkins' hash function for 64-bit integers. Used when LH3_HASH_INT macro is set. */ +inline bit64_t __lh3_Jenkins_hash_64(bit64_t key) +{ + key += ~(key << 32); + key ^= (key >> 22); + key += ~(key << 13); + key ^= (key >> 8); + key += (key << 3); + key ^= (key >> 15); + key += ~(key << 27); + key ^= (key >> 31); + return key; +} +/** Wang's hash function for 32-bit inegers. Used when LH3_HASH_INT macro is set. */ +inline bit32_t __lh3_Wang_hash_int(bit32_t key) +{ + key += ~(key << 15); + key ^= (key >> 10); + key += (key << 3); + key ^= (key >> 6); + key += ~(key << 11); + key ^= (key >> 16); + return key; +} +/** hash function for 16-bit integers */ +inline bit32_t __lh3_hash_fun(bit16_t key) +{ +#ifndef LH3_HASH_INT + return __lh3_Wang_hash_int(bit32_t(key)); +#else + return bit32_t(key); +#endif +} +/** hash function for 32-bit integers */ +inline bit32_t __lh3_hash_fun(bit32_t key) +{ +#ifndef LH3_HASH_INT + return __lh3_Wang_hash_int(key); +#else + return key; +#endif +} +/** hash function for 64-bit integers */ +inline bit32_t __lh3_hash_fun(bit64_t key) +{ +#ifdef LH3_HASH_INT + return bit32_t(__lh3_Jenkins_hash_64(key)); +#else + return bit32_t(key>>16) ^ bit32_t(key); +#endif +} +/** hash function for strings (char*) */ +inline bit32_t __lh3_hash_fun(const char *key) +{ + return __lh3_X31_hash_string(key); +} + +/* + * Equality operator "==" + */ +/** "==" for 16-bit integers */ +inline bool __lh3_key_equal(bit16_t a, bit16_t b) +{ + return a == b; +} +/** "==" for 32-bit integers */ +inline bool __lh3_key_equal(bit32_t a, bit32_t b) +{ + return a == b; +} +/** "==" for 64-bit integers */ +inline bool __lh3_key_equal(bit64_t a, bit64_t b) +{ + return a == b; +} +/** "==" for strings (char*) */ +inline bool __lh3_key_equal(const char *a, const char *b) +{ + return (a && b && strcmp(a, b) == 0); +} + +/* + * Table for primes + */ +const int __lh3_HASH_PRIME_SIZE = 32; +static const bit32_t __lh3_prime_list[__lh3_HASH_PRIME_SIZE] = +{ + 0ul, 3ul, 11ul, 23ul, 53ul, + 97ul, 193ul, 389ul, 769ul, 1543ul, + 3079ul, 6151ul, 12289ul, 24593ul, 49157ul, + 98317ul, 196613ul, 393241ul, 786433ul, 1572869ul, + 3145739ul, 6291469ul, 12582917ul, 25165843ul, 50331653ul, + 100663319ul, 201326611ul, 402653189ul, 805306457ul, 1610612741ul, + 3221225473ul, 4294967291ul +}; + +/** Threshold for rehashing */ +const double __lh3_HASH_UPPER = 0.77; + +/* + * Constants and macros for retrieve/set flags "isempty" and "isdel". + */ +typedef bit32_t __lh3_flag_t; +const int __lh3_FLAG_SHIFT = 4; +const int __lh3_FLAG_MASK = 0xful; +const __lh3_flag_t __lh3_FLAG_DEFAULT = 0xaaaaaaaaul; + +#define __lh3_isempty(flag, i) ((flag[i>>__lh3_FLAG_SHIFT]>>((i&__lh3_FLAG_MASK)<<1))&2) +#define __lh3_isdel(flag, i) ((flag[i>>__lh3_FLAG_SHIFT]>>((i&__lh3_FLAG_MASK)<<1))&1) +#define __lh3_isboth(flag, i) ((flag[i>>__lh3_FLAG_SHIFT]>>((i&__lh3_FLAG_MASK)<<1))&3) +#define __lh3_set_isdel_false(flag, i) (flag[i>>__lh3_FLAG_SHIFT]&=~(1ul<<((i&__lh3_FLAG_MASK)<<1))) +#define __lh3_set_isempty_false(flag, i) (flag[i>>__lh3_FLAG_SHIFT]&=~(2ul<<((i&__lh3_FLAG_MASK)<<1))) +#define __lh3_set_isboth_false(flag, i) (flag[i>>__lh3_FLAG_SHIFT]&=~(3ul<<((i&__lh3_FLAG_MASK)<<1))) +#define __lh3_set_isdel_true(flag, i) (flag[i>>__lh3_FLAG_SHIFT]|=1ul<<((i&__lh3_FLAG_MASK)<<1)) + +/* + * Auxiliary functions for search/insert/erase. + */ +template +inline hashint_t __lh3_hash_search_aux(const keytype_t &key, hashint_t m, const keytype_t *keys, const __lh3_flag_t *flag) +{ + if (!m) return 0; + hashint_t inc, k, i; + k = __lh3_hash_fun(key); + i = k % m; + inc = 1 + k % (m - 1); + hashint_t last = i; + while (!__lh3_isempty(flag, i) && !__lh3_key_equal(keys[i], key)) { + if (i + inc >= m) i = i + inc - m; // inc < m, and so never write this line as: "i += inc - m;" + else i += inc; + if (i == last) return m; // fail to find + } + return i; +} +template +inline hashint_t __lh3_hash_insert_aux(const keytype_t &key, hashint_t m, const keytype_t *keys, const __lh3_flag_t *flag) +{ + hashint_t inc, k, i, site; + site = m; + k = __lh3_hash_fun(key); + i = k % m; + inc = 1 + k % (m - 1); + + hashint_t last = i; + while (!__lh3_isempty(flag, i) && !__lh3_key_equal(keys[i], key)) { + if (__lh3_isdel(flag, i)) site = i; + if (i + inc >= m) i = i + inc - m; + else i += inc; + if (i == last) return site; + } + if (__lh3_isempty(flag, i) && site != m) return site; + else return i; +} +template +inline hashint_t __lh3_hash_erase_aux(const keytype_t &key, hashint_t m, const keytype_t *keys, __lh3_flag_t *flag) +{ + if (!m) return 0; + hashint_t i; + i = __lh3_hash_search_aux(key, m, keys, flag); + if (i != m && !__lh3_isempty(flag, i)) { + if (__lh3_isdel(flag, i)) return m; // has been deleted + __lh3_set_isdel_true(flag, i); // set "isdel" flag as "true" + return i; + } else return m; +} + +/** "iterator" class for "hash_set_char" and "hash_set_misc" */ +template +class __lh3_hash_base_iterator +{ +protected: + hashint_t i; + keytype_t *keys; + __lh3_flag_t *flags; +public: + __lh3_hash_base_iterator() {} // No initialization. This is unsafe, but reasonable use will not cause any problems. + __lh3_hash_base_iterator(hashint_t _i, keytype_t *_keys, __lh3_flag_t *_flags) { + i = _i; keys = _keys; flags = _flags; + } + inline const keytype_t &operator & () { return keys[i]; } // Keys should never be changed by an iterator. + inline const keytype_t &key() { return keys[i]; } // an alias of the operator "&" + inline bool operator != (const __lh3_hash_base_iterator &iter) { return i != iter.i; } + inline bool operator == (const __lh3_hash_base_iterator &iter) { return i == iter.i; } + inline bool operator < (const __lh3_hash_base_iterator &iter) { return i < iter.i; } + inline bool operator > (const __lh3_hash_base_iterator &iter) { return i > iter.i; } + inline void operator ++ () { ++i; } + inline void operator ++ (int) { ++i; } + inline void operator -- () { --i; } + inline void operator -- (int) { --i; } + inline bool isfilled() { return !__lh3_isboth(flags, i); } + inline bool operator + () { return isfilled(); } // an alias of "isfilled()" +}; + +/** "iterator" class for "hash_map_char" and "hash_map_misc" */ +template +class __lh3_hash_val_iterator : public __lh3_hash_base_iterator +{ +protected: + valtype_t *vals; +public: + __lh3_hash_val_iterator() {} + __lh3_hash_val_iterator(hashint_t _i, keytype_t *_keys, __lh3_flag_t *_flags, valtype_t *_vals) { + this->i = _i; this->keys = _keys; this->flags = _flags; vals = _vals; + } + inline valtype_t &operator * () { return vals[this->i]; } // Values can be changed here. + inline const valtype_t &value() { return vals[this->i]; } // the following two functions are alternatives to the operator "*". + inline void value(const valtype_t &v) { vals[this->i] = v; } +}; + +/** Base class of all hash classes */ +template +class __lh3_hash_base_class +{ +protected: + hashint_t n_capacity; /**< maximum size of the hash table */ + hashint_t n_size; /**< number of elements in hash table */ + hashint_t n_occupied; /**< number of cells that have not been flaged as "isempty" (n_capacity >= n_occupied >= n_size) */ + hashint_t upper_bound; /**< The upper bound. When n_occupied exceeds this, rehashing will be performed. */ + __lh3_flag_t *flags; /**< flag array which stores the status "isempty" or "isdel" of each hash cell. */ + keytype_t *keys; /**< array that stores hash keys */ + // return 0 for unchanged, 1 for empty, 2 for deleted + inline int direct_insert_aux(const keytype_t &key, hashint_t m, keytype_t *K, __lh3_flag_t *F, hashint_t *i) { + *i = __lh3_hash_insert_aux(key, m, K, F); + if (__lh3_isempty(F, *i)) { + K[*i] = key; + __lh3_set_isboth_false(F, *i); + return 1; + } else if (__lh3_isdel(F, *i)) { + K[*i] = key; + __lh3_set_isboth_false(F, *i); + return 2; + } else return 0; + } + inline bool resize_aux1(hashint_t *new_capacity, __lh3_flag_t **new_flags) { + hashint_t t; + t = __lh3_HASH_PRIME_SIZE - 1; + while (__lh3_prime_list[t] > *new_capacity) --t; + *new_capacity = __lh3_prime_list[t+1]; + if (n_size >= hashint_t(*new_capacity * __lh3_HASH_UPPER + 0.5)) return false; // do not rehash + keys = (keytype_t*)realloc(keys, *new_capacity * sizeof(keytype_t)); + if (keys == 0) return false; // insufficient memory? + *new_flags = (__lh3_flag_t*)malloc(*new_capacity * sizeof(__lh3_flag_t)); + if (*new_flags == 0) { // insufficient memory? + ::free(*new_flags); return false; + } + for (t = 0; t < ((*new_capacity>>__lh3_FLAG_SHIFT) + 1); ++t) + (*new_flags)[t] = __lh3_FLAG_DEFAULT; + return true; + } + inline void resize_aux2(hashint_t new_capacity, __lh3_flag_t *new_flags) { + ::free(flags); + flags = new_flags; + n_capacity = new_capacity; + n_occupied = n_size; + upper_bound = hashint_t(n_capacity * __lh3_HASH_UPPER + 0.5); + } + /** Test whether rehashing is needed and perform rehashing if this is the fact. */ + inline void rehash() { + if (n_occupied >= upper_bound) { + if (n_capacity > (n_size<<1)) resize(n_capacity - 1); // do not enlarge + else resize(n_capacity + 1); // enlarge the capacity + } + } +public: + typedef __lh3_hash_base_iterator iterator; + __lh3_hash_base_class(void) { + keys = 0; flags = 0; + n_capacity = n_size = n_occupied = upper_bound = 0;; + } + ~__lh3_hash_base_class(void) { ::free(keys); ::free(flags); } + /** resize the hash table and perform rehashing */ + inline bool resize(hashint_t new_capacity) { + __lh3_flag_t *new_flags; + if (!resize_aux1(&new_capacity, &new_flags)) return false; + for (hashint_t j = 0; j != n_capacity; ++j) { + if (__lh3_isboth(flags, j) == 0) { + keytype_t key = keys[j]; // take out the key + __lh3_set_isdel_true(flags, j); // mark "deleted" + while (1) { + hashint_t inc, k, i; + k = __lh3_hash_fun(key); + i = k % new_capacity; // calculate the new position + inc = 1 + k % (new_capacity - 1); + while (!__lh3_isempty(new_flags, i)) { + if (i + inc >= new_capacity) i = i + inc - new_capacity; + else i += inc; + } + __lh3_set_isempty_false(new_flags, i); + if (i < this->n_capacity && __lh3_isboth(flags, i) == 0) { // something is here + { keytype_t tmp = keys[i]; keys[i] = key; key = tmp; } // take it out + __lh3_set_isdel_true(flags, i); + } else { // put key and quit the loop + keys[i] = key; + break; + } + } + } + } + resize_aux2(new_capacity, new_flags); + return true; + } + /** get n_size */ + inline hashint_t size(void) const { return n_size; }; + /** get n_capacity */ + inline hashint_t capacity(void) const { return n_capacity; }; + /** the first iterator */ + inline iterator begin() { return iterator(0, keys, flags); } + /** the last iterator */ + inline iterator end() { return iterator(n_capacity, keys, flags); } + /** clear the hash table, but do not free the memory */ + inline void clear(void) { + if (flags) { + for (hashint_t t = 0; t < ((n_capacity>>__lh3_FLAG_SHIFT) + 1); ++t) + flags[t] = __lh3_FLAG_DEFAULT; + } + n_size = 0; + } + /** clear the hash table and free the memory */ + inline void free() { + ::free(keys); ::free(flags); + keys = 0; flags = 0; + n_capacity = n_size = n_occupied = upper_bound = 0;; + } +}; + +/** hash_set_misc class */ +template +class hash_set_misc : public __lh3_hash_base_class +{ +public: + hash_set_misc(void) {}; + ~hash_set_misc(void) {}; + /** search a key */ + inline bool find(const keytype_t &key) const { + hashint_t i = __lh3_hash_search_aux(key, this->n_capacity, this->keys, this->flags); + return (i != this->n_capacity && __lh3_isboth(this->flags, i) == 0)? true : false; + } + /** insert a key */ + inline bool insert(const keytype_t &key) { + __lh3_hash_base_class::rehash(); + hashint_t i; + int ret = direct_insert_aux(key, this->n_capacity, this->keys, this->flags, &i); + if (ret == 0) return true; + if (ret == 1) { ++(this->n_size); ++(this->n_occupied); } + else ++(this->n_size); // then ret == 2 + return false; + } + /** delete a key */ + inline bool erase(const keytype_t &key) { + hashint_t i = __lh3_hash_erase_aux(key, this->n_capacity, this->keys, this->flags); + if (i != this->n_capacity) { + --(this->n_size); + return true; + } else return false; + } +}; + +/** hash_map_misc class */ +template +class hash_map_misc : public hash_set_misc +{ + valtype_t *vals; + /** a copy of __lh3_hash_base_class::rehash() */ + inline void rehash() { + if (this->n_occupied >= this->upper_bound) { + if (this->n_capacity > (this->n_size<<1)) resize(this->n_capacity - 1); + else resize(this->n_capacity + 1); + } + } +public: + hash_map_misc(void) { vals = 0; }; + ~hash_map_misc(void) { ::free(vals); }; + typedef __lh3_hash_val_iterator iterator; + /** analogy of __lh3_hash_base_class::resize(hashint_t) */ + inline bool resize(hashint_t new_capacity) { + __lh3_flag_t *new_flags; + if (!__lh3_hash_base_class::resize_aux1(&new_capacity, &new_flags)) return false; + vals = (valtype_t*)realloc(vals, sizeof(valtype_t) * new_capacity); + if (vals == 0) { // insufficient enough memory? + ::free(new_flags); + return false; + } + for (hashint_t j = 0; j != this->n_capacity; ++j) { + if (__lh3_isboth(this->flags, j) == 0) { + keytype_t key = this->keys[j]; // take out the key + valtype_t val = vals[j]; + __lh3_set_isdel_true(this->flags, j); // mark "deleted" + while (1) { + hashint_t inc, k, i; + k = __lh3_hash_fun(key); + i = k % new_capacity; // calculate the new position + inc = 1 + k % (new_capacity - 1); + while (!__lh3_isempty(new_flags, i)) { + if (i + inc >= new_capacity) i = i + inc - new_capacity; + else i += inc; + } + __lh3_set_isempty_false(new_flags, i); + if (i < this->n_capacity && __lh3_isboth(this->flags, i) == 0) { // something is here + { keytype_t tmp = this->keys[i]; this->keys[i] = key; key = tmp; } // take it out + { valtype_t tmp = vals[i]; vals[i] = val; val = tmp; } // take it out + __lh3_set_isdel_true(this->flags, i); + } else { // clear + this->keys[i] = key; + vals[i] = val; + break; + } + } + } + } + __lh3_hash_base_class::resize_aux2(new_capacity, new_flags); + return true; + } + inline bool find(const keytype_t &key, valtype_t *q) const { + hashint_t i = __lh3_hash_search_aux(key, this->n_capacity, this->keys, this->flags); + if (i != this->n_capacity && __lh3_isboth(this->flags, i) == 0) { + *q = vals[i]; + return true; + } else return false; + } + inline bool insert(const keytype_t &key, const valtype_t &val) { + rehash(); + hashint_t i; + int ret =this->direct_insert_aux(key, this->n_capacity, this->keys, this->flags, &i); +//int ret =direct_insert_aux(key, this->n_capacity, this->keys, this->flags, &i); + vals[i] = val; + if (ret == 0) return true; + if (ret == 1) { ++(this->n_size); ++(this->n_occupied); } + else ++(this->n_size); // then ret == 2 + return false; + } + inline bool insert(const keytype_t &key, valtype_t **q) { + rehash(); + hashint_t i; + int ret = direct_insert_aux(key, this->n_capacity, this->keys, this->flags, &i); + *q = vals + i; + if (ret == 0) return true; + if (ret == 1) { ++(this->n_size); ++(this->n_occupied); } + else ++(this->n_size); // then ret == 2 + return false; + } + inline bool erase(const keytype_t &key) { return hash_set_misc::erase(key); } + inline bool erase(const keytype_t &key, valtype_t **q) { + hashint_t i = __lh3_hash_erase_aux(key, this->n_capacity, this->keys, this->flags); + if (i != this->n_capacity) { + --(this->n_size); + *q = vals + i; + return true; + } else return false; + } + inline iterator begin() { return iterator(0, this->keys, this->flags, vals); } + inline iterator end() { return iterator(this->n_capacity, this->keys, this->flags, vals); } + inline void free() { + hash_set_misc::free(); ::free(vals); vals = 0; + } +}; + +typedef char *__lh3_char_t; + +/** hash_set_char class */ +class hash_set_char : public __lh3_hash_base_class +{ +protected: + inline int insert_aux(const char *key, hashint_t m, char **K, __lh3_flag_t *F, hashint_t *i) { + *i = __lh3_hash_insert_aux((const __lh3_char_t)key, m, K, F); + if (__lh3_isempty(F, *i)) { + K[*i] = strdup(key); + __lh3_set_isboth_false(F, *i); + return 1; + } else if (__lh3_isdel(F, *i)) { + K[*i] = strdup(key); + __lh3_set_isboth_false(F, *i); + return 2; + } else return 0; + } +public: + hash_set_char(void) {}; + ~hash_set_char(void) { clear(); }; + inline bool find(const char *key) const { + hashint_t i = __lh3_hash_search_aux((const __lh3_char_t)key, this->n_capacity, this->keys, this->flags); + return (i != this->n_capacity && __lh3_isboth(this->flags, i) == 0)? true : false; + } + inline bool insert(const char *key) { + rehash(); + hashint_t i; + int ret = insert_aux(key, this->n_capacity, this->keys, this->flags, &i); + if (ret == 0) return true; + if (ret == 1) { ++(this->n_size); ++(this->n_occupied); } + else ++(this->n_size); // then ret == 2 + return false; + } + inline bool erase(const char *key) { + hashint_t i = __lh3_hash_erase_aux((const __lh3_char_t)key, this->n_capacity, this->keys, this->flags); + if (i != this->n_capacity) { + ::free(this->keys[i]); this->keys[i] = 0; + --(this->n_size); + return true; + } else return false; + } + inline void clear(void) { + for (hashint_t i = 0; i != this->n_capacity; ++i) + if (!__lh3_isboth(this->flags, i)) { + ::free(this->keys[i]); this->keys[i] = 0; + } + __lh3_hash_base_class::clear(); + } + inline void free() { + clear(); + __lh3_hash_base_class::free(); + } +}; + +/** hash_map_char class */ +template +class hash_map_char : public hash_set_char +{ + valtype_t *vals; + inline void rehash() { + if (this->n_occupied >= this->upper_bound) { + if (this->n_capacity > (this->n_size<<1)) resize(this->n_capacity - 1); + else resize(this->n_capacity + 1); + } + } +public: + typedef __lh3_hash_val_iterator iterator; + hash_map_char(void) { vals = 0; }; + ~hash_map_char(void) { clear(); ::free(vals); }; + inline valtype_t &val(hashint_t i) { return vals[i]; } + inline void val(hashint_t i, const valtype_t &v) { return vals[i] = v; } + inline bool resize(hashint_t new_capacity) { + __lh3_flag_t *new_flags; + if (!resize_aux1(&new_capacity, &new_flags)) return false; + vals = (valtype_t*)realloc(vals, sizeof(valtype_t) * new_capacity); + if (vals == 0) { // insufficient enough memory? + ::free(new_flags); + return false; + } + for (hashint_t j = 0; j != this->n_capacity; ++j) { + if (__lh3_isboth(this->flags, j) == 0) { + char *key = this->keys[j]; // take out the key + valtype_t val = vals[j]; + __lh3_set_isdel_true(this->flags, j); // mark "deleted" + while (1) { + hashint_t inc, k, i; + k = __lh3_hash_fun(key); + i = k % new_capacity; // calculate the new position + inc = 1 + k % (new_capacity - 1); + while (!__lh3_isempty(new_flags, i)) { + if (i + inc >= new_capacity) i = i + inc - new_capacity; + else i += inc; + } + __lh3_set_isempty_false(new_flags, i); + if (i < this->n_capacity && __lh3_isboth(this->flags, i) == 0) { // something is here + { char* tmp = this->keys[i]; this->keys[i] = key; key = tmp; } // take it out + { valtype_t tmp = vals[i]; vals[i] = val; val = tmp; } // take it out + __lh3_set_isdel_true(this->flags, i); + } else { // clear + this->keys[i] = key; + vals[i] = val; + break; + } + } + } + } + resize_aux2(new_capacity, new_flags); + return true; + } + inline bool find(const char *key, valtype_t *q) const { + hashint_t i = __lh3_hash_search_aux((const __lh3_char_t)key, this->n_capacity, this->keys, this->flags); + if (i != this->n_capacity && __lh3_isboth(this->flags, i) == 0) { + *q = vals[i]; + return true; + } else return false; + } + inline bool insert(const char *key, const valtype_t &val) { + rehash(); + hashint_t i; + int ret = insert_aux(key, this->n_capacity, this->keys, this->flags, &i); + vals[i] = val; + if (ret == 0) return true; + if (ret == 1) { ++(this->n_size); ++(this->n_occupied); } + else ++(this->n_size); // then ret == 2 + return false; + } + inline bool insert(const char *key, valtype_t **q) { + rehash(); + hashint_t i; + int ret = insert_aux(key, this->n_capacity, this->keys, this->flags, &i); + *q = vals + i; + if (ret == 0) return true; + if (ret == 1) { ++(this->n_size); ++(this->n_occupied); } + else ++(this->n_size); // then ret == 2 + return false; + } + inline bool erase(const char *key) { return hash_set_char::erase(key); } + inline bool erase(const char *key, valtype_t **q) { + hashint_t i = __lh3_hash_erase_aux((const __lh3_char_t)key, this->n_capacity, this->keys, this->flags); + if (i != this->n_capacity) { + ::free(this->keys[i]); this->keys[i] = 0; + --(this->n_size); + *q = vals + i; + return true; + } else return false; + } + inline iterator begin() { return iterator(0, this->keys, this->flags, vals); } + inline iterator end() { return iterator(this->n_capacity, this->keys, this->flags, vals); } + inline void free() { + hash_set_char::free(); ::free(vals); vals = 0; + } +}; + +#endif // LH3_STDHASH_H_ diff --git a/src/ALL/msort/stdhashc.cc b/src/ALL/msort/stdhashc.cc new file mode 100644 index 0000000..673b089 --- /dev/null +++ b/src/ALL/msort/stdhashc.cc @@ -0,0 +1,103 @@ +#include +#include "stdhash.hh" +#include "stdhashc.h" + +// hashci + +typedef hash_map_char hashci_cpp_t; + +hashci_t *hci_init() +{ + hashci_t *h = (hashci_t*)malloc(sizeof(hashci_t)); + h->ptr = new hashci_cpp_t; + return h; +} +void hci_destroy(hashci_t *h) +{ + delete (hashci_cpp_t*)h->ptr; + free(h); +} +int hci_put(hashci_t *h, const char *key, int value) +{ + return ((hashci_cpp_t*)h->ptr)->insert(key, value); +} +int hci_del(hashci_t *h, const char *key) +{ + return ((hashci_cpp_t*)h->ptr)->erase(key); +} +int hci_get(const hashci_t *h, const char *key, int *value) +{ + return ((hashci_cpp_t*)h->ptr)->find(key, value); +} +u_int32_t hci_size(hashci_t *h) +{ + return ((hashci_cpp_t*)h->ptr)->size(); +} +u_int32_t hci_capacity(hashci_t *h) +{ + return ((hashci_cpp_t*)h->ptr)->capacity(); +} +int hci_resize(hashci_t *h, u_int32_t new_size) +{ + return ((hashci_cpp_t*)h->ptr)->resize(new_size); +} +void hci_traverse(hashci_t *h, hashci_f func) +{ + hashci_cpp_t *hash = (hashci_cpp_t*)h->ptr; + hashci_cpp_t::iterator iter; + for (iter = hash->begin(); iter != hash->end(); ++iter) { + if (iter.isfilled()) { + func(iter.key(), iter.value()); + } + } +} + +// hashii + +typedef hash_map_misc hashii_cpp_t; + +hashii_t *hii_init() +{ + hashii_t *h = (hashii_t*)malloc(sizeof(hashii_t)); + h->ptr = new hashii_cpp_t; + return h; +} +void hii_destroy(hashii_t *h) +{ + delete (hashii_cpp_t*)h->ptr; + free(h); +} +int hii_put(hashii_t *h, u_int32_t key, int value) +{ + return ((hashii_cpp_t*)h->ptr)->insert(key, value); +} +int hii_del(hashii_t *h, u_int32_t key) +{ + return ((hashii_cpp_t*)h->ptr)->erase(key); +} +int hii_get(const hashii_t *h, u_int32_t key, int *value) +{ + return ((hashii_cpp_t*)h->ptr)->find(key, value); +} +u_int32_t hii_size(hashii_t *h) +{ + return ((hashii_cpp_t*)h->ptr)->size(); +} +u_int32_t hii_capacity(hashii_t *h) +{ + return ((hashii_cpp_t*)h->ptr)->capacity(); +} +int hii_resize(hashii_t *h, u_int32_t new_size) +{ + return ((hashii_cpp_t*)h->ptr)->resize(new_size); +} +void hii_traverse(hashii_t *h, hashii_f func) +{ + hashii_cpp_t *hash = (hashii_cpp_t*)h->ptr; + hashii_cpp_t::iterator iter; + for (iter = hash->begin(); iter != hash->end(); ++iter) { + if (iter.isfilled()) { + func(iter.key(), iter.value()); + } + } +} diff --git a/src/ALL/msort/stdhashc.h b/src/ALL/msort/stdhashc.h new file mode 100644 index 0000000..fc9f2c3 --- /dev/null +++ b/src/ALL/msort/stdhashc.h @@ -0,0 +1,60 @@ +#ifndef STDHASHC_H +#define STDHASHC_H + +#include + +/* hashci */ + +typedef struct +{ + void *ptr; +} hashci_t; + +typedef int (*hashci_f)(const char *key, int value); + +#ifdef __cplusplus +extern "C" { +#endif + + hashci_t *hci_init(); + void hci_destroy(hashci_t *h); + int hci_put(hashci_t *h, const char *key, int value); + int hci_del(hashci_t *h, const char *key); + int hci_get(const hashci_t *h, const char *key, int *value); + u_int32_t hci_size(hashci_t *h); + u_int32_t hci_capacity(hashci_t *h); + int hci_resize(hashci_t *h, u_int32_t new_size); + void hci_traverse(hashci_t *h, hashci_f func); + +#ifdef __cplusplus +} +#endif + +/* hashii */ + +typedef struct +{ + void *ptr; +} hashii_t; + +typedef int (*hashii_f)(u_int32_t key, int value); + +#ifdef __cplusplus +extern "C" { +#endif + + hashii_t *hii_init(); + void hii_destroy(hashii_t *h); + int hii_put(hashii_t *h, u_int32_t key, int value); + int hii_del(hashii_t *h, u_int32_t key); + int hii_get(const hashii_t *h, u_int32_t key, int *value); + u_int32_t hii_size(hashii_t *h); + u_int32_t hii_capacity(hashii_t *h); + int hii_resize(hashii_t *h, u_int32_t new_size); + void hii_traverse(hashii_t *h, hashii_f func); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/Noname_1.pl b/src/Noname_1.pl new file mode 100644 index 0000000..1406a81 --- /dev/null +++ b/src/Noname_1.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl-w +use strict; +#explanation:this program is edited to +#edit by HeWeiMing; Mon May 14 16:38:54 HKT 2018 +#Version 1.0 hewm@genomics.org.cn + +die "Version 1.0\t2018-05-14;\nUsage: $0 \n" unless (@ARGV ==1); + +#############Befor Start , open the files #################### + +open (IA,"$ARGV[0]") || die "input file can't open $!"; + +#open (OA,">$ARGV[1]") || die "output file can't open $!" ; + +print "void More_HelpFM()\n"; +print "{\n"; +################ Do what you want to do ####################### +print "cout<<\"\"\n"; +while() +{ + chomp ; + if ($_=~s/Usage/Usage/) + { + print "\"\\t$_\\n\"","\n"; + } + elsif ($_ eq "") + { + print "\"\\n\"\n"; + } + else + { + print "\"\\t\\t$_\\n\"","\n"; + + } +} +print "\"\\n\";\n"; +#print "return 1 ;\n"; +print "}\n"; +close IA; +#close OA ; +# 37 "\t\t-b output BAM file\n" +# 38 "\t\t-s output SAM file\n" +# +######################swimming in the sky and flying in the sea ########################### diff --git a/src/convert/bam2fa.h b/src/convert/bam2fa.h new file mode 100644 index 0000000..f770721 --- /dev/null +++ b/src/convert/bam2fa.h @@ -0,0 +1,250 @@ + +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include +#include +#include "../ALL/gzstream/gzstream.h" +#include +using namespace std; +typedef long long llong ; + + + +void print_Ausage_Xam2fa() +{ + cout<<"" + "\n" + "\tUsage: bam2fa -i -o \n" + "\n" + "\t\t-i input SAM/BAM file\n" + "\t\t-o output FASTA file\n" + "\n" + "\t\t-u only output unmapped reads\n" + "\n" + "\t\t-h show more details for help \n" + "\n"; +} + +void More_Help_Xam2fa() +{ + cout<<"" + "\n" + "\t\t1. bam2fa -i -o AAA\n" + "\t\t This will convert the all the BAM to FASTA and output to a compressed file named AAA in current directory.\n" + "\n" + "\t\t2. bam2fa -i -o AAA -u\n" + "\t\t This will convert the unmapped part of BAM to FASTA and output to a compressed file named AAA in current directory. If all the reads are mapped, this will give nothing.\n" + "\n"; +} + + +int parse_Acmd_Xam2fa(int argc, char **argv, In3str1v * para_Xam2fa) +{ + if (argc <2 ) {print_Ausage_Xam2fa();return 0;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-","") ; + + if (flag == "InPut" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam2fa->InStr1=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam2fa->InStr2=argv[i]; + } + else if (flag == "UnMap" || flag == "u") + { + para_Xam2fa->TF=false; + } + ///*//// + else if (flag == "help" || flag == "h") + { + More_Help_Xam2fa();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() || (para_Xam2fa->InStr1).empty() ) + { + cerr<< "lack argument for the must"<InStr2=add_Asuffix(para_Xam2fa->InStr2); + return 1 ; +} + + + +//programme entry +///////// swimming in the sky and flying in the sea //////////// +//int main(int argc, char **argv) +int Bam2fa_main(int argc, char **argv) +{ + In3str1v * para_Xam2fa = new In3str1v; + if (parse_Acmd_Xam2fa(argc, argv , para_Xam2fa )==0) + { + delete para_Xam2fa ; + return 0 ; + } + + bam_hdr_t *header; + bam1_t *aln = bam_init1(); + samFile *in = sam_open((para_Xam2fa->InStr1).c_str(), "r"); + header = sam_hdr_read(in); + + + ogzstream OUT(para_Xam2fa->InStr2.c_str()) ; + + + int Samp[256]={0}; + Samp['A']='T'; Samp['C']='G'; + Samp['T']='A'; Samp['G']='C'; + Samp['N']='N'; + + int Count=0; + uint8_t Base[16] = {0,65,67,0,71,0,0,0,84,0,0,0,0,0,0,78}; + if ( para_Xam2fa->TF) + { + while ( (sam_read1(in, header, aln) >= 0) ) + { + string readID=bam_get_qname(aln); + + if ( (((aln)->core.flag&64) != 0)) + { + readID= "@"+readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID= "@"+readID + "/2" ; + } + else + { + readID= "@"+readID ; + } + + + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + for(int i=0; i < (aln->core).l_qseq ; i++) + { + BaseSeq=BaseSeq+(char)(Base[bam_seqi(seq, i)]); + } + + + + + if ((((aln)->core.flag&16) != 0)) + { + reverse(BaseSeq.begin(), BaseSeq.end()); + for (int i=0 ; i<(aln->core).l_qseq ; i++) + { + BaseSeq[i]=Samp[BaseSeq[i]]; + } + } + + OUT<<">"<= 0) ) + { + if ((aln->core).tid >= 0) + { + continue ; + } + + string readID=bam_get_qname(aln); + + if ( (((aln)->core.flag&64) != 0)) + { + readID= "@"+readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID= "@"+readID + "/2" ; + } + else + { + readID= "@"+readID ; + } + + + + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + for(int i=0; i < (aln->core).l_qseq ; i++) + { + BaseSeq=BaseSeq+Int2Str(Base[bam_seqi(seq, i)]); + } + + + + + if ((((aln)->core.flag&16) != 0)) + { + reverse(BaseSeq.begin(), BaseSeq.end()); + for (int i=0 ; i<(aln->core).l_qseq ; i++) + { + BaseSeq[i]=Samp[BaseSeq[i]]; + } + } + + OUT<<">"< +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include +#include +#include "../ALL/gzstream/gzstream.h" +#include +using namespace std; +typedef long long llong ; + + +void print_Ausage_Xam2fq() +{ + cout<<"" + "\n" + "\tUsage: bam2fq -i -o \n" + "\n" + "\t\t-i input SAM/BAM file\n" + "\t\t-o output FASTQ file\n" + "\n" + "\t\t-u only output unmapped reads\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_HelpFM_Xam2fq() +{ + cout<<"" + "\n" + "\t\t1. bam2fq -i -o AAA\n" + "\t\t This will convert the all the BAM to FASTQ and output to a compressed file named AAA in current directory.\n" + "\n" + "\t\t2. bam2fq -i -o AAA -u\n" + "\t\t This will convert the unmapped part of BAM to FASTQ and output to a compressed file named AAA in current directory. If all the reads are mapped, this will give nothing.\n" + "\n"; +} + +int parse_Acmd_Xam2fq(int argc, char **argv, In3str1v * para_Xam2fq) +{ + if (argc <2 ) {print_Ausage_Xam2fq();return 0;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-","") ; + + if (flag == "InPut" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam2fq->InStr1=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam2fq->InStr2=argv[i]; + } + else if (flag == "UnMap" || flag == "u") + { + para_Xam2fq->TF=false; + } + ///*//// + else if (flag == "help" || flag == "h") + { + More_HelpFM_Xam2fq();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() || (para_Xam2fq->InStr1).empty() ) + { + cerr<< "lack argument for the must"<InStr2=add_Asuffix(para_Xam2fq->InStr2); + return 1 ; +} + + + +//programme entry +///////// swimming in the sky and flying in the sea //////////// +//int main(int argc, char **argv) +int Bam2fq_main(int argc, char **argv) +{ + In3str1v * para_Xam2fq = new In3str1v; + if (parse_Acmd_Xam2fq(argc, argv , para_Xam2fq )==0) + { + delete para_Xam2fq ; + return 0 ; + } + + bam_hdr_t *header; + bam1_t *aln = bam_init1(); + samFile *in = sam_open((para_Xam2fq->InStr1).c_str(), "r"); + header = sam_hdr_read(in); + + + ogzstream OUT(para_Xam2fq->InStr2.c_str()) ; + + + int Samp[256]={0}; + Samp['A']='T'; Samp['C']='G'; + Samp['T']='A'; Samp['G']='C'; + Samp['N']='N'; + + int Count=0; + uint8_t Base[16] = {0,65,67,0,71,0,0,0,84,0,0,0,0,0,0,78}; + if ( para_Xam2fq->TF) + { + while ( (sam_read1(in, header, aln) >= 0) ) + { + string readID=bam_get_qname(aln); + + if ( (((aln)->core.flag&64) != 0)) + { + readID= "@"+readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID= "@"+readID + "/2" ; + } + else + { + readID= "@"+readID ; + } + + + uint8_t * seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int i=0; i < (aln->core).l_qseq ; i++) + { + BaseSeqQ=BaseSeqQ+(char)((seqQ[i])+31); + BaseSeq=BaseSeq+(char)(Base[bam_seqi(seq, i)]); + } + + + + + if ((((aln)->core.flag&16) != 0)) + { + reverse(BaseSeq.begin(), BaseSeq.end()); + reverse(BaseSeqQ.begin(), BaseSeqQ.end()); + for (int i=0 ; i<(aln->core).l_qseq ; i++) + { + BaseSeq[i]=Samp[BaseSeq[i]]; + } + } + + OUT<= 0) ) + { + if ((aln->core).tid >= 0) + { + continue ; + } + + string readID=bam_get_qname(aln); + + if ( (((aln)->core.flag&64) != 0)) + { + readID= "@"+readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID= "@"+readID + "/2" ; + } + else + { + readID= "@"+readID ; + } + + + + uint8_t * seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int i=0; i < (aln->core).l_qseq ; i++) + { + BaseSeqQ=BaseSeqQ+Int2Str(seqQ[i]); + BaseSeq=BaseSeq+Int2Str(Base[bam_seqi(seq, i)]); + } + + + + + if ((((aln)->core.flag&16) != 0)) + { + reverse(BaseSeq.begin(), BaseSeq.end()); + reverse(BaseSeqQ.begin(), BaseSeqQ.end()); + for (int i=0 ; i<(aln->core).l_qseq ; i++) + { + BaseSeq[i]=Samp[BaseSeq[i]]; + } + } + + OUT< +#include +#include "../ALL/gzstream/gzstream.h" +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +using namespace std; + + +void print_Ausage_A14() +{ + cout<<"" + "\n" + "\tUsage: bam2soap -i -o \n" + "\n" + "\t\t-i input SAM/BAM file \n" + "\t\t-o output SOAP file\n" + "\n" + "\t\t-Q shift sequence quality score by [+31] or [-31] or [0], default [0]\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_Help_A14() +{ + cout<<"" + "\n" + "\t\t1. bam2soap -i -s AAA\n" + "\t\t This will convert the BAM to SOAP and output to a compressed file named AAA in current directory.\n" + "\n" + "\t\t2. bam2soap -i -s AAA -Q -31\n" + "\t\t This will convert the BAM to SOAP with quality score updated from Solexa to Sanger and output to a compressed file named AAA in current directory.\n" + "\t\t\n" + "\n" + "\n"; +} + +int parse_Acmd_A14(int argc, char **argv, In3str1v * para_A14) +{ + if (argc <2 ) {print_Ausage_A14();return 0 ;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InFile" || flag == "i" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + para_A14->InStr1=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_A14->InStr3=argv[i]; + } + else if (flag == "QShift" || flag == "Q") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_A14->InInt=atoi(argv[i]); + } + + else if (flag == "help" || flag == "h") + { + More_Help_A14();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr3).empty() || (para_A14->InStr1).empty()) + { + cerr<< "lack argument for the must"<InStr3)= add_Asuffix ( (para_A14->InStr3) ) ; + + return 1 ; +} + + +void Talignment_format( bam_hdr_t *header ,bam1_t *aln , ogzstream & OUT , uint8_t * Base ,int shiftQ ) +{ + + + string readID=bam_get_qname(aln); + + string ab="a"; + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + ab="b"; + } + + uint8_t * seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int i=0; i < (aln->core).l_qseq ; i++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[i]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, i)]); + } + + string ZF="+"; + if ((((aln)->core.flag&16) != 0)) + { + ZF="-"; + } + + + + string mapchr=(header->target_name[(aln->core).tid]); + int site=(aln->core).pos; + + int Hit=1; + if ((aln->core).qual==0) + { + Hit=10; + } + else if ((aln->core).qual<30) + { + Hit=2; + } + + + string cigarStr="*"; + if (aln->core.n_cigar) + { // cigar + uint32_t *cigar = bam_get_cigar(aln); + cigarStr=""; + for (int i = 0; i < aln->core.n_cigar; ++i) + { + stringstream sstrm ; + sstrm << (bam_cigar_oplen(cigar[i])) ; + cigarStr=cigarStr+sstrm.str()+(char)bam_cigar_opchr(cigar[i]); + } + } + OUT<core).l_qseq<<"\t"<core).pos<<"\t"<InInt)+=31; + + bam_hdr_t *header; + bam1_t *aln = bam_init1(); + samFile *in = sam_open((para_A14->InStr1).c_str(), "r"); + header = sam_hdr_read(in); + uint8_t Base[16] = {0,65,67,0,71,0,0,0,84,0,0,0,0,0,0,78}; + + ogzstream OUT(para_A14->InStr3.c_str()); + if (!OUT.good()) + { + cerr<<"Can't open OutFile "<InStr3<= 0) ) + { + if ((aln->core).tid < 0) + { + continue ; + } + Talignment_format( header , aln , OUT , Base,para_A14->InInt); + } + + + OUT.close(); + sam_close(in); + bam_destroy1(aln); + bam_hdr_destroy(header); + + + delete para_A14 ; + return 0; +} +#endif // xam2soap_H_ +///////// swimming in the sky and flying in the sea //////////// + +/* format the sam text to the soap text*/ + + diff --git a/src/convert/covert.h b/src/convert/covert.h new file mode 100644 index 0000000..d39a983 --- /dev/null +++ b/src/convert/covert.h @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include +#include +#include "soap2bam.h" +#include "bam2fq.h" +#include "bam2fa.h" +#include "bam2soap.h" + + + +using namespace std; + +int soap2bam_main(int argc, char **argv); +int Bam2fq_main(int argc, char **argv); +int Bam2fa_main(int argc, char **argv); +int Bam2Soap_main(int argc, char **argv); + +static int covert_usage () +{ + cerr<<"" + "\n" + "\t\tsoap2bam soap --> bam/sam Format\n" + "\t\tbam2soap bam/sam --> soap Format\n" + "\t\tbam2fq bam/sam --> Fastq Format\n" + "\t\tbam2fa bam/sam --> Fasta Format\n" + "\n" + "\t\tHelp Show this help\n" + "\n"; + return 1; +} + + +int convert_main(int argc, char *argv[]) +{ + if (argc < 2) { return covert_usage(); } + else if (strcmp(argv[1], "soap2bam") == 0) { return soap2bam_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bam2soap") == 0) { return Bam2Soap_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bam2fq") == 0) { return Bam2fq_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bam2fa") == 0) { return Bam2fa_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "Help") == 0 || strcmp(argv[1], "help") == 0 || strcmp(argv[1], "?")== 0 || ( argv[1][0] == '-' &&( argv[1][1] =='h' || argv[1][1] =='H' || argv[1][1] =='?' ) ) || strcmp(argv[1], "less") == 0 ) + { + return covert_usage(); + } + else + { + cerr<<"convert [main] unrecognized command "< +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include "../ALL/dealfun.cpp" + + +//KSEQ_INIT(gzFile, gzread) + +using namespace std; +typedef long long llong ; +int msort_main(int argc, char **argv) ; + + +void print_Ausage_Formt01() +{ + cout <<"" + "\n" + "\tUsage: soap2bam -i -s \n" + "\tUsage: soap2bam -i -b -d Ref.dict\n" + "\n" + "\t\t-i input SOAP file\n" + "\t\t-b output BAM file\n" + "\t\t-s output SAM file\n" + "\n" + "\t\t-d input reference FASTA to get header for BAM\n" + "\t\t-p if soap is PairOut,for flag\n" + "\t\t-Q shift sequence quality score by [+31] or [-31] or [0], default [0]\n" + "\t\t-g all read in memory to search mate information\n" + "\n" + "\t\t-h show more details for help [hewm2008 v1.04]\n" + "\n"; +} + +void More_Help1() +{ + cout<<"" + "\n" + "\t\t1. soap2bam -i -s AAA\n" + "\t\t This will convert the SOAP to SAM and output to a compressed file named AAA in current directory.\n" + "\n" + "\t\t2. soap2bam -i -b AAA -d Ref.fa\n" + "\t\t This will convert the SOAP to BAM with the header from reference FASTA and output to a compressed file named AAA in current directory.\n" + "\n"; +} + + + +int parse_Acmd_Formt01(int argc, char **argv , Para_Formt01 * para_Formt01) +{ + if (argc <=1 ) {print_Ausage_Formt01();return 0;} + + for(int i = 1; i < argc; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InSoap" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Formt01->input_file=argv[i]; + } + else if (flag == "OutSam" || flag == "s") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Formt01->OutSamFile=argv[i]; + } + else if (flag == "OutBam" || flag == "b") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Formt01->OutBamFile=argv[i]; + } + else if (flag == "Dict" || flag == "d") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Formt01->Dict=argv[i]; + } + else if (flag == "ShiftQ" || flag == "Q") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Formt01->shiftQ=atoi(argv[i]); + } + else if (flag == "Pair" || flag == "p" ) + { + (para_Formt01->PE)=1; + } + else if (flag == "NoOri"|| flag == "g" ) + { + (para_Formt01->sort)=1; + } + else if (flag == "help" || flag == "h") + { + More_Help1();return 0; + } + else + { + cerr << "UnKnow argument -"<input_file).empty() ) + { + cerr<< "lack argument for the must [-i] "<OutSamFile).empty() && (para_Formt01->OutBamFile).empty() ) + { + cerr<< "lack argument for the must [-s] or [-b] "<OutSamFile).empty() )) + { + (para_Formt01->OutSamFile)=add_Asuffix( para_Formt01->OutSamFile ); + } + else + { + if ((para_Formt01->Dict).empty()) + { + cerr<< "[-b] must together with [-d] "<OutBamFile); + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + if (ext != "bam") + { + (para_Formt01->OutBamFile)=path+".bam" ; + } + } + return 1 ; +} + + + + + +int soap2sam_mainfun ( Para_Formt01 * para_Formt01 ) +{ + ogzstream OUT ((para_Formt01->OutSamFile).c_str()); + if(!OUT.good()) + { + cerr << "open InputFile error: "<<(para_Formt01->OutSamFile)<Dict).empty()) + { + string path=(para_Formt01->Dict); + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + + if (ext=="dict") + { + Write_Sam_head (para_Formt01->Dict,OUT) ; + } + else + { + int AA=path.rfind('/') ==string::npos ? path.length() : path.rfind('/')+1 ; + string File_Pre =path.substr(0,AA ); + ext =path.substr(AA); + ext=replace_all(ext,".fasta.gz",""); + ext=replace_all(ext,".fasta",""); + ext=replace_all(ext,".fa.gz",""); + ext=replace_all(ext,".fa",""); + string newDictPath=File_Pre+ext+".dict"; + + if ( access(newDictPath.c_str(), 0) == 0 ) + { + Write_Sam_head (newDictPath , OUT) ; + } + else + { + string newDictPathV2=(para_Formt01->Dict)+".dict"; + if ( access(newDictPathV2.c_str(), 0) == 0 ) + { + Write_Sam_head (newDictPathV2 , OUT) ; + } + else + { + string newDictPathV3=(para_Formt01->Dict)+".chrlist"; + if ( access(newDictPathV3.c_str(), 0) == 0 ) + { + ifstream IN (newDictPathV3.c_str(),ifstream::in); + string line ; + getline(IN,line); + while(!IN.eof()) + { + getline(IN,line); + if (line.length()<=0) { continue ; } + vector inf; + split(line,inf," \t"); + OUT<<"@SQ\tSN:"<Dict).c_str(), "r"); + seq = kseq_init(fp); + while ((l = kseq_read(seq)) >= 0) + { + OUT<<"@SQ\tSN:"<<(seq->name.s)<<"\tLN:"<<(seq->seq.l)<shiftQ)==0) + { + + + + if (para_Formt01->sort) + { + char * A = const_cast((para_Formt01->input_file).c_str()); + //char * B = const_cast(tmpo.c_str()); + char * ssTmp[3]={(char *)"msort", (char *)"-k1", A }; + file_t *db; + string outPut ; + db=ReadParaAnd ( 3 , ssTmp , outPut) ; + sort_file_lines(db); + + SamLine *sam1 = new SamLine ; + SamLine *sam2 = new SamLine ; + SamLine *samtmp = new SamLine ; + + for(int i=0;iline_size;i++) + { + string line=db->lines[i].str ; + if ( soap2sam (line , para_Formt01 , sam1 )) + { + if ( (sam2->IF) && ( (sam1->RID) == (sam2->RID))) + { + mating( sam1 , sam2 ); + sam2->Print(OUT); sam2->rm(); + sam1->Print(OUT); sam1->rm(); + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + sam2->Print(OUT); + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + sam2->Print(OUT); sam2->rm(); + } + free_file_lines(db); + delete sam1 ; + delete sam2 ; + delete samtmp ; + } + else + { + igzstream IN ((para_Formt01->input_file).c_str(),ifstream::in); + + if(!IN.good()) + { + cerr << "open InputFile error: "<<(para_Formt01->input_file)<IF) && ( (sam1->RID) == (sam2->RID) )) + { + mating( sam1 , sam2 ); + sam2->Print(OUT); sam2->rm(); + sam1->Print(OUT); sam1->rm(); + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + sam2->Print(OUT); + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + sam2->Print(OUT); sam2->rm(); + } + + delete sam1 ; + delete sam2 ; + delete samtmp ; + IN.close(); + } + + + + + } + + else + { + + + + if (para_Formt01->sort) + { + char * A = const_cast((para_Formt01->input_file).c_str()); + char * ssTmp[3]={(char *)"msort", (char *)"-k1", A }; + file_t *db; + string outPut ; + db=ReadParaAnd ( 3 , ssTmp , outPut) ; + sort_file_lines(db); + + SamLine *sam1 = new SamLine ; + SamLine *sam2 = new SamLine ; + SamLine *samtmp = new SamLine ; + + for(int i=0;iline_size;i++) + { + string line=db->lines[i].str ; + if ( soap2samQ (line , para_Formt01 , sam1 )) + { + if ( (sam2->IF) && ( (sam1->RID) == (sam2->RID))) + { + mating( sam1 , sam2 ); + sam2->Print(OUT); sam2->rm(); + sam1->Print(OUT); sam1->rm(); + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + sam2->Print(OUT); + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + sam2->Print(OUT); sam2->rm(); + } + free_file_lines(db); + delete sam1 ; + delete sam2 ; + delete samtmp ; + } + else + { + igzstream IN ((para_Formt01->input_file).c_str(),ifstream::in); + + if(!IN.good()) + { + cerr << "open InputFile error: "<<(para_Formt01->input_file)<IF) && ( (sam1->RID) == (sam2->RID) )) + { + mating( sam1 , sam2 ); + sam2->Print(OUT); sam2->rm(); + sam1->Print(OUT); sam1->rm(); + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + sam2->Print(OUT); + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + sam2->Print(OUT); sam2->rm(); + } + + delete sam1 ; + delete sam2 ; + delete samtmp ; + IN.close(); + } + + + + } + + OUT.close(); + return 1; +} + + + + +int soap2bam_mainfun ( Para_Formt01 * para_Formt01 ) +{ + + htsFile *OUTBam = hts_open((para_Formt01->OutBamFile).c_str(), "wb"); + bam_hdr_t *header=NULL; + + string path=(para_Formt01->Dict); + + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + + if (ext=="dict") + { + ifstream IN (path.c_str(),ifstream::in); + kstring_t str = { 0, 0, NULL }; + while(!IN.eof()) + { + string line ; + getline(IN,line); + if (line.length()<=0) { continue ; } + kputs(line.c_str(), &str); + kputc('\n', &str); + } + IN.close(); + // if (str.l == 0) kputsn("", 0, &str); + header= sam_hdr_parse(str.l, str.s); + header->l_text = str.l; header->text = str.s; + header=sam_hdr_sanitise(header); + } + else + { + int AA=path.rfind('/') ==string::npos ? path.length() : path.rfind('/')+1 ; + string File_Pre =path.substr(0,AA); + ext =path.substr(AA); + ext=replace_all(ext,".fasta.gz",""); + ext=replace_all(ext,".fasta",""); + ext=replace_all(ext,".fa.gz",""); + ext=replace_all(ext,".fa",""); + ext=replace_all(ext,".dict",""); + string newDictPath=File_Pre+ext+".dict"; + if ( access(newDictPath.c_str(), 0) == 0 ) + { + + ifstream IN (newDictPath.c_str(),ifstream::in); + kstring_t str = { 0, 0, NULL }; + while(!IN.eof()) + { + string line ; + getline(IN,line); + if (line.length()<=0) { continue ; } + kputs(line.c_str(), &str); + kputc('\n', &str); + + } + IN.close(); + header= sam_hdr_parse(str.l, str.s); + header->l_text = str.l; header->text = str.s; + header=sam_hdr_sanitise(header); + } + + string newDictPathV2=(para_Formt01->Dict)+".dict"; + if ( access(newDictPathV2.c_str(), 0) == 0 ) + { + ifstream IN (newDictPathV2.c_str(),ifstream::in); + kstring_t str = { 0, 0, NULL }; + while(!IN.eof()) + { + string line ; + getline(IN,line); + if (line.length()<=0) { continue ; } + kputs(line.c_str(), &str); + kputc('\n', &str); + } + IN.close(); + header= sam_hdr_parse(str.l, str.s); + header->l_text = str.l; header->text = str.s; + header=sam_hdr_sanitise(header); + } + else + { + string newDictPathV3=(para_Formt01->Dict)+".chrlist"; + if ( access(newDictPathV3.c_str(), 0) == 0 ) + { + + ifstream IN (newDictPathV3.c_str(),ifstream::in); + kstring_t str = { 0, 0, NULL }; + string line ; + getline(IN,line); + while(!IN.eof()) + { + getline(IN,line); + if (line.length()<=0) { continue ; } + vector inf; + split(line,inf," \t"); + string Nline="@SQ\tSN:"+inf[0]+"\tLN:"+inf[1]+"\n"; + kputs(Nline.c_str(), &str); + } + IN.close(); + + header= sam_hdr_parse(str.l, str.s); + header->l_text = str.l; header->text = str.s; + header=sam_hdr_sanitise(header); + + } + else + { + header=Fa_hdr_read(para_Formt01->Dict); + } + } + } + + + if (sam_hdr_write(OUTBam, header) < 0) + { + fprintf(stderr, "Error writing output.\n"); + exit(-1); + } + + bam1_t *aln = bam_init1(); + + int tmp=0; + + + + if ( (para_Formt01->shiftQ)==0) + { + + + if (para_Formt01->sort) + { + char * A = const_cast((para_Formt01->input_file).c_str()); + //char * B = const_cast(tmpo.c_str()); + char * ssTmp[3]={(char *)"msort", (char *)"-k1", A }; + file_t *db; + string outPut ; + db=ReadParaAnd ( 3 , ssTmp , outPut) ; + sort_file_lines(db); + + SamLine *sam1 = new SamLine ; + SamLine *sam2 = new SamLine ; + SamLine *samtmp = new SamLine ; + string OutStrA ,OutStrB; + + for(int i=0;iline_size;i++) + { + string line=db->lines[i].str ; + if ( soap2sam (line , para_Formt01 , sam1 )) + { + if ( (sam2->IF) && ( (sam1->RID) == (sam2->RID))) + { + mating( sam1 , sam2 ); + + + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + + kstring_t str1 = { 0, 0, NULL }; + sam1->OUT2str(OutStrA); + kputs(OutStrA.c_str(), &str1); + sam2bam2( str1 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam1->rm(); + + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + } + free_file_lines(db); + delete sam1 ; + delete sam2 ; + delete samtmp ; + } + + else + { + igzstream IN ((para_Formt01->input_file).c_str(),ifstream::in); + + if(!IN.good()) + { + cerr << "open InputFile error: "<<(para_Formt01->input_file)<IF) && ( (sam1->RID) == (sam2->RID) )) + { + mating( sam1 , sam2 ); + + + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + + kstring_t str1 = { 0, 0, NULL }; + sam1->OUT2str(OutStrA); + kputs(OutStrA.c_str(), &str1); + sam2bam2( str1 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam1->rm(); + + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + } + + delete sam1 ; + delete sam2 ; + delete samtmp ; + IN.close(); + } + + + } + else + { + + + + + if (para_Formt01->sort) + { + char * A = const_cast((para_Formt01->input_file).c_str()); + //char * B = const_cast(tmpo.c_str()); + char * ssTmp[3]={(char *)"msort", (char *)"-k1", A }; + file_t *db; + string outPut ; + db=ReadParaAnd ( 3 , ssTmp , outPut) ; + sort_file_lines(db); + + SamLine *sam1 = new SamLine ; + SamLine *sam2 = new SamLine ; + SamLine *samtmp = new SamLine ; + string OutStrA ,OutStrB; + + for(int i=0;iline_size;i++) + { + string line=db->lines[i].str ; + if ( soap2samQ (line , para_Formt01 , sam1 )) + { + if ( (sam2->IF) && ( (sam1->RID) == (sam2->RID))) + { + mating( sam1 , sam2 ); + + + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + + kstring_t str1 = { 0, 0, NULL }; + sam1->OUT2str(OutStrA); + kputs(OutStrA.c_str(), &str1); + sam2bam2( str1 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam1->rm(); + + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + } + free_file_lines(db); + delete sam1 ; + delete sam2 ; + delete samtmp ; + } + + else + { + igzstream IN ((para_Formt01->input_file).c_str(),ifstream::in); + + if(!IN.good()) + { + cerr << "open InputFile error: "<<(para_Formt01->input_file)<IF) && ( (sam1->RID) == (sam2->RID) )) + { + mating( sam1 , sam2 ); + + + + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + + kstring_t str1 = { 0, 0, NULL }; + sam1->OUT2str(OutStrA); + kputs(OutStrA.c_str(), &str1); + sam2bam2( str1 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam1->rm(); + + } + else + { + if ((sam2->IF)) + { + sam2->Flag |= 0x8 ; + + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + + sam2->Flag |= 0x8 ; + } + samtmp->copy(sam2); + sam2->copy(sam1); + sam1->copy(samtmp); + } + } + } + + if ((sam2->IF)) + { + kstring_t str2 = { 0, 0, NULL }; + sam2->OUT2str(OutStrB); + kputs(OutStrB.c_str(), &str2); + sam2bam2( str2 , header , aln); + tmp=sam_write1(OUTBam, header, aln); + sam2->rm(); + } + + delete sam1 ; + delete sam2 ; + delete samtmp ; + IN.close(); + } + + + + + + + + } + + bam_hdr_destroy(header); + bam_destroy1(aln); + sam_close(OUTBam); + return 1; +} + + + + + +int soap2bam_main(int argc, char *argv[]) +{ + Para_Formt01 * para_Formt01 = new Para_Formt01; + if (parse_Acmd_Formt01(argc, argv , para_Formt01 )==0) + { + delete para_Formt01 ; + return 1; + } + + + if (!((para_Formt01->OutBamFile).empty())) + { + soap2bam_mainfun ( para_Formt01 ); + } + else + { + soap2sam_mainfun ( para_Formt01 ); + } + + delete para_Formt01 ; + return 0; + +} + + +///////// swimming in the sky and flying in the sea //////////// +// + + +#endif // soap2bam_H_ + + +////////////////////////swimming in the sea & flying in the sky ////////////////// + + + diff --git a/src/modify/bamAssign.h b/src/modify/bamAssign.h new file mode 100644 index 0000000..f10debd --- /dev/null +++ b/src/modify/bamAssign.h @@ -0,0 +1,520 @@ +#ifndef BamAssign_H_ +#define BamAssign_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; + +void BamAssign_help() +{ + cout<<"" + "\n" + "\tUsage: bamAssign -i -a -r\n" + "\tUsage: bamAssign -l -a \n" + "\n" + "\t\t-i input SAM/BAM files, delimited by space\n" + "\t\t-l input list of SAM/BAM/CRAM files\n" + "\t\t-a list indicating how to assign chromosomes to outputs\n" + "\n" + "\t\t-o output directory, default [PWD]\n" + "\t\t-q reads with quality lower than this would be classified to unmap.bam, default [10]\n" + "\t\t-r reset output files headers by remove the chromosomes not in the output files\n" + "\n" + "\t\t-h show more details for help [hewm2008 v1.02]\n" + "\n" + "\n"; +} + +void More_HelpBamAssign() +{ + cout<<"" + "\n" + "\t\t1. bamAssign -i -a -q Q -r\n" + "\t\t bamAssign -l -a -q Q -r\n" + "\t\t This will assign the chromosomes in the input SAM/BAM to different files according to the and output the results to current directory.\n" + "\t\t (1.1) -l lists the input files. For example, if user has two input files A.bam and B.bam, bam.list should be formatted as:\n" + "\t\t ./A.bam\n" + "\t\t ./B.bam\n" + "\t\t (1.2) Headers of the input SAM/BAMs should be the same.\n" + "\t\t (1.3) The indicates how to assign chromosomes to outputs. \n" + "\t\t For example, if there are 5 chromosomes (Chr1, Chr2, Chr3, Chr4, Chr5) in the input, and the is formatted as:\n" + "\t\t Chr1 AAA\n" + "\t\t Chr2 AAA\n" + "\t\t Chr3 BBB\n" + "\t\t Chr4 BBB\n" + "\t\t bamAssign would output the reads of Chr1 and Chr2 to the file named AAA and output the reads of Chr3 and Chr4 to the file BBB.\n" + "\t\t (1.4) Chromosomes not in the (like Chr5 in this example) would be outputted to a file named NaAss.bam.\n" + "\t\t (1.5) Both unmapped reads and reads with quality lower than Q (default value of Q is 10) would be outputted to file named UnMap.bam.\n" + "\t\t (1.6) With -r added, the header of the output SAM/BAM will keep its own chromosomes. As the example above, header of AAA would contain only Chr1 and Chr2. Without -r, the header of output would be the same as the header of input.\n" + "\n" + "\n"; +} + +int BamAssign_help01(int argc, char **argv , In3str1v * paraBamS ) +{ + if (argc <2 ) {BamAssign_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraBamS->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutDir" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InStr2=argv[i]; + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InInt=atoi(argv[i]); + } + else if (flag == "ReSetHead" || flag == "r") + { + paraBamS->TF=false ; + } + else if (flag == "chr2File" || flag == "a") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InStr3=argv[i]; + } + else if (flag == "help" || flag == "h") + { + More_HelpBamAssign();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr3).empty() ) + { + cerr<< "lack argument for the must"< chr2Int; + map outFile2Int; + map :: iterator Mapit ; + + igzstream LIST ((paraBamS->InStr3).c_str(),ifstream::in); // igzstream + if (!LIST.good()) + { + cerr << "open chr2outFile error: "<<(paraBamS->InStr3)< inf; + split(line,inf," \t"); + Mapit=outFile2Int.find(inf[1]); + if (Mapit!=outFile2Int.end()) + { + tmp=Mapit->second; + } + else + { + tmp=OutFileNum; + outFile2Int.insert( map :: value_type(inf[1],tmp)); + OutFileNum++; + } + + Mapit=chr2Int.find(inf[0]); + if (Mapit!=chr2Int.end()) + { + if ((Mapit->second)!=tmp) + { + + cerr<<"chr ID: "< :: value_type (inf[0],tmp) ); + } + + + } + LIST.close(); + + + + + + string BamPath=(paraBamS->List)[0]; + + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + + + htsFile *UUM; + string aaa=(paraBamS->InStr2)+"/UnMap.bam" ; + UUM=hts_open(aaa.c_str(), "wb"); + tmp=sam_hdr_write(UUM, header); + + + + map Int2IntMap ; + map :: iterator MapitInt ; + + tmp=OutFileNum; + for (int i=0; i<(header->n_targets) ; i++) + { + aaa=(header->target_name[i]); + Mapit=chr2Int.find(aaa); + if (Mapit!=chr2Int.end()) + { + Int2IntMap.insert(map :: value_type(i,Mapit->second)); + } + else + { + paraBamS->TF2=false; + Int2IntMap.insert( map :: value_type(i,tmp)); + cerr<<"warning :chr ID :"< :: value_type(aaa,tmp)); + } + } + + if (paraBamS->TF2) + { + } + else + { + OutFileNum++; + outFile2Int.insert(map :: value_type("NaAss",tmp)); + } + + + htsFile **OUTBam = new htsFile *[OutFileNum]; + + + if (paraBamS->TF) + { + for ( Mapit=outFile2Int.begin() ;Mapit!=outFile2Int.end() ; Mapit++) + { + + aaa=(paraBamS->InStr2)+"/"+(Mapit->first)+".bam" ; + OUTBam[(Mapit->second)]=hts_open(aaa.c_str(), "wb"); + tmp=sam_hdr_write(OUTBam[(Mapit->second)], header); + } + + + int FileNum=(paraBamS->List).size(); + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<= 0) + { + int i=(aln->core).tid ; + if ( ((aln->core).qual < (paraBamS->InInt)) || (i < 0 ) ) + { + int AA=bam_write1(UUM->fp.bgzf, aln); + } + else + { + MapitInt=Int2IntMap.find(i); + int AA=bam_write1(OUTBam[MapitInt->second]->fp.bgzf, aln); + } + } + sam_close(InBam); + bam_destroy1(aln); + + bam_hdr_destroy(headerA); + } + + + } + else + { + + + map ChangIDMap ; + + for ( Mapit=outFile2Int.begin() ;Mapit!=outFile2Int.end() ; Mapit++) + { + int Flag=0; + kstring_t str = { 0, 0, NULL }; + for ( MapitInt=Int2IntMap.begin() ; MapitInt!=Int2IntMap.end(); MapitInt++) + { + if ((MapitInt->second)==(Mapit->second)) + { + string chr=(header->target_name[MapitInt->first]); + int TR=(header->target_len[MapitInt->first]); + kputsn("@SQ\tSN:", 7, &str); + kputs(chr.c_str(), &str); + kputsn("\tLN:", 4, &str); + kputw(TR, &str); + kputc('\n', &str); + ChangIDMap.insert(map :: value_type(MapitInt->first,Flag)); + Flag++; + } + } + + aaa=(paraBamS->InStr2)+"/"+(Mapit->first)+".bam" ; + OUTBam[(Mapit->second)]=hts_open(aaa.c_str(), "wb"); + + bam_hdr_t *NewHeader; + NewHeader= sam_hdr_parse(str.l, str.s); + NewHeader->l_text = str.l; NewHeader->text = str.s; + NewHeader=sam_hdr_sanitise(NewHeader); + tmp=sam_hdr_write(OUTBam[(Mapit->second)], NewHeader); + bam_hdr_destroy(NewHeader); + + } + + + + + + + int FileNum=(paraBamS->List).size(); + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<= 0) + { + int i=(aln->core).tid ; + if ( ((aln->core).qual < (paraBamS->InInt)) || (i < 0 ) ) + { + tmp=bam_write1(UUM->fp.bgzf, aln); + } + else + { + + if ((aln->core).tid>=0) + { + MapitInt=ChangIDMap.find((aln->core).tid); + if (MapitInt!=ChangIDMap.end()) + { + (aln->core).tid=MapitInt->second; + } + else + { + (aln->core).tid=-1; + } + } + + if ((aln->core).mtid>=0) + { + MapitInt=ChangIDMap.find((aln->core).mtid); + if (MapitInt!=ChangIDMap.end()) + { + (aln->core).mtid=MapitInt->second; + } + else + { + (aln->core).mtid=-1; + } + } + + MapitInt=Int2IntMap.find(i); + tmp=bam_write1(OUTBam[MapitInt->second]->fp.bgzf, aln); + + } + } + sam_close(InBam); + bam_destroy1(aln); + + bam_hdr_destroy(headerA); + } + + + + + + + + + + + + + + + + } + + sam_close(UUM); + for (int i=0; iInInt=10; + paraBamS->InStr2="./" ; + if ((BamAssign_help01(argc, argv, paraBamS)==0)) + { + delete paraBamS ; + return 0 ; + } + + Assign2Bam( paraBamS ); + + delete paraBamS ; + return 0; +} +#endif // BamAssign_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/modify/bamCat.h b/src/modify/bamCat.h new file mode 100644 index 0000000..90250b6 --- /dev/null +++ b/src/modify/bamCat.h @@ -0,0 +1,659 @@ +#ifndef BamCat_H_ +#define BamCat_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; + +void BamCat_help() +{ + cout<<"" + "\n" + "\tUsage: bamCat -l -o -s\n" + "\tUsage: bamCat -i -o C.bam\n" + "\n" + "\t\t-i input SAM/BAM files, delimited by space\n" + "\t\t-l input list of SAM/BAM files\n" + "\t\t-o output BAM file\n" + "\n" + "\t\t-s output sort bam file when all inputs were sorted\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_Help_BamCat() +{ + cout<<"" + "\n" + "\t\t1. bamCat -i -o AAA\n" + "\t\t bamCat -i -o AAA -s\n" + "\t\t bamCat -l -o AAA\n" + "\t\t bamCat -l -o AAA -s\n" + "\t\t This will capture the input files into one file and output the result to a sorted BAM file named AAA in current directory.\n" + "\t\t (1.1) -i input files could be all BAM, all SAM or the mix of two.\n" + "\t\t (1.2) -l lists the input files. For example, if user has two input files A.bam and B.bam, bam.list should be formatted as:\n" + "\t\t ./A.bam\n" + "\t\t ./B.bam\n" + "\t\t (1.3) Input files could have different headers. If the input files have the same chromosome with different length, warning would be given and the longest length would be kept in the header for that chromosome.\n" + "\t\t (1.4) -s only works when the input files are sorted. Otherwise, the input files would be simply captured together.\n" + "\n"; +} + +int BamCat_help01(int argc, char **argv , In3str1v * paraBamS ) +{ + if (argc <2 ) {BamCat_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraBamS->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutFile" || flag == "o" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InStr2=argv[i]; + } + else if (flag == "Merge" || flag == "Sorted" || flag == "s") + { + paraBamS->TF=false; + } + else if (flag == "help" || flag == "h") + { + More_Help_BamCat();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InStr2); + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + if (ext != "bam") + { + (paraBamS->InStr2)=path+".bam" ; + } + + return 1 ; +} + + +void run_Aread ( samFile *InBam , int & position , int & chrID, htsFile *OUT , bam1_t *aln , bam_hdr_t *headerA ) +{ + int tmp=bam_write1(OUT->fp.bgzf, aln); + + for (int i =1 ; i>0 ; i++) + { + if (sam_read1(InBam, headerA, aln) >= 0) + { + if ((aln->core).pos<=position && (aln->core).tid == chrID ) + { + tmp=bam_write1(OUT->fp.bgzf, aln); + } + else + { + position=(aln->core).pos ; + chrID=(aln->core).tid; + break ; + } + } + else + { + position=-8; + chrID=-888; + break ; + } + } +} + + + +void run_Aread ( samFile *InBam , int & position , int & chrID, htsFile *OUT , bam1_t *aln , bam_hdr_t *headerA , map & ChrInfo ) +{ + string chrTmp ; + map :: iterator MapIt ; + + int tmp=bam_write1(OUT->fp.bgzf, aln); + + for (int i =1 ; i>0 ; i++) + { + if (sam_read1(InBam, headerA, aln) >= 0) + { + if ((aln->core).tid>=0) + { + chrTmp=(headerA->target_name[(aln->core).tid]); + MapIt=ChrInfo.find(chrTmp); + (aln->core).tid=MapIt->second; + } + + if ( (aln->core).mtid >=0 ) + { + chrTmp=((headerA)->target_name[(aln->core).mtid]); + MapIt=ChrInfo.find(chrTmp); + if (MapIt!=ChrInfo.end()) + { + (aln->core).mtid=MapIt->second; + } + else + { + (aln->core).mtid=-1; + } + } + + if ((aln->core).pos<=position && (aln->core).tid == chrID ) + { + tmp=bam_write1(OUT->fp.bgzf, aln); + } + else + { + position=(aln->core).pos ; + chrID=(aln->core).tid; + break ; + } + } + else + { + position=-8; + chrID=-888; + break ; + } + } +} + + +int chose_Afile ( const int Posi[] , const int ChrID[] , const int count ) +{ + + int IDD =-8888; + int i=0; + + for ( ; i ChrID[i]) + { + IDD=ChrID[i]; + } + } + } + + int min_Aflag=-1; + int start =-2 ; + for ( i=0 ; i -1 && Posi[i] List ) +{ + string BamPath=List[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + int FileNum=List.size(); + for (int ii=1 ; ii< FileNum ; ii++) + { + string line =List[ii]; + bam_hdr_t *headerA; + samFile *InBam = sam_open(line.c_str(), "r"); + headerA = sam_hdr_read(InBam); + sam_close(InBam); + + if ((header->n_targets)!=(headerA->n_targets)) + { + bam_hdr_destroy(header); + bam_hdr_destroy(headerA); + return false; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if ((strcmp(header->target_name[i],headerA->target_name[i])!=0) || ((header->target_len[i])!=(headerA->target_len[i]))) + { + NoSameBam=true; + break ; + } + } + if (NoSameBam) + { + bam_hdr_destroy(header); + bam_hdr_destroy(headerA); + return false; + } + bam_hdr_destroy(headerA); + } + + bam_hdr_destroy(header); + return true ; + +} + + + + +void bamCat_WithDiffHead(In3str1v *paraBamS ) +{ + + htsFile *OUT; + OUT=hts_open((paraBamS->InStr2).c_str(), "wb"); + + map ChrInfo ; + map :: iterator MapIt ; + + + int FileNum=(paraBamS->List).size(); + + + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue ; } + bam_hdr_t *headerA; + samFile *InBam = sam_open(line.c_str(), "r"); + headerA = sam_hdr_read(InBam); + bool NoSameBam=false; + for(int i = 0; i < (headerA->n_targets); i++) + { + string chr=headerA->target_name[i]; + int TR=headerA->target_len[i]; + MapIt=ChrInfo.find(chr); + if (MapIt==ChrInfo.end()) + { + ChrInfo.insert( map :: value_type (chr,TR)); + } + else + { + if ((MapIt->second)==TR) + { + continue ; + } + cerr << "Warning! chr name : "<second)<<" and "<second)second=TR; + } + } + } + bam_hdr_destroy(headerA); + sam_close(InBam); + } + + + kstring_t str = { 0, 0, NULL }; + // map Chr2Int ; + int Flag=0; + + for ( MapIt=ChrInfo.begin(); MapIt!=ChrInfo.end(); MapIt++) + { + kputsn("@SQ\tSN:", 7, &str); + kputs((MapIt->first).c_str(), &str); + kputsn("\tLN:", 4, &str); + kputw(MapIt->second, &str); + kputc('\n', &str); + MapIt->second= Flag ; + Flag++; + } + + bam_hdr_t *NewHeader; + NewHeader= sam_hdr_parse(str.l, str.s); + NewHeader->l_text = str.l; NewHeader->text = str.s; + NewHeader=sam_hdr_sanitise(NewHeader); + + int tmp=sam_hdr_write(OUT, NewHeader); + string chrTmp ; + if (paraBamS->TF) + { + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue ;} + cout <<"Begin Bam :"<= 0) + { + if ( (aln->core).tid>=0 ) + { + chrTmp=(headerA->target_name[(aln->core).tid]); + MapIt=ChrInfo.find(chrTmp); + (aln->core).tid=MapIt->second; + } + if ( (aln->core).mtid >=0 ) + { + chrTmp=((headerA)->target_name[(aln->core).mtid]); + MapIt=ChrInfo.find(chrTmp); + if (MapIt!=ChrInfo.end()) + { + (aln->core).mtid=MapIt->second; + } + else + { + (aln->core).mtid=-1; + } + + } + + tmp=bam_write1(OUT->fp.bgzf, aln); + } + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + } + else + { + + samFile **InBam = new samFile *[FileNum]; + bam_hdr_t **headerA =new bam_hdr_t *[FileNum]; + bam1_t **aln= new bam1_t *[FileNum]; + int *Posi=new int[FileNum] ; + int *ChrID=new int[FileNum] ; + + for (int ii=0 ; ii< FileNum ; ii++) + { + aln[ii]=bam_init1(); + InBam[ii]=sam_open((paraBamS->List)[ii].c_str(), "r"); + headerA[ii]=sam_hdr_read(InBam[ii]); + if (sam_read1(InBam[ii], headerA[ii], aln[ii]) >= 0) + { + if ( (aln[ii]->core).tid >=0 ) + { + chrTmp=((headerA[ii])->target_name[(aln[ii]->core).tid]); + MapIt=ChrInfo.find(chrTmp); + (aln[ii]->core).tid=MapIt->second; + } + + if ( (aln[ii]->core).mtid >=0 ) + { + chrTmp=((headerA[ii])->target_name[(aln[ii]->core).mtid]); + MapIt=ChrInfo.find(chrTmp); + + if (MapIt!=ChrInfo.end()) + { + (aln[ii]->core).mtid=MapIt->second; + } + else + { + (aln[ii]->core).mtid=-1; + } + + } + + ChrID[ii]=(aln[ii]->core).tid; + Posi[ii]=(aln[ii]->core).pos; + } + else + { + cerr<<"can Not read bam file : "<<(paraBamS->List)[ii]< -1 ) + { + run_Aread (InBam[file_Arun_Acout] , Posi[file_Arun_Acout] , ChrID[file_Arun_Acout], OUT , aln[file_Arun_Acout] ,headerA[file_Arun_Acout] , ChrInfo ); + file_Arun_Acout=chose_Afile(Posi ,ChrID , FileNum) ; + } + + for (int ii=0 ; ii< FileNum ; ii++) + { + sam_close(InBam[ii]); + bam_destroy1(aln[ii]); + bam_hdr_destroy(headerA[ii]); + + } + + + delete [] Posi; + delete [] ChrID; + delete [] InBam ; + delete [] aln ; + delete [] headerA ; + + } + + + sam_close(OUT); + bam_hdr_destroy(NewHeader); + +} + + + + + + + + +void bamCat_WithSameHead(In3str1v *paraBamS ) +{ + + htsFile *OUT; + OUT=hts_open((paraBamS->InStr2).c_str(), "wb"); + bam_hdr_t *NewHeader; + + + string BamPath=(paraBamS->List)[0]; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + NewHeader = sam_hdr_read(BamIn); + sam_close(BamIn); + + int tmp=sam_hdr_write(OUT, NewHeader); + string chrTmp ; + int FileNum=(paraBamS->List).size(); + + if (paraBamS->TF) + { + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue ;} + cout <<"Begin Bam :"<= 0) + { + tmp=bam_write1(OUT->fp.bgzf, aln); + } + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + } + else + { + + samFile **InBam = new samFile *[FileNum]; + bam_hdr_t **headerA =new bam_hdr_t *[FileNum]; + bam1_t **aln= new bam1_t *[FileNum]; + int *Posi=new int[FileNum]; + int *ChrID=new int[FileNum]; + + for (int ii=0 ; ii< FileNum ; ii++) + { + aln[ii]=bam_init1(); + InBam[ii]=sam_open((paraBamS->List)[ii].c_str(), "r"); + headerA[ii]=sam_hdr_read(InBam[ii]); + if (sam_read1(InBam[ii], headerA[ii], aln[ii]) >= 0) + { + ChrID[ii]=(aln[ii]->core).tid; + Posi[ii]=(aln[ii]->core).pos; + } + else + { + cerr<<"can Not read bam file : "<<(paraBamS->List)[ii]< -1 ) + { + run_Aread (InBam[file_Arun_Acout] , Posi[file_Arun_Acout] , ChrID[file_Arun_Acout], OUT , aln[file_Arun_Acout] ,headerA[file_Arun_Acout]); + file_Arun_Acout=chose_Afile(Posi ,ChrID , FileNum) ; + } + + for (int ii=0 ; ii< FileNum ; ii++) + { + sam_close(InBam[ii]); + bam_destroy1(aln[ii]); + bam_hdr_destroy(headerA[ii]); + } + + + delete [] Posi; + delete [] ChrID; + delete [] InBam ; + delete [] aln ; + delete [] headerA ; + + } + + + + sam_close(OUT); + bam_hdr_destroy(NewHeader); + + + +} + + +int bamCat_main(int argc, char *argv[]) +{ + In3str1v *paraBamS = new In3str1v; + + if ((BamCat_help01(argc, argv, paraBamS)==0)) + { + delete paraBamS ; + return 0; + } + + bool Samhead=ALL_same_header(paraBamS->List); + + + if (Samhead) + { + bamCat_WithSameHead( paraBamS ) ; + } + else + { + bamCat_WithDiffHead( paraBamS ) ; + } + + + + delete paraBamS ; + return 0; +} +#endif // BamCat_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/modify/bamFilter.h b/src/modify/bamFilter.h new file mode 100644 index 0000000..3e99900 --- /dev/null +++ b/src/modify/bamFilter.h @@ -0,0 +1,255 @@ +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include +#include +#include "../ALL/gzstream/gzstream.h" +using namespace std; +typedef long long llong ; + + +class Para_FF { + public: + string input_Sam ; + string OutPut ; + llong start ; + llong end ; + string chr; + int minLeng ; + int minMapQ ; + int maxHit ; + bool TF ; + + Para_FF() + { + start=0; + end=1000000000; + minLeng=30 ; + minMapQ =15 ; + maxHit=1 ; + TF=false; + chr=""; + } +}; + + +void print_Ausage_FF() +{ + cout<<"" + "\n" + "\tUsage: BamFilter -i -o \n" + "\n" + "\t\t-i input SAM/BAM file\n" + "\t\t-o output BAM file\n" + "\n" + "\t\t-q the quality to filter reads, default [15]\n" + "\t\t-l the length to filter reads, default [30]\n" + "\t\t-s the beginning of interval containing the 1-based leftmost mapping position of first matching base, default [0]\n" + "\t\t-e the end of interval containing the 1-based leftmost mapping position of first matching base, default [1e9]\n" + "\t\t-c specify the chromosome to output, default [all chromosomes]\n" + "\t\t-d remove the duplicate read\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_Help_FF() +{ + cout<<"" + "\n" + "\t\t1. BamFilter -i -o AAA\n" + "\t\t This will remove the aligned reads whose quality lower than 15 or length shorter than 30bp and output the reads left to the file named AAA in current directory.\n" + "\n" + "\t\t2. BamFilter -i -o AAA -q Q -l L -s S -e E -c ChrX\n" + "\t\t This will remove the aligned reads whose quality lower than Q or length shorter than L bp or the 1-based leftmost mapping position of first matching base does not locate within [S,E], and output the reads left of ChrX to the file named AAA in current directory.\n" + "\n"; +} + + +int parse_Acmd_FF(int argc, char **argv, Para_FF * para_FF) +{ + if (argc <2 ) {print_Ausage_FF();return 0;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InPut" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_FF->input_Sam=argv[i]; + } + else if (flag == "OutPut" || flag == "o" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_FF->OutPut=argv[i]; + } + else if (flag == "Chr" || flag == "c" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_FF->chr=argv[i]; + } + else if (flag == "MinMapQ" || flag == "q" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_FF->minMapQ=atoi(argv[i]); + } + else if (flag == "MinLeng" || flag == "l") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + para_FF->minLeng=atoi(argv[i]); + } + else if (flag == "End" || flag == "e") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_FF->end=atol(argv[i]); + } + else if (flag == "d") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_FF->TF=true; + } + else if (flag == "Start" || flag == "s") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_FF->start=atol(argv[i]); + } + else if (flag == "help" || flag == "h" ) + { + More_Help_FF();return 0; + } + else + { + cerr << "UnKnow argument -"<input_Sam).empty() || (para_FF->OutPut).empty() ) + { + cerr<< "lack argument for the must"<input_Sam).c_str(), "r"); + + samFile *outR1 = sam_open(para_FF->OutPut.c_str(), "wb"); + + header = sam_hdr_read(in); + + if (sam_hdr_write(outR1, header) < 0) + { + fprintf(stderr, "Error writing output.\n"); + exit(-1); + } + int tmp=0; + if (para_FF->TF) + { + while (sam_read1(in, header, aln) >= 0) + { + if ( (aln->core).qual < (para_FF->minMapQ) ) + { + continue ; + } + if ( (aln->core).pos < ((para_FF->start)) || (aln->core).pos > (para_FF->end) ) + { + continue ; + } + if ((aln->core).l_qseq < ( para_FF->minLeng )) + { + continue ; + } + if ( (aln->core).flag & 0x400 ) { continue ; } + + string chrID="*"; + if ((aln->core).tid >= 0) + { // chr + chrID=header->target_name[(aln->core).tid]; + } + + if (!(para_FF->chr).empty() && chrID!=(para_FF->chr)) + { + continue ; + } + + tmp=sam_write1(outR1, header, aln); + } + } + else + { + while (sam_read1(in, header, aln) >= 0) + { + if ( (aln->core).qual < (para_FF->minMapQ) ) + { + continue ; + } + if ( (aln->core).pos < ((para_FF->start)) || (aln->core).pos > (para_FF->end) ) + { + continue ; + } + if ((aln->core).l_qseq < ( para_FF->minLeng )) + { + continue ; + } + string chrID="*"; + if ((aln->core).tid >= 0) + { // chr + chrID=header->target_name[(aln->core).tid]; + } + + if (!(para_FF->chr).empty() && chrID!=(para_FF->chr)) + { + continue ; + } + + tmp=sam_write1(outR1, header, aln); + } + + } + + sam_close(in); + sam_close(outR1); + + + delete para_FF ; + return 0; +} + +///////// swimming in the sky and flying in the sea //////////// diff --git a/src/modify/bamLimit.h b/src/modify/bamLimit.h new file mode 100644 index 0000000..2f31c0a --- /dev/null +++ b/src/modify/bamLimit.h @@ -0,0 +1,179 @@ + +#ifndef BamLimit_H_ +#define BamLimit_H_ + + +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +using namespace std; +typedef long long llong ; + +/* + int print_usage_Limit() + { + cout <<"" + "\n" + "\tUsage: bamLimit -InPut -OutPut \n" + "\n" + "\t\t-InPut InPut sam/bam File\n" + "\t\t-OutDir OutPut bam OutFix\n" + "\n" + "\t\t-MaxNum Max Read Number for each bam[1000000000]\n" + "\n" + "\t\t-help show this help\n" + "\n"; + return 1; + } + */ + +void print_usage_Limit() +{ + cout<<"" + "\n" + "\tUsage: bamLimit -i -o ./\n" + "\n" + "\t\t-i input SAM/BAM file\n" + "\t\t-o output directory, default [PWD]\n" + "\n" + "\t\t-n max read number for each bam[1000000000]\n" + "\n" + "\t\t-h show more details for help\n" + "\n" + "\n"; +} + +void More_print_usage_Limit() +{ + cout<<"" + "\n" + "\t\t1. bamLimit -i -o ./ -n N\n" + "\t\tThis will split the input BAM file and output the splitting files in current directory. Each output has at most N reads, default value of N is 1000000000.\n" + "\n" + "\n" + "\n"; +} + +int parse_Acmd_Limit(int argc, char **argv, In3str1v * para_Xam04 ) +{ + if (argc <2 ) {print_usage_Limit();return 0;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InPut" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->InStr1=argv[i]; + } + else if (flag == "OutDir") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam04->InStr2=argv[i]; + } + else if (flag == "MaxNum") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam04->InInt=atoi(argv[i]); + } + else if (flag == "help" || flag == "h") + { + More_print_usage_Limit();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr1).empty() || (para_Xam04->InStr2).empty() ) + { + cerr<< "lack argument for the must"<InInt=1000000000; + if (parse_Acmd_Limit(argc, argv , para_Xam04 )==0) + { + delete para_Xam04 ; + return 0 ; + } + + bam_hdr_t *header; + bam1_t *aln = bam_init1(); + samFile *in = sam_open((para_Xam04->InStr1).c_str(), "r"); + + + header = sam_hdr_read(in); + string AAOUT=(para_Xam04->InStr2)+".1.bam"; + samFile *outR1 = sam_open(AAOUT.c_str(), "wb"); + if (sam_hdr_write(outR1, header) < 0) + { + fprintf(stderr, "Error writing output.\n"); + exit(-1); + } + int X=0; + int Flag=0; + int Cout=1; + + while (sam_read1(in, header, aln) >= 0) + { + if (Flag>=(para_Xam04->InInt)) + { + Flag=0; + sam_close(outR1); + Cout++; + string AAOUT=(para_Xam04->InStr2)+"."+Int2Str(Cout)+".bam"; + outR1 = sam_open(AAOUT.c_str(), "wb"); + if (sam_hdr_write(outR1, header) < 0) + { + fprintf(stderr, "Error writing output.\n"); + exit(-1); + } + X=sam_write1(outR1, header, aln); + Flag++; + } + else + { + X=sam_write1(outR1, header, aln); + Flag++; + } + } + + sam_close(in); + sam_close(outR1); + + + delete para_Xam04 ; + return 0; +} +#endif +///////// swimming in the sky and flying in the sea //////////// diff --git a/src/modify/bamRand.h b/src/modify/bamRand.h new file mode 100644 index 0000000..bd160ce --- /dev/null +++ b/src/modify/bamRand.h @@ -0,0 +1,152 @@ +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +using namespace std; +typedef long long llong ; + + +void print_Ausage_Xam04() +{ + cout<<"" + "\n" + "\tUsage: bamRand -i -o \n" + "\n" + "\t\t-i input SAM/BAM file\n" + "\t\t-o output BAM file\n" + "\n" + "\t\t-p probability with which each read would be outputed, default [0.1]\n" + "\t\t-s random seed, default [time]\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_Help_bamRand() +{ + cout<<"" + "\n" + "\t\t1. bamRand -i -p X -o AAA\n" + "\t\t For each read in input SAM/BAM, they would be output into a file named AAA with a probability X (default 0.1) in current directory.\n" + "\n"; +} + + +int parse_Acmd_Xam04(int argc, char **argv, In3str1v * para_Xam04 ) +{ + if (argc <2 ) {print_Ausage_Xam04();return 0;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InPut" || flag == "i" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->InStr1=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam04->InStr2=argv[i]; + } + else if (flag == "seed" || flag == "s") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam04->InInt=atoi(argv[i]); + } + else if (flag == "proportion" || flag == "p") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->InF=atof(argv[i]); + } + else if (flag == "help" || flag == "h") + { + More_Help_bamRand();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr1).empty() || (para_Xam04->InStr2).empty() ) + { + cerr<< "lack argument for the must"<InF=0.1; + if (parse_Acmd_Xam04(argc, argv , para_Xam04 )==0) + { + delete para_Xam04 ; + return 0 ; + } + + bam_hdr_t *header; + bam1_t *aln = bam_init1(); + samFile *in = sam_open((para_Xam04->InStr1).c_str(), "r"); + + samFile *outR1 = sam_open(para_Xam04->InStr2.c_str(), "wb"); + + header = sam_hdr_read(in); + + if (sam_hdr_write(outR1, header) < 0) + { + fprintf(stderr, "Error writing output.\n"); + exit(-1); + } + + if (para_Xam04->InInt==0) + { + srand((unsigned)time(NULL)); + } + else + { + srand(para_Xam04->InInt); + } + + int Y=int(para_Xam04->InF*100); + int X=0; + + while (sam_read1(in, header, aln) >= 0) + { + X=(rand()%100); + if (X>Y) { continue; } + X=sam_write1(outR1, header, aln); + } + sam_close(in); + sam_close(outR1); + + + delete para_Xam04 ; + return 0; +} + +///////// swimming in the sky and flying in the sea //////////// diff --git a/src/modify/bamShiftQ.h b/src/modify/bamShiftQ.h new file mode 100644 index 0000000..8e12b59 --- /dev/null +++ b/src/modify/bamShiftQ.h @@ -0,0 +1,280 @@ +#ifndef BamShiftQ_H_ +#define BamShiftQ_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/dealfun.cpp" +#include +#include +#include + +using namespace std; +typedef long long llong ; + + +void print_Ausage_shiftQ() +{ + cout<<"" + "\n" + "\tUsage: BamShiftQ -i -o \n" + "\n" + "\t\t-i input SAM/BAM file\n" + "\t\t-o output BAM file\n" + "\n" + "\t\t-p phred quality in output BAM, [1]: ASCII+33 or [2]: ASCII+64, default [1]\n" + "\t\t-q the quality to filter reads, default [10]\n" + "\t\t-l the length to filter reads, default [30]\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_Help_shiftQ() +{ + cout<<"" + "\n" + "\t\t1. bamShiftQ -i -o AAA -p 1\n" + "\t\t This will set the phred quality of output file to ASCII 33 and output the results to a file named AAA in current directory. If the input file is already in ASCII 33 quality system, ShiftQ would ask the user if they still want to continue.\n" + "\n"; +} + + +int parse_Acmd_Xam04(int argc, char **argv, Para_FF * para_Xam04) +{ + if (argc <2 ) {print_Ausage_shiftQ();return 0;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-","") ; + + if (flag == "InPut" || flag =="i" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->input_Sam=argv[i]; + } + else if (flag == "OutPut" || flag =="o") + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam04->OutPut=argv[i]; + } + else if (flag == "MinMapQ" || flag =="q") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->minMapQ=atoi(argv[i]); + } + else if (flag == "MinLeng" || flag =="l") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + para_Xam04->minLeng=atoi(argv[i]); + } + else if (flag == "PhredQ" || flag =="p") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + para_Xam04->maxHit=atoi(argv[i]); + } + else if (flag == "help" || flag =="h") + { + More_Help_shiftQ();return 0; + } + else + { + cerr << "UnKnow argument -"<input_Sam).empty() || (para_Xam04->OutPut).empty() ) + { + cerr<< "lack argument for the must"<OutPut); + + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + + if (ext != "bam") + { + (para_Xam04->OutPut)=path+".bam"; + } + + return 1 ; + + +} + + +//programme entry +///////// swimming in the sky and flying in the sea //////////// +//int main(int argc, char **argv) +int bam_ShiftQ_main(int argc, char **argv) +{ + Para_FF * para_Xam04 = new Para_FF; + if (parse_Acmd_Xam04(argc, argv , para_Xam04 )==0) + { + delete para_Xam04 ; + return 0 ; + } + + samFile *outR1 = sam_open(para_Xam04->OutPut.c_str(), "wb"); + + + + int ASCII_raw=Get_qual_Data ( (para_Xam04->input_Sam) ); + + + + bam_hdr_t *header_SS; + bam1_t *aln_SS = bam_init1(); + samFile *in_SS = sam_open((para_Xam04->input_Sam).c_str(), "r"); + + + header_SS = sam_hdr_read(in_SS); + + if (sam_hdr_write(outR1, header_SS) < 0) + { + fprintf(stderr, "Error writing output.\n"); + exit(-1); + } + int tmp=1; + if (( para_Xam04->maxHit)==1 && (ASCII_raw!=0) ) + { + cout <<"PhredQ : ASCII+64 ---> ASCII+33 "<= 0) ) + { + if ( (aln_SS->core).qual < (para_Xam04->minMapQ) ) + { + continue ; + } + if ((aln_SS->core).l_qseq < ( para_Xam04->minLeng )) + { + continue ; + } + uint8_t * seqQ=bam_get_qual(aln_SS); + for(int i=0; i < (aln_SS->core).l_qseq ; i++) + { + seqQ[i]-=ASCII_raw ; + } + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + else if ( ( para_Xam04->maxHit)!=1 && (ASCII_raw==0) ) + { + cout <<"PhredQ : ASCII+33 ---> ASCII+64 "<= 0) ) + { + if ( (aln_SS->core).qual < (para_Xam04->minMapQ) ) + { + continue ; + } + if ((aln_SS->core).l_qseq < ( para_Xam04->minLeng )) + { + continue ; + } + uint8_t * seqQ=bam_get_qual(aln_SS); + for(int i=0; i < (aln_SS->core).l_qseq ; i++) + { + seqQ[i]+=31 ; + } + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + else + // if ( ( para_Xam04->maxHit)==1 && (ASCII_raw==0) ) + { + if (( para_Xam04->maxHit)==1 ) + { + + cout <<"PhredQ : ASCII+33 ---> ASCII+33\n Do you want to write out [y/n] "< ASCII+64\n Do you want to write out [y/n] "<OutPut); + std::system(cc.c_str()) ; + cout <<"you can use linux command :\t ln -s "<<(para_Xam04->input_Sam)<<"\t"<OutPut<= 0) ) + { + if ( (aln_SS->core).qual < (para_Xam04->minMapQ) ) + { + continue ; + } + if ((aln_SS->core).l_qseq < ( para_Xam04->minLeng )) + { + continue ; + } + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + + + sam_close(in_SS); + + sam_close(outR1); + bam_destroy1(aln_SS); + bam_hdr_destroy(header_SS); + + delete para_Xam04 ; + return 0; +} +#endif +///////// swimming in the sky and flying in the sea //////////// diff --git a/src/modify/bamSplit.h b/src/modify/bamSplit.h new file mode 100644 index 0000000..9b46515 --- /dev/null +++ b/src/modify/bamSplit.h @@ -0,0 +1,539 @@ +#ifndef BamSplit_H_ +#define BamSplit_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; + + +void BamSplit_help() +{ + cout<<"" + "\n" + "\tUsage: bamSplit -l \n" + "\tUsage: bamSplit -i \n" + "\n" + "\t\t-i input SAM/BAM files, delimited by space \n" + "\t\t-l input list of SAM/BAM files\n" + "\n" + "\t\t-o output directory, default [PWD]\n" + "\t\t-s to set the output files in SAM format, default output is in BAM format.\n" + "\t\t-q reads with quality lower than this would be classified to unmap.bam, default [10]\n" + "\t\t-r reset output files headers by remove the chromosomes not in the output files\n" + "\n" + "\t\t-h show more details for help [hewm2008 v1.04]\n" + "\n"; +} + + +void More_HelpBamSplit() +{ + cout<<"" + "\n" + "\t\t1. bamSplit -i -q Q\n" + "\t\t This will split A.bam and B.bam by chromosome and output the splitting BAM files to current directory.\n" + "\t\t (1.1) A.bam and B.bam should have same header.\n" + "\t\t (1.2) The splitting files would keep the same headers as input files.\n" + "\t\t (1.3) Reads in A.bam and B.bam with quality lower than Q would be outputted to the file unmap.bam.\n" + "\n" + "\t\t2. bamSplit -l -r -s \n" + "\t\t This will split the files in bam.list by chromosome and output the splitting SAM files to current directory.\n" + "\t\t (2.1) files in bam.list should have same header. \n" + "\t\t For example, if user has two BAM files A.bam and B.bam to split, bam.list should be formatted as:\n" + "\t\t ./A.bam\n" + "\t\t ./B.bam\n" + "\t\t (2.2) with -s added, the output files would be compressed SAM files.\n" + "\t\t (2.3) with -r added, the header of each output file would keep its own chromosome.\n" + "\n"; +} + + + +int BamSplit_help01(int argc, char **argv , In3str1v * paraBamS ) +{ + if (argc <2 ) {BamSplit_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraBamS->List))); + } + else if (flag == "InFile" || flag == "i" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutDir" || flag == "o" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InStr2=argv[i]; + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InInt=atoi(argv[i]); + } + else if (flag == "ReSetHead" || flag == "r") + { + paraBamS->TF=true ; + } + else if (flag == "OutSam" || flag == "s" ) + { + paraBamS->TF2=false ; + } + else if (flag == "help" || flag == "h") + { + More_HelpBamSplit();return 0; + } + else + { + cerr << "UnKnow argument -"<List)[0]; + + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + ogzstream *Soap2Chr = new ogzstream[(header->n_targets)]; + ogzstream UnMapOut ; + string UUUtmp=(paraBamS->InStr2)+"/Unmap.sam.gz"; + UnMapOut.open(UUUtmp.c_str()); + for (int j=0; j<(header->n_targets) ; j++) + { + UnMapOut<<"@SQ\tSN:"<<(header->target_name[j])<<"\tLN:"<<(header->target_len[j])<TF)) + { + + for (int i=0; i<(header->n_targets) ; i++) + { + string aaa=(paraBamS->InStr2)+"/"+(header->target_name[i])+".sam.gz" ; + Soap2Chr[i].open(aaa.c_str()); + if (!Soap2Chr[i].good()) + { + cerr<<"Can't open follow output:\n"<n_targets) ; j++) + { + Soap2Chr[i]<<"@SQ\tSN:"<<(header->target_name[j])<<"\tLN:"<<(header->target_len[j])<n_targets) ; i++) + { + string aaa=(paraBamS->InStr2)+"/"+(header->target_name[i])+".sam.gz" ; + Soap2Chr[i].open(aaa.c_str()); + if (!Soap2Chr[i].good()) + { + cerr<<"Can't open follow output:\n"<target_name[i])<<"\tLN:"<<(header->target_len[i])<List).size(); + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue ; } + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<= 0) + { + kstring_t Kstr = { 0, 0, NULL }; + int A=sam_format1(header, aln, &Kstr); + + if ( ((aln->core).tid < 0) || (aln->core).qual < (paraBamS->InInt) ) + { + UnMapOut<core).tid]<n_targets) ; i++) + { + Soap2Chr[i].close() ; + } + + bam_hdr_destroy(header); + delete [] Soap2Chr ; + + return 1 ; +} + + + + +int Split2Bam( In3str1v * paraBamS ) +{ + + string BamPath=(paraBamS->List)[0]; + + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + htsFile **OUTBam = new htsFile *[(header->n_targets)]; + bam_hdr_t **OUTheader= new bam_hdr_t *[(header->n_targets)]; + + htsFile *UUM; + string aaa=(paraBamS->InStr2)+"/UnMap.bam" ; + UUM=hts_open(aaa.c_str(), "wb"); + int tmp=sam_hdr_write(UUM, header); + + + for (int i=0; i<(header->n_targets) ; i++) + { + string aaa=(paraBamS->InStr2)+"/"+(header->target_name[i])+".bam" ; + OUTBam[i]=hts_open(aaa.c_str(), "wb"); + OUTheader[i]=NULL; + + kstring_t str = { 0, 0, NULL }; + kputsn("@SQ\tSN:", 7, &str); + kputs((header->target_name[i]), &str); + kputsn("\tLN:", 4, &str); + kputw(header->target_len[i], &str); + kputc('\n', &str); + + OUTheader[i]= sam_hdr_parse(str.l, str.s); + OUTheader[i]->l_text = str.l; OUTheader[i]->text = str.s; + OUTheader[i]=sam_hdr_sanitise(OUTheader[i]); + if (sam_hdr_write(OUTBam[i], OUTheader[i]) < 0) + { + cerr<<"Can't Write bam Header:\n"<List).size(); + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<= 0) + { + int32_t i=(aln->core).tid ; + if ( ((aln->core).qual < (paraBamS->InInt)) || (i < 0 ) ) + { + int AA=bam_write1(UUM->fp.bgzf, aln); + } + else + { + + if ((aln->core).tid==(aln->core).mtid) + { + (aln->core).mtid=0; + } + else if ( (aln->core).mtid >0 ) + { + (aln->core).mtid=-1; + } + (aln->core).tid=0; + + int AA=bam_write1(OUTBam[i]->fp.bgzf, aln); + } + } + sam_close(InBam); + bam_destroy1(aln); + + bam_hdr_destroy(headerA); + } + + + sam_close(UUM); + for (int i=0; i<(header->n_targets) ; i++) + { + sam_close(OUTBam[i]); + bam_hdr_destroy(OUTheader[i]); + } + + bam_hdr_destroy(header); + delete [] OUTheader ; + delete [] OUTBam ; + return 1 ; +} + + + + + +int Split2BamSameHeader( In3str1v * paraBamS ) +{ + + string BamPath=(paraBamS->List)[0]; + + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + htsFile **OUTBam = new htsFile *[(header->n_targets)]; + + htsFile *UUM; + string aaa=(paraBamS->InStr2)+"/UnMap.bam" ; + UUM=hts_open(aaa.c_str(), "wb"); + int tmp=sam_hdr_write(UUM, header); + + for (int i=0; i<(header->n_targets) ; i++) + { + aaa=(paraBamS->InStr2)+"/"+(header->target_name[i])+".bam" ; + OUTBam[i]=hts_open(aaa.c_str(), "wb"); + if (sam_hdr_write(OUTBam[i], header) < 0) + { + cerr<<"Can't Write bam Header:\n"<List).size(); + for (int ii=0 ; ii< FileNum ; ii++) + { + string line =(paraBamS->List)[ii]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<= 0) + { + int32_t i=(aln->core).tid ; + if (( (aln->core).qual < (paraBamS->InInt) ) || (i < 0 )) + { + int A=bam_write1(UUM->fp.bgzf, aln); + } + else + { + int A=bam_write1(OUTBam[i]->fp.bgzf, aln); + } + } + sam_close(InBam); + bam_destroy1(aln); + + bam_hdr_destroy(headerA); + } + + sam_close(UUM); + + for (int i=0; i<(header->n_targets) ; i++) + { + sam_close(OUTBam[i]); + } + + bam_hdr_destroy(header); + delete [] OUTBam ; + return 1 ; +} + + + + + + + + +int bamSplit_main(int argc, char *argv[]) +{ + In3str1v *paraBamS = new In3str1v; + paraBamS->InInt=10; + paraBamS->TF=false ; + paraBamS->InStr2="./" ; + if ((BamSplit_help01(argc, argv, paraBamS)==0)) + { + delete paraBamS ; + return 0 ; + } + + if (paraBamS->TF2) + { + if (paraBamS->TF) + { + Split2Bam( paraBamS ); + } + else + { + Split2BamSameHeader( paraBamS ); + } + } + else + { + Split2Sam( paraBamS ); + } + + delete paraBamS ; + return 0; +} +#endif // BamSplit_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/modify/bamSubChr.h b/src/modify/bamSubChr.h new file mode 100644 index 0000000..57b7380 --- /dev/null +++ b/src/modify/bamSubChr.h @@ -0,0 +1,414 @@ +#ifndef BamSubChr_H_ +#define BamSubChr_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include + +using namespace std; +typedef long long llong ; + + +void print_SubChr_Usage() +{ + cout<<"" + "\n" + "\tUsage: bamSubChr -i -d -o \n" + "\tUsage: bamSubChr -i -k -o \n" + "\n" + "\t\t-i input SAM/BAMi file\n" + "\t\t-o output BAM file\n" + "\n" + "\t\t-k list of chromosomes to be kept\n" + "\t\t-d list of chromosomes to be deleted\n" + "\n" + "\t\t-u remove unmapped reads\n" + "\t\t-r reset output headers by remove the chr(s) not in the out files\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + + +void More_HelpSubChr() +{ + cout<<"" + "\n" + "\t\t1. bamSubChr -i -d -o AAA -r\n" + "\t\t This will remove the chromosome(s) in the delete.list from input SAM/BAM and output the reads left to a file named AAA in current directory. For example, if user would like to remove Chr1 and Chr2 from input BAM file, the delete.list would be formatted as:\n" + "\t\t Chr1\n" + "\t\t Chr2\n" + "\t\t The header of the output SAM/BAM will also remove the name(s) of the chromosome(s) in the delete.list. As the example above, Chr1 and Chr2 would not show up in the header of output file.\n" + "\n" + "\t\t2. bamSubChr -i -k -o AAA -r\n" + "\t\t This will extract the chromosome(s) in the keep.list from input SAM/BAM and output them to a file named AAA in current directory. keep.list is formatted in the same way as delete.list shown above.\n" + "\n" + "\t\t3. bamSubChr -i -o AAA -u\n" + "\t\t This will remove the unmapped reads from input SAM/BAM and output the reads left to a file named AAA in current directory.\n" + "\n"; +} + + +int parse_Acmd_SubChr(int argc, char **argv, In3str1v * para_Xam04) +{ + if (argc <2 ) {print_SubChr_Usage();return 0;} + + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-","") ; + + if (flag == "InPut" || flag == "i" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->InStr1=argv[i]; + } + else if (flag == "OutPut" || flag == "o" ) + { + if(i + 1 == argc) {LogLackArg(flag);return 0; } + i++; + para_Xam04->InStr2=argv[i]; + } + else if (flag == "KeepList" || flag == "k") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->InStr3=(argv[i]); + para_Xam04->InInt=(para_Xam04->InInt) | 0x1; + } + else if (flag == "RmList" || flag == "d") + { + if(i + 1 == argc) {LogLackArg(flag);return 0;} + i++; + para_Xam04->InStr3=(argv[i]); + para_Xam04->InInt=(para_Xam04->InInt) | 0x2; + } + else if (flag == "ReSetHead" || flag == "r") + { + para_Xam04->TF=false; + } + else if (flag == "RmUnmap" || flag == "u") + { + para_Xam04->TF2=false; + } + else if (flag == "help" || flag == "h") + { + More_HelpSubChr();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr1).empty() || (para_Xam04->InStr2).empty() || (para_Xam04->InStr3).empty() ) + { + cerr<< "lack argument for the must"<InInt==3) + { + cerr<< "Para [ -RmList ] and [ -KeepList ] can not use together"<InInt==0) + { + cerr<< "One of Para [ -RmList ] and [ -KeepList ] must be seted"<InStr2); + + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + + if (ext != "bam") + { + (para_Xam04->InStr2)=path+".bam"; + } + + return 1 ; + + +} + + +//programme entry +///////// swimming in the sky and flying in the sea //////////// +//int main(int argc, char **argv) +int bam_SubChr_main(int argc, char **argv) +{ + In3str1v * para_Xam04 = new In3str1v; + if (parse_Acmd_SubChr(argc, argv , para_Xam04 )==0) + { + delete para_Xam04; + return 0; + } + + samFile *outR1 = sam_open(para_Xam04->InStr2.c_str(), "wb"); + + + + bam_hdr_t *header_SS; + bam1_t *aln_SS = bam_init1(); + samFile *in_SS = sam_open((para_Xam04->InStr1).c_str(), "r"); + + + header_SS = sam_hdr_read(in_SS); + + + igzstream LIST (para_Xam04->InStr3.c_str(),ifstream::in); // igzstream + + int soapfilecout=0; + if (!LIST.good()) + { + cerr << "open List error: "<InStr3< ChrInfo; + + + while(!LIST.eof()) + { + string line ; + getline(LIST,line); + if (line.length()<=0) { continue ; } + ChrInfo.insert( map :: value_type (line,-1)); + soapfilecout++; + } + LIST.close(); + + + string chrID ; + int tmp=1; + + if ( para_Xam04->TF ) + { + if (sam_hdr_write(outR1, header_SS) < 0) + { + fprintf(stderr, "Error writing output.\n"); + exit(-1); + } + + + if ( (para_Xam04->InInt)==1 ) + { + while((sam_read1(in_SS, header_SS, aln_SS) >= 0)) + { + if ((aln_SS->core).tid >= 0) + { // chr + chrID=header_SS->target_name[(aln_SS->core).tid]; + if (ChrInfo.find(chrID)!=ChrInfo.end()) + { + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + } + } + else + { + while((sam_read1(in_SS, header_SS, aln_SS) >= 0)) + { + if ((aln_SS->core).tid >= 0) + { // chr + chrID=header_SS->target_name[(aln_SS->core).tid]; + if (ChrInfo.find(chrID)==ChrInfo.end()) + { + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + else + { + if (para_Xam04->TF2) + { + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + } + } + + } + + + else + { + + + kstring_t str = { 0, 0, NULL }; + map :: iterator MapIt ; + int Flag=0; + + if ( (para_Xam04->InInt)==1) + { + for(int i = 0; i < (header_SS->n_targets); i++) + { + string chr=header_SS->target_name[i]; + int TR=header_SS->target_len[i]; + MapIt=ChrInfo.find(chr); + if (MapIt!=ChrInfo.end()) + { + kputsn("@SQ\tSN:", 7, &str); + kputs((MapIt->first).c_str(), &str); + kputsn("\tLN:", 4, &str); + kputw(TR, &str); + kputc('\n', &str); + MapIt->second= Flag ; + Flag++; + } + } + + + + bam_hdr_t *NewHeader; + NewHeader= sam_hdr_parse(str.l, str.s); + NewHeader->l_text = str.l; NewHeader->text = str.s; + NewHeader=sam_hdr_sanitise(NewHeader); + tmp=sam_hdr_write(outR1, NewHeader); + bam_hdr_destroy(NewHeader); + + while((sam_read1(in_SS, header_SS, aln_SS) >= 0)) + { + if ((aln_SS->core).tid >= 0) + { // chr + chrID=header_SS->target_name[(aln_SS->core).tid]; + MapIt=ChrInfo.find(chrID); + if (MapIt!=ChrInfo.end()) + { + (aln_SS->core).tid=MapIt->second; + if ((aln_SS->core).mtid>=0) + { + chrID=header_SS->target_name[(aln_SS->core).mtid]; + MapIt=ChrInfo.find(chrID); + if (MapIt!=ChrInfo.end()) + { + (aln_SS->core).mtid=MapIt->second; + } + else + { + (aln_SS->core).mtid=-1; + } + } + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + } + + + + } + else + { + + + map NewChangID ; + for(int i = 0; i < (header_SS->n_targets); i++) + { + string chr=header_SS->target_name[i]; + int TR=header_SS->target_len[i]; + MapIt=ChrInfo.find(chr); + if (MapIt==ChrInfo.end()) + { + kputsn("@SQ\tSN:", 7, &str); + kputs(chr.c_str(), &str); + kputsn("\tLN:", 4, &str); + kputw(TR, &str); + kputc('\n', &str); + NewChangID.insert( map :: value_type (chr,Flag)); + Flag++; + } + } + + + bam_hdr_t *NewHeader; + + NewHeader= sam_hdr_parse(str.l, str.s); + NewHeader->l_text = str.l; NewHeader->text = str.s; + NewHeader=sam_hdr_sanitise(NewHeader); + tmp=sam_hdr_write(outR1, NewHeader); + bam_hdr_destroy(NewHeader); + + while((sam_read1(in_SS, header_SS, aln_SS) >= 0)) + { + if ((aln_SS->core).tid >= 0) + { // chr + chrID=header_SS->target_name[(aln_SS->core).tid]; + + MapIt=NewChangID.find(chrID); + if (MapIt!=NewChangID.end()) + { + (aln_SS->core).tid=MapIt->second; + if ((aln_SS->core).mtid>=0) + { + chrID=header_SS->target_name[(aln_SS->core).mtid]; + MapIt=NewChangID.find(chrID); + if (MapIt!=NewChangID.end()) + { + (aln_SS->core).mtid=MapIt->second; + } + else + { + (aln_SS->core).mtid=-1; + } + } + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + else + { + if (para_Xam04->TF2) + { + if ((aln_SS->core).mtid>=0) + { + chrID=header_SS->target_name[(aln_SS->core).mtid]; + MapIt=NewChangID.find(chrID); + if (MapIt!=NewChangID.end()) + { + (aln_SS->core).mtid=MapIt->second; + } + else + { + (aln_SS->core).mtid=-1; + } + } + tmp=bam_write1(outR1->fp.bgzf, aln_SS); + } + } + } + } + + + + + + + + } + + sam_close(in_SS); + + sam_close(outR1); + bam_destroy1(aln_SS); + bam_hdr_destroy(header_SS); + + delete para_Xam04 ; + return 0; +} +#endif +///////// swimming in the sky and flying in the sea //////////// diff --git a/src/modify/modify.h b/src/modify/modify.h new file mode 100644 index 0000000..d73cd4f --- /dev/null +++ b/src/modify/modify.h @@ -0,0 +1,73 @@ +#include +#include +#include +#include +#include +#include +#include +#include "bamRand.h" +#include "bamCat.h" +#include "bamFilter.h" +#include "bamShiftQ.h" +#include "bamSplit.h" +#include "bamSubChr.h" +#include "bamAssign.h" +#include "bamLimit.h" + + + +using namespace std; + +int bamRand_main(int argc, char **argv); +int bam_Filter_main(int argc, char **argv); +int bam_ShiftQ_main(int argc, char **argv); +int bamSplit_main(int argc, char *argv[]) ; +int bamCat_main(int argc, char *argv[]); +int bam_SubChr_main(int argc, char **argv); +int bamAssign_main(int argc, char *argv[]); +int bamLimit_main(int argc, char *argv[]); + +static int modify_usage () +{ + cerr<<"" + "\n" + "\t\tbamFilter filter low quality read in bam\n" + "\t\tbamSplit split single/muti-Bam by chr\n" + "\t\tbamAssign split single/muti-Bam by assign chr\n" + "\t\tbamCat Merge/Cat muti (diff header) bam to one bam\n" + "\t\tbamRand random out partly of bam read\n" + "\t\tbamSubChr extract or remove chr(s) from SAM/BAM\n" + "\t\tbamShiftQ modify seq Phred quality in bam\n" + "\t\tbamLimit Limit big bam to muti subbam by fix line\n" + "\n" + "\t\tHelp Show this help\n" + "\n"; + return 1; +} + +int modify_main(int argc, char *argv[]) +{ + if (argc < 2) { return modify_usage(); } + else if (strcmp(argv[1], "bamRand") == 0) { return bamRand_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bamFilter") == 0) { return bam_Filter_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bamSplit") == 0) { return bamSplit_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bamAssign") == 0) { return bamAssign_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bamSubChr") == 0) { return bam_SubChr_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bamCat") == 0) { return bamCat_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bamShiftQ") == 0) { return bam_ShiftQ_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "bamLimit") == 0) { return bamLimit_main(argc-1, argv+1) ; } + else if (strcmp(argv[1], "Help") == 0 || strcmp(argv[1], "help") == 0 || strcmp(argv[1], "?")== 0 || ( argv[1][0] == '-' &&( argv[1][1] =='h' || argv[1][1] =='H' || argv[1][1] =='?' ) ) || strcmp(argv[1], "less") == 0 ) + { + return modify_usage(); + } + else + { + cerr<<"convert [main] unrecognized command "< + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. */ + +#ifndef HTSLIB_SAM_H +#define HTSLIB_SAM_H + +#include +#include "hts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// Highest SAM format version supported by this library +#define SAM_FORMAT_VERSION "1.6" + +/*************************** + *** SAM/BAM/CRAM header *** + ***************************/ + +/*! @typedef + * @abstract Header extension structure, grouping a collection + * of hash tables that contain the parsed header data. + */ + +typedef struct sam_hrecs_t sam_hrecs_t; + +/*! @typedef + @abstract Structure for the alignment header. + @field n_targets number of reference sequences + @field l_text length of the plain text in the header (may be zero if + the header has been edited) + @field target_len lengths of the reference sequences + @field target_name names of the reference sequences + @field text plain text (may be NULL if the header has been edited) + @field sdict header dictionary + @field hrecs pointer to the extended header struct (internal use only) + @field ref_count reference count + + @note The text and l_text fields are included for backwards compatibility. + These fields may be set to NULL and zero respectively as a side-effect + of calling some header API functions. New code that needs to access the + header text should use the sam_hdr_str() and sam_hdr_length() functions + instead of these fields. + */ + +typedef struct sam_hdr_t { + int32_t n_targets, ignore_sam_err; + size_t l_text; + uint32_t *target_len; + const int8_t *cigar_tab HTS_DEPRECATED("Use bam_cigar_table[] instead"); + char **target_name; + char *text; + void *sdict; + sam_hrecs_t *hrecs; + uint32_t ref_count; +} sam_hdr_t; + +/*! @typedef + * @abstract Old name for compatibility with existing code. + */ +typedef sam_hdr_t bam_hdr_t; + +/**************************** + *** CIGAR related macros *** + ****************************/ + +#define BAM_CMATCH 0 +#define BAM_CINS 1 +#define BAM_CDEL 2 +#define BAM_CREF_SKIP 3 +#define BAM_CSOFT_CLIP 4 +#define BAM_CHARD_CLIP 5 +#define BAM_CPAD 6 +#define BAM_CEQUAL 7 +#define BAM_CDIFF 8 +#define BAM_CBACK 9 + +#define BAM_CIGAR_STR "MIDNSHP=XB" +#define BAM_CIGAR_SHIFT 4 +#define BAM_CIGAR_MASK 0xf +#define BAM_CIGAR_TYPE 0x3C1A7 + +/*! @abstract Table for converting a CIGAR operator character to BAM_CMATCH etc. +Result is operator code or -1. Be sure to cast the index if it is a plain char: + int op = bam_cigar_table[(unsigned char) ch]; +*/ +extern const int8_t bam_cigar_table[256]; + +#define bam_cigar_op(c) ((c)&BAM_CIGAR_MASK) +#define bam_cigar_oplen(c) ((c)>>BAM_CIGAR_SHIFT) +// Note that BAM_CIGAR_STR is padded to length 16 bytes below so that +// the array look-up will not fall off the end. '?' is chosen as the +// padding character so it's easy to spot if one is emitted, and will +// result in a parsing failure (in sam_parse1(), at least) if read. +#define bam_cigar_opchr(c) (BAM_CIGAR_STR "??????" [bam_cigar_op(c)]) +#define bam_cigar_gen(l, o) ((l)<>((o)<<1)&3) // bit 1: consume query; bit 2: consume reference + +/*! @abstract the read is paired in sequencing, no matter whether it is mapped in a pair */ +#define BAM_FPAIRED 1 +/*! @abstract the read is mapped in a proper pair */ +#define BAM_FPROPER_PAIR 2 +/*! @abstract the read itself is unmapped; conflictive with BAM_FPROPER_PAIR */ +#define BAM_FUNMAP 4 +/*! @abstract the mate is unmapped */ +#define BAM_FMUNMAP 8 +/*! @abstract the read is mapped to the reverse strand */ +#define BAM_FREVERSE 16 +/*! @abstract the mate is mapped to the reverse strand */ +#define BAM_FMREVERSE 32 +/*! @abstract this is read1 */ +#define BAM_FREAD1 64 +/*! @abstract this is read2 */ +#define BAM_FREAD2 128 +/*! @abstract not primary alignment */ +#define BAM_FSECONDARY 256 +/*! @abstract QC failure */ +#define BAM_FQCFAIL 512 +/*! @abstract optical or PCR duplicate */ +#define BAM_FDUP 1024 +/*! @abstract supplementary alignment */ +#define BAM_FSUPPLEMENTARY 2048 + +/************************* + *** Alignment records *** + *************************/ + +/* + * Assumptions made here. While pos can be 64-bit, no sequence + * itself is that long, but due to ref skip CIGAR fields it + * may span more than that. (CIGAR itself is 28-bit len + 4 bit + * type, but in theory we can combine multiples together.) + * + * Mate position and insert size also need to be 64-bit, but + * we won't accept more than 32-bit for tid. + * + * The bam_core_t structure is the *in memory* layout and not + * the same as the on-disk format. 64-bit changes here permit + * SAM to work with very long chromosomes and permit BAM and CRAM + * to seamlessly update in the future without further API/ABI + * revisions. + */ + +/*! @typedef + @abstract Structure for core alignment information. + @field pos 0-based leftmost coordinate + @field tid chromosome ID, defined by sam_hdr_t + @field bin bin calculated by bam_reg2bin() + @field qual mapping quality + @field l_extranul length of extra NULs between qname & cigar (for alignment) + @field flag bitwise flag + @field l_qname length of the query name + @field n_cigar number of CIGAR operations + @field l_qseq length of the query sequence (read) + @field mtid chromosome ID of next read in template, defined by sam_hdr_t + @field mpos 0-based leftmost coordinate of next read in template + @field isize observed template length ("insert size") + */ +typedef struct { + hts_pos_t pos; + int32_t tid; + uint16_t bin; // NB: invalid on 64-bit pos + uint8_t qual; + uint8_t l_extranul; + uint16_t flag; + uint16_t l_qname; + uint32_t n_cigar; + int32_t l_qseq; + int32_t mtid; + hts_pos_t mpos; + hts_pos_t isize; +} bam1_core_t; + +/*! @typedef + @abstract Structure for one alignment. + @field core core information about the alignment + @field id + @field data all variable-length data, concatenated; structure: qname-cigar-seq-qual-aux + @field l_data current length of bam1_t::data + @field m_data maximum length of bam1_t::data + @field mempolicy memory handling policy, see bam_set_mempolicy() + + @discussion Notes: + + 1. The data blob should be accessed using bam_get_qname, bam_get_cigar, + bam_get_seq, bam_get_qual and bam_get_aux macros. These returns pointers + to the start of each type of data. + 2. qname is terminated by one to four NULs, so that the following + cigar data is 32-bit aligned; core.l_qname includes these trailing NULs, + while core.l_extranul counts the excess NULs (so 0 <= l_extranul <= 3). + 3. Cigar data is encoded 4 bytes per CIGAR operation. + See the bam_cigar_* macros for manipulation. + 4. seq is nibble-encoded according to bam_nt16_table. + See the bam_seqi macro for retrieving individual bases. + 5. Per base qualilties are stored in the Phred scale with no +33 offset. + Ie as per the BAM specification and not the SAM ASCII printable method. + */ +typedef struct { + bam1_core_t core; + uint64_t id; + uint8_t *data; + int l_data; + uint32_t m_data; + uint32_t mempolicy:2, :30 /* Reserved */; +} bam1_t; + +/*! @function + @abstract Get whether the query is on the reverse strand + @param b pointer to an alignment + @return boolean true if query is on the reverse strand + */ +#define bam_is_rev(b) (((b)->core.flag&BAM_FREVERSE) != 0) +/*! @function + @abstract Get whether the query's mate is on the reverse strand + @param b pointer to an alignment + @return boolean true if query's mate on the reverse strand + */ +#define bam_is_mrev(b) (((b)->core.flag&BAM_FMREVERSE) != 0) +/*! @function + @abstract Get the name of the query + @param b pointer to an alignment + @return pointer to the name string, null terminated + */ +#define bam_get_qname(b) ((char*)(b)->data) +/*! @function + @abstract Get the CIGAR array + @param b pointer to an alignment + @return pointer to the CIGAR array + + @discussion In the CIGAR array, each element is a 32-bit integer. The + lower 4 bits gives a CIGAR operation and the higher 28 bits keep the + length of a CIGAR. + */ +#define bam_get_cigar(b) ((uint32_t*)((b)->data + (b)->core.l_qname)) +/*! @function + @abstract Get query sequence + @param b pointer to an alignment + @return pointer to sequence + + @discussion Each base is encoded in 4 bits: 1 for A, 2 for C, 4 for G, + 8 for T and 15 for N. Two bases are packed in one byte with the base + at the higher 4 bits having smaller coordinate on the read. It is + recommended to use bam_seqi() macro to get the base. + */ +#define bam_get_seq(b) ((b)->data + ((b)->core.n_cigar<<2) + (b)->core.l_qname) +/*! @function + @abstract Get query quality + @param b pointer to an alignment + @return pointer to quality string + */ +#define bam_get_qual(b) ((b)->data + ((b)->core.n_cigar<<2) + (b)->core.l_qname + (((b)->core.l_qseq + 1)>>1)) +/*! @function + @abstract Get auxiliary data + @param b pointer to an alignment + @return pointer to the concatenated auxiliary data + */ +#define bam_get_aux(b) ((b)->data + ((b)->core.n_cigar<<2) + (b)->core.l_qname + (((b)->core.l_qseq + 1)>>1) + (b)->core.l_qseq) +/*! @function + @abstract Get length of auxiliary data + @param b pointer to an alignment + @return length of the concatenated auxiliary data + */ +#define bam_get_l_aux(b) ((b)->l_data - ((b)->core.n_cigar<<2) - (b)->core.l_qname - (b)->core.l_qseq - (((b)->core.l_qseq + 1)>>1)) +/*! @function + @abstract Get a base on read + @param s Query sequence returned by bam_get_seq() + @param i The i-th position, 0-based + @return 4-bit integer representing the base. + */ +#define bam_seqi(s, i) ((s)[(i)>>1] >> ((~(i)&1)<<2) & 0xf) + +/************************** + *** Exported functions *** + **************************/ + +/*************** + *** BAM I/O *** + ***************/ + +/* Header */ + +/// Generates a new unpopulated header structure. +/*! + * + * @return A valid pointer to new header on success, NULL on failure + * + * The sam_hdr_t struct returned by a successful call should be freed + * via sam_hdr_destroy() when it is no longer needed. + */ +HTSLIB_EXPORT +sam_hdr_t *sam_hdr_init(void); + +/// Read the header from a BAM compressed file. +/*! + * @param fp File pointer + * @return A valid pointer to new header on success, NULL on failure + * + * This function only works with BAM files. It is usually better to use + * sam_hdr_read(), which works on SAM, BAM and CRAM files. + * + * The sam_hdr_t struct returned by a successful call should be freed + * via sam_hdr_destroy() when it is no longer needed. + */ +HTSLIB_EXPORT +sam_hdr_t *bam_hdr_read(BGZF *fp); + +/// Writes the header to a BAM file. +/*! + * @param fp File pointer + * @param h Header pointer + * @return 0 on success, -1 on failure + * + * This function only works with BAM files. Use sam_hdr_write() to + * write in any of the SAM, BAM or CRAM formats. + */ +HTSLIB_EXPORT +int bam_hdr_write(BGZF *fp, const sam_hdr_t *h) HTS_RESULT_USED; + +/*! + * Frees the resources associated with a header. + */ +HTSLIB_EXPORT +void sam_hdr_destroy(sam_hdr_t *h); + +/// Duplicate a header structure. +/*! + * @return A valid pointer to new header on success, NULL on failure + * + * The sam_hdr_t struct returned by a successful call should be freed + * via sam_hdr_destroy() when it is no longer needed. + */ +HTSLIB_EXPORT +sam_hdr_t *sam_hdr_dup(const sam_hdr_t *h0); + +/*! + * @abstract Old names for compatibility with existing code. + */ +static inline sam_hdr_t *bam_hdr_init(void) { return sam_hdr_init(); } +static inline void bam_hdr_destroy(sam_hdr_t *h) { sam_hdr_destroy(h); } +static inline sam_hdr_t *bam_hdr_dup(const sam_hdr_t *h0) { return sam_hdr_dup(h0); } + +typedef htsFile samFile; + +/// Create a header from existing text. +/*! + * @param l_text Length of text + * @param text Header text + * @return A populated sam_hdr_t structure on success; NULL on failure. + * @note The text field of the returned header will be NULL, and the l_text + * field will be zero. + * + * The sam_hdr_t struct returned by a successful call should be freed + * via sam_hdr_destroy() when it is no longer needed. + */ +HTSLIB_EXPORT +sam_hdr_t *sam_hdr_parse(size_t l_text, const char *text); + +/// Read a header from a SAM, BAM or CRAM file. +/*! + * @param fp Pointer to a SAM, BAM or CRAM file handle + * @return A populated sam_hdr_t struct on success; NULL on failure. + * + * The sam_hdr_t struct returned by a successful call should be freed + * via sam_hdr_destroy() when it is no longer needed. + */ +HTSLIB_EXPORT +sam_hdr_t *sam_hdr_read(samFile *fp); + +/// Write a header to a SAM, BAM or CRAM file. +/*! + * @param fp SAM, BAM or CRAM file header + * @param h Header structure to write + * @return 0 on success; -1 on failure + */ +HTSLIB_EXPORT +int sam_hdr_write(samFile *fp, const sam_hdr_t *h) HTS_RESULT_USED; + +/// Returns the current length of the header text. +/*! + * @return >= 0 on success, SIZE_MAX on failure + */ +HTSLIB_EXPORT +size_t sam_hdr_length(sam_hdr_t *h); + +/// Returns the text representation of the header. +/*! + * @return valid char pointer on success, NULL on failure + * + * The returned string is part of the header structure. It will remain + * valid until a call to a header API function causes the string to be + * invalidated, or the header is destroyed. + * + * The caller should not attempt to free or realloc this pointer. + */ +HTSLIB_EXPORT +const char *sam_hdr_str(sam_hdr_t *h); + +/// Returns the number of references in the header. +/*! + * @return >= 0 on success, -1 on failure + */ +HTSLIB_EXPORT +int sam_hdr_nref(const sam_hdr_t *h); + +/* ==== Line level methods ==== */ + +/// Add formatted lines to an existing header. +/*! + * @param lines Full SAM header record, eg "@SQ\tSN:foo\tLN:100", with + * optional new-line. If it contains more than 1 line then + * multiple lines will be added in order + * @param len The maximum length of lines (if an early NUL is not + * encountered). len may be 0 if unknown, in which case + * lines must be NUL-terminated + * @return 0 on success, -1 on failure + * + * The lines will be appended to the end of the existing header + * (apart from HD, which always comes first). + */ +HTSLIB_EXPORT +int sam_hdr_add_lines(sam_hdr_t *h, const char *lines, size_t len); + +/// Adds a single line to an existing header. +/*! + * Specify type and one or more key,value pairs, ending with the NULL key. + * Eg. sam_hdr_add_line(h, "SQ", "ID", "foo", "LN", "100", NULL). + * + * @param type Type of the added line. Eg. "SQ" + * @return 0 on success, -1 on failure + * + * The new line will be added immediately after any others of the same + * type, or at the end of the existing header if no lines of the + * given type currently exist. The exception is HD lines, which always + * come first. If an HD line already exists, it will be replaced. + */ +HTSLIB_EXPORT +int sam_hdr_add_line(sam_hdr_t *h, const char *type, ...); + +/// Returns a complete line of formatted text for a given type and ID. +/*! + * @param type Type of the searched line. Eg. "SQ" + * @param ID_key Tag key defining the line. Eg. "SN" + * @param ID_value Tag value associated with the key above. Eg. "ref1" + * @param ks kstring to hold the result + * @return 0 on success; + * -1 if no matching line is found + * -2 on other failures + * + * Puts a complete line of formatted text for a specific header type/ID + * combination into @p ks. If ID_key is NULL then it returns the first line of + * the specified type. + * + * Any existing content in @p ks will be overwritten. + */ +HTSLIB_EXPORT +int sam_hdr_find_line_id(sam_hdr_t *h, const char *type, + const char *ID_key, const char *ID_val, kstring_t *ks); + +/// Returns a complete line of formatted text for a given type and index. +/*! + * @param type Type of the searched line. Eg. "SQ" + * @param position Index in lines of this type (zero-based) + * @param ks kstring to hold the result + * @return 0 on success; + * -1 if no matching line is found + * -2 on other failures + * + * Puts a complete line of formatted text for a specific line into @p ks. + * The header line is selected using the @p type and @p position parameters. + * + * Any existing content in @p ks will be overwritten. + */ +HTSLIB_EXPORT +int sam_hdr_find_line_pos(sam_hdr_t *h, const char *type, + int pos, kstring_t *ks); + +/// Remove a line with given type / id from a header +/*! + * @param type Type of the searched line. Eg. "SQ" + * @param ID_key Tag key defining the line. Eg. "SN" + * @param ID_value Tag value associated with the key above. Eg. "ref1" + * @return 0 on success, -1 on error + * + * Remove a line from the header by specifying a tag:value that uniquely + * identifies the line, i.e. the @SQ line containing "SN:ref1". + * + * \@SQ line is uniquely identified by the SN tag. + * \@RG line is uniquely identified by the ID tag. + * \@PG line is uniquely identified by the ID tag. + * Eg. sam_hdr_remove_line_id(h, "SQ", "SN", "ref1") + * + * If no key:value pair is specified, the type MUST be followed by a NULL argument and + * the first line of the type will be removed, if any. + * Eg. sam_hdr_remove_line_id(h, "SQ", NULL, NULL) + * + * @note Removing \@PG lines is currently unsupported. + */ +HTSLIB_EXPORT +int sam_hdr_remove_line_id(sam_hdr_t *h, const char *type, const char *ID_key, const char *ID_value); + +/// Remove nth line of a given type from a header +/*! + * @param type Type of the searched line. Eg. "SQ" + * @param position Index in lines of this type (zero-based). E.g. 3 + * @return 0 on success, -1 on error + * + * Remove a line from the header by specifying the position in the type + * group, i.e. 3rd @SQ line. + */ +HTSLIB_EXPORT +int sam_hdr_remove_line_pos(sam_hdr_t *h, const char *type, int position); + +/// Add or update tag key,value pairs in a header line. +/*! + * @param type Type of the searched line. Eg. "SQ" + * @param ID_key Tag key defining the line. Eg. "SN" + * @param ID_value Tag value associated with the key above. Eg. "ref1" + * @return 0 on success, -1 on error + * + * Adds or updates tag key,value pairs in a header line. + * Eg. for adding M5 tags to @SQ lines or updating sort order for the + * @HD line. + * + * Specify multiple key,value pairs ending in NULL. Eg. + * sam_hdr_update_line(h, "RG", "ID", "rg1", "DS", "description", "PG", "samtools", NULL) + * + * Attempting to update the record name (i.e. @SQ SN or @RG ID) will + * work as long as the new name is not already in use, however doing this + * on a file opened for reading may produce unexpected results. + * + * Renaming an @RG record in this way will only change the header. Alignment + * records written later will not be updated automatically even if they + * reference the old read group name. + * + * Attempting to change an @PG ID tag is not permitted. + */ +HTSLIB_EXPORT +int sam_hdr_update_line(sam_hdr_t *h, const char *type, + const char *ID_key, const char *ID_value, ...); + +/// Remove all lines of a given type from a header, except the one matching an ID +/*! + * @param type Type of the searched line. Eg. "SQ" + * @param ID_key Tag key defining the line. Eg. "SN" + * @param ID_value Tag value associated with the key above. Eg. "ref1" + * @return 0 on success, -1 on failure + * + * Remove all lines of type from the header, except the one + * specified by tag:value, i.e. the @SQ line containing "SN:ref1". + * + * If no line matches the key:value ID, all lines of the given type are removed. + * To remove all lines of a given type, use NULL for both ID_key and ID_value. + */ +HTSLIB_EXPORT +int sam_hdr_remove_except(sam_hdr_t *h, const char *type, const char *ID_key, const char *ID_value); + +/// Remove header lines of a given type, except those in a given ID set +/*! + * @param type Type of the searched line. Eg. "RG" + * @param id Tag key defining the line. Eg. "ID" + * @param rh Hash set initialised by the caller with the values to be kept. + * See description for how to create this. If @p rh is NULL, all + * lines of this type will be removed. + * @return 0 on success, -1 on failure + * + * Remove all lines of type @p type from the header, except the ones + * specified in the hash set @p rh. If @p rh is NULL, all lines of + * this type will be removed. + * Declaration of @p rh is done using KHASH_SET_INIT_STR macro. Eg. + * @code{.c} + * #include "htslib/khash.h" + * KHASH_SET_INIT_STR(keep) + * typedef khash_t(keep) *keephash_t; + * + * void your_method() { + * samFile *sf = sam_open("alignment.bam", "r"); + * sam_hdr_t *h = sam_hdr_read(sf); + * keephash_t rh = kh_init(keep); + * int ret = 0; + * kh_put(keep, rh, strdup("chr2"), &ret); + * kh_put(keep, rh, strdup("chr3"), &ret); + * if (sam_hdr_remove_lines(h, "SQ", "SN", rh) == -1) + * fprintf(stderr, "Error removing lines\n"); + * khint_t k; + * for (k = 0; k < kh_end(rh); ++k) + * if (kh_exist(rh, k)) free((char*)kh_key(rh, k)); + * kh_destroy(keep, rh); + * sam_hdr_destroy(h); + * sam_close(sf); + * } + * @endcode + * + */ +HTSLIB_EXPORT +int sam_hdr_remove_lines(sam_hdr_t *h, const char *type, const char *id, void *rh); + +/// Count the number of lines for a given header type +/*! + * @param h BAM header + * @param type Header type to count. Eg. "RG" + * @return Number of lines of this type on success; -1 on failure + */ +HTSLIB_EXPORT +int sam_hdr_count_lines(sam_hdr_t *h, const char *type); + +/// Index of the line for the types that have dedicated look-up tables (SQ, RG, PG) +/*! + * @param h BAM header + * @param type Type of the searched line. Eg. "RG" + * @param key The value of the identifying key. Eg. "rg1" + * @return 0-based index on success; -1 if line does not exist; -2 on failure + */ +HTSLIB_EXPORT +int sam_hdr_line_index(sam_hdr_t *bh, const char *type, const char *key); + +/// Id key of the line for the types that have dedicated look-up tables (SQ, RG, PG) +/*! + * @param h BAM header + * @param type Type of the searched line. Eg. "RG" + * @param pos Zero-based index inside the type group. Eg. 2 (for the third RG line) + * @return Valid key string on success; NULL on failure + */ +HTSLIB_EXPORT +const char *sam_hdr_line_name(sam_hdr_t *bh, const char *type, int pos); + +/* ==== Key:val level methods ==== */ + +/// Return the value associated with a key for a header line identified by ID_key:ID_val +/*! + * @param type Type of the line to which the tag belongs. Eg. "SQ" + * @param ID_key Tag key defining the line. Eg. "SN". Can be NULL, if looking for the first line. + * @param ID_value Tag value associated with the key above. Eg. "ref1". Can be NULL, if ID_key is NULL. + * @param key Key of the searched tag. Eg. "LN" + * @param ks kstring where the value will be written + * @return 0 on success + * -1 if the requested tag does not exist + * -2 on other errors + * + * Looks for a specific key in a single SAM header line and writes the + * associated value into @p ks. The header line is selected using the ID_key + * and ID_value parameters. Any pre-existing content in @p ks will be + * overwritten. + */ +HTSLIB_EXPORT +int sam_hdr_find_tag_id(sam_hdr_t *h, const char *type, const char *ID_key, const char *ID_value, const char *key, kstring_t *ks); + +/// Return the value associated with a key for a header line identified by position +/*! + * @param type Type of the line to which the tag belongs. Eg. "SQ" + * @param position Index in lines of this type (zero-based). E.g. 3 + * @param key Key of the searched tag. Eg. "LN" + * @param ks kstring where the value will be written + * @return 0 on success + * -1 if the requested tag does not exist + * -2 on other errors + * + * Looks for a specific key in a single SAM header line and writes the + * associated value into @p ks. The header line is selected using the @p type + * and @p position parameters. Any pre-existing content in @p ks will be + * overwritten. + */ +HTSLIB_EXPORT +int sam_hdr_find_tag_pos(sam_hdr_t *h, const char *type, int pos, const char *key, kstring_t *ks); + +/// Remove the key from the line identified by type, ID_key and ID_value. +/*! + * @param type Type of the line to which the tag belongs. Eg. "SQ" + * @param ID_key Tag key defining the line. Eg. "SN" + * @param ID_value Tag value associated with the key above. Eg. "ref1" + * @param key Key of the targeted tag. Eg. "M5" + * @return 1 if the key was removed; 0 if it was not present; -1 on error + */ +HTSLIB_EXPORT +int sam_hdr_remove_tag_id(sam_hdr_t *h, const char *type, const char *ID_key, const char *ID_value, const char *key); + +/// Get the target id for a given reference sequence name +/*! + * @param ref Reference name + * @return Positive value on success, + * -1 if unknown reference, + * -2 if the header could not be parsed + * + * Looks up a reference sequence by name in the reference hash table + * and returns the numerical target id. + */ +HTSLIB_EXPORT +int sam_hdr_name2tid(sam_hdr_t *h, const char *ref); + +/// Get the reference sequence name from a target index +/*! + * @param tid Target index + * @return Valid reference name on success, NULL on failure + * + * Fetch the reference sequence name from the target name array, + * using the numerical target id. + */ +HTSLIB_EXPORT +const char *sam_hdr_tid2name(const sam_hdr_t *h, int tid); + +/// Get the reference sequence length from a target index +/*! + * @param tid Target index + * @return Strictly positive value on success, 0 on failure + * + * Fetch the reference sequence length from the target length array, + * using the numerical target id. + */ +HTSLIB_EXPORT +hts_pos_t sam_hdr_tid2len(const sam_hdr_t *h, int tid); + +/// Alias of sam_hdr_name2tid(), for backwards compatibility. +/*! + * @param ref Reference name + * @return Positive value on success, + * -1 if unknown reference, + * -2 if the header could not be parsed + */ +static inline int bam_name2id(sam_hdr_t *h, const char *ref) { return sam_hdr_name2tid(h, ref); } + +/// Generate a unique \@PG ID: value +/*! + * @param name Name of the program. Eg. samtools + * @return Valid ID on success, NULL on failure + * + * Returns a unique ID from a base name. The string returned will remain + * valid until the next call to this function, or the header is destroyed. + * The caller should not attempt to free() or realloc() it. + */ +HTSLIB_EXPORT +const char *sam_hdr_pg_id(sam_hdr_t *h, const char *name); + +/// Add an \@PG line. +/*! + * @param name Name of the program. Eg. samtools + * @return 0 on success, -1 on failure + * + * If we wish complete control over this use sam_hdr_add_line() directly. This + * function uses that, but attempts to do a lot of tedious house work for + * you too. + * + * - It will generate a suitable ID if the supplied one clashes. + * - It will generate multiple \@PG records if we have multiple PG chains. + * + * Call it as per sam_hdr_add_line() with a series of key,value pairs ending + * in NULL. + */ +HTSLIB_EXPORT +int sam_hdr_add_pg(sam_hdr_t *h, const char *name, ...); + +/*! + * A function to help with construction of CL tags in @PG records. + * Takes an argc, argv pair and returns a single space-separated string. + * This string should be deallocated by the calling function. + * + * @return + * Returns malloced char * on success; + * NULL on failure + */ +HTSLIB_EXPORT +char *stringify_argv(int argc, char *argv[]); + +/// Increments the reference count on a header +/*! + * This permits multiple files to share the same header, all calling + * sam_hdr_destroy when done, without causing errors for other open files. + */ +HTSLIB_EXPORT +void sam_hdr_incr_ref(sam_hdr_t *h); + +/* + * Macros for changing the \@HD line. They eliminate the need to use NULL method arguments. + */ + +/// Returns the SAM formatted text of the \@HD header line +#define sam_hdr_find_hd(h, ks) sam_hdr_find_line_id((h), "HD", NULL, NULL, (ks)) +/// Returns the value associated with a given \@HD line tag +#define sam_hdr_find_tag_hd(h, key, ks) sam_hdr_find_tag_id((h), "HD", NULL, NULL, (key), (ks)) +/// Adds or updates tags on the header \@HD line +#define sam_hdr_update_hd(h, ...) sam_hdr_update_line((h), "HD", NULL, NULL, __VA_ARGS__, NULL) +/// Removes the \@HD line tag with the given key +#define sam_hdr_remove_tag_hd(h, key) sam_hdr_remove_tag_id((h), "HD", NULL, NULL, (key)) + +/* Alignment */ + +/// Create a new bam1_t alignment structure +/** + @return An empty bam1_t structure on success, NULL on failure + + The bam1_t struct returned by a successful call should be freed + via bam_destroy1() when it is no longer needed. + */ +HTSLIB_EXPORT +bam1_t *bam_init1(void); + +/// Destroy a bam1_t structure +/** + @param b structure to destroy + + Does nothing if @p b is NULL. If not, all memory associated with @p b + will be freed, along with the structure itself. @p b should not be + accessed after calling this function. + */ +HTSLIB_EXPORT +void bam_destroy1(bam1_t *b); + +#define BAM_USER_OWNS_STRUCT 1 +#define BAM_USER_OWNS_DATA 2 + +/// Set alignment record memory policy +/** + @param b Alignment record + @param policy Desired policy + + Allows the way HTSlib reallocates and frees bam1_t data to be + changed. @policy can be set to the bitwise-or of the following + values: + + \li \c BAM_USER_OWNS_STRUCT + If this is set then bam_destroy1() will not try to free the bam1_t struct. + + \li \c BAM_USER_OWNS_DATA + If this is set, bam_destroy1() will not free the bam1_t::data pointer. + Also, functions which need to expand bam1_t::data memory will change + behaviour. Instead of calling realloc() on the pointer, they will + allocate a new data buffer and copy any existing content in to it. + The existing memory will \b not be freed. bam1_t::data will be + set to point to the new memory and the BAM_USER_OWNS_DATA flag will be + cleared. + + BAM_USER_OWNS_STRUCT allows bam_destroy1() to be called on bam1_t + structures that are members of an array. + + BAM_USER_OWNS_DATA can be used by applications that want more control + over where the variable-length parts of the bam record will be stored. + By preventing calls to free() and realloc(), it allows bam1_t::data + to hold pointers to memory that cannot be passed to those functions. + + Example: Read a block of alignment records, storing the variable-length + data in a single buffer and the records in an array. Stop when either + the array or the buffer is full. + + \code{.c} + #define MAX_RECS 1000 + #define REC_LENGTH 400 // Average length estimate, to get buffer size + size_t bufsz = MAX_RECS * REC_LENGTH, nrecs, buff_used = 0; + bam1_t *recs = calloc(MAX_RECS, sizeof(bam1_t)); + uint8_t *buffer = malloc(bufsz); + int res = 0, result = EXIT_FAILURE; + uint32_t new_m_data; + + if (!recs || !buffer) goto cleanup; + for (nrecs = 0; nrecs < MAX_RECS; nrecs++) { + bam_set_mempolicy(BAM_USER_OWNS_STRUCT|BAM_USER_OWNS_DATA); + + // Set data pointer to unused part of buffer + recs[nrecs].data = &buffer[buff_used]; + + // Set m_data to size of unused part of buffer. On 64-bit platforms it + // will be necessary to limit this to UINT32_MAX due to the size of + // bam1_t::m_data (not done here as our buffer is only 400K). + recs[nrecs].m_data = bufsz - buff_used; + + // Read the record + res = sam_read1(file_handle, header, &recs[nrecs]); + if (res <= 0) break; // EOF or error + + // Check if the record data didn't fit - if not, stop reading + if ((bam_get_mempolicy(&recs[nrecs]) & BAM_USER_OWNS_DATA) == 0) { + nrecs++; // Include last record in count + break; + } + + // Adjust m_data to the space actually used. If space is available, + // round up to eight bytes so the next record aligns nicely. + new_m_data = ((uint32_t) recs[nrecs].l_data + 7) & (~7U); + if (new_m_data < recs[nrecs].m_data) recs[nrecs].m_data = new_m_data; + + buff_used += recs[nrecs].m_data; + } + if (res < 0) goto cleanup; + result = EXIT_SUCCESS; + + // ... use data ... + + cleanup: + for (size_t i = 0; i < nrecs; i++) + bam_destroy1(i); + free(buffer); + free(recs); + + \endcode +*/ +static inline void bam_set_mempolicy(bam1_t *b, uint32_t policy) { + b->mempolicy = policy; +} + +/// Get alignment record memory policy +/** @param b Alignment record + + See bam_set_mempolicy() + */ +static inline uint32_t bam_get_mempolicy(bam1_t *b) { + return b->mempolicy; +} + +/// Read a BAM format alignment record +/** + @param fp BGZF file being read + @param b Destination for the alignment data + @return number of bytes read on success + -1 at end of file + < -1 on failure + + This function can only read BAM format files. Most code should use + sam_read1() instead, which can be used with BAM, SAM and CRAM formats. +*/ +HTSLIB_EXPORT +int bam_read1(BGZF *fp, bam1_t *b) HTS_RESULT_USED; + +/// Write a BAM format alignment record +/** + @param fp BGZF file being written + @param b Alignment record to write + @return number of bytes written on success + -1 on error + + This function can only write BAM format files. Most code should use + sam_write1() instead, which can be used with BAM, SAM and CRAM formats. +*/ +HTSLIB_EXPORT +int bam_write1(BGZF *fp, const bam1_t *b) HTS_RESULT_USED; + +/// Copy alignment record data +/** + @param bdst Destination alignment record + @param bsrc Source alignment record + @return bdst on success; NULL on failure + */ +HTSLIB_EXPORT +bam1_t *bam_copy1(bam1_t *bdst, const bam1_t *bsrc) HTS_RESULT_USED; + +/// Create a duplicate alignment record +/** + @param bsrc Source alignment record + @return Pointer to a new alignment record on success; NULL on failure + + The bam1_t struct returned by a successful call should be freed + via bam_destroy1() when it is no longer needed. + */ +HTSLIB_EXPORT +bam1_t *bam_dup1(const bam1_t *bsrc); + +/// Calculate query length from CIGAR data +/** + @param n_cigar Number of items in @p cigar + @param cigar CIGAR data + @return Query length + + CIGAR data is stored as in the BAM format, i.e. (op_len << 4) | op + where op_len is the length in bases and op is a value between 0 and 8 + representing one of the operations "MIDNSHP=X" (M = 0; X = 8) + + This function returns the sum of the lengths of the M, I, S, = and X + operations in @p cigar (these are the operations that "consume" query + bases). All other operations (including invalid ones) are ignored. + + @note This return type of this function is hts_pos_t so that it can + correctly return the length of CIGAR sequences including many long + operations without overflow. However, other restrictions (notably the sizes + of bam1_core_t::l_qseq and bam1_t::data) limit the maximum query sequence + length supported by HTSlib to fewer than INT_MAX bases. + */ +HTSLIB_EXPORT +hts_pos_t bam_cigar2qlen(int n_cigar, const uint32_t *cigar); + +/// Calculate reference length from CIGAR data +/** + @param n_cigar Number of items in @p cigar + @param cigar CIGAR data + @return Reference length + + CIGAR data is stored as in the BAM format, i.e. (op_len << 4) | op + where op_len is the length in bases and op is a value between 0 and 8 + representing one of the operations "MIDNSHP=X" (M = 0; X = 8) + + This function returns the sum of the lengths of the M, D, N, = and X + operations in @p cigar (these are the operations that "consume" reference + bases). All other operations (including invalid ones) are ignored. + */ +HTSLIB_EXPORT +hts_pos_t bam_cigar2rlen(int n_cigar, const uint32_t *cigar); + +/*! + @abstract Calculate the rightmost base position of an alignment on the + reference genome. + + @param b pointer to an alignment + @return the coordinate of the first base after the alignment, 0-based + + @discussion For a mapped read, this is just b->core.pos + bam_cigar2rlen. + For an unmapped read (either according to its flags or if it has no cigar + string), we return b->core.pos + 1 by convention. + */ +HTSLIB_EXPORT +hts_pos_t bam_endpos(const bam1_t *b); + +HTSLIB_EXPORT +int bam_str2flag(const char *str); /** returns negative value on error */ + +HTSLIB_EXPORT +char *bam_flag2str(int flag); /** The string must be freed by the user */ + +/*! @function + @abstract Set the name of the query + @param b pointer to an alignment + @return 0 on success, -1 on failure + */ +HTSLIB_EXPORT +int bam_set_qname(bam1_t *b, const char *qname); + +/************************* + *** BAM/CRAM indexing *** + *************************/ + +// These BAM iterator functions work only on BAM files. To work with either +// BAM or CRAM files use the sam_index_load() & sam_itr_*() functions. +#define bam_itr_destroy(iter) hts_itr_destroy(iter) +#define bam_itr_queryi(idx, tid, beg, end) sam_itr_queryi(idx, tid, beg, end) +#define bam_itr_querys(idx, hdr, region) sam_itr_querys(idx, hdr, region) +#define bam_itr_next(htsfp, itr, r) hts_itr_next((htsfp)->fp.bgzf, (itr), (r), 0) + +// Load/build .csi or .bai BAM index file. Does not work with CRAM. +// It is recommended to use the sam_index_* functions below instead. +#define bam_index_load(fn) hts_idx_load((fn), HTS_FMT_BAI) +#define bam_index_build(fn, min_shift) (sam_index_build((fn), (min_shift))) + +/// Initialise fp->idx for the current format type for SAM, BAM and CRAM types . +/** @param fp File handle for the data file being written. + @param h Bam header structured (needed for BAI and CSI). + @param min_shift 0 for BAI, or larger for CSI (CSI defaults to 14). + @param fnidx Filename to write index to. This pointer must remain valid + until after sam_idx_save is called. + @return 0 on success, <0 on failure. + + @note This must be called after the header has been written, but before + any other data. +*/ +HTSLIB_EXPORT +int sam_idx_init(htsFile *fp, sam_hdr_t *h, int min_shift, const char *fnidx); + +/// Writes the index initialised with sam_idx_init to disk. +/** @param fp File handle for the data file being written. + @return 0 on success, <0 on filaure. +*/ +HTSLIB_EXPORT +int sam_idx_save(htsFile *fp) HTS_RESULT_USED; + +/// Load a BAM (.csi or .bai) or CRAM (.crai) index file +/** @param fp File handle of the data file whose index is being opened + @param fn BAM/CRAM/etc filename to search alongside for the index file + @return The index, or NULL if an error occurred. + +Equivalent to sam_index_load3(fp, fn, NULL, HTS_IDX_SAVE_REMOTE); +*/ +HTSLIB_EXPORT +hts_idx_t *sam_index_load(htsFile *fp, const char *fn); + +/// Load a specific BAM (.csi or .bai) or CRAM (.crai) index file +/** @param fp File handle of the data file whose index is being opened + @param fn BAM/CRAM/etc data file filename + @param fnidx Index filename, or NULL to search alongside @a fn + @return The index, or NULL if an error occurred. + +Equivalent to sam_index_load3(fp, fn, fnidx, HTS_IDX_SAVE_REMOTE); +*/ +HTSLIB_EXPORT +hts_idx_t *sam_index_load2(htsFile *fp, const char *fn, const char *fnidx); + +/// Load or stream a BAM (.csi or .bai) or CRAM (.crai) index file +/** @param fp File handle of the data file whose index is being opened + @param fn BAM/CRAM/etc data file filename + @param fnidx Index filename, or NULL to search alongside @a fn + @param flags Flags to alter behaviour (see description) + @return The index, or NULL if an error occurred. + +The @p flags parameter can be set to a combination of the following values: + + HTS_IDX_SAVE_REMOTE Save a local copy of any remote indexes + HTS_IDX_SILENT_FAIL Fail silently if the index is not present + +Note that HTS_IDX_SAVE_REMOTE has no effect for remote CRAM indexes. They +are always downloaded and never cached locally. + +The index struct returned by a successful call should be freed +via hts_idx_destroy() when it is no longer needed. +*/ +HTSLIB_EXPORT +hts_idx_t *sam_index_load3(htsFile *fp, const char *fn, const char *fnidx, int flags); + +/// Generate and save an index file +/** @param fn Input BAM/etc filename, to which .csi/etc will be added + @param min_shift Positive to generate CSI, or 0 to generate BAI + @return 0 if successful, or negative if an error occurred (usually -1; or + -2: opening fn failed; -3: format not indexable; -4: + failed to create and/or save the index) +*/ +HTSLIB_EXPORT +int sam_index_build(const char *fn, int min_shift) HTS_RESULT_USED; + +/// Generate and save an index to a specific file +/** @param fn Input BAM/CRAM/etc filename + @param fnidx Output filename, or NULL to add .bai/.csi/etc to @a fn + @param min_shift Positive to generate CSI, or 0 to generate BAI + @return 0 if successful, or negative if an error occurred (see + sam_index_build for error codes) +*/ +HTSLIB_EXPORT +int sam_index_build2(const char *fn, const char *fnidx, int min_shift) HTS_RESULT_USED; + +/// Generate and save an index to a specific file +/** @param fn Input BAM/CRAM/etc filename + @param fnidx Output filename, or NULL to add .bai/.csi/etc to @a fn + @param min_shift Positive to generate CSI, or 0 to generate BAI + @param nthreads Number of threads to use when building the index + @return 0 if successful, or negative if an error occurred (see + sam_index_build for error codes) +*/ +HTSLIB_EXPORT +int sam_index_build3(const char *fn, const char *fnidx, int min_shift, int nthreads) HTS_RESULT_USED; + +/// Free a SAM iterator +/// @param iter Iterator to free +#define sam_itr_destroy(iter) hts_itr_destroy(iter) + +/// Create a BAM/CRAM iterator +/** @param idx Index + @param tid Target id + @param beg Start position in target + @param end End position in target + @return An iterator on success; NULL on failure + +The following special values (defined in htslib/hts.h)can be used for @p tid. +When using one of these values, @p beg and @p end are ignored. + + HTS_IDX_NOCOOR iterates over unmapped reads sorted at the end of the file + HTS_IDX_START iterates over the entire file + HTS_IDX_REST iterates from the current position to the end of the file + HTS_IDX_NONE always returns "no more alignment records" + +When using HTS_IDX_REST or HTS_IDX_NONE, NULL can be passed in to @p idx. + */ +HTSLIB_EXPORT +hts_itr_t *sam_itr_queryi(const hts_idx_t *idx, int tid, hts_pos_t beg, hts_pos_t end); + +/// Create a SAM/BAM/CRAM iterator +/** @param idx Index + @param hdr Header + @param region Region specification + @return An iterator on success; NULL on failure + +Regions are parsed by hts_parse_reg(), and take one of the following forms: + +region | Outputs +--------------- | ------------- +REF | All reads with RNAME REF +REF: | All reads with RNAME REF +REF:START | Reads with RNAME REF overlapping START to end of REF +REF:-END | Reads with RNAME REF overlapping start of REF to END +REF:START-END | Reads with RNAME REF overlapping START to END +. | All reads from the start of the file +* | Unmapped reads at the end of the file (RNAME '*' in SAM) + +The form `REF:` should be used when the reference name itself contains a colon. + +Note that SAM files must be bgzf-compressed for iterators to work. + */ +HTSLIB_EXPORT +hts_itr_t *sam_itr_querys(const hts_idx_t *idx, sam_hdr_t *hdr, const char *region); + +/// Create a multi-region iterator +/** @param idx Index + @param hdr Header + @param reglist Array of regions to iterate over + @param regcount Number of items in reglist + +Each @p reglist entry should have the reference name in the `reg` field, an +array of regions for that reference in `intervals` and the number of items +in `intervals` should be stored in `count`. No other fields need to be filled +in. + +The iterator will return all reads overlapping the given regions. If a read +overlaps more than one region, it will only be returned once. + */ +HTSLIB_EXPORT +hts_itr_t *sam_itr_regions(const hts_idx_t *idx, sam_hdr_t *hdr, hts_reglist_t *reglist, unsigned int regcount); + +/// Create a multi-region iterator +/** @param idx Index + @param hdr Header + @param regarray Array of ref:interval region specifiers + @param regcount Number of items in regarray + +Each @p regarray entry is parsed by hts_parse_reg(), and takes one of the +following forms: + +region | Outputs +--------------- | ------------- +REF | All reads with RNAME REF +REF: | All reads with RNAME REF +REF:START | Reads with RNAME REF overlapping START to end of REF +REF:-END | Reads with RNAME REF overlapping start of REF to END +REF:START-END | Reads with RNAME REF overlapping START to END +. | All reads from the start of the file +* | Unmapped reads at the end of the file (RNAME '*' in SAM) + +The form `REF:` should be used when the reference name itself contains a colon. + +The iterator will return all reads overlapping the given regions. If a read +overlaps more than one region, it will only be returned once. + */ +HTSLIB_EXPORT +hts_itr_t *sam_itr_regarray(const hts_idx_t *idx, sam_hdr_t *hdr, char **regarray, unsigned int regcount); + +/// Get the next read from a SAM/BAM/CRAM iterator +/** @param htsfp Htsfile pointer for the input file + @param itr Iterator + @param r Pointer to a bam1_t struct + @return >= 0 on success; -1 when there is no more data; < -1 on error + */ +static inline int sam_itr_next(htsFile *htsfp, hts_itr_t *itr, bam1_t *r) { + if (!htsfp->is_bgzf && !htsfp->is_cram) { + hts_log_error("%s not BGZF compressed", htsfp->fn ? htsfp->fn : "File"); + return -2; + } + if (!itr) { + hts_log_error("Null iterator"); + return -2; + } + + if (itr->multi) + return hts_itr_multi_next(htsfp, itr, r); + else + return hts_itr_next(htsfp->is_bgzf ? htsfp->fp.bgzf : NULL, itr, r, htsfp); +} + +/// Get the next read from a BAM/CRAM multi-iterator +/** @param htsfp Htsfile pointer for the input file + @param itr Iterator + @param r Pointer to a bam1_t struct + @return >= 0 on success; -1 when there is no more data; < -1 on error + */ +#define sam_itr_multi_next(htsfp, itr, r) sam_itr_next(htsfp, itr, r) + +HTSLIB_EXPORT +const char *sam_parse_region(sam_hdr_t *h, const char *s, int *tid, + hts_pos_t *beg, hts_pos_t *end, int flags); + + /*************** + *** SAM I/O *** + ***************/ + + #define sam_open(fn, mode) (hts_open((fn), (mode))) + #define sam_open_format(fn, mode, fmt) (hts_open_format((fn), (mode), (fmt))) + #define sam_close(fp) hts_close(fp) + + HTSLIB_EXPORT + int sam_open_mode(char *mode, const char *fn, const char *format); + + // A version of sam_open_mode that can handle ,key=value options. + // The format string is allocated and returned, to be freed by the caller. + // Prefix should be "r" or "w", + HTSLIB_EXPORT + char *sam_open_mode_opts(const char *fn, + const char *mode, + const char *format); + + HTSLIB_EXPORT + int sam_hdr_change_HD(sam_hdr_t *h, const char *key, const char *val); + + HTSLIB_EXPORT + int sam_parse1(kstring_t *s, sam_hdr_t *h, bam1_t *b) HTS_RESULT_USED; + HTSLIB_EXPORT + int sam_format1(const sam_hdr_t *h, const bam1_t *b, kstring_t *str) HTS_RESULT_USED; + +/// sam_read1 - Read a record from a file +/** @param fp Pointer to the source file + * @param h Pointer to the header previously read (fully or partially) + * @param b Pointer to the record placeholder + * @return >= 0 on successfully reading a new record, -1 on end of stream, < -1 on error + */ + HTSLIB_EXPORT + int sam_read1(samFile *fp, sam_hdr_t *h, bam1_t *b) HTS_RESULT_USED; +/// sam_write1 - Write a record to a file +/** @param fp Pointer to the destination file + * @param h Pointer to the header structure previously read + * @param b Pointer to the record to be written + * @return >= 0 on successfully writing the record, -1 on error + */ + HTSLIB_EXPORT + int sam_write1(samFile *fp, const sam_hdr_t *h, const bam1_t *b) HTS_RESULT_USED; + + /************************************* + *** Manipulating auxiliary fields *** + *************************************/ + +/// Return a pointer to an aux record +/** @param b Pointer to the bam record + @param tag Desired aux tag + @return Pointer to the tag data, or NULL if tag is not present or on error + If the tag is not present, this function returns NULL and sets errno to + ENOENT. If the bam record's aux data is corrupt (either a tag has an + invalid type, or the last record is incomplete) then errno is set to + EINVAL and NULL is returned. + */ +HTSLIB_EXPORT +uint8_t *bam_aux_get(const bam1_t *b, const char tag[2]); + +/// Get an integer aux value +/** @param s Pointer to the tag data, as returned by bam_aux_get() + @return The value, or 0 if the tag was not an integer type + If the tag is not an integer type, errno is set to EINVAL. This function + will not return the value of floating-point tags. +*/ +HTSLIB_EXPORT +int64_t bam_aux2i(const uint8_t *s); + +/// Get an integer aux value +/** @param s Pointer to the tag data, as returned by bam_aux_get() + @return The value, or 0 if the tag was not an integer type + If the tag is not an numeric type, errno is set to EINVAL. The value of + integer flags will be returned cast to a double. +*/ +HTSLIB_EXPORT +double bam_aux2f(const uint8_t *s); + +/// Get a character aux value +/** @param s Pointer to the tag data, as returned by bam_aux_get(). + @return The value, or 0 if the tag was not a character ('A') type + If the tag is not a character type, errno is set to EINVAL. +*/ +HTSLIB_EXPORT +char bam_aux2A(const uint8_t *s); + +/// Get a string aux value +/** @param s Pointer to the tag data, as returned by bam_aux_get(). + @return Pointer to the string, or NULL if the tag was not a string type + If the tag is not a string type ('Z' or 'H'), errno is set to EINVAL. +*/ +HTSLIB_EXPORT +char *bam_aux2Z(const uint8_t *s); + +/// Get the length of an array-type ('B') tag +/** @param s Pointer to the tag data, as returned by bam_aux_get(). + @return The length of the array, or 0 if the tag is not an array type. + If the tag is not an array type, errno is set to EINVAL. + */ +HTSLIB_EXPORT +uint32_t bam_auxB_len(const uint8_t *s); + +/// Get an integer value from an array-type tag +/** @param s Pointer to the tag data, as returned by bam_aux_get(). + @param idx 0-based Index into the array + @return The idx'th value, or 0 on error. + If the array is not an integer type, errno is set to EINVAL. If idx + is greater than or equal to the value returned by bam_auxB_len(s), + errno is set to ERANGE. In both cases, 0 will be returned. + */ +HTSLIB_EXPORT +int64_t bam_auxB2i(const uint8_t *s, uint32_t idx); + +/// Get a floating-point value from an array-type tag +/** @param s Pointer to the tag data, as returned by bam_aux_get(). + @param idx 0-based Index into the array + @return The idx'th value, or 0.0 on error. + If the array is not a numeric type, errno is set to EINVAL. This can + only actually happen if the input record has an invalid type field. If + idx is greater than or equal to the value returned by bam_auxB_len(s), + errno is set to ERANGE. In both cases, 0.0 will be returned. + */ +HTSLIB_EXPORT +double bam_auxB2f(const uint8_t *s, uint32_t idx); + +/// Append tag data to a bam record +/* @param b The bam record to append to. + @param tag Tag identifier + @param type Tag data type + @param len Length of the data in bytes + @param data The data to append + @return 0 on success; -1 on failure. +If there is not enough space to store the additional tag, errno is set to +ENOMEM. If the type is invalid, errno may be set to EINVAL. errno is +also set to EINVAL if the bam record's aux data is corrupt. +*/ +HTSLIB_EXPORT +int bam_aux_append(bam1_t *b, const char tag[2], char type, int len, const uint8_t *data); + +/// Delete tag data from a bam record +/* @param b The bam record to update + @param s Pointer to the tag to delete, as returned by bam_aux_get(). + @return 0 on success; -1 on failure + If the bam record's aux data is corrupt, errno is set to EINVAL and this + function returns -1; +*/ +HTSLIB_EXPORT +int bam_aux_del(bam1_t *b, uint8_t *s); + +/// Update or add a string-type tag +/* @param b The bam record to update + @param tag Tag identifier + @param len The length of the new string + @param data The new string + @return 0 on success, -1 on failure + This function will not change the ordering of tags in the bam record. + New tags will be appended to any existing aux records. + + On failure, errno may be set to one of the following values: + + EINVAL: The bam record's aux data is corrupt or an existing tag with the + given ID is not of type 'Z'. + + ENOMEM: The bam data needs to be expanded and either the attempt to + reallocate the data buffer failed or the resulting buffer would be + longer than the maximum size allowed in a bam record (2Gbytes). +*/ +HTSLIB_EXPORT +int bam_aux_update_str(bam1_t *b, const char tag[2], int len, const char *data); + +/// Update or add an integer tag +/* @param b The bam record to update + @param tag Tag identifier + @param val The new value + @return 0 on success, -1 on failure + This function will not change the ordering of tags in the bam record. + New tags will be appended to any existing aux records. + + On failure, errno may be set to one of the following values: + + EINVAL: The bam record's aux data is corrupt or an existing tag with the + given ID is not of an integer type (c, C, s, S, i or I). + + EOVERFLOW (or ERANGE on systems that do not have EOVERFLOW): val is + outside the range that can be stored in an integer bam tag (-2147483647 + to 4294967295). + + ENOMEM: The bam data needs to be expanded and either the attempt to + reallocate the data buffer failed or the resulting buffer would be + longer than the maximum size allowed in a bam record (2Gbytes). +*/ +HTSLIB_EXPORT +int bam_aux_update_int(bam1_t *b, const char tag[2], int64_t val); + +/// Update or add a floating-point tag +/* @param b The bam record to update + @param tag Tag identifier + @param val The new value + @return 0 on success, -1 on failure + This function will not change the ordering of tags in the bam record. + New tags will be appended to any existing aux records. + + On failure, errno may be set to one of the following values: + + EINVAL: The bam record's aux data is corrupt or an existing tag with the + given ID is not of a float type. + + ENOMEM: The bam data needs to be expanded and either the attempt to + reallocate the data buffer failed or the resulting buffer would be + longer than the maximum size allowed in a bam record (2Gbytes). +*/ +HTSLIB_EXPORT +int bam_aux_update_float(bam1_t *b, const char tag[2], float val); + +/// Update or add an array tag +/* @param b The bam record to update + @param tag Tag identifier + @param type Data type (one of c, C, s, S, i, I or f) + @param items Number of items + @param data Pointer to data + @return 0 on success, -1 on failure + The type parameter indicates the how the data is interpreted: + + Letter code | Data type | Item Size (bytes) + ----------- | --------- | ----------------- + c | int8_t | 1 + C | uint8_t | 1 + s | int16_t | 2 + S | uint16_t | 2 + i | int32_t | 4 + I | uint32_t | 4 + f | float | 4 + + This function will not change the ordering of tags in the bam record. + New tags will be appended to any existing aux records. The bam record + will grow or shrink in order to accomodate the new data. + + The data parameter must not point to any data in the bam record itself or + undefined behaviour may result. + + On failure, errno may be set to one of the following values: + + EINVAL: The bam record's aux data is corrupt, an existing tag with the + given ID is not of an array type or the type parameter is not one of + the values listed above. + + ENOMEM: The bam data needs to be expanded and either the attempt to + reallocate the data buffer failed or the resulting buffer would be + longer than the maximum size allowed in a bam record (2Gbytes). +*/ +HTSLIB_EXPORT +int bam_aux_update_array(bam1_t *b, const char tag[2], + uint8_t type, uint32_t items, void *data); + +/************************** + *** Pileup and Mpileup *** + **************************/ + +#if !defined(BAM_NO_PILEUP) + +/*! @typedef + @abstract Generic pileup 'client data'. + + @discussion The pileup iterator allows setting a constructor and + destructor function, which will be called every time a sequence is + fetched and discarded. This permits caching of per-sequence data in + a tidy manner during the pileup process. This union is the cached + data to be manipulated by the "client" (the caller of pileup). +*/ +typedef union { + void *p; + int64_t i; + double f; +} bam_pileup_cd; + +/*! @typedef + @abstract Structure for one alignment covering the pileup position. + @field b pointer to the alignment + @field qpos position of the read base at the pileup site, 0-based + @field indel indel length; 0 for no indel, positive for ins and negative for del + @field level the level of the read in the "viewer" mode + @field is_del 1 iff the base on the padded read is a deletion + @field is_head 1 iff this is the first base in the query sequence + @field is_tail 1 iff this is the last base in the query sequence + @field is_refskip 1 iff the base on the padded read is part of CIGAR N op + @field aux (used by bcf_call_gap_prep()) + @field cigar_ind index of the CIGAR operator that has just been processed + + @discussion See also bam_plbuf_push() and bam_lplbuf_push(). The + difference between the two functions is that the former does not + set bam_pileup1_t::level, while the later does. Level helps the + implementation of alignment viewers, but calculating this has some + overhead. + */ +typedef struct { + bam1_t *b; + int32_t qpos; + int indel, level; + uint32_t is_del:1, is_head:1, is_tail:1, is_refskip:1, /* reserved */ :1, aux:27; + bam_pileup_cd cd; // generic per-struct data, owned by caller. + int cigar_ind; +} bam_pileup1_t; + +typedef int (*bam_plp_auto_f)(void *data, bam1_t *b); + +struct __bam_plp_t; +typedef struct __bam_plp_t *bam_plp_t; + +struct __bam_mplp_t; +typedef struct __bam_mplp_t *bam_mplp_t; + + /** + * bam_plp_init() - sets an iterator over multiple + * @func: see mplp_func in bam_plcmd.c in samtools for an example. Expected return + * status: 0 on success, -1 on end, < -1 on non-recoverable errors + * @data: user data to pass to @func + * + * The struct returned by a successful call should be freed + * via bam_plp_destroy() when it is no longer needed. + */ + HTSLIB_EXPORT + bam_plp_t bam_plp_init(bam_plp_auto_f func, void *data); + + HTSLIB_EXPORT + void bam_plp_destroy(bam_plp_t iter); + + HTSLIB_EXPORT + int bam_plp_push(bam_plp_t iter, const bam1_t *b); + + HTSLIB_EXPORT + const bam_pileup1_t *bam_plp_next(bam_plp_t iter, int *_tid, int *_pos, int *_n_plp); + + HTSLIB_EXPORT + const bam_pileup1_t *bam_plp_auto(bam_plp_t iter, int *_tid, int *_pos, int *_n_plp); + + HTSLIB_EXPORT + const bam_pileup1_t *bam_plp64_next(bam_plp_t iter, int *_tid, hts_pos_t *_pos, int *_n_plp); + + HTSLIB_EXPORT + const bam_pileup1_t *bam_plp64_auto(bam_plp_t iter, int *_tid, hts_pos_t *_pos, int *_n_plp); + + HTSLIB_EXPORT + void bam_plp_set_maxcnt(bam_plp_t iter, int maxcnt); + + HTSLIB_EXPORT + void bam_plp_reset(bam_plp_t iter); + + /** + * bam_plp_constructor() - sets a callback to initialise any per-pileup1_t fields. + * @plp: The bam_plp_t initialised using bam_plp_init. + * @func: The callback function itself. When called, it is given the + * data argument (specified in bam_plp_init), the bam structure and + * a pointer to a locally allocated bam_pileup_cd union. This union + * will also be present in each bam_pileup1_t created. + */ + HTSLIB_EXPORT + void bam_plp_constructor(bam_plp_t plp, + int (*func)(void *data, const bam1_t *b, bam_pileup_cd *cd)); + HTSLIB_EXPORT + void bam_plp_destructor(bam_plp_t plp, + int (*func)(void *data, const bam1_t *b, bam_pileup_cd *cd)); + + /// Get pileup padded insertion sequence + /** + * @param p pileup data + * @param ins the kstring where the insertion sequence will be written + * @param del_len location for deletion length + * @return the length of insertion string on success; -1 on failure. + * + * Fills out the kstring with the padded insertion sequence for the current + * location in 'p'. If this is not an insertion site, the string is blank. + * + * If del_len is not NULL, the location pointed to is set to the length of + * any deletion immediately following the insertion, or zero if none. + */ + HTSLIB_EXPORT + int bam_plp_insertion(const bam_pileup1_t *p, kstring_t *ins, int *del_len) HTS_RESULT_USED; + + /// Create a new bam_mplp_t structure + /** The struct returned by a successful call should be freed + * via bam_mplp_destroy() when it is no longer needed. + */ + HTSLIB_EXPORT + bam_mplp_t bam_mplp_init(int n, bam_plp_auto_f func, void **data); + + /// Set up mpileup overlap detection + /** + * @param iter mpileup iterator + * @return 0 on success; a negative value on error + * + * If called, mpileup will detect overlapping + * read pairs and for each base pair set the base quality of the + * lower-quality base to zero, thus effectively discarding it from + * calling. If the two bases are identical, the quality of the other base + * is increased to the sum of their qualities (capped at 200), otherwise + * it is multiplied by 0.8. + */ + HTSLIB_EXPORT + int bam_mplp_init_overlaps(bam_mplp_t iter); + + HTSLIB_EXPORT + void bam_mplp_destroy(bam_mplp_t iter); + + HTSLIB_EXPORT + void bam_mplp_set_maxcnt(bam_mplp_t iter, int maxcnt); + + HTSLIB_EXPORT + int bam_mplp_auto(bam_mplp_t iter, int *_tid, int *_pos, int *n_plp, const bam_pileup1_t **plp); + + HTSLIB_EXPORT + int bam_mplp64_auto(bam_mplp_t iter, int *_tid, hts_pos_t *_pos, int *n_plp, const bam_pileup1_t **plp); + + HTSLIB_EXPORT + void bam_mplp_reset(bam_mplp_t iter); + + HTSLIB_EXPORT + void bam_mplp_constructor(bam_mplp_t iter, + int (*func)(void *data, const bam1_t *b, bam_pileup_cd *cd)); + + HTSLIB_EXPORT + void bam_mplp_destructor(bam_mplp_t iter, + int (*func)(void *data, const bam1_t *b, bam_pileup_cd *cd)); + +#endif // ~!defined(BAM_NO_PILEUP) + + +/*********************************** + * BAQ calculation and realignment * + ***********************************/ + +HTSLIB_EXPORT +int sam_cap_mapq(bam1_t *b, const char *ref, hts_pos_t ref_len, int thres); + +/// Calculate BAQ scores +/** @param b BAM record + @param ref Reference sequence + @param ref_len Reference sequence length + @param flag Flags, see description + @return 0 on success \n + -1 if the read was unmapped, zero length, had no quality values, did not have at least one M, X or = CIGAR operator, or included a reference skip. \n + -3 if BAQ alignment has already been done and does not need to be applied, or has already been applied. \n + -4 if alignment failed (most likely due to running out of memory) + +This function calculates base alignment quality (BAQ) values using the method +described in "Improving SNP discovery by base alignment quality", Heng Li, +Bioinformatics, Volume 27, Issue 8 (https://doi.org/10.1093/bioinformatics/btr076). + +The following @param flag bits can be used: + +Bit 0: Adjust the quality values using the BAQ values + + If set, the data in the BQ:Z tag is used to adjust the quality values, and + the BQ:Z tag is renamed to ZQ:Z. + + If clear, and a ZQ:Z tag is present, the quality values are reverted using + the data in the tag, and the tag is renamed to BQ:Z. + +Bit 1: Use "extended" BAQ. + + Changes the BAQ calculation to increase sensitivity at the expense of + reduced specificity. + +Bit 2: Recalculate BAQ, even if a BQ tag is present. + + Force BAQ to be recalculated. Note that a ZQ:Z tag will always disable + recalculation. + +@bug +If the input read has both BQ:Z and ZQ:Z tags, the ZQ:Z one will be removed. +Depending on what previous processing happened, this may or may not be the +correct thing to do. It would be wise to avoid this situation if possible. +*/ + +HTSLIB_EXPORT +int sam_prob_realn(bam1_t *b, const char *ref, hts_pos_t ref_len, int flag); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/statistics/BamBasesCount.h b/src/statistics/BamBasesCount.h new file mode 100644 index 0000000..ee9b623 --- /dev/null +++ b/src/statistics/BamBasesCount.h @@ -0,0 +1,814 @@ +#ifndef bamBasesCount_H_ +#define bamBasesCount_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +void BaseCount_help() +{ + cout<<"" + "\n" + "\tUsage: BasesCount -l -o \n" + "\tUsage: BasesCount -i < A.bam B.bam > -o \n" + "\n" + "\t\t-i input SAM/BAM files, delimited by space\n" + "\t\t-l input list of SAM/BAM files\n" + "\t\t-o prefix of output file\n" + "\n" + "\t\t-b list of the regions of which the coverage and mean of depth would be given\n" + "\t\t-q the quality to filter reads, default [10]\n" + "\t\t-d Filter the PCR or optical duplicate read(DUP)\n" + "\t\t-s Filter the secondary alignment read(SECONDARY)\n" + "\t\t-c Filter the not passing quality controls read(QCFAIL)\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_BaseCount_help() +{ + cout<<"" + "\n" + "\t\t1. BasesCount -i -o AAA -q Q\n" + "\t\tBasesCount -l -o AAA -q Q\n" + "\t\tThis will generate three files (ATCG four base depth,depth frequency and basic statistics) and output the result to current directory. Output files are named with the prefix AAA.\n" + "\t\t(1.1) the reads with quality lower than Q will be removed from analysis, default value of Q is 10.\n" + "\t\t2. BasesCount -i -o AAA -b \n" + "\t\tBasesCount -l -o AAA -b \n" + "\t\tThis will generate the same outputs as the example above with an extra file giving\n" + "\t\tcoverage and mean of depth information for the regions listed in the .\n" + "\t\tThe is formatted as [Chr_name Start_site End_site]. For example:\n" + "\t\tChr1 1 100\n" + "\t\tChr1 1000 2000\n" + "\t\tChr2 3 50\n" + "\t\t...\n" + "\n" + "\n" + "\n"; +} +/* + int BaseCount_help() + { + cout <<"" + "\n" + "\tUsage: BasesCount -List -OutPut \n" + "\n" + "\t\t-InList Input Bam/Sam File List\n" + "\t\t-InFile Input Bam/Sam File File[repeat]\n" + "\t\t-OutPut OutPut File prefix\n" + "\n" + "\t\t-Bed Stat Coverage,MeanDepth for bed Regions\n" + "\t\t-MinQ Ignore too low mapQ read[10]\n" + "\t\t-RmDup Filter the duplicated read\n" + "\n" + "\t\t-help Show this help [hewm2008]\n" + "\n"; + return 1; + } + */ + +int BaseCount_help01(int argc, char **argv , In3str1v * paraFA04 ) +{ + if (argc <=1 ) {BaseCount_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "List" || flag == "l") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "Bed" || flag == "b") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr1=argv[i]; + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "RmDup" || flag == "d" ) + { + paraFA04->TF=false ; + } + else if (flag == "RmSec" || flag =="s") + { + paraFA04->TF2=false ; + } + else if (flag == "RmQCFAIL" || flag =="c") + { + paraFA04->InInt2=1 ; + } + else if (flag == "help" || flag == "h") + { + More_BaseCount_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InStr2)=add_Asuffix(paraFA04->InStr2); + return 1 ; +} + + +int BaseCount_main(int argc, char *argv[]) +//int main(int argc, char *argv[]) +{ + In3str1v *paraFA04 = new In3str1v; + paraFA04->InInt=10; + if ((BaseCount_help01(argc, argv, paraFA04)==0)) + { + delete paraFA04 ; + return 0 ; + } + + (paraFA04->InStr2)=(paraFA04->InStr2).substr(0,(paraFA04->InStr2).length()-3); + string path=(paraFA04->InStr2); + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + + string PrefixO=path; + + if (ext == "BaseCount" || ext == "Depth") + { + PrefixO=path.substr(0,path.rfind('.')); + } + + string outFaDepth=PrefixO+".BaseCount.gz"; + ogzstream OUT (outFaDepth.c_str()); + + if((!OUT.good())) + { + cerr << "open OUT File error: "<List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + + cout<<"begin new the memory ...\n"; + bool QCFAIL=true; + if ((paraFA04->InInt2)!=0) {QCFAIL=false;} + + unsigned short int **depth = new unsigned short int*[(header->n_targets)]; // + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])*5+500; + depth[i] = new unsigned short int [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=0; + } + } + + cout<<"new the memory done"<List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + uint32_t *cigar; + uint8_t *seq; + int iref =0; + int iseq=0; int arryFlag=0; + + + //#define BAM_CMATCH 0 + //#define BAM_CINS 1 + //#define BAM_CDEL 2 + //#define BAM_CREF_SKIP 3 + //#define BAM_CSOFT_CLIP 4 + //#define BAM_CHARD_CLIP 5 + //#define BAM_CPAD 6 + //#define BAM_CEQUAL 7 + //#define BAM_CDIFF 8 + + + if ((paraFA04->TF) && (paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + // BAM_CHARD_CLIP BAM_CPAD + } + } + + } + else if ((!paraFA04->TF) && (paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + } + } + } + else if ((!paraFA04->TF) && (!paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + } + } + } + else if ((paraFA04->TF) && (!paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x100 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + } + } + } + else if ((!paraFA04->TF) && (!paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + } + } + } + else if ((!paraFA04->TF) && (paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + } + } + } + else if ((paraFA04->TF) && (!paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x100 ) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + } + } + } + else if ((paraFA04->TF) && (paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][arryFlag]++; + iseq++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + iref=iref+ncig; + continue; + } + else if(cig==BAM_CINS || cig==BAM_CSOFT_CLIP ) + { + iseq += ncig; + continue; + } + } + } + } + + + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + + cout <<"ALL Bam Read done"< MapDepthSum ; + map :: iterator Th_mapiT ; + ubit64_t Sum_chrLen=0; + ubit64_t Sum_CoverBase=0; + ubit64_t Sum_Depth=0; + OUT<<"#site\tA_Count\tC_Count\tG_Count\tT_Count\n##Site with Zero Depth no OutPut"<n_targets); i++) + { + OUT<<">"<<(header->target_name[i])< MapDepthChr ; + map :: iterator mapIt_Depth ; + int CC=(header->target_len[i])*5; + int Site=0; + for (int j=0; j :: value_type (SiteSumDepth,1)); + } + else + { + (mapIt_Depth->second)++; + } + Site++; + if (SiteSumDepth==0) + { + continue; + } + OUT<first)!=0) + { + CovBase+=mapIt_Depth->second; + } + Th_mapiT=MapDepthSum.find(mapIt_Depth->first); + TotalDepth+=(mapIt_Depth->second)*(mapIt_Depth->first); + if (Th_mapiT==MapDepthSum.end()) + { + MapDepthSum.insert( map :: value_type (mapIt_Depth->first,mapIt_Depth->second)); + } + else + { + (Th_mapiT->second)+=(mapIt_Depth->second); + } + } + + double Coverage=CovBase*100.0/(header->target_len[i]); + double MeanDepth=TotalDepth*1.0/(header->target_len[i]); + Sum_chrLen+=(header->target_len[i]); + Sum_CoverBase+=CovBase ; + Sum_Depth+=TotalDepth; + OUTSTAT<<(header->target_name[i])<<"\t"<<(header->target_len[i])<<"\t"<first<<"\t"<second<InStr1).empty()) + { + + string StatBed=PrefixO+".bed.stat"; + ofstream OUTPP (StatBed.c_str()); + + igzstream LIST ((paraFA04->InStr1).c_str(),ifstream::in); // igzstream + if (!LIST.good()) + { + cerr << "open bed File error: "<<(paraFA04->InStr1)< Chr2IntMap; + for(int i = 0; i < (header->n_targets); i++) + { + string ChrName=header->target_name[i]; + Chr2IntMap.insert( map :: value_type (ChrName,i)); + } + + map :: iterator MapItChr2Int ; + int Start ; int End ; string ChrName ; + ubit64_t SS_Len =0; + ubit64_t SS_Cov=0; + ubit64_t SS_TotalD=0; + int SiteDepth=0; + int ArryFlag=0; int NumCover=0; ubit64_t SumDepth=0; + int Length= 0; + while(!LIST.eof()) + { + string line; + getline(LIST,line); + if (line.length()<=0) {continue;} + if (line[0] == '#') { OUTPP<>ChrName>>Start>>End; + if (Start > End ) + { + cerr<second][ArryFlag+1]+depth[MapItChr2Int->second][ArryFlag+2]+depth[MapItChr2Int->second][ArryFlag+3]+depth[MapItChr2Int->second][ArryFlag+4]; + if ( SiteDepth >0 ) + { + NumCover++; + SumDepth+=SiteDepth; + } + } + double Coverage=NumCover*100.0/Length ; + double MeanDepth=SumDepth*1.0/Length ; + OUTPP<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + + + bam_hdr_destroy(header); + delete paraFA04 ; + return 0; +} +#endif // bamBasesCount_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/statistics/BamCoverage.h b/src/statistics/BamCoverage.h new file mode 100644 index 0000000..b934d8a --- /dev/null +++ b/src/statistics/BamCoverage.h @@ -0,0 +1,1086 @@ +#ifndef bamCov_H_ +#define bamCov_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +//KSEQ_INIT(gzFile, gzread) + + +void bamCov_help() +{ + cout<<"" + "\n" + "\tUsage: Coverage -l -r -o \n" + "\tUsage: Coverage -i -r -o \n" + "\n" + "\t\t-i input SAM/BAM/cram files, delimited by space\n" + "\t\t-l input list of SAM/BAM/cram files\n" + "\t\t-o prefix of output file\n" + "\n" + "\t\t-r input reference FASTA to get Depth-GC wig\n" + "\t\t-w windows size for Depth-GC wig, default [10000]\n" + "\t\t-b list of the regions of which the coverage and mean of depth would be given\n" + "\t\t-g InPut gff/gtf file to stat only gene CDS Depth/Coverage\n" + "\n" + "\t\t-q the quality to filter reads, default [0]\n" + "\t\t-d Filter the PCR or optical duplicate read(DUP)\n" + "\t\t-s Filter the secondary alignment read(SECONDARY)\n" + "\t\t-c Filter the not passing quality controls read(QCFAIL)\n" + "\n" + "\t\t-h show more details for help [hewm2008 v1.42]\n" + "\n"; +} + +/* + int bamCov_help() + { + cout <<"" + "\n" + "\tUsage: Coverage -List -OutPut \n" + "\n" + "\t\t-InList Input Bam/Sam File List\n" + "\t\t-InFile Input Bam/Sam File File[repeat]\n" + "\t\t-OutPut OutPut File prefix\n" + "\n" + "\t\t-Ref In Ref.fa If Want Out Depth-GC wig info\n" + "\t\t-Windows Windows size for Depth-GC wig[10000]\n" + "\t\t-Bed Stat Coverage,MeanDepth for these bed Regions\n" + "\n" + "\t\t-MinQ Filter the read with low mapQ[10]\n" + "\t\t-RmDup Filter the duplicated read\n" + "\n" + "\t\t-help Show this help [hewm2008 v1.32]\n" + "\n"; + return 1; + } + */ + +void More_bamCov_help() +{ + cout<<"" + "\n" + "\t\t1. Coverage -i -r -o AAA -q Q\n" + "\t\tCoverage -l -r -o AAA -q Q\n" + "\t\tThis will generate four files (GC with depth, depth frequency, depth along reads in reference FASTA and basic statistics) and output the result to current directory. Output files are named with the prefix AAA.\n" + "\t\t(1.1) the reads with quality lower than Q will be removed from analysis, default value of Q is 10.\n" + "\n" + "\t\t2. Coverage -i -r -o AAA -b \n" + "\t\tCoverage -l -r -o AAA -b \n" + "\t\tThis will generate the same outputs as the example above with an extra file giving coverage and mean of depth information for the regions listed in the . The is formatted as [Chr_name Start_site End_site]. For example:\n" + "\t\tChr1 1 100\n" + "\t\tChr1 1000 2000\n" + "\t\tChr2 3 50\n" + "\t\t...\n" + "\n" + "\n"; +} + + +int bamCov_help01(int argc, char **argv , In3str1v * paraFA04 , In3str1v * SedparaFA04 ) +{ + if (argc <=1 ) {bamCov_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + + + if (flag == "InList" || flag == "List" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutPut"|| flag == "o" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "Ref" || flag =="r") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr3=argv[i]; + } + else if (flag == "Gff" || flag =="g" || flag =="Gtf") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + SedparaFA04->InStr1=argv[i]; + SedparaFA04->InInt=3; + + igzstream INGFF (argv[i],ifstream::in); + if (INGFF.fail()) + { + cerr << "open File error: "<InInt=1; + } + else if (tmp.find("transcript_id")!=string::npos) + { + SedparaFA04->InInt=2; + } + } + + INGFF.close(); + + if (SedparaFA04->InInt==3) + { + cerr<<"Error:InPut gff/gtf file can not find [Parent] or [transcript_id] to judge GFF or GTF,please check the -g file :"<InStr1=argv[i]; + } + else if (flag == "Windows" || flag =="w") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InF=atof(argv[i]); + } + else if (flag == "MinQ" || flag =="q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "RmDup" || flag =="d") + { + paraFA04->TF=false ; + } + else if (flag == "RmSec" || flag =="s") + { + paraFA04->TF2=false ; + } + else if (flag == "RmQCFAIL" || flag =="c") + { + paraFA04->InInt2=1 ; + } + else if (flag == "help" || flag =="h") + { + More_bamCov_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InStr2)=add_Asuffix(paraFA04->InStr2); + return 1 ; +} + + +int bamCov_main(int argc, char *argv[]) +//int main(int argc, char *argv[]) +{ + In3str1v *paraFA04 = new In3str1v; + In3str1v *SedparaFA04 = new In3str1v; + paraFA04->InInt=-1; + paraFA04->InF=10000; + if ((bamCov_help01(argc, argv, paraFA04,SedparaFA04)==0)) + { + delete paraFA04 ; + return 0 ; + } + + + (paraFA04->InStr2)=(paraFA04->InStr2).substr(0,(paraFA04->InStr2).length()-3); + string path=(paraFA04->InStr2); + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + + string PrefixO=path; + + + if (ext == "depthsite" || ext == "DepthGC") + { + PrefixO=path.substr(0,path.rfind('.')); + } + + string outFaDepth=PrefixO+".depthsite.fa.gz"; + ogzstream OUT (outFaDepth.c_str()); + + if((!OUT.good())) + { + cerr << "open OUT File error: "<List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + if(BamIn->format.format == htsExactFormat::cram) + { + if ((paraFA04->InStr3).empty()) + { + cerr<<"InPut cram file must add -r ref.fa as together\n"; + return 1; + } + const char* ref_file = (paraFA04->InStr3).c_str(); + hts_set_fai_filename(BamIn, ref_file); + } + + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + + cout<<"begin new the memory ...\n"; + + unsigned short int **depth = new unsigned short int*[(header->n_targets)]; // + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])+500; + depth[i] = new unsigned short int [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=0; + } + } + + cout<<"new the memory done"<InInt2)!=0) {QCFAIL=false;} + int FileNum=(paraFA04->List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<format.format == htsExactFormat::cram) + { + if ((paraFA04->InStr3).empty()) + { + cerr<<"InPut cram file must add -r ref.fa as together\n"; + return 1; + } + const char* ref_file = (paraFA04->InStr3).c_str(); + hts_set_fai_filename(BamIn, ref_file); + } + + headerA = sam_hdr_read(InBam); + + if ((header->n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + uint32_t *cigar; + + //#define BAM_CMATCH 0 + //#define BAM_CINS 1 + //#define BAM_CDEL 2 + //#define BAM_CREF_SKIP 3 + //#define BAM_CSOFT_CLIP 4 + //#define BAM_CHARD_CLIP 5 + //#define BAM_CPAD 6 + //#define BAM_CEQUAL 7 + //#define BAM_CDIFF 8 + + if ( (paraFA04->TF) && (paraFA04->TF2) && QCFAIL ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) + { + continue ; + } + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + } + } + else if ( (!paraFA04->TF) && (paraFA04->TF2) && QCFAIL ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) { continue ; } + if ( (aln->core).flag & 0x400 ) { continue ; } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + } + else if ( (!paraFA04->TF) && (!paraFA04->TF2) && QCFAIL ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) { continue ; } + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + } + else if ( (paraFA04->TF) && (!paraFA04->TF2) && QCFAIL ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + } + else if ( (!paraFA04->TF) && (!paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) { continue ; } + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + } + else if ( (!paraFA04->TF) && (paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + if ( (aln->core).flag & 0x400 ) { continue ; } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + } + else if ( (paraFA04->TF) && (paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + } + else if ( (paraFA04->TF) && (!paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + } + + + + + + + + + + + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + + cout <<"ALL Bam Read done"<InStr3).empty()) + { + string GCDepth=PrefixO+".DepthGC.gz"; + ogzstream OUTGC (GCDepth.c_str()); + OUTGC<<"##Bigin\tDepth(X)\tGC(%)\n"; + + gzFile fp; + kseq_t *seq; + int l; + fp = gzopen((paraFA04->InStr3).c_str(), "r"); + seq = kseq_init(fp); + int Windows=int(paraFA04->InF); + int cutOffLen=int(Windows*0.4); + while ((l = kseq_read(seq)) >= 0) + { + int NumIntSca=0; + for(NumIntSca=0; NumIntSca <(header->n_targets); NumIntSca++) + { + if ( strcmp(header->target_name[NumIntSca],(seq->name.s)) ==0) + { + break; + } + } + int LastDis=(header->target_len[NumIntSca])-(Windows); + if (LastDis<0) {continue;} + OUTGC<<"#>"<<(seq->name.s)<<"\tWindowsSite:\t"<<(Windows)<seq.s[site]]++; + TotalDepth+=depth[NumIntSca][site]; + } + int N_Aleng= Ascii['N']+Ascii['n'] ; + int eff_Acout=(Windows)-N_Aleng ; + if (eff_Acout MapDepthSum ; + map :: iterator Th_mapiT ; + ubit64_t Sum_chrLen=0; + ubit64_t Sum_CoverBase=0; + ubit64_t Sum_Depth=0; + + for(int i = 0; i <(header->n_targets); i++) + { + + OUT<<">"<<(header->target_name[i]); + map MapDepthChr ; + map :: iterator mapIt_Depth ; + + for (int j =0 ; j< (header->target_len[i]) ; j++) + { + + mapIt_Depth=MapDepthChr.find(depth[i][j]); + if (mapIt_Depth==MapDepthChr.end()) + { + MapDepthChr.insert( map :: value_type (depth[i][j],1)); + } + else + { + (mapIt_Depth->second)++; + } + + if (j%50000==0) + { + OUT<first)!=0) + { + CovBase+=mapIt_Depth->second; + } + Th_mapiT=MapDepthSum.find(mapIt_Depth->first); + TotalDepth+=(mapIt_Depth->second)*(mapIt_Depth->first); + if (Th_mapiT==MapDepthSum.end()) + { + MapDepthSum.insert( map :: value_type (mapIt_Depth->first,mapIt_Depth->second)); + } + else + { + (Th_mapiT->second)+=(mapIt_Depth->second); + } + } + + double Coverage=CovBase*100.0/(header->target_len[i]); + double MeanDepth=TotalDepth*1.0/(header->target_len[i]); + Sum_chrLen+=(header->target_len[i]); + Sum_CoverBase+=CovBase ; + Sum_Depth+=TotalDepth; + OUTSTAT<<(header->target_name[i])<<"\t"<<(header->target_len[i])<<"\t"<first<<"\t"<second<InStr1).empty()) + { + + string StatBed=PrefixO+".bed.stat"; + ofstream OUTPP (StatBed.c_str()); + + igzstream LIST ((paraFA04->InStr1).c_str(),ifstream::in); // igzstream + if (!LIST.good()) + { + cerr << "open bed File error: "<<(paraFA04->InStr1)< Chr2IntMap; + for(int i = 0; i < (header->n_targets); i++) + { + string ChrName=header->target_name[i]; + Chr2IntMap.insert( map :: value_type (ChrName,i)); + } + + map :: iterator MapItChr2Int ; + int Start ; int End ; string ChrName ; + ubit64_t SS_Len =0; + ubit64_t SS_Cov=0; + ubit64_t SS_TotalD=0; + + // OUTPP<<"#chr\tStart\tEnd\tCoverage%\tMeanDepth"<>ChrName>>Start>>End; + if (Start > End ) + { + cerr<second][ii]>0 ) + { + NumCover++; + SumDepth+=(depth[MapItChr2Int->second][ii]); + } + } + double Coverage=NumCover*100.0/Length ; + double MeanDepth=SumDepth*1.0/Length ; + OUTPP<InInt)!=0) + { + + string StatBed=PrefixO+".gene.stat"; + ofstream OUTPP (StatBed.c_str()); + + igzstream LIST ((SedparaFA04->InStr1).c_str(),ifstream::in); // igzstream + if (!LIST.good()) + { + cerr << "open bed File error: "<<(paraFA04->InStr1)< Chr2IntMap; + for(int i = 0; i < (header->n_targets); i++) + { + string ChrName=header->target_name[i]; + Chr2IntMap.insert( map :: value_type (ChrName,i)); + } + + map :: iterator MapItChr2Int ; + int Start ; int End ; string ChrName ; + ubit64_t SS_Len =0; + ubit64_t SS_Cov=0; + ubit64_t SS_TotalD=0; + unordered_map GeneLength; + unordered_map GeneCover; + unordered_map GeneDepth; + + // OUTPP<<"#chr\tStart\tEnd\tCoverage%\tMeanDepth"<InInt)==1) + { + + while(!LIST.eof()) + { + string line; + getline(LIST,line); + + if (line.length()<=0 || line[0] == '#' ) { continue ; } + istringstream isone (line,istringstream::in); + string flag , CDS , ZhengFu ,geneID ; + llong Start,End ; + isone>>ChrName>>flag>>CDS ; + if (CDS != "CDS" ) { continue ; } + isone>>Start>>End>>flag>>ZhengFu>>flag>>geneID ; + vector inf; + vector Temp; + split(geneID,inf,",;"); + split(inf[0],Temp,"="); + string GeneID= Temp[Temp.size()-1] ; + for ( int jk=1; jk Temptmp2; + split(inf[jk],Temptmp2,"="); + if (Temptmp2[0] == "Parent") + { + GeneID= Temptmp2[Temptmp2.size()-1]; + } + } + + + Start--; End--; + + MapItChr2Int=Chr2IntMap.find(ChrName); + + if (MapItChr2Int==Chr2IntMap.end()) + { + cerr<second][ii]>0 ) + { + NumCover++; + SumDepth+=(depth[MapItChr2Int->second][ii]); + } + } + GeneLength[GeneID]+=Length; + GeneCover[GeneID]+=NumCover; + GeneDepth[GeneID]+=SumDepth; + SS_Cov+=NumCover; + SS_Len+=Length; + SS_TotalD+=SumDepth; + } + } + + } + else + { + + while(!LIST.eof()) + { + string line; + getline(LIST,line); + + if (line.length()<=0 || line[0] == '#' ) { continue ; } + line=replace_all(line,"\"",""); + line=replace_all(line,";",""); + istringstream isone (line,istringstream::in); + string flag , CDS , ZhengFu ,geneID ; + llong Start,End ; + isone>>ChrName>>flag>>CDS ; + if (CDS != "CDS" ) { continue ; } + isone>>Start>>End>>flag>>ZhengFu>>flag ; + vector inf; + split(line,inf,"\t "); + string GeneID=inf[9]; + for ( int jk=8; jksecond][ii]>0 ) + { + NumCover++; + SumDepth+=(depth[MapItChr2Int->second][ii]); + } + } + GeneLength[GeneID]+=Length; + GeneCover[GeneID]+=NumCover; + GeneDepth[GeneID]+=SumDepth; + SS_Cov+=NumCover; + SS_Len+=Length; + SS_TotalD+=SumDepth; + } + } + } + LIST.close(); + + OUTPP<<"#GeneID\tLength\tCoveredSite\tTotalDepth\tCoverage%\tMeanDepth\n"; + + for (auto iter = GeneLength.begin(); iter != GeneLength.end(); ++iter) + { + string GeneID=iter->first; + int Length=GeneLength[GeneID]; + int NumCover=GeneCover[GeneID]; + int SumDepth= GeneDepth[GeneID]; + double Coverage=NumCover*100.0/Length ; + double MeanDepth=SumDepth*1.0/Length; + OUTPP<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + + + bam_hdr_destroy(header); + delete paraFA04 ; + delete SedparaFA04; + return 0; +} +#endif // bamCov_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/statistics/BamDeteCNV.h b/src/statistics/BamDeteCNV.h new file mode 100644 index 0000000..6a1fbf4 --- /dev/null +++ b/src/statistics/BamDeteCNV.h @@ -0,0 +1,984 @@ +#ifndef bamCNV_H_ +#define bamCNV_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include "Bmath/pnorm.c" +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +//KSEQ_INIT(gzFile, gzread) +/* +int bamCNV_help() +{ + cout <<"" + "\n" + "\tUsage: DeteCNV -List -OutPut \n" + "\n" + "\t\t-InList Input Bam/Sam File List\n" + "\t\t-InFile Input Bam/Sam File File[repeat]\n" + "\t\t-Ref In Ref.fa If Want Out Ref N-base ratio info\n" + "\t\t-OutPut OutPut CNV File Prefix\n" + "\n" + "\t\t-Ratio DepthRatio to judge breakpoint of merge adjacent[0.45]\n" + "\t\t-ChrDepth Use Chr Depth as mean depth,default whole genome\n" + "\n" + "\t\t-MinLength Min Length of CNV length [1800]\n" + "\t\t-PValue PValue of CNV Depth bias[0.02]\n" + "\t\t-MinQ Filter the low mapQ read in bam[10]\n" + "\n" + "\t\t-help Show this help [hewm2008]\n" + "\n"; + return 1; +} +*/ +void bamCNV_help() +{ +cout<<"" +"\n" +"\tUsage: DeteCNV -l -r -o \n" +"\tUsage: DeteCNV -i -r -o \n" +"\n" +"\t\t-i input SAM/BAM files, delimited by space\n" +"\t\t-l input list of SAM/BAM files\n" +"\t\t-o prefix of output file\n" +"\t\t-r input reference FASTA to get N-base ratio \n" +"\n" +"\t\t-f depthRatio to judge breakpoint of merge adjacent[0.45]\n" +"\t\t-c for each chromosome, use its own mean of depth into calculation\n" +"\t\t default would use the mean of depth of the whole genome\n" +"\n" +"\t\t-m set the minimum length of CNV, default [1800]\n" +"\t\t-p p-value of CNV depth bias, default [0.02]\n" +"\t\t-q the quality to filter reads, default [10]\n" +"\n" +"\t\t-h show more details for help\n" +"\n" +"\n"; +} + + + +void More_bamCNV_help() +{ +cout<<"" +"\n" +"\t\t1. DeteCNV -i -r -o AAA -q Q -m M\n" +"\t\tDeteCNV -l -r -o AAA -q Q -m M\n" +"\t\tThis will generate two files (raw cnv file and filtered cnv file) and output the result to current directory. Output files are named with the prefix AAA.\n" +"\t\t(1.1) the reads with quality lower than Q will be removed from analysis, default value of Q is 10.\n" +"\t\t(1.2) it will not be considered a CNV with the minimum length less than M, default value of M is 1800.\n" +"\n" +"\n" +"\n"; +} + + +int bamCNV_help01(int argc, char **argv , In3str1v * paraFA04 ) +{ + if (argc <=1 ) {bamCNV_help();return 0;} + (paraFA04->InStr1)="0.02"; + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "List" || flag == "l") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "Ref" || flag == "r") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr3=argv[i]; + } + else if (flag == "PValue" || flag == "p") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + (paraFA04->InStr1)=argv[i]; + } + else if (flag == "Ratio" || flag == "f") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InF=atof(argv[i]); + } + else if (flag == "MinLength" || flag == "m") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt2=atoi(argv[i]); + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "ChrDepth" || flag == "c" ) + { + paraFA04->TF=false ; + } + else if (flag == "help" || flag == "h") + { + More_bamCNV_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() || (paraFA04->InStr3).empty() ) + { + cerr<< "lack argument for the must"<InStr2)=add_Asuffix(paraFA04->InStr2); + return 1 ; +} + + +int bamCNV_main(int argc, char *argv[]) +//int main(int argc, char *argv[]) +{ + In3str1v *paraFA04 = new In3str1v; + paraFA04->InInt=10; + paraFA04->InInt2=1800; + paraFA04->InF=0.45; + if ((bamCNV_help01(argc, argv, paraFA04)==0)) + { + delete paraFA04 ; + return 0 ; + } + + double FilterPValue=atof((paraFA04->InStr1).c_str()) ; + if (FilterPValue >0.5 ) + { + FilterPValue=0.5; + cout<<"warning P value should no too big, reset 0.5"<List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + + cout<<"begin new the memory ...\n"; + + unsigned short int **depth = new unsigned short int*[(header->n_targets)]; // + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])+500; + depth[i] = new unsigned short int [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=0; + } + } + + cout<<"new the memory done"<List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + + uint32_t *cigar; + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) + { + continue ; + } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + } + + + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + + cout <<"ALL Bam Read done"<InStr2).substr(0,(paraFA04->InStr2).length()-3); + string StatF=PrefixO+".tmp"; + ofstream OUTSTAT (StatF.c_str()); + + cout<<"#ID\tLength\tCoverageBase\tTotalDepth\tCoverage%\tMeanDepth"< MapDepthSum ; + map :: iterator Th_mapiT ; + ubit64_t Sum_chrLen=0; + ubit64_t Sum_CNVerBase=0; + ubit64_t Sum_Depth=0; + + + struct Region + { + int start; + int end ; + double depth; + }; + + vector ThisChrRegion ; + vector ArryRegion ; + + + for(int i = 0; i <(header->n_targets); i++) + { + map MapDepthChr; + map :: iterator mapIt_Depth; + Region One ; + One.start=0;One.end=0;One.depth=depth[i][0]; + ArryRegion.clear(); + + + for (int j =0 ; j< (header->target_len[i]) ; j++) + { + mapIt_Depth=MapDepthChr.find(depth[i][j]); + if (mapIt_Depth==MapDepthChr.end()) + { + MapDepthChr.insert( map :: value_type (depth[i][j],1)); + } + else + { + (mapIt_Depth->second)++; + } + + if (One.depth==depth[i][j]) + { + One.end=j; + } + else + { + ArryRegion.push_back(One); + One.start=j;One.end=j;One.depth=depth[i][j]; + } + } + + ArryRegion.push_back(One); + + + ubit64_t CNVBase=0; + ubit64_t TotalDepth=0; + for (mapIt_Depth=MapDepthChr.begin(); mapIt_Depth!=MapDepthChr.end(); mapIt_Depth++) + { + if ((mapIt_Depth->first)!=0) + { + CNVBase+=mapIt_Depth->second; + } + Th_mapiT=MapDepthSum.find(mapIt_Depth->first); + TotalDepth+=(mapIt_Depth->second)*(mapIt_Depth->first); + if (Th_mapiT==MapDepthSum.end()) + { + MapDepthSum.insert( map :: value_type (mapIt_Depth->first,mapIt_Depth->second)); + } + else + { + (Th_mapiT->second)+=(mapIt_Depth->second); + } + } + + double CNVerage=CNVBase*100.0/(header->target_len[i]); + double MeanDepth=TotalDepth*1.0/(header->target_len[i]); + Sum_chrLen+=(header->target_len[i]); + Sum_CNVerBase+=CNVBase ; + Sum_Depth+=TotalDepth; + cout<<(header->target_name[i])<<"\t"<<(header->target_len[i])<<"\t"<InF) > AA ) + { + AA=paraFA04->InF; + } + else + { + binDouble=(AA-(paraFA04->InF))/10; + } + double BB=1/AA; + + for ( ; ii< 20 ; ii++) + { + if (AA > paraFA04->InF ) + { + RunFlag=false ; + AA=AA-binDouble; + } + BB=1/AA; + if (RunFlag) {break ;} + RunFlag=true; + + if (VecAB) + { + ThisChrRegion.clear(); + VecAB=false ; + ZV_size =ArryRegion.size(); + One.start=ArryRegion[0].start; + One.end=ArryRegion[0].end; + One.depth=ArryRegion[0].depth; + for (int j=1 ; j< ZV_size ; j++) + { + double ratio = 0; + if (ArryRegion[j].depth>0) + { + ratio=One.depth/ArryRegion[j].depth; + } + if (ratio > AA && ratio < BB ) + { + int LengthA=ArryRegion[j].end-ArryRegion[j].start+1; + int LengthB=One.end-One.start+1; + One.depth=(One.depth*LengthB+ArryRegion[j].depth*LengthA)/(LengthA+LengthB); + One.end=ArryRegion[j].end; + RunFlag=false ; + } + else + { + ThisChrRegion.push_back(One); + One.start=ArryRegion[j].start; + One.end=ArryRegion[j].end; + One.depth=ArryRegion[j].depth; + } + } + ThisChrRegion.push_back(One); + } + else + { + ArryRegion.clear(); + VecAB=true ; + ZV_size =ThisChrRegion.size(); + One.start=ThisChrRegion[0].start; + One.end=ThisChrRegion[0].end; + One.depth=ThisChrRegion[0].depth; + + for (int j=1 ; j< ZV_size ; j++) + { + double ratio = 0; + if (ArryRegion[j].depth>0) + { + ratio=One.depth/ThisChrRegion[j].depth; + } + if (ratio > AA && ratio < BB ) + { + int LengthA=ThisChrRegion[j].end-ThisChrRegion[j].start+1; + int LengthB=One.end-One.start+1; + One.depth=(One.depth*LengthB+ThisChrRegion[j].depth*LengthA)/(LengthA+LengthB); + One.end=ThisChrRegion[j].end; + RunFlag=false; + } + else + { + ArryRegion.push_back(One); + One.start=ThisChrRegion[j].start; + One.end=ThisChrRegion[j].end; + One.depth=ThisChrRegion[j].depth; + } + } + ArryRegion.push_back(One); + } + } + + + + + /// meger Low Depth /// + AA=MeanDepth*0.1; + if (VecAB) + { + ThisChrRegion.clear(); + ZV_size =ArryRegion.size(); + One.start=ArryRegion[0].start; + One.end=ArryRegion[0].end; + One.depth=ArryRegion[0].depth; + VecAB=false ; + for (int j=1 ; j< ZV_size ; j++) + { + if ( One.depth < AA && ArryRegion[j].depth < AA ) + { + int LengthA=ArryRegion[j].end-ArryRegion[j].start+1; + int LengthB=One.end-One.start+1; + One.depth=(One.depth*LengthB+ArryRegion[j].depth*LengthA)/(LengthA+LengthB); + One.end=ArryRegion[j].end; + } + else + { + ThisChrRegion.push_back(One); + One.start=ArryRegion[j].start; + One.end=ArryRegion[j].end; + One.depth=ArryRegion[j].depth; + } + } + ThisChrRegion.push_back(One); + } + else + { + ArryRegion.clear();VecAB=true ; + ZV_size =ThisChrRegion.size(); + One.start=ThisChrRegion[0].start; + One.end=ThisChrRegion[0].end; + One.depth=ThisChrRegion[0].depth; + for (int j=1 ; j< ZV_size ; j++) + { + if ( One.depth < AA && ThisChrRegion[j].depth < AA ) + { + int LengthA=ThisChrRegion[j].end-ThisChrRegion[j].start+1; + int LengthB=One.end-One.start+1; + One.depth=(One.depth*LengthB+ThisChrRegion[j].depth*LengthA)/(LengthA+LengthB); + One.end=ThisChrRegion[j].end; + } + else + { + ArryRegion.push_back(One); + One.start=ThisChrRegion[j].start; + One.end=ThisChrRegion[j].end; + One.depth=ThisChrRegion[j].depth; + } + } + ArryRegion.push_back(One); + } + + + + RunFlag=false ; + AA=paraFA04->InF; + BB=1/AA; + + for ( ; ii< 100; ii++) + { + if (RunFlag) {break ;} + RunFlag=true; + if (VecAB) + { + ThisChrRegion.clear();VecAB=false; + ZV_size =ArryRegion.size(); + One.start=ArryRegion[0].start; + One.end=ArryRegion[0].end; + One.depth=ArryRegion[0].depth; + for (int j=1 ; j< ZV_size; j++) + { + double ratio = 0; + if (ArryRegion[j].depth>0) + { + ratio=One.depth/ArryRegion[j].depth; + } + if (ratio > AA && ratio < BB ) + { + int LengthA=ArryRegion[j].end-ArryRegion[j].start+1; + int LengthB=One.end-One.start+1; + One.depth=(One.depth*LengthB+ArryRegion[j].depth*LengthA)/(LengthA+LengthB); + One.end=ArryRegion[j].end; + RunFlag=false ; + } + else + { + ThisChrRegion.push_back(One); + One.start=ArryRegion[j].start; + One.end=ArryRegion[j].end; + One.depth=ArryRegion[j].depth; + } + } + ThisChrRegion.push_back(One); + ArryRegion.clear(); + } + else + { + ArryRegion.clear();VecAB=true; + ZV_size =ThisChrRegion.size(); + One.start=ThisChrRegion[0].start; + One.end=ThisChrRegion[0].end; + One.depth=ThisChrRegion[0].depth; + + for (int j=1 ; j< ZV_size ; j++) + { + double ratio = 0; + if (ArryRegion[j].depth>0) + { + ratio=One.depth/ThisChrRegion[j].depth; + } + if (ratio > AA && ratio < BB ) + { + int LengthA=ThisChrRegion[j].end-ThisChrRegion[j].start+1; + int LengthB=One.end-One.start+1; + One.depth=(One.depth*LengthB+ThisChrRegion[j].depth*LengthA)/(LengthA+LengthB); + One.end=ThisChrRegion[j].end; + RunFlag=false; + } + else + { + ArryRegion.push_back(One); + One.start=ThisChrRegion[j].start; + One.end=ThisChrRegion[j].end; + One.depth=ThisChrRegion[j].depth; + } + } + ArryRegion.push_back(One); + ThisChrRegion.clear(); + } + } + + + + + double CNV_N; + if (VecAB) + { + ZV_size=ArryRegion.size(); + for (int j=0 ; j< ZV_size ; j++) + { + CNV_N=ArryRegion[j].depth/MeanDepth; + OUTSTAT<<(header->target_name[i])<<"\t"<target_name[i])<<"\t"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + bam_hdr_destroy(header); + + + + + + + + + + + + // // + // // + // // + // // + // // + + + long double Lsd=0.0 ; ubit64_t L_count=0; + long double Rsd=0.0 ; ubit64_t R_count=0; + long double diff=0.0 ; + long double this_count=0.0 ; + string tempsss; + int Start , End; + double DepthRegion; + + + igzstream INB ((StatF).c_str(),ifstream::in); + if(!INB.good()) + { + cerr << "open IN File error: "<TF) + { + while(!INB.eof()) + { + string line ; + getline(INB,line); + if ( (line.length()<=0) || (line[0] == '#') ) { continue ;} + istringstream stream (line,istringstream::in); + stream >> tempsss>>Start>>End ; + stream >>DepthRegion ; + this_count=DepthRegion/MeanDepth; + diff=this_count-1.0 ; + int NumC=(End-Start+1); + if (diff>0) + { + R_count+=NumC; + Rsd+=(diff*diff)*NumC; + } + else if (diff<0) + { + L_count+=NumC; + Lsd+=(diff*diff)*NumC; + } + } + } + else + { + while(!INB.eof()) + { + string line ; + getline(INB,line); + if ( (line.length()<=0) || (line[0] == '#') ) { continue ;} + istringstream stream (line,istringstream::in); + stream >> tempsss>>Start>>End ; + stream >>DepthRegion>> this_count ; + diff=this_count-1.0 ; + int NumC=(End-Start+1); + if (diff>0) + { + R_count+=NumC; + Rsd+=(diff*diff)*NumC; + } + else if (diff<0) + { + L_count+=NumC; + Lsd+=(diff*diff)*NumC; + } + } + + } + + INB.close(); + Rsd=sqrt(Rsd/R_count); + Lsd=sqrt(Lsd/L_count); + + + gzFile fp; + kseq_t *seq; + int l; + fp = gzopen((paraFA04->InStr3).c_str(), "r"); + seq = kseq_init(fp); + map ChrSeq ; + + while ((l = kseq_read(seq)) >= 0) + { + string RefSeq=(seq->seq.s); + string chr=(seq->name.s); + ChrSeq.insert(map ::value_type(chr,RefSeq)); + } + kseq_destroy(seq); + gzclose(fp); + + map ::iterator Mapit; + + string StatRaw=PrefixO+".raw.gz"; + ogzstream OUT (StatRaw.c_str()); + OUT<<"#Chr\tStart\tEnd\tLength\tMeanDepth\tCNV\tNratio\tZScore\tPValue\n"; + OUT<<"##MeanDepth: "<TF) + { + while(!INC.eof()) + { + string line ; + getline(INC,line); + if ( (line.length()<=0) || (line[0] == '#') ) { continue ;} + istringstream stream (line,istringstream::in); + stream >>tempsss>>Start>>End ; + stream >>DepthRegion ; + this_count=DepthRegion/MeanDepth; + diff=this_count-1.0 ; + int NumC=(End-Start+1); + Mapit=ChrSeq.find(tempsss); + int Ascii[256] = {0}; + for(int ix=Start ; ix<=End ; ix++) + { + Ascii[(Mapit->second)[ix]]++; + } + int N_Num=Ascii['N']+Ascii['n']; + double Nratio=N_Num*100.0/NumC; + PValue=1.0; + if (diff>0) + { + PValue=(1-pnorm5(this_count, 1.0 , Rsd , 1 , 0 )); + ZScore=diff/Rsd; + } + else if (diff<0) + { + PValue=(pnorm5(this_count, 1.0 , Lsd , 1 , 0 )); + ZScore=diff/Lsd; + } + else + { + PValue=0.99; + ZScore=0.0; + } + OUT< (paraFA04->InInt2) && Nratio<10 ) + { + OUTCNV<>tempsss>>Start>>End ; + stream >>DepthRegion >>this_count ; + diff=this_count-1.0 ; + int NumC=(End-Start+1); + Mapit=ChrSeq.find(tempsss); + int Ascii[256] = {0}; + for(int ix=Start ; ix<=End ; ix++) + { + Ascii[(Mapit->second)[ix]]++; + } + + int N_Num=Ascii['N']+Ascii['n']; + double Nratio=N_Num*100.0/NumC; + + if (diff>0) + { + PValue=(1-pnorm5(this_count, 1.0 , Rsd , 1 , 0 )); + ZScore=diff/Rsd; + } + else if (diff<0) + { + PValue=(pnorm5(this_count, 1.0 , Lsd , 1 , 0 )); + ZScore=diff/Lsd; + } + else + { + PValue=0.99; + ZScore=0.0; + } + + OUT< (paraFA04->InInt2) && Nratio<10 ) + { + OUTCNV< +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; + + +/* +int bamSV_help() +{ + cout <<"" + "\n" + "\tUsage: bamSV(beta) -InFile A.bam B.bam -OutFile outFix\n" + "\n" + "\t\t-InFile In Bam/Sam File to Dete SV[repeat]\n" + "\t\t-OutFile OutFile Prefix\n" + "\n" + "\t\t-InList In Bam File List\n" + "\t\t-Insert set insert[auto]\n" + "\t\t-SD set insert SD[auto]\n" + "\t\t-Ref In Ref.fa to get gap info to filter SV\n" + "\t\t-MinDepth minimum count of PE in one cluster[6]\n" + "\n" + "\t\t-help Show more help [hewm2008]\n" + "\n"; + return 1; +} +*/ + +void bamSV_help() +{ +cout<<"" +"\n" +"\tUsage: DeteSV(beta) -l -o \n" +"\tUsage: DeteSV(beta) -I < A.bam B.bam > -o \n" +"\n" +"\t\t-i input SAM/BAM files, delimited by space\n" +"\t\t-l input list of SAM/BAM files\n" +"\t\t-o prefix of output file\n" +"\n" +"\t\t-s set the insert value,default[auto]\n" +"\t\t-d set the insert standard deviation value,default[auto]\n" +"\t\t-r input reference FASTA to get gap information\n" +"\t\t-m set the minimum count of paired-end read in one cluster,default[6]\n" +"\n" +"\t\t-h show more details for help\n" +"\n" +"\n"; +} + +void More_bamSV_help() +{ +cout<<"" +"\n" +"\t\t1. DeteSV -i -r -o AAA -m M\n" +"\t\t DeteSV -l -r -o AAA -m M\n" +"\t\tThis will generate two files and output the result to current directory. Output files are named with the prefix AAA.\n" +"\t\t(1.1) -m number of paired-end read which support this structure variation,if it is lower than M,this structure variation will be filtered.\n" +"\n" +"\n"; +} +int bamSV_help01(int argc, char **argv , In3str1v * paraBamS ) +{ + if (argc <=1 ) {bamSV_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraBamS->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraBamS->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutFile" || flag == "o" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InStr2=argv[i]; + } + else if (flag == "Ref" || flag == "r") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InStr1=argv[i]; + } + else if (flag == "Insert" || flag == "s" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InInt=atoi(argv[i]); + } + else if (flag == "SD" || flag == "d") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InInt2=atoi(argv[i]); + } + else if (flag == "MinDepth" || flag == "m") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraBamS->InF=atof(argv[i]); + } + + + + + else if (flag == "help" || flag == "h") + { + More_bamSV_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InF=6.0; + if ((bamSV_help01(argc, argv, paraBamS)==0)) + { + delete paraBamS ; + return 0; + } + + string strPE=(paraBamS->InStr2)+".OutInsert.pe.gz"; + ogzstream OUTPE (strPE.c_str()); + + string strSV=(paraBamS->InStr2)+".sv"; + ofstream OUTSV (strSV.c_str()); + + + OUTSV<<"#Chr\tSV_type\tLength\tClusterStartA\tClusterStartB\tClusterEndA\tClusterEndB\tFR\tSupRead\n"; + + struct clusterPE + { + int Start_A; + int End_A; + int Start_B; + int End_B; + int chrID ; + char Flag[2]; + int Number ; + }; + + vector Vcluster_A; + int ZV_sizeA=0; + + bam_hdr_t *headerALL; + samFile *InBamALL = sam_open((paraBamS->List)[0].c_str(), "r"); + headerALL = sam_hdr_read(InBamALL); + sam_close(InBamALL); + + int FileNum=(paraBamS->List).size(); + + int Final_Insert=0; + + for (int ii=0 ; iiList)[ii]; + if (line.length()<=0) { continue ; } + vector TmpVV ; + split (line , TmpVV ," \t"); + line=TmpVV[0]; + + int InsertThis = (paraBamS->InInt) ; + int SD=(paraBamS->InInt2); + if (TmpVV.size()>1) + { + InsertThis=atoi(TmpVV[1].c_str()); + } + if (TmpVV.size()>2) + { + SD=atoi(TmpVV[2].c_str()); + } + + bam1_t *aln = bam_init1(); + + if (InsertThis<10 || SD<5 ) + { + cout <<"Begin Bam :"< map_insert ; + map :: iterator mapIt ; + int Count=0; + while (sam_read1(InBam, header, aln) >= 0 && Count <88888) + { + if ( ((aln->core).tid < 0) || ( (aln->core).qual < 10) ) {continue ;} + if ( (((aln)->core.flag & 0x40) ==0 )) + { + continue ; + } + if ( (((aln)->core.flag & 0x1) == 0)) + { + continue ; + } + if ( (((aln)->core.flag & 0x8) != 0)) + { + continue ; + } + if ((aln->core).tid != (aln->core).mtid) + { + continue ; + } + if ( (aln->core).isize<0) + { + (aln->core).isize=0-(aln->core).isize; + } + mapIt=map_insert.find((aln->core).isize); + if (mapIt!=map_insert.end()) + { + (mapIt->second)++; + } + else + { + map_insert.insert( map :: value_type ((aln->core).isize,1)); + } + Count++; + } + sam_close(InBam); + bam_hdr_destroy(header); + + int max_y = 0; + int max_x = 0; + mapIt=map_insert.begin(); + + while(mapIt !=map_insert.end()) + { + if (max_y <= (mapIt->second)) + { + max_y= mapIt->second; + max_x= mapIt->first; + } + mapIt++; + } + + int Num=0; + int SumDiff=0; + int cutoffX=(max_x*100); + if (cutoffX>500000) {cutoffX=500000;} + + for ( mapIt=map_insert.begin(); mapIt !=map_insert.end() ; mapIt++ ) + { + if ( (mapIt->first)>cutoffX) + { + continue; + } + int Diff=(mapIt->first)-max_x; + Num+=(mapIt->second); + SumDiff=(mapIt->second)*Diff*Diff; + } + SD=int(sqrt(SumDiff/Num)); + if (InsertThis<20) + { + InsertThis=max_x; + } + } + + cout<<"Insert Size Peaks is Estimated: "<= 0 ) + { + if ( ((aln->core).tid < 0) || ( (aln->core).qual < 10) ) {continue ;} + if ( (((aln)->core.flag & 0x40) ==0)) + { + continue ; + } + if ( (((aln)->core.flag & 0x1) == 0)) + { + continue ; + } + if ( (((aln)->core.flag & 0x8) != 0)) + { + continue ; + } + if ((aln->core).tid != (aln->core).mtid) + { + continue ; + } + int Insert=(aln->core).isize; + if ( Insert<0) + { + Insert=0-Insert; + } + if (Insert > MaxXX || Insert < MinXX) + { + clusterPE ThisPE; + ThisPE.Number=1; + ThisPE.Flag[0]='+'; + ThisPE.Flag[1]='+'; + ThisPE.Flag[2]='\0'; + ThisPE.chrID=(aln->core).tid; + + if (((aln)->core.flag & 0x10) ) {ThisPE.Flag[0]='-';} + if (((aln)->core.flag & 0x20) ) {ThisPE.Flag[1]='-';} + string readID=bam_get_qname(aln); + + if ((aln->core).pos < (aln->core).mpos) + { + ThisPE.Start_B=(aln->core).mpos; + ThisPE.End_B=(aln->core).mpos; + ThisPE.Start_A=(aln->core).pos; + ThisPE.End_A=(aln->core).pos; + OUTPE<<(headerC->target_name[(aln->core).tid])<<"\t"<<(aln->core).pos<<"\t"<<(headerC->target_name[(aln->core).mtid])<<"\t"<<(aln->core).mpos<<"\t"<core).mpos; + ThisPE.End_A=(aln->core).mpos; + ThisPE.Start_B=(aln->core).pos; + ThisPE.End_B=(aln->core).pos; + OUTPE<<(headerC->target_name[(aln->core).mtid])<<"\t"<<(aln->core).mpos<<"\t"<<(headerC->target_name[(aln->core).tid])<<"\t"<<(aln->core).pos<<"\t"<Vcluster_A[ii].End_A) {Vcluster_A[ii].End_A=ThisPE.End_A;} + if (ThisPE.End_B>Vcluster_A[ii].End_B) {Vcluster_A[ii].End_B=ThisPE.End_B;} + TF_End=false ; + break; + } + } + if (TF_End) + { + Vcluster_A.push_back(ThisPE); + } + } + } + + bam_destroy1(aln); + sam_close(InBamC); + bam_hdr_destroy(headerC); + + } + + + + OUTPE.close(); + + + int MinDepthF = int (paraBamS->InF); + for (int ii=0 ; ii< ZV_sizeA ; ii++) + { + if ( (Vcluster_A[ii].Number) < MinDepthF ) + { + continue ; + } + int Len=Vcluster_A[ii].Start_B-Vcluster_A[ii].End_A; + + if (Vcluster_A[ii].Flag[0] == '+' && Vcluster_A[ii].Flag[1] == '-' ) + { + if (Len<0) { continue ;} + else + { + if (Len>Final_Insert) + { + OUTSV<<(headerALL->target_name[Vcluster_A[ii].chrID])<<"\tDeletion\t"<target_name[Vcluster_A[ii].chrID])<<"\tInsertion\t"<target_name[Vcluster_A[ii].chrID])<<"\tNANAtmp\t"< Vcluster_B; + + int ZV_sizeB=0; + bool VecAB=true ; + bool TF_End=true; + + if ( (paraBamS->InInt) < 250 ) { (paraBamS->InInt)=250;} + + for ( int cc=3 ; cc< (paraBamS->InInt) ; cc++) + { + if (VecAB) + { + Vcluster_B.clear(); + ZV_sizeA=Vcluster_A.size(); + VecAB=false; + for (int ii=0 ; ii< ZV_sizeA ; ii++) + { + ZV_sizeB=Vcluster_B.size(); + TF_End=true; + for (int jj=0 ; jj< ZV_sizeB ; jj++) + { + if (( Vcluster_B[jj].chrID==Vcluster_A[ii].chrID) && (strcmp(Vcluster_A[ii].Flag ,Vcluster_B[jj].Flag)==0 ) && (abs(Vcluster_B[jj].Start_A-Vcluster_A[ii].Start_A)Vcluster_A[ii].Start_A) {Vcluster_B[jj].Start_A=Vcluster_A[ii].Start_A;} + if (Vcluster_B[jj].Start_B>Vcluster_A[ii].Start_B) {Vcluster_B[jj].Start_B=Vcluster_A[ii].Start_B;} + + if (Vcluster_B[jj].End_AVcluster_A[ii].End_A) {Vcluster_A[ii].End_A=Vcluster_B[jj].End_A;} + if (Vcluster_B[jj].End_B>Vcluster_A[ii].End_B) {Vcluster_A[ii].End_B=Vcluster_B[jj].End_B;} + TF_End=false; + break; + } + } + if (TF_End) + { + Vcluster_A.push_back(Vcluster_B[jj]); + } + } + +} +} + + + + +int MinDepthF = int (paraBamS->InF); +if (VecAB) +{ + ZV_sizeA=Vcluster_A.size(); + for (int ii=0 ; ii< ZV_sizeA ; ii++) + { + if ( (Vcluster_A[ii].Number) < MinDepthF ) + { + continue ; + } + int Len=Vcluster_A[ii].Start_B-Vcluster_A[ii].End_A; + + if (Vcluster_A[ii].Flag[0] == '+' && Vcluster_A[ii].Flag[1] == '-' ) + { + if (Len<0) { continue ;} + else + { + if (Len>Final_Insert) + { + OUTSV<<(headerALL->target_name[Vcluster_A[ii].chrID])<<"\tDeletion\t"<target_name[Vcluster_A[ii].chrID])<<"\tInsertion\t"<target_name[Vcluster_A[ii].chrID])<<"\tNANAtmp\t"<Final_Insert) + { + OUTSV<<(headerALL->target_name[Vcluster_B[jj].chrID])<<"\tDeletion\t"<target_name[Vcluster_B[jj].chrID])<<"\tInsertion\t"<target_name[Vcluster_B[jj].chrID])<<"\tNAtmp\t"< +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +//KSEQ_INIT(gzFile, gzread) + +/* +int bamLDR_help() +{ + cout <<"" + "\n" + "\tUsage: LowDepth -InList -OutPut \n" + "\tUsage: LowDepth -InDepthFa -OutPut \n" + "\n" + "\t\t-InList Input Bam/Sam File List\n" + "\t\t-InFile Input Bam/Sam File File[repeat]\n" + "\t\t-InDepthF In DepthFA File,bamCoverage OutFile\n" + "\t\t-OutPut OutPut Bed Region File\n" + "\n" + "\t\t-LowDepth Regard SiteDepth < X as LowDepth[2]\n" + "\t\t-MinLength Filter too short region [1000]\n" + "\t\t-MinQ Ignore too low mapQ read[10]\n" + "\n" + "\t\t-help Show this help [hewm2008 v1.01]\n" + "\n"; + return 1; +} +*/ + + +void bamLDR_help() +{ +cout<<"" +"\n" +"\tUsage: LowDepth -l -o \n" +"\tUsage: LowDepth -d -o \n" +"\n" +"\t\t-i input SAM/BAM files, delimited by space\n" +"\t\t-l input list of SAM/BAM files\n" +"\t\t-d depth along site in reference FASTA\n" +"\t\t-o output bed region file\n" +"\n" +"\t\t-x set the minimum value of low depth,default[2]\n" +"\t\t-s the length to filter short region, default [1000]\n" +"\t\t-q ignore too low mapQ read, default [10]\n" +"\n" +"\t\t-h show more details for help\n" +"\n" +"\n"; +} + +void More_bamLDR_help() +{ +cout<<"" +"\n" +"\t\t1. LowDepth -i < A.bam B.bam > -o -q Q -s S\n" +"\t\tLowDepth -l -o -q Q -s S\n" +"\t\tThis will generate one compressed file (bed file of low depth region) named out.bed.gz in current directory.\n" +"\t\t(1.1) the reads with quality lower than Q will be removed from analysis, default value of Q is 10.\n" +"\t\t(1.2) the bed region length lower than S will be filtered.\n" +"\t\t2. LowDepth -d -o -q Q\n" +"\t\tThis operation is the same with the example above but with different input format.\n" +"\t\t(2.1) the input file shows the depth along the reference FASTA. User could get this file with the function Coverage in the Statistics module. Below isan example of the usage of this command. More details could be found with the -h in this command.\n" +"\t\tbamdeal statistics Coverage -i -o AAA -r \n" +"\n" +"\n"; +} +int bamLDR_help01(int argc, char **argv , In3str1v * paraFA04 ) +{ + if (argc <=1 ) {bamLDR_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "List" || flag == "l") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + + else if (flag == "InDepthF" || flag == "d" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr3=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "LowDepth" || flag == "x" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt2=atoi(argv[i]); + } + else if (flag == "MinLength" || flag == "s" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InF=atof(argv[i]); + } + else if (flag == "help" || flag == "h") + { + More_bamLDR_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InStr3).empty()) + { + cerr<< "lack argument for the must"<InStr2)=add_Asuffix(paraFA04->InStr2); + return 1 ; +} + + +int bamLowDepth_main(int argc, char *argv[]) +//int main(int argc, char *argv[]) +{ + In3str1v *paraFA04 = new In3str1v; + paraFA04->InInt=2; + paraFA04->InInt2=10; + paraFA04->InF=1000; + if ((bamLDR_help01(argc, argv, paraFA04)==0)) + { + delete paraFA04 ; + return 1 ; + } + + int MinLength=int(paraFA04->InF); + + ogzstream OUT ((paraFA04->InStr2).c_str()); + + if((!OUT.good())) + { + cerr << "open OUT File error: "<<(paraFA04->InStr2)<InStr3).empty()) + { + + } + else + { + + igzstream FAIN ((paraFA04->InStr3).c_str(),ifstream::in); + + bool S_E=false; + int Start=0; + int End=0; + int Count=0; + string chrName=""; + int Depth=0; + getline(FAIN,chrName); + chrName=chrName.substr(1); + + while(!FAIN.eof()) + { + string line ; + getline(FAIN,line); + if (line.length()<=0) { continue ; } + if (line[0] == '>') + { + if (S_E) + { + if ((End-Start)>MinLength) + { + OUT<>Depth) + { + Count++; + if ( (!S_E) && ( Depth > (paraFA04->InInt)) ) + { + continue ; + } + else if ( (S_E) && ( Depth > (paraFA04->InInt)) ) + { + S_E=false ; + if ((End-Start)>MinLength) + { + OUT<InInt)) ) + { + S_E=true ; + Start=Count ; End=Count; + } + else + { + End=Count; + } + } + } + + + } + + if (S_E) + { + if ((End-Start)>MinLength) + { + OUT<List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + + cout<<"begin new the memory ...\n"; + + unsigned short int **depth = new unsigned short int*[(header->n_targets)]; // + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])+500; + depth[i] = new unsigned short int [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=0; + } + } + + cout<<"new the memory done"<List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + + uint32_t *cigar; + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) + { + continue ; + } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + continue; + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + } + + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + + cout <<"ALL Bam Read done"<n_targets); i++) + { + bool S_E=false ; + int Start=0; + int End=0; + for (int j =0 ; j< (header->target_len[i]) ; j++) + { + if ( (!S_E) && ( depth[i][j] > (paraFA04->InInt)) ) + { + continue ; + } + else if ( (S_E) && ( depth[i][j] > (paraFA04->InInt)) ) + { + S_E=false ; + if ((End-Start)>MinLength) + { + OUT<<(header->target_name[i])<<"\t"<InInt)) ) + { + S_E=true ; + Start=j ; End=j; + } + else + { + End=j; + } + } + if (S_E) + { + if ((End-Start)>MinLength) + { + OUT<<(header->target_name[i])<<"\t"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + + + bam_hdr_destroy(header); + delete paraFA04 ; + return 0; +} +#endif // bamLDR_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/statistics/BamSiteRead.h b/src/statistics/BamSiteRead.h new file mode 100644 index 0000000..f9e7207 --- /dev/null +++ b/src/statistics/BamSiteRead.h @@ -0,0 +1,847 @@ +#ifndef bamSiteRead_H_ +#define bamSiteRead_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +void SiteRead_help() +{ + cout<<"" + "\n" + "\tUsage: BamSiteRead -l -b SNP.vcf -o \n" + "\tUsage: BamSiteRead -i < A.bam B.bam > -b SNP.vcf -o \n" + "\n" + "\t\t-b input SNP Site(chr site)\n" + "\t\t-i input SAM/BAM files, delimited by space\n" + "\t\t-l input list of SAM/BAM files\n" + "\t\t-o prefix of output file\n" + "\n" + "\t\t-q the quality to filter reads, default [10]\n" + "\t\t-d Filter the PCR or optical duplicate read(DUP)\n" + "\t\t-s Filter the secondary alignment read(SECONDARY)\n" + "\t\t-c Filter the not passing quality controls read(QCFAIL)\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_SiteRead_help() +{ + cout<<"" + "\n" + "\t\t1. SiteRead -i -b SNP.vcf -o AAA -q -1\n" + "\t\tSiteRead -l -b SNP.vcf -o AAA -q -1\n" + "\t\tThis will generate Read(with read and base info covering the SNP site).\n" + "\t\t...\n" + "\n" + "\n"; +} + +int SiteRead_help01(int argc, char **argv , In3str1v * paraFA04 ) +{ + if (argc <=1 ) {SiteRead_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "List" || flag == "l") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "Bed" || flag == "b") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr1=argv[i]; + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "RmDup" || flag == "d" ) + { + paraFA04->TF=false ; + } + else if (flag == "RmSec" || flag =="s") + { + paraFA04->TF2=false ; + } + else if (flag == "RmQCFAIL" || flag =="c") + { + paraFA04->InInt2=1 ; + } + else if (flag == "help" || flag == "h") + { + More_SiteRead_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() || (paraFA04->InStr1).empty() ) + { + cerr<< "lack argument for the must"<InStr2)=add_Asuffix(paraFA04->InStr2); + return 1 ; +} + + +int SiteRead_main(int argc, char *argv[]) +//int main(int argc, char *argv[]) +{ + In3str1v *paraFA04 = new In3str1v; + paraFA04->InInt=10; + if ((SiteRead_help01(argc, argv, paraFA04)==0)) + { + delete paraFA04 ; + return 0 ; + } + + (paraFA04->InStr2)=(paraFA04->InStr2).substr(0,(paraFA04->InStr2).length()-3); + string path=(paraFA04->InStr2); + string ext =path.substr(path.rfind('.') ==string::npos ? path.length() : path.rfind('.') + 1); + + string PrefixO=path; + + if (ext == "Read" || ext == "read") + { + PrefixO=path.substr(0,path.rfind('.')); + } + + string outFaDepth=PrefixO+".Read.gz"; + ogzstream OUT (outFaDepth.c_str()); + + if((!OUT.good())) + { + cerr << "open OUT File error: "<List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + + cout<<"begin new the memory ...\n"; + bool QCFAIL=true; + if ((paraFA04->InInt2)!=0) {QCFAIL=false;} + + bool **depth = new bool *[(header->n_targets)]; // + map Name2Int ; + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])+500; + depth[i] = new bool [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=false; + } + string Name=header->target_name[i]; + Name2Int[Name]=i; + } + + cout<<"new the memory done"<InStr1).c_str(),ifstream::in); + if (VCFIN.fail()) + { + cerr << "open VCFIN File error: "<<(paraFA04->InStr1)<>chr_id>>Position; + Position--; + depth[Name2Int[chr_id]][Position]=true; + } + VCFIN.close(); + int shiftQ=33; + int FileNum=(paraFA04->List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + uint32_t *cigar; + uint8_t *seq; + int iref =0; + int iseq=0; int arryFlag=0; + + + //#define BAM_CMATCH 0 + //#define BAM_CINS 1 + //#define BAM_CDEL 2 + //#define BAM_CREF_SKIP 3 + //#define BAM_CSOFT_CLIP 4 + //#define BAM_CHARD_CLIP 5 + //#define BAM_CPAD 6 + //#define BAM_CEQUAL 7 + //#define BAM_CDIFF 8 + + + if ((paraFA04->TF) && (paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){continue ;} + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<TF) && (paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<TF) && (!paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<TF) && (!paraFA04->TF2) && (QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x100 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<TF) && (!paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x100 ) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<TF) && (paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x400 ) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<TF) && (!paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x100 ) { continue ; } + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<TF) && (paraFA04->TF2) && (!QCFAIL) ) + { + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)){ continue ;} + if ( (aln->core).flag & 0x200 ) { continue ; } + cigar = bam_get_cigar(aln); + seq = bam_get_seq(aln); + iref=((aln->core).pos); + iseq=0; + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=iref+ncig; + for ( ; irefcore).tid][iref]) + { + string readID=bam_get_qname(aln); + if ( (((aln)->core.flag&64) != 0)) + { + readID=readID + "/1" ; + } + else if ((((aln)->core.flag&128) != 0) ) + { + readID=readID + "/2" ; + } + char BaseNow=Base[bam_seqi(seq, iseq)]; + uint8_t *seqQ=bam_get_qual(aln); + uint8_t *seq=bam_get_seq(aln); + string BaseSeq=""; + string BaseSeqQ=""; + for(int io=0; io < (aln->core).l_qseq ; io++) + { + BaseSeqQ=BaseSeqQ+char(seqQ[io]+shiftQ); + BaseSeq=BaseSeq+char(Base[bam_seqi(seq, io)]); + } + Position=iref+1;uint32_t MQ=(aln->core).qual; + OUT<target_name[(aln->core).tid]<<"\t"<core).pos<<"\t"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + + bam_hdr_destroy(header); + delete paraFA04 ; + return 0; +} +#endif // bamSiteRead_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/statistics/Bmath/dpq.h b/src/statistics/Bmath/dpq.h new file mode 100644 index 0000000..8f48a9c --- /dev/null +++ b/src/statistics/Bmath/dpq.h @@ -0,0 +1,124 @@ +/* + * R : A Computer Language for Statistical Data Analysis + * Copyright (C) 2000--2007 R Core Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * http://www.r-project.org/Licenses/ + */ + /* Utilities for `dpq' handling (density/probability/quantile) */ + +/* give_log in "d"; log_p in "p" & "q" : */ +#define give_log log_p + /* "DEFAULT" */ + /* --------- */ +#define R_D__0 (log_p ? ML_NEGINF : 0.) /* 0 */ +#define R_D__1 (log_p ? 0. : 1.) /* 1 */ +#define R_DT_0 (lower_tail ? R_D__0 : R_D__1) /* 0 */ +#define R_DT_1 (lower_tail ? R_D__1 : R_D__0) /* 1 */ + +/* Use 0.5 - p + 0.5 to perhaps gain 1 bit of accuracy */ +#define R_D_Lval(p) (lower_tail ? (p) : (0.5 - (p) + 0.5)) /* p */ +#define R_D_Cval(p) (lower_tail ? (0.5 - (p) + 0.5) : (p)) /* 1 - p */ + +#define R_D_val(x) (log_p ? log(x) : (x)) /* x in pF(x,..) */ +#define R_D_qIv(p) (log_p ? exp(p) : (p)) /* p in qF(p,..) */ +#define R_D_exp(x) (log_p ? (x) : exp(x)) /* exp(x) */ +#define R_D_log(p) (log_p ? (p) : log(p)) /* log(p) */ +#define R_D_Clog(p) (log_p ? log1p(-(p)) : (0.5 - (p) + 0.5)) /* [log](1-p) */ + +/* log(1 - exp(x)) in more stable form than log1p(- R_D_qIv(x))) : */ +#define R_Log1_Exp(x) ((x) > -M_LN2 ? log(-expm1(x)) : log1p(-exp(x))) + +/* log(1-exp(x)): R_D_LExp(x) == (log1p(- R_D_qIv(x))) but even more stable:*/ +#define R_D_LExp(x) (log_p ? R_Log1_Exp(x) : log1p(-x)) + +#define R_DT_val(x) (lower_tail ? R_D_val(x) : R_D_Clog(x)) +#define R_DT_Cval(x) (lower_tail ? R_D_Clog(x) : R_D_val(x)) + +/*#define R_DT_qIv(p) R_D_Lval(R_D_qIv(p)) * p in qF ! */ +#define R_DT_qIv(p) (log_p ? (lower_tail ? exp(p) : - expm1(p)) \ + : R_D_Lval(p)) + +/*#define R_DT_CIv(p) R_D_Cval(R_D_qIv(p)) * 1 - p in qF */ +#define R_DT_CIv(p) (log_p ? (lower_tail ? -expm1(p) : exp(p)) \ + : R_D_Cval(p)) + +#define R_DT_exp(x) R_D_exp(R_D_Lval(x)) /* exp(x) */ +#define R_DT_Cexp(x) R_D_exp(R_D_Cval(x)) /* exp(1 - x) */ + +#define R_DT_log(p) (lower_tail? R_D_log(p) : R_D_LExp(p))/* log(p) in qF */ +#define R_DT_Clog(p) (lower_tail? R_D_LExp(p): R_D_log(p))/* log(1-p) in qF*/ +#define R_DT_Log(p) (lower_tail? (p) : R_Log1_Exp(p)) +/* == R_DT_log when we already "know" log_p == TRUE :*/ + + +#define R_Q_P01_check(p) \ + if ((log_p && p > 0) || \ + (!log_p && (p < 0 || p > 1)) ) \ + ML_ERR_return_NAN + +/* Do the boundaries exactly for q*() functions : + * Often _LEFT_ = ML_NEGINF , and very often _RIGHT_ = ML_POSINF; + * + * R_Q_P01_boundaries(p, _LEFT_, _RIGHT_) :<==> + * + * R_Q_P01_check(p); + * if (p == R_DT_0) return _LEFT_ ; + * if (p == R_DT_1) return _RIGHT_; + * + * the following implementation should be more efficient (less tests): + */ +#define R_Q_P01_boundaries(p, _LEFT_, _RIGHT_) \ + if (log_p) { \ + if(p > 0) \ + ML_ERR_return_NAN; \ + if(p == 0) /* upper bound*/ \ + return lower_tail ? _RIGHT_ : _LEFT_; \ + if(p == ML_NEGINF) \ + return lower_tail ? _LEFT_ : _RIGHT_; \ + } \ + else { /* !log_p */ \ + if(p < 0 || p > 1) \ + ML_ERR_return_NAN; \ + if(p == 0) \ + return lower_tail ? _LEFT_ : _RIGHT_; \ + if(p == 1) \ + return lower_tail ? _RIGHT_ : _LEFT_; \ + } + +#define R_P_bounds_01(x, x_min, x_max) \ + if(x <= x_min) return R_DT_0; \ + if(x >= x_max) return R_DT_1 +/* is typically not quite optimal for (-Inf,Inf) where + * you'd rather have */ +#define R_P_bounds_Inf_01(x) \ + if(!R_FINITE(x)) { \ + if (x > 0) return R_DT_1; \ + /* x < 0 */return R_DT_0; \ + } + + + +/* additions for density functions (C.Loader) */ +#define R_D_fexp(f,x) (give_log ? -0.5*log(f)+(x) : exp(x)/sqrt(f)) +#define R_D_forceint(x) floor((x) + 0.5) +#define R_D_nonint(x) (fabs((x) - floor((x)+0.5)) > 1e-7) +/* [neg]ative or [non int]eger : */ +#define R_D_negInonint(x) (x < 0. || R_D_nonint(x)) + +#define R_D_nonint_check(x) \ + if(R_D_nonint(x)) { \ + MATHLIB_WARNING("non-integer x = %f", x); \ + return R_D__0; \ + } diff --git a/src/statistics/Bmath/pnorm.c b/src/statistics/Bmath/pnorm.c new file mode 100644 index 0000000..2081eee --- /dev/null +++ b/src/statistics/Bmath/pnorm.c @@ -0,0 +1,331 @@ +/* + * Mathlib : A C Library of Special Functions + * Copyright (C) 1998 Ross Ihaka + * Copyright (C) 2000-2010 The R Core Team + * Copyright (C) 2003 The R Foundation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * http://www.r-project.org/Licenses/ + * + * SYNOPSIS + * + * #include + * + * double pnorm5(double x, double mu, double sigma, int lower_tail,int log_p); + * {pnorm (..) is synonymous and preferred inside R} + * + * void pnorm_both(double x, double *cum, double *ccum, + * int i_tail, int log_p); + * + * DESCRIPTION + * + * The main computation evaluates near-minimax approximations derived + * from those in "Rational Chebyshev approximations for the error + * function" by W. J. Cody, Math. Comp., 1969, 631-637. This + * transportable program uses rational functions that theoretically + * approximate the normal distribution function to at least 18 + * significant decimal digits. The accuracy achieved depends on the + * arithmetic system, the compiler, the intrinsic functions, and + * proper selection of the machine-dependent constants. + * + * REFERENCE + * + * Cody, W. D. (1993). + * ALGORITHM 715: SPECFUN - A Portable FORTRAN Package of + * Special Function Routines and Test Drivers". + * ACM Transactions on Mathematical Software. 19, 22-32. + * + * EXTENSIONS + * + * The "_both" , lower, upper, and log_p variants were added by + * Martin Maechler, Jan.2000; + * as well as log1p() and similar improvements later on. + * + * James M. Rath contributed bug report PR#699 and patches correcting SIXTEN + * and if() clauses {with a bug: "|| instead of &&" -> PR #2883) more in line + * with the original Cody code. + */ + +//#include "nmath.h" + + +///hewe +//*///////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef pnorm_H_ +#define pnorm_H_ + + + +#define ML_POSINF ( 1.0 ) +#define ML_NEGINF (-1.0 ) +#define ML_NAN ( 0.0 ) + +//#define ME_DOMAIN 1 + + +//#define ML_ERR_return_NAN { return ML_NAN; } +#define R_FINITE(x) R_finite(x) + +#define M_SQRT_32 5.656854249492380195206754896838 +#define M_1_SQRT_2PI 0.398942280401432677939946059934 +#define DBL_EPSILON 2.2204460492503131e-16 + +#ifndef isnan +#if __cplusplus <= 199711L // c++98 or older +# define isnan(x) ::isnan(x) +#else +# define isnan(x) std::isnan(x) +#endif +#endif + +int R_finite(double x) +{ +#ifdef HAVE_WORKING_ISFINITE + return isfinite(x); +# else + return (!isnan(x) & (x != ML_POSINF) & (x != ML_NEGINF)); +#endif +} + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////*/ + + + +//SSSS +#include "dpq.h" + + + +#define SIXTEN 16 /* Cutoff allowing exact "*" and "/" */ + +void pnorm_both(double x, double *cum, double *ccum, int i_tail, int log_p) +{ + /* i_tail in {0,1,2} means: "lower", "upper", or "both" : + if(lower) return *cum := P[X <= x] + if(upper) return *ccum := P[X > x] = 1 - P[X <= x] + */ + const static double a[5] = { + 2.2352520354606839287, + 161.02823106855587881, + 1067.6894854603709582, + 18154.981253343561249, + 0.065682337918207449113 + }; + const static double b[4] = { + 47.20258190468824187, + 976.09855173777669322, + 10260.932208618978205, + 45507.789335026729956 + }; + const static double c[9] = { + 0.39894151208813466764, + 8.8831497943883759412, + 93.506656132177855979, + 597.27027639480026226, + 2494.5375852903726711, + 6848.1904505362823326, + 11602.651437647350124, + 9842.7148383839780218, + 1.0765576773720192317e-8 + }; + const static double d[8] = { + 22.266688044328115691, + 235.38790178262499861, + 1519.377599407554805, + 6485.558298266760755, + 18615.571640885098091, + 34900.952721145977266, + 38912.003286093271411, + 19685.429676859990727 + }; + const static double p[6] = { + 0.21589853405795699, + 0.1274011611602473639, + 0.022235277870649807, + 0.001421619193227893466, + 2.9112874951168792e-5, + 0.02307344176494017303 + }; + const static double q[5] = { + 1.28426009614491121, + 0.468238212480865118, + 0.0659881378689285515, + 0.00378239633202758244, + 7.29751555083966205e-5 + }; + + double xden, xnum, temp, del, eps, xsq, y; +#ifdef NO_DENORMS + double min = DBL_MIN; +#endif + int i, lower, upper; + + /* Consider changing these : */ + eps = DBL_EPSILON * 0.5; + + /* i_tail in {0,1,2} =^= {lower, upper, both} */ + lower = i_tail != 1; + upper = i_tail != 0; + + y = fabs(x); + if (y <= 0.67448975) { /* qnorm(3/4) = .6744.... -- earlier had 0.66291 */ + if (y > eps) { + xsq = x * x; + xnum = a[4] * xsq; + xden = xsq; + for (i = 0; i < 3; ++i) { + xnum = (xnum + a[i]) * xsq; + xden = (xden + b[i]) * xsq; + } + } else xnum = xden = 0.0; + + temp = x * (xnum + a[3]) / (xden + b[3]); + if(lower) *cum = 0.5 + temp; + if(upper) *ccum = 0.5 - temp; + if(log_p) { + if(lower) *cum = log(*cum); + if(upper) *ccum = log(*ccum); + } + } + else if (y <= M_SQRT_32) { + + /* Evaluate pnorm for 0.674.. = qnorm(3/4) < |x| <= sqrt(32) ~= 5.657 */ + + xnum = c[8] * y; + xden = y; + for (i = 0; i < 7; ++i) { + xnum = (xnum + c[i]) * y; + xden = (xden + d[i]) * y; + } + temp = (xnum + c[7]) / (xden + d[7]); + +#define do_del(X) \ + xsq = trunc(X * SIXTEN) / SIXTEN; \ + del = (X - xsq) * (X + xsq); \ + if(log_p) { \ + *cum = (-xsq * xsq * 0.5) + (-del * 0.5) + log(temp); \ + if((lower && x > 0.) || (upper && x <= 0.)) \ + *ccum = log1p(-exp(-xsq * xsq * 0.5) * \ + exp(-del * 0.5) * temp); \ + } \ + else { \ + *cum = exp(-xsq * xsq * 0.5) * exp(-del * 0.5) * temp; \ + *ccum = 1.0 - *cum; \ + } + +#define swap_tail \ + if (x > 0.) {/* swap ccum <--> cum */ \ + temp = *cum; if(lower) *cum = *ccum; *ccum = temp; \ + } + + do_del(y); + swap_tail; + } + + /* else |x| > sqrt(32) = 5.657 : + * the next two case differentiations were really for lower=T, log=F + * Particularly *not* for log_p ! + + * Cody had (-37.5193 < x && x < 8.2924) ; R originally had y < 50 + * + * Note that we do want symmetry(0), lower/upper -> hence use y + */ + else if((log_p && y < 1e170) /* avoid underflow below */ + /* ^^^^^ MM FIXME: can speedup for log_p and much larger |x| ! + * Then, make use of Abramowitz & Stegun, 26.2.13, something like + + xsq = x*x; + + if(xsq * DBL_EPSILON < 1.) + del = (1. - (1. - 5./(xsq+6.)) / (xsq+4.)) / (xsq+2.); + else + del = 0.; + *cum = -.5*xsq - M_LN_SQRT_2PI - log(x) + log1p(-del); + *ccum = log1p(-exp(*cum)); /.* ~ log(1) = 0 *./ + + swap_tail; + + [Yes, but xsq might be infinite.] + +*/ + || (lower && -37.5193 < x && x < 8.2924) + || (upper && -8.2924 < x && x < 37.5193) + ) { + + /* Evaluate pnorm for x in (-37.5, -5.657) union (5.657, 37.5) */ + xsq = 1.0 / (x * x); /* (1./x)*(1./x) might be better */ + xnum = p[5] * xsq; + xden = xsq; + for (i = 0; i < 4; ++i) { + xnum = (xnum + p[i]) * xsq; + xden = (xden + q[i]) * xsq; + } + temp = xsq * (xnum + p[4]) / (xden + q[4]); + temp = (M_1_SQRT_2PI - temp) / y; + + do_del(x); + swap_tail; + } else { /* large x such that probs are 0 or 1 */ + if(x > 0) { *cum = R_D__1; *ccum = R_D__0; } + else { *cum = R_D__0; *ccum = R_D__1; } + } + + +#ifdef NO_DENORMS + /* do not return "denormalized" -- we do in R */ + if(log_p) { + if(*cum > -min) *cum = -0.; + if(*ccum > -min)*ccum = -0.; + } + else { + if(*cum < min) *cum = 0.; + if(*ccum < min) *ccum = 0.; + } +#endif + return; +} + + + + + +double pnorm5(double x, double mu, double sigma, int lower_tail, int log_p) +{ + double p, cp; + + /* Note: The structure of these checks has been carefully thought through. + * For example, if x == mu and sigma == 0, we get the correct answer 1. + */ + if(!R_FINITE(x) && mu == x) return ML_NAN;/* x-mu is NaN */ + if (sigma <= 0) { + // if(sigma < 0) ML_ERR_return_NAN; + if(sigma < 0) return ML_NAN; ; + /* sigma = 0 : */ + return (x < mu) ? R_DT_0 : R_DT_1; + } + p = (x - mu) / sigma; + if(!R_FINITE(p)) + return (x < mu) ? R_DT_0 : R_DT_1; + x = p; + + pnorm_both(x, &p, &cp, (lower_tail ? 0 : 1), log_p); + + return(lower_tail ? p : cp); +} +#endif // pnorm diff --git a/src/statistics/statistics.h b/src/statistics/statistics.h new file mode 100644 index 0000000..43d72bf --- /dev/null +++ b/src/statistics/statistics.h @@ -0,0 +1,69 @@ +#ifndef bamStatistics_H_ +#define bamStatistics_H_ + + +#include +#include +#include +#include +#include +#include +#include +#include "BamCoverage.h" +#include "BamLowDepthRegion.h" +#include "BamDeteCNV.h" +#include "BamDeteSV.h" +#include "BamBasesCount.h" +#include "BamSiteRead.h" + + + +using namespace std; + +int bamSV_main(int argc, char *argv[]); +int bamCov_main(int argc, char *argv[]) ; +int bamLowDepth_main(int argc, char *argv[]); +int bamCNV_main(int argc, char *argv[]); +int BaseCount_main(int argc, char *argv[]); + +static int statistics_usage () +{ + cerr<<"" + "\n" + "\t\tCoverage Calculate Genome Coverage/Depth/GC Dis based Bam\n" + "\t\tBasesCount Calculate Genome every Site's four base Depth\n" + "\t\tDeteCNV Detect CNV/Deletion Region by merge Depth info based Bam\n" + "\t\tDeteSV Detect SV by Pair End Read insert size in Bam\n" + "\t\tLowDepth GiveOut bed file of low Depth Region(may BigDeletion)\n" + "\t\tSiteRead Extract the read (with base) covering the SNP site\n" + "\n" + "\t\tHelp Show this help\n" + "\n"; + return 1; +} + +int statistics_main(int argc, char *argv[]) +{ + if (argc < 2) { return statistics_usage(); } + else if (strcmp(argv[1], "Coverage") == 0) { return bamCov_main(argc-1, argv+1);} + else if (strcmp(argv[1], "LowDepth") == 0) { return bamLowDepth_main(argc-1, argv+1);} + else if (strcmp(argv[1], "DeteSV") == 0) { return bamSV_main(argc-1, argv+1);} + else if (strcmp(argv[1], "BasesCount") == 0) { return BaseCount_main(argc-1, argv+1);} + else if (strcmp(argv[1], "DeteCNV") == 0) { return bamCNV_main(argc-1, argv+1);} + else if (strcmp(argv[1], "SiteRead") == 0) { return SiteRead_main(argc-1, argv+1);} + else if (strcmp(argv[1], "Help") == 0 || strcmp(argv[1], "help") == 0 || strcmp(argv[1], "?")== 0 || ( argv[1][0] == '-' &&( argv[1][1] =='h' || argv[1][1] =='H' || argv[1][1] =='?' ) ) || strcmp(argv[1], "less") == 0 ) + { + return statistics_usage(); + } + else + { + cerr<<"convert [main] unrecognized command "< +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +//KSEQ_INIT(gzFile, gzread) + + +void bamDepth_help() +{ + cout<<"" + "\n" + "\tUsage: DepthCov -i -o \n" + "\tUsage: DepthCov -d -o \n" + "\n" + "\t\t-i input SAM/BAM files, delimited by space\n" + "\t\t-l input list of SAM/BAM files\n" + "\t\t-o prefix of output file\n" + "\n" + "\t\t-d depth along site in reference FASTA\n" + "\t\t-m x-axis of the plot, default [4*meanDepth]\n" + "\t\t-q the quality to filter reads, default [10]\n" + "\t\t-k output the Rscript used to generate plots\n" + "\n" + "\t\t-h show more details for help[hewm2008 v1.40]\n" + "\n"; +} + +void More_Help_bamDepth() +{ + cout<<"" + "\n" + "\t\t1. DepthCov -i -o AAA -k -q Q\n" + "\t\t DepthCov -l -o AAA -k -q Q\n" + "\t\t This will generate a plot with sequencing depth in x-axis and two y-axes on different sides (left and right): base proportion and accumulative coverage. The output file will be named with the prefix AAA and output to current directory.\n" + "\t\t (1.1) -l lists the input files. For example, if user has two input files A.bam and B.bam, bam.list should be formatted as:\n" + "\t\t ./A.bam\n" + "\t\t ./B.bam\n" + "\t\t (1.2) the reads with quality lower than Q will be removed, default value of Q is 10.\n" + "\n" + "\t\t2. DepthCov -d -o AAA -k -q Q\n" + "\t\tThis operation is the same with the example above but with different input format.\n" + "\t\t (2.1) the input file shows the depth along the reference FASTA. User could get this file with the function Coverage in the Statistics module. Below is an example of the usage of this command. More details could be found with the -h in this command.\n" + "\t\t bamdeal statistics Coverage -i -o AAA -r \n" + "\n"; +} + + +int bamDepth_help01(int argc, char **argv , In3str1v * paraFA04 ) +{ + if (argc <=1 ) {bamDepth_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + + if (flag == "InList" || flag == "List" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile"|| flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "InDepthF" || flag == "d") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr3=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "MaxXaxis" || flag == "m") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt2=atoi(argv[i]); + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "keepR" || flag == "k") + { + paraFA04->TF=false ; + } + else if (flag == "help" || flag == "h") + { + More_Help_bamDepth();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InStr3).empty()) + { + cerr<< "lack argument for the must"<InStr2)+".Depth_Cov"; + ofstream OUT (OStatFile.c_str()); + + ubit64_t Count=0; + map MapDepth ; + map :: iterator mapIt_Depth ; + + string chrName=""; + int Depth=0; + getline(FAIN,chrName); + chrName=chrName.substr(1); + ubit64_t TotolBase =0; + while(!FAIN.eof()) + { + string line ; + getline(FAIN,line); + if (line.length()<=0) { continue ; } + if (line[0] == '>') + { + chrName=line.substr(1); + // Count=0; + } + else + { + istringstream isone (line,istringstream::in); + while(isone>>Depth) + { + Count++; + TotolBase+=Depth; + mapIt_Depth=MapDepth.find(Depth); + if (mapIt_Depth==MapDepth.end()) + { + MapDepth.insert( map :: value_type (Depth,1)); + } + else + { + (mapIt_Depth->second)++; + } + } + } + } + + FAIN.close(); + + + if (( paraFA04->InInt2)<2) + { + ( paraFA04->InInt2) =(int(TotolBase/Count)+1)*4 ; + } + + OUT<<"##Depth\tDepthNumber\tCoveraged_Base\tDepthNumber(%)\tCoverage(%)\n"; + ubit64_t SumDtmp=0; + ubit64_t DThis=0; + double DA_ratio=0.0; + double DB_ratio=0.0; + ubit64_t EndCount=0; + for (mapIt_Depth=MapDepth.begin(); mapIt_Depth!=MapDepth.end();mapIt_Depth++) + { + DA_ratio= (mapIt_Depth->second)*100.0/(Count); + SumDtmp+=(mapIt_Depth->second); + DB_ratio= SumDtmp*100.0/(Count); + if ((mapIt_Depth->first)==0) + { + SumDtmp=SumDtmp-(mapIt_Depth->second); + OUT<<"#0\t"<<(mapIt_Depth->second)<<"\t"<first)<(paraFA04->InInt2)) + { + OUT<<(mapIt_Depth->first)<<"\t"<<(mapIt_Depth->second)<<"\t"<second); + } + } + + if (EndCount!=0) + { + DA_ratio= (EndCount)*100.0/(Count); + DB_ratio= SumDtmp*100.0/(Count); + OUT<<(paraFA04->InInt2)<<"\t"<InStr2)+".r"; + ofstream OUTR (OutPlotr.c_str()); + + OUTR<<"" + "\n" + "read.table(\""<r;\n" + "pdf(\""<<(paraFA04->InStr2)<<".pdf\");\n" + "plot(r[,1],r[,4],col=\"red\",type=\"l\",lwd=4,xaxt=\"n\",ylab=\"\",xlab=\"Sequencing Depth(X)\",col.axis=\"red\")\n" + "axis(2,col=\"red\",col.ticks=\"red\",col.axis=\"red\")\n" + "mtext(\"Base Proportion (%)\",side=2,line=2.2,col=\"red\")\n" + "par(new=T)\n" + "plot(r[,1],r[,5],col=\"blue\",type=\"l\",lwd=4,ylab=\"\",xlab=\"\",yaxt=\"n\",ylim=c(0,100))\n" + "axis(4,col=\"blue\",col.ticks=\"blue\",col.axis=\"blue\")\n" + "mtext(\"Accumulative coverage (%)\",side=4,line=-1,col=\"blue\")\n" + "dev.off();\n" + + "png(\""<<(paraFA04->InStr2)<<".png\");\n" + "plot(r[,1],r[,4],col=\"red\",type=\"l\",lwd=4,xaxt=\"n\",ylab=\"\",xlab=\"Sequencing Depth(X)\",col.axis=\"red\")\n" + "axis(2,col=\"red\",col.ticks=\"red\",col.axis=\"red\")\n" + "mtext(\"Base Proportion (%)\",side=2,line=2.2,col=\"red\")\n" + "par(new=T)\n" + "plot(r[,1],r[,5],col=\"blue\",type=\"l\",lwd=4,ylab=\"\",xlab=\"\",yaxt=\"n\",ylim=c(0,100))\n" + "axis(4,col=\"blue\",col.ticks=\"blue\",col.axis=\"blue\")\n" + "mtext(\"Accumulative coverage (%)\",side=4,line=-1,col=\"blue\")\n" + "dev.off();\n" + <TF) + { + cc=binPath+"\t"+OutPlotr+" ; rm -rf "+ OutPlotr ; + std::system(cc.c_str()) ; + } + else + { + cc=binPath+"\t"+OutPlotr ; + std::system(cc.c_str()) ; + cout <<"\t\tRePlot : Rscript "<InInt=10; + + if ((bamDepth_help01(argc, argv, paraFA04)==0)) + { + delete paraFA04 ; + return 0 ; + } + + if (!(paraFA04->InStr3).empty()) + { + Plot_Depth_Cov( paraFA04->InStr3 , paraFA04 ); + delete paraFA04 ; + return 1; + } + + + string DepthOFile=(paraFA04->InStr2)+".depth.fa.gz"; + ogzstream OUT (DepthOFile.c_str()); + if((!OUT.good())) + { + cerr << "open OUT File error: "<<(paraFA04->InStr2)<List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + cout<<"begin new the memory ...\n"; + + unsigned short int **depth = new unsigned short int*[(header->n_targets)]; // + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])+500; + depth[i] = new unsigned short int [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=0; + } + } + + cout<<"new the memory done"<List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + uint32_t *cigar; + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) + { + continue ; + } + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + } + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + + cout <<"ALL Bam Read done"<n_targets); i++) + { + OUT<<">"<<(header->target_name[i]); + for (int j =0 ; j< (header->target_len[i]) ; j++) + { + if (j%50000==0) + { + OUT<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + + + Plot_Depth_Cov( DepthOFile , paraFA04 ); + + bam_hdr_destroy(header); + delete paraFA04 ; + return 0; +} +#endif // bamDepth_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/visualize/BamShowDepthGC.h b/src/visualize/BamShowDepthGC.h new file mode 100644 index 0000000..01d7795 --- /dev/null +++ b/src/visualize/BamShowDepthGC.h @@ -0,0 +1,554 @@ +#ifndef bamDepGC_H_ +#define bamDepGC_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +//KSEQ_INIT(gzFile, gzread) + +/* +int bamDeGCshow_help() +{ + cout <<"" + "\n" + "\tUsage: DepthGC -InList -Ref -OutPut \n" + "\tUsage: DepthGC -InWigF -OutPut \n" + "\n" + "\t\t-InList Input Bam/Sam File List\n" + "\t\t-InFile Input Bam/Sam File File[repeat]\n" + "\t\t-InWigF Input Depth-GC wig File,BamCoverage OutPut\n" + "\t\t-OutPut OutPut Prefix File for Depth-GC Plot pdf\n" + "\n" + "\t\t-Ref In Ref.fa Want Out Depth-GC wig info\n" + "\t\t-Windows Windows size for Depth-GC wig[10000]\n" + "\t\t-MinQ Ignore too low mapQ read[10]\n" + "\t\t-MaxYaxis Max Y axis to plot the Result [3*meanD]\n" + "\t\t-keepR Keep the Rscript to RePlot the Figure\n" + "\n" + "\t\t-help Show this help [hewm2008 v1.20]\n" + "\n"; + return 1; +} +*/ + +void bamDeGCshow_help() +{ +cout<<"" +"\n" +"\tUsage: DepthGC -l -r -o \n" +"\tUsage: DepthGC -f -o \n" +"\n" +"\t\t-i input SAM/BAM files, delimited by space\n" +"\t\t-l input list of SAM/BAM files\n" +"\t\t-o prefix of output file\n" +"\n" +"\t\t-r input reference FASTA\n" +"\t\t-f file containing depth and GC content in each window. This file is one of the output files of Bamdeal statistics Coverage.\n" +"\t\t-w window size to calculate base frequency, default [10000]\n" +"\t\t-q reads with quality lower than this will be filtered, default [10]\n" +"\t\t-y maximum of y axis of the plot, default [3*mean of depth]\n" +"\t\t-k output the Rscript used to generate plots\n" +"\n" +"\t\t-h show more details for help\n" +"\n" +"\n"; +} + + +void More_bamDeGCshow_help() +{ +cout<<"" +"\n" +"\t\t1. DepthGC -i -r -o AAA -k -q Q\n" +"\t\tDepthGC -l -r -o AAA -k -q Q\n" +"\t\tThis will generate the plot of depth v.s GC content by window. The output file will be named with the prefix AAA and output to current directory.\n" +"\t\t(1.1) -l lists the input files. For example, if user has two input files A.bam and B.bam, bam.list should be formatted as:\n" +"\t\t./A.bam\n" +"\t\t./B.bam\n" +"\t\t(1.2) the reads with quality lower than Q will be removed, default value of Q is 10.\n" +"\n" +"\t\t2. DepthGC -f -o AAA -k -q Q\n" +"\t\tThis operation is the same with the example above but with different input format.\n" +"\t\t(2.1) the input file shows depth and GC content by window. User could get this file with the function Coverage in the Statistics module. Below is an example of the usage of this command. More details could be found with the -h in this command.\n" +"\t\tbamdeal statistics Coverage -i -o AAA -r \n" +"\n" +"\n"; +} + + +int bamDeGCshow_help01(int argc, char **argv , In3str1v * paraFA04 ) +{ + if (argc <=1 ) {bamDeGCshow_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "List" || flag == "l") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + else if (flag == "InWigF" || flag == "f") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + (paraFA04->InStr1)=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "Ref" || flag == "r") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr3=argv[i]; + } + else if (flag == "Windows" || flag == "w") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InF=atof(argv[i]); + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "MaxYaxis" || flag == "y") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt2=atoi(argv[i]); + } + else if (flag == "keepR" || flag == "k" ) + { + paraFA04->TF=false ; + } + else if (flag == "help" || flag == "h" ) + { + More_bamDeGCshow_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InStr1).empty()) + { + return 1 ; + } + + if ( (file_count<1) || (paraFA04->InStr3).empty()) + { + cerr<< "lack argument for the must"<InStr2)=add_Asuffix(paraFA04->InStr2); + return 1 ; +} + + +void DrawDepthGC( string File , In3str1v * paraFA04 ) +{ + + if ((paraFA04->InInt2)<2) + { + igzstream LLT (File.c_str(),ifstream::in); // igzstream + + if (!LLT.good()) + { + cerr << "open List error: "<>name>>Depth; + SumDepth+=Depth; + Count++; + } + LLT.close(); + (paraFA04->InInt2)=(int(SumDepth/Count)+1)*3; + } + + + + igzstream LIST (File.c_str(),ifstream::in); // igzstream + if (!LIST.good()) + { + cerr << "open List error: "< > hash_map; + + while(!LIST.eof()) + { + string line ; + getline(LIST,line); + if (line.length()<=0) { continue ; } + if (line[0] == '#') { continue ; } + if (line[line.length()-1] == 'A') { continue ; } + istringstream isone (line,istringstream::in); + isone>>name>>Depth>>GC; + if (Depth>(paraFA04->InInt2)) + { + Depth=(paraFA04->InInt2); + } + hash_map[GC][Depth]++; + } + LIST.close(); + + string OutPlotTmp=(paraFA04->InStr2)+".tmp"; + ofstream OUTPLOT (OutPlotTmp.c_str()); + + OUTPLOT<<"GC_ratio\tDepth\tNumbers\n"; + map > ::const_iterator outerit=hash_map.begin(); + map ::const_iterator innerit ; + + + for(outerit=hash_map.begin() ; outerit!=hash_map.end(); outerit++) + { + for(innerit=outerit->second.begin() ; innerit!=outerit->second.end(); innerit++) + { + OUTPLOT<first<<"\t"<first<<"\t"<second<InStr2)+".r"; + ofstream OUTR (OutPlotr.c_str()); + + OUTR<<"" + "\n" + "library(ggplot2);\nlibrary(gridExtra);\nlibrary(ggExtra)\n" + "read.table(\""<tab;\n" + "GC_ratio<-tab[,1];\n" + "Depth<-tab[,2];\n" + "Numbers<-tab[,3];\n" + "df <- data.frame(GC_ratio , Depth );\n" + "pdf(\""<<(paraFA04->InStr2)<<".pdf\");\n" + "p <- ggplot(df, aes(GC_ratio, Depth,colour=Numbers)) + geom_point(size=1.5) +theme(legend.direction=\"horizontal\",legend.position= \"bottom\",legend.title = element_text(face = \"bold\",size=7));\n" + "ggExtra::ggMarginal(p, type = \"histogram\");\n" + "dev.off();\n" + "png(\""<<(paraFA04->InStr2)<<".png\");\n" + "ggExtra::ggMarginal(p, type = \"histogram\");\n" + "\ndev.off();"<TF) + { + cc=binPath+"\t"+OutPlotr+" ; rm -rf "+ OutPlotr +" "+ OutPlotTmp ; + std::system(cc.c_str()) ; + } + else + { + cc=binPath+"\t"+OutPlotr ; + std::system(cc.c_str()) ; + cout <<"\t\tRePlot : Rscript "<InInt=10; + paraFA04->InF=10000; + if ((bamDeGCshow_help01(argc, argv, paraFA04)==0)) + { + delete paraFA04 ; + return 0 ; + } + + if (!(paraFA04->InStr1).empty()) + { + DrawDepthGC( paraFA04->InStr1 , paraFA04 ) ; + delete paraFA04 ; + return 1 ; + } + + string GCDepth=(paraFA04->InStr2); + GCDepth=GCDepth+".DepthGC.wig.gz"; + ogzstream OUTGC (GCDepth.c_str()); + + string BamPath=(paraFA04->List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + cout<<"begin new the memory ...\n"; + + unsigned short int **depth = new unsigned short int*[(header->n_targets)]; // + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])+500; + depth[i] = new unsigned short int [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=0; + } + } + + cout<<"new the memory done"<List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + uint32_t *cigar; + while (sam_read1(InBam, header, aln)>= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) + { + continue ; + } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + /*/// + for (int32_t j=0 ; j< ((aln->core).l_qseq) ; j++) + { + int32_t This=((aln->core).pos)+j; + depth[(aln->core).tid][This]++; + } + *//// + } + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + + cout <<"ALL Bam Read done"<InStr3).c_str(), "r"); + seq = kseq_init(fp); + int Windows=int(paraFA04->InF); + int cutOffLen=int(Windows*0.4); + + while ((l = kseq_read(seq)) >= 0) + { + int NumIntSca=0; + for(NumIntSca=0; NumIntSca <(header->n_targets); NumIntSca++) + { + if ( strcmp(header->target_name[NumIntSca],(seq->name.s)) ==0) + { + break; + } + } + int LastDis=(header->target_len[NumIntSca])-(Windows); + if (LastDis<0) {continue;} + OUTGC<<"#>"<<(seq->name.s)<<"\tWindowsSite:\t"<<(Windows)<seq.s[site]]++; + TotalDepth+=depth[NumIntSca][site]; + } + int N_Aleng= Ascii['N']+Ascii['n'] ; + int eff_Acout=(Windows)-N_Aleng ; + if (eff_Acoutn_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + + + bam_hdr_destroy(header); + delete paraFA04 ; + return 0; +} +#endif // bamDepGC_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/visualize/BamShowDepthSlide.h b/src/visualize/BamShowDepthSlide.h new file mode 100644 index 0000000..62da3a7 --- /dev/null +++ b/src/visualize/BamShowDepthSlide.h @@ -0,0 +1,587 @@ +#ifndef bamDepSlid_H_ +#define bamDepSlid_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include +#include +#include +#include +#include + +using namespace std; +typedef unsigned long long ubit64_t; +//KSEQ_INIT(gzFile, gzread) + +/* +int bamDepSliding_help() +{ + cout <<"" + "\n" + "\tUsage: DepthSlide -InList -Ref -OutPut \n" + "\tUsage: DepthSlide -InWigF -OutPut -DrawChr chr1,chr2\n" + "\n" + "\t\t-InList Input Bam/Sam File List\n" + "\t\t-InFile Input Bam/Sam File File[repeat]\n" + "\t\t-InWigF Input Depth-GC wig File,BamCoverage OutPut\n" + "\t\t-OutPut OutPut Prefix File for Depth-Slide pdf\n" + "\n" + "\t\t-Ref In Ref.fa Want Out Depth-GC wig info\n" + "\t\t-Windows Windows size for Depth-GC wig[10000]\n" + "\t\t-SlideRatio Windows slidint ratio(0,1] default 1\n" + "\t\t-MinQ Ignore too low mapQ read[10]\n" + "\n" + "\t\t-DrawChr only draw some chr Depth sliding [ALL_chr]\n" + "\t\t-MaxY MaxDepth Yaxis to plot Result [4*meanDepth]\n" + "\t\t-keepR Keep the Rscript to RePlot the Figure\n" + "\n" + "\t\t-help Show this help [hewm2008 v1.20]\n" + "\n"; + return 1; +} +*/ + +void bamDepSliding_help() +{ +cout<<"" +"\n" +"\tUsage: DepthSlide -l -r -o \n" +//"\tUsage: DepthSlide -i -r -o \n" +"\tUsage: DepthSlide -f -o -c chr1,chr2\n" +"\n" +"\t\t-i input SAM/BAM files, delimited by space\n" +"\t\t-l input list of SAM/BAM files\n" +"\t\t-o prefix of output file\n" +"\t\t-r input reference FASTA\n" +"\t\t-f file containing depth and GC content in each window. This file is one of the output files of Bamdeal statistics Coverage.\n" +"\n" +"\t\t-w window size to calculate base frequency, default [10000]\n" +"\t\t-s windows sliding ratio (0,1], default [1]\n" +"\t\t-q reads with quality lower than this will be filtered, default [10]\n" +"\t\t-c chromosome(s) to draw, delimited by comma. default [all chromosomes]\n" +"\t\t-y maximum of y axis of the plot, default [4*mean of depth]\n" +"\t\t-k output the Rscript used to generate plots\n" +"\n" +"\t\t-h show more details for help\n" +"\n" +"\n"; +} + + +void More_bamDepSliding_help() +{ +cout<<"" +"\n" +"\t\t1. DepthSlide -i -r -o AAA -k -q Q\n" +"\t\tDepthSlide -l -r -o AAA -k -q Q\n" +"\t\tThis will generate the plot of depth v.s GC content by window. The output file will be named with the prefix AAA and output to current directory.\n" +"\t\t(1.1) -l lists the input files. For example, if user has two input files A.bam and B.bam, bam.list should be formatted as:\n" +"\t\t./A.bam\n" +"\t\t./B.bam\n" +"\t\t(1.2) the reads with quality lower than Q will be removed, default value of Q is 10.\n" +"\n" +"\t\t2. DepthGC -f -o AAA -k -q Q\n" +"\t\tThis operation is the same with the example above but with different input format. \n" +"\t\t(2.1) the input file shows depth and GC content by window. User could get this file with the function Coverage in the Statistics module. Below is an example of the usage of this command. More details could be found with the -h in this command.\n" +"\t\tbamdeal statistics Coverage -i -o AAA -r \n" +"\n" +"\t\t3. DepthSlide -i -r -o AAA -c Chr1,Chr3 -s 0.2\n" +"\t\tThis will generate the plot of depth v.s GC content of Chr1 and Chr3 by window. The output file will be named with the prefix AAA and output to current directory. \n" +"\t\t(3.1) with -s set as 0.2, every time it would move forward r*w (window size) bases to begin a new window. For example, if window size is 10000 by default, the firstwindow would start at site 1, the second window would start at site 2001 (1+10000*0.2=2001), the third window would start at site 4001 (2001+10000*0.2=4001), and so on.\n" +"\n" +"\n"; +} + +int bamDepSliding_help01(int argc, char **argv , In3str1v * paraFA04 , string & OnlyChr , string & MaxY ) +{ + if (argc <=1 ) {bamDepSliding_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "List" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + } + + else if (flag == "InWigF" || flag == "f") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr1=argv[i]; + file_count++; + } + else if (flag == "MaxY" || flag == "y") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + MaxY=argv[i]; + } + else if (flag == "DrawChr" || flag == "c" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + OnlyChr=argv[i]; + } + else if (flag == "OutPut" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "Ref" || flag == "r") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr3=argv[i]; + } + else if (flag == "Windows" || flag == "w") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt2=atoi(argv[i]); + } + else if (flag == "MinQ" || flag == "q") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InInt=atoi(argv[i]); + } + else if (flag == "SlideRatio" || flag == "s" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InF=atof(argv[i]); + } + else if (flag == "keepR" || flag == "k") + { + paraFA04->TF=false ; + } + else if (flag == "help" || flag == "h") + { + More_bamDepSliding_help();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2).empty() ) + { + cerr<< "lack argument for the must"<InInt2)<10 ) + { + cerr<< " windows size too small"<InStr1).empty())) + { + return 1 ; + } + + if ( ( file_count<1 ) || (paraFA04->InStr3).empty()) + { + cerr<< "lack argument for the must"<InF) <=0 || (paraFA04->InF) > 1 ) + { + cerr <<"SlideRatio Must be the in (0,1] "<InStr2)=add_Asuffix(paraFA04->InStr2); + return 1 ; +} + + +void DrawDepthSliding( string File , In3str1v * paraFA04 , string OnlyChr , string MaxYtemp ) +{ + + igzstream LIST (File.c_str(),ifstream::in); // igzstream + if (!LIST.good()) + { + cerr << "open List error: "<InStr2)+".tmp"; + ofstream OUTPLOT (OutPlotTmp.c_str()); + OUTPLOT<<"Chr\tSite\tDepth\n"; + + string chr=""; + getline(LIST,chr); + string site=""; + int Depth=0; + // string OnlyChr=(paraFA04->List)[0]; + // string MaxYtemp=(paraFA04->List)[1]; + + int Count=0; + ubit64_t SumDepth=0; + vector ChrVec; + int VecSize=0; + if (OnlyChr!="NA") + { + split(OnlyChr,ChrVec,",-"); + VecSize=ChrVec.size(); + } + + bool YYY=false; + + while(!LIST.eof()) + { + string line ; + getline(LIST,line); + if (line.length()<=0) { continue ; } + istringstream isone (line,istringstream::in); + if (line[0] == '#') + { + isone>>chr; + chr=chr.substr(2); + if (OnlyChr!="NA") + { + YYY=true ; + for (int iii=0 ; iii>site>>Depth; + Count++; + SumDepth+=Depth; + OUTPLOT<InStr2)+".r"; + ofstream OUTR (OutPlotr.c_str()); + + OUTR<<"" + "\n" + "library(ggplot2);\n" + "read.table(\""<data;\ndata = data[order(data$Chr),];\nchrlist = sort(levels(data$Chr))\n" + "data$Site = data$Site/1000\n" + "if(length(chrlist)>1){\n" + "for(i in 2:length(chrlist))\n" + "{\n" + "\tadd = max(data$Site[which(data$Chr==chrlist[i-1])])\n" + "\tnew_site = data$Site[which(data$Chr==chrlist[i])]+add\n" + "\tdata$Site[which(data$Chr==chrlist[i])] = new_site\n" + "}\n" + "}\n" + "data$Site = data$Site/1000\n" + "x_axis = scale_x_continuous(name=\"Site by chromosome(Mb)\",breaks=as.vector(by(data$Site,data$Chr,median)),labels = sort(levels(data$Chr)))\n" + "plot_theme = theme(axis.title=element_text(face='bold',size=10),axis.text = element_text(size=8),legend.position='none')\n" + "p <- ggplot(data,aes(Site,Depth,col=Chr))+geom_point(size=1.25)+ylim(1,"<InStr2)<<".pdf\",h=6,w=25);\n" + "p\n" + "dev.off()\n" + "png(\""<<(paraFA04->InStr2)<<".png\",h=6,w=25);\n" + "p\n" + "dev.off()\n"<TF) + { + cc=binPath+"\t"+OutPlotr+" ; rm -rf "+ OutPlotr +" "+ OutPlotTmp ; + std::system(cc.c_str()) ; + } + else + { + cc=binPath+"\t"+OutPlotr ; + std::system(cc.c_str()) ; + cout <<"\t\tRePlot : Rscript "<InInt=10; + paraFA04->InF=1; + paraFA04->InInt2=10000; + string OnlyChr ="NA"; + string MaxYtemp="NA"; + if ((bamDepSliding_help01(argc, argv, paraFA04,OnlyChr,MaxYtemp)==0)) + { + delete paraFA04; + return 0; + } + if (!(paraFA04->InStr1).empty()) + { + DrawDepthSliding(paraFA04->InStr1, paraFA04 ,OnlyChr,MaxYtemp ); + delete paraFA04; + return 1; + } + + string GCDepth=(paraFA04->InStr2); + GCDepth=GCDepth+".DepthGC.wig.gz"; + ogzstream OUTGC (GCDepth.c_str()); + + string BamPath=(paraFA04->List)[0]; + bam_hdr_t *header; + samFile *BamIn = hts_open(BamPath.c_str(), "r"); + header = sam_hdr_read(BamIn); + sam_close(BamIn); + + cout<<"begin new the memory ...\n"; + + unsigned short int **depth = new unsigned short int*[(header->n_targets)]; // + for(int i = 0; i < (header->n_targets); i++) + { + int CC=(header->target_len[i])+500; + depth[i] = new unsigned short int [CC]; // + for (int32_t j =0 ; j< CC ; j++) + { + depth[i][j]=0; + } + } + + cout<<"new the memory done"<List).size(); + for (int kij=0 ; kij< FileNum ; kij++ ) + { + string line = (paraFA04->List)[kij]; + if (line.length()<=0) { continue ; } + + cout <<"Begin Bam :"<n_targets)!=(headerA->n_targets)) + { + cerr<<"Error1 :Bam header should be the same\n"<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + bool NoSameBam=false; + for(int i = 0; i < (header->n_targets); i++) + { + if (strcmp(header->target_name[i],headerA->target_name[i])!=0) + { + NoSameBam=true; + cerr<target_name[i]<<"\t"<target_name[i]<n_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + delete paraFA04 ; + return 1; + } + + uint32_t *cigar; + + while (sam_read1(InBam, header, aln) >= 0) + { + if ((aln->core).tid < 0) {continue ;} + if ( (aln->core).qual < (paraFA04->InInt)) + { + continue ; + } + + cigar = bam_get_cigar(aln); + int32_t This=((aln->core).pos); + for(int i=0; i < aln->core.n_cigar;++i) + { + int cig=bam_cigar_op(cigar[i]); + int ncig = bam_cigar_oplen(cigar[i]); + if (cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF ) + { + int end=This+ncig; + for ( ; Thiscore).tid][This]++; + } + } + else if (cig==BAM_CDEL || cig==BAM_CREF_SKIP ) + { + This=This+ncig; + } + } + + /* + for (int32_t j=0 ; j< ((aln->core).l_qseq) ; j++) + { + int32_t This=((aln->core).pos)+j; + depth[(aln->core).tid][This]++; + } + */ + } + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(headerA); + } + + cout <<"ALL Bam Read done"<InStr3).c_str(), "r"); + seq = kseq_init(fp); + int Windows=int(paraFA04->InInt2); + int SlidingLen=int(Windows*(paraFA04->InF)); + int cutOffLen=int(Windows*0.4); + + while ((l = kseq_read(seq)) >= 0) + { + int NumIntSca=0; + for(NumIntSca=0; NumIntSca <(header->n_targets); NumIntSca++) + { + if ( strcmp(header->target_name[NumIntSca],(seq->name.s)) ==0) + { + break; + } + } + int LastDis=(header->target_len[NumIntSca])-(Windows); + if (LastDis<0) {continue;} + OUTGC<<"#>"<<(seq->name.s)<<"\tWindowsSite:\t"<<(Windows)<seq.s[site]]++; + TotalDepth+=depth[NumIntSca][site]; + } + int N_Aleng= Ascii['N']+Ascii['n'] ; + int eff_Acout=(Windows)-N_Aleng ; + if (eff_Acoutn_targets); i++) + { + delete[] depth[i]; + } + delete[] depth; + + bam_hdr_destroy(header); + delete paraFA04 ; + return 0; +} +#endif // bamDepSlid_H_ // +///////// swimming in the sky and flying in the sea //////////// + + + + + diff --git a/src/visualize/BamStatQC.h b/src/visualize/BamStatQC.h new file mode 100644 index 0000000..5c43b73 --- /dev/null +++ b/src/visualize/BamStatQC.h @@ -0,0 +1,548 @@ +#ifndef BamStatQC_H_ +#define BamStatQC_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../ALL/comm.h" +#include "../ALL/DataClass.h" +#include "../ALL/dealfun.cpp" +#include +#include +#include +#include +#include +#include +#define MAX_Q 128 + +using namespace std; +typedef unsigned long long ubit64_t; +//KSEQ_INIT(gzFile, gzread) + + +void BamStatQC_help() +{ + cout<<"" + "\n" + "\tUsage: StatQC -i in.bam -o ./\n" + "\tUsage: StatQC -l \n" + "\n" + "\t\t-i input SAM/BAM files, delimited by space\n" + "\t\t-l input list of SAM/BAM files\n" + "\n" + "\t\t-o output directory, default [PWD]\n" + "\t\t-k output the Rscript used to generate plots\n" + "\n" + "\t\t-h show more details for help\n" + "\n"; +} + +void More_HelpBamStatQC() +{ + cout<<"" + "\n" + "\t\t1. StatQC -i -k\n" + "\t\t StatQC -l -k \n" + "\t\t This will generate four plots (GC with depth, insert size, base distribution and quality distribution) and output the result to current directory. Output files are named with the prefix bamQC.\n" + "\t\t (1.1) -l lists the input files. For example, if user has two input files A.bam and B.bam, bam.list should be formatted as:\n" + "\t\t ./A.bam\n" + "\t\t ./B.bam\n" + "\n"; +} + + +int BamStatQC_help01(int argc, char **argv , In3str1v * paraFA04) +{ + if (argc <=1 ) {BamStatQC_help();return 0;} + int file_count=0; + for(int i = 1; i < argc ; i++) + { + if(argv[i][0] != '-') + { + cerr << "command option error! please check." << endl; + return 0; + } + string flag=argv[i] ; + flag=replace_all(flag,"-",""); + + if (flag == "InList" || flag == "l" ) + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + file_count+=(ReadList(A ,(paraFA04->List))); + } + else if (flag == "InFile" || flag == "i") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + string A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + bool RunT=true; + while(RunT) + { + if ( (i+1) < argc && (argv[i+1][0]!='-')) + { + i++; + A=argv[i]; + (paraFA04->List).push_back(A); + file_count++; + } + else + { + RunT=false; + } + } + + } + else if (flag == "OutDir" || flag == "o") + { + if(i + 1 == argc) {LogLackArg(flag); return 0;} + i++; + paraFA04->InStr2=argv[i]; + } + else if (flag == "keepR" || flag == "k") + { + paraFA04->TF=false ; + } + else if (flag == "help" || flag == "h") + { + More_HelpBamStatQC();return 0; + } + else + { + cerr << "UnKnow argument -"<InStr2)="./"; + paraFA04->InF=10000; + if ((BamStatQC_help01(argc, argv, paraFA04)==0)) + { + delete paraFA04; + return 0; + } + + + int Raw_ASICC=Get_qual_Data ( (paraFA04->List)[0] ); + int ReadMaxL=0; + Get_BamInfo((paraFA04->List)[0], ReadMaxL); + + + mkdir((paraFA04->InStr2).c_str() , 0755 ) ; + (paraFA04->InStr2)=(paraFA04->InStr2)+"/bamQC"; + + //static long int cycle_qual[MAX_L][MAX_Q];//ÿ??cycle?????ֲ? + ubit64_t **cycle_qual = new ubit64_t *[ReadMaxL]; //¿ª±ڐΠ + for(int i = 0; i < ReadMaxL; i++) + { + cycle_qual[i] = new ubit64_t [MAX_Q]; //¿ª±ځΠ + for (int32_t j =0 ; j< MAX_Q ; j++) + { + cycle_qual[i][j]=0; + } + } + + + ubit64_t **cycle_base = new ubit64_t *[ReadMaxL]; //¿ª±? + for(int i = 0; i < ReadMaxL; i++) + { + cycle_base[i] = new ubit64_t [5]; //¿ª±ځΠ + for (int32_t j =0 ; j<5 ; j++) + { + cycle_base[i][j]=0; + } + } + + + int FileNum=(paraFA04->List).size(); + ubit64_t TotalBase=0; + ubit64_t TotalRead=0; + ubit64_t UnmapRead=0, UnmapBase=0; + ubit64_t LowQRead=0; + ubit64_t duplicate=0; + ubit64_t not_primary=0; + map InsertSize ; + map GCDepth; + map :: iterator MapIt ; + + uint8_t UC[16] = {0,0,1,0,2,0,0,0,3,0,0,0,0,0,0,4}; + + for (int ii=0 ; ii< FileNum ; ii++ ) + { + string line =(paraFA04->List)[ii]; + if (line.length()<=0) { continue; } + + cout <<"Begin Bam :"<= 0) + { + TotalRead++; TotalBase+=((aln->core).l_qseq); + if ((aln->core).tid < 0) + { + UnmapRead++ ; UnmapBase+=((aln->core).l_qseq) ; LowQRead++; continue ; + } + + if ( (aln->core).flag & 0x2 ) + { + MapIt=InsertSize.find((aln->core).isize); + if (MapIt==InsertSize.end()) + { + InsertSize.insert( map :: value_type ((aln->core).isize,1)); + } + else + { + (MapIt->second)++; + } + } + + if ( (aln->core).flag & 0x400 ) + { + duplicate++; + } + if ( (aln->core).flag & 0x100 ) + { + not_primary++; + } + if (ReadMaxL==(aln->core).l_qseq) + { + uint8_t *seq=bam_get_seq(aln); + uint8_t *seqQ=bam_get_qual(aln); + int DepthGC[5]={0}; + int Tmp=0; + for (int c=0;c :: value_type (Tmp,1)); + } + else + { + (MapIt->second)++; + } + } + + if ( (aln->core).qual ==0 ) + { + LowQRead++; + } + } + sam_close(InBam); + bam_destroy1(aln); + bam_hdr_destroy(header); + } + + cout <<"ALL Bam Read done"<InStr2)+".InsertSize"; + ofstream OUTIS (OutIS.c_str()); + + MapIt=InsertSize.begin(); + int X_InMax=0; + int Y_InMax=0; + + OUTIS<<"#Insert\tNumber\n"; + for ( ; MapIt!=InsertSize.end(); MapIt++) + { + OUTIS<first<<"\t"<second<<"\n"; + proper_pair+=(MapIt->second); + if ( (MapIt->second)>Y_InMax) + { + Y_InMax=(MapIt->second); + X_InMax=MapIt->first; + } + } + OUTIS.close(); + + + string OutGCD=(paraFA04->InStr2)+".GC-depth"; + ofstream OUTGCD (OutGCD.c_str()); + int X_max=0; + int Y_max=0; + MapIt=GCDepth.begin(); + OUTGCD<<"#GC\tNumber\n"; + + for ( ; MapIt!=GCDepth.end(); MapIt++) + { + double PMap=(MapIt->first)*100.0/ReadMaxL; + OUTGCD<second<<"\n"; + if (Y_max<=(MapIt->second)) + { + Y_max=(MapIt->second); + X_max=PMap; + } + } + OUTGCD.close(); + + + + + + + string OutStat=(paraFA04->InStr2)+".stat"; + cerr<=30) q30+=qual[q]; + if (q>=20) q20+=qual[q]; + } + } + + + int Low=33+Raw_ASICC; + + ubit64_t MappedR=TotalRead-UnmapRead; + double PMap=MappedR*100.0/TotalRead ; + double PD=duplicate*100.0/TotalRead ; + double Pproper_pair=proper_pair*100.0/TotalRead ; + + double Pnot_prim=not_primary*100.0/TotalRead ; + int MeanRL=TotalBase/TotalRead; + + ubit64_t MappedB=TotalBase-UnmapBase; + double PMapBase=MappedB*100.0/TotalBase; + OUTS<<"#Read\n\t##Total:\t"<InStr2)+".QC"; + ofstream OUTFile (OutQC.c_str()); + + baseACTG+=base[4]; + + OUTFile<<"# A C G T N "; + + for(int q=0;q<=qMAX;q++) + { + OUTFile<InStr2)+".r"; + ofstream OUTR (OutPlotr.c_str()); + OUTR<<"" + "\n" + "read.table(\""<r;\n" + "pdf(\""<r;\n" + "pdf(\""<r;\n" + "pdf(\""<TF) + { + cc=binPath+"\t"+OutPlotr+" ; rm -rf "+ OutPlotr ; + } + std::system(cc.c_str()) ; + } + + + + + for(int i = 0; i +#include +#include +#include +#include +#include +#include +#include "BamStatQC.h" +#include "BamShowDepthCov.h" +#include "BamShowDepthGC.h" +#include "BamShowDepthSlide.h" + + +using namespace std; + +int bamCov_main(int argc, char *argv[]) ; +int bamLowDepth_main(int argc, char *argv[]); +int bamDepthGC_main(int argc, char *argv[]); +int bamDepthCov_main(int argc, char *argv[]); +int bamDepthSlide_main(int argc, char *argv[]); +int bamCNV_main(int argc, char *argv[]); +int BamStatQC_main(int argc, char *argv[]) ; + +static int visualize_usage () +{ + cerr<<"" + "\n" + "\t\tStatQC generate plots for quality control\n" + "\t\tDepthCov Show Fig of Depth Dis & Depth~Coverage\n" + "\t\tDepthGC Show Fig of Depth~RefGC\n" + "\t\tDepthSlide Show Manhattan Fig of Depth sliding Windows along genome\n" + "\n" + "\t\tHelp Show this help\n" + "\n"; + return 1; +} + + +int visualize_main(int argc, char *argv[]) +{ + if (argc < 2) { return visualize_usage(); } + else if (strcmp(argv[1], "Coverage") == 0) { return bamCov_main(argc-1, argv+1);} + else if (strcmp(argv[1], "StatQC") == 0) { return BamStatQC_main(argc-1, argv+1);} + else if (strcmp(argv[1], "LowDepth") == 0) { return bamLowDepth_main(argc-1, argv+1);} + else if (strcmp(argv[1], "DeteCNV") == 0) { return bamCNV_main(argc-1, argv+1);} + else if (strcmp(argv[1], "DepthGC") == 0) { return bamDepthGC_main(argc-1, argv+1);} + else if (strcmp(argv[1], "DepthCov")== 0) { return bamDepthCov_main(argc-1, argv+1);} + else if (strcmp(argv[1], "DepthSlide")== 0) { return bamDepthSlide_main(argc-1, argv+1);} + else if (strcmp(argv[1], "Help") == 0 || strcmp(argv[1], "help") == 0 || strcmp(argv[1], "?")== 0 || ( argv[1][0] == '-' &&( argv[1][1] =='h' || argv[1][1] =='H' || argv[1][1] =='?' ) ) || strcmp(argv[1], "less") == 0) + { + return visualize_usage(); + } + else + { + cerr<<"convert [main] unrecognized command "<