odelaneau / shapeit4

Segmented HAPlotype Estimation and Imputation Tool
MIT License
90 stars 18 forks source link

Compilation problems / documentation #3

Closed cwhelan closed 3 years ago

cwhelan commented 5 years ago

I'd love to try out shapeit4, but I'm having issues compiling it on my system. When I try compiling with GCC 4.3: I get the error:

g++ -std=c++0x -O3 -c src/phaser/phaser_initialise.cpp -o obj/phaser_initialise.o -Isrc -Iinclude -I/broad/software/free/Linux/redhat_6_x86_64/pkgs/boost_1.66.0/include
In file included from src/utils/otools.h:64:0,
                 from src/phaser/phaser_header.h:27,
                 from src/phaser/phaser_initialise.cpp:22:
src/utils/timer.h: In member function 'std::string timer::date()':
src/utils/timer.h:59:12: error: 'put_time' is not a member of 'std'
make: *** [obj/phaser_initialise.o] Error 1

Some googling made me thing that this might be fixed with a newer GCC, but when I try with GCC 5.2, I get:

$ make
g++ -std=c++0x -O3 -c src/phaser/phaser_initialise.cpp -o obj/phaser_initialise.o -Isrc -Iinclude -I/broad/software/free/Linux/redhat_6_x86_64/pkgs/boost_1.66.0/include
In file included from src/phaser/phaser_header.h:29:0,
                 from src/phaser/phaser_initialise.cpp:22:
src/models/haplotype_segment.h: In member function 'bool haplotype_segment::TRANSH()':
src/models/haplotype_segment.h:403:25: error: call of overloaded 'isnan(double&)' is ambiguous
  return (isnan(sumHProbs) || sumHProbs < numeric_limits<double>::min());
                         ^
In file included from /usr/include/features.h:361:0,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/x86_64-redhat-linux/bits/os_defines.h:39,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/x86_64-redhat-linux/bits/c++config.h:482,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/bits/stl_algobase.h:59,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/vector:60,
                 from src/utils/otools.h:26,
                 from src/phaser/phaser_header.h:27,
                 from src/phaser/phaser_initialise.cpp:22:
/usr/include/bits/mathcalls.h:235:1: note: candidate: int isnan(double)
 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 ^
In file included from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/random:38:0,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/bits/stl_algo.h:66,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/algorithm:62,
                 from src/utils/otools.h:35,
                 from src/phaser/phaser_header.h:27,
                 from src/phaser/phaser_initialise.cpp:22:
/broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/cmath:626:3: note: candidate: constexpr bool std::isnan(long double)
   isnan(long double __x)
   ^
/broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/cmath:622:3: note: candidate: constexpr bool std::isnan(double)
   isnan(double __x)
   ^
/broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/cmath:618:3: note: candidate: constexpr bool std::isnan(float)
   isnan(float __x)
   ^
In file included from src/phaser/phaser_header.h:29:0,
                 from src/phaser/phaser_initialise.cpp:22:
src/models/haplotype_segment.h: In member function 'bool haplotype_segment::TRANSD(int&)':
src/models/haplotype_segment.h:444:25: error: call of overloaded 'isnan(double&)' is ambiguous
  return (isnan(sumDProbs) || sumDProbs < numeric_limits<double>::min());
                         ^
In file included from /usr/include/features.h:361:0,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/x86_64-redhat-linux/bits/os_defines.h:39,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/x86_64-redhat-linux/bits/c++config.h:482,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/bits/stl_algobase.h:59,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/vector:60,
                 from src/utils/otools.h:26,
                 from src/phaser/phaser_header.h:27,
                 from src/phaser/phaser_initialise.cpp:22:
/usr/include/bits/mathcalls.h:235:1: note: candidate: int isnan(double)
 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 ^
In file included from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/random:38:0,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/bits/stl_algo.h:66,
                 from /broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/algorithm:62,
                 from src/utils/otools.h:35,
                 from src/phaser/phaser_header.h:27,
                 from src/phaser/phaser_initialise.cpp:22:
/broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/cmath:626:3: note: candidate: constexpr bool std::isnan(long double)
   isnan(long double __x)
   ^
/broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/cmath:622:3: note: candidate: constexpr bool std::isnan(double)
   isnan(double __x)
   ^
/broad/software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/include/c++/5.2.0/cmath:618:3: note: candidate: constexpr bool std::isnan(float)
   isnan(float __x)
   ^
make: *** [obj/phaser_initialise.o] Error 1

What versions of GCC, Boost, and Samtools should I be using to compile?

cwhelan commented 5 years ago

FWIW, I figured out that I could compile in a docker image. There must be something off about the compiler and library versions available on my login servers, but I'm still not sure what. In case it's helpful to anyone, here's a (relatively unoptimized) Dockerfile that successfully compiles SHAPEIT4:

FROM ubuntu:18.10

ARG DEBIAN_FRONTEND=noninteractive
ARG SAMTOOLS_VERSION=1.9
RUN apt-get -qqy update --fix-missing && \
    apt-get -qqy dist-upgrade && \
    apt-get -qqy install --no-install-recommends \
                 ca-certificates \
                 libbz2-dev \
                 libcurl4-openssl-dev \
                 liblzma-dev \
                 libncurses5-dev \
                 autoconf \
                 automake \
                 bzip2 \
                 gcc \
         g++ \
                 make \
                 wget \
                 zlib1g-dev \
         libboost-all-dev \
         git && \
    wget https://github.com/samtools/samtools/releases/download/${SAMTOOLS_VERSION}/samtools-${SAMTOOLS_VERSION}.tar.bz2 && \
    tar xjf samtools-${SAMTOOLS_VERSION}.tar.bz2 && \
    cd samtools-${SAMTOOLS_VERSION} && ./configure CFLAGS="-static" --without-curses && make -s all all-htslib && make install install-htslib && cd - && \ 
    rm -rf samtools-${SAMTOOLS_VERSION}* && \
    git clone https://github.com/odelaneau/shapeit4.git && \
    cd shapeit4 && \
    cat makefile | sed 's|HTSLIB_INC=$(HOME)/Tools/htslib-1.9|HTSLIB_INC=/usr/local/include|' | sed 's|HTSLIB_LIB=$(HOME)/Tools/htslib-1.9/libhts.a|HTSLIB_LIB=/usr/local/lib/libhts.a|' > makefile2 && \
    mv makefile makefile.old && \
    mv makefile2 makefile && \
    make

ENV PATH="/shapeit4/bin/:${PATH}"

If you're interested in adding docker support to your project, I'd be happy to put this into a pull request.

zhudakai commented 4 years ago

Yes it'll be nice if we can pull this down as a docker container. Our plan is to use singularity to run this in a RedHat 6 HPC - simply don't have the required prerequisites. But I'm going to give your dockerfile a shot and see. Thanks! Dakai