This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Issues installing bcftools with GNU Scientific Library

I am trying to compile the latest bcftools (version 1.9) with the GNU Scientific Library, in order to be able to use the polysomy algorithm.

I'm not sudo on the shared system, so I installed zlib-1.2.11 in my home directory.

Then in the bcftools directory I tried:

./configure --enable-libgsl CPPFLAGS="-l/my_home/lib/zlib-1.2.11"

Output:

checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for grep that handles long lines and -e... /bin/grep
checking for C compiler warning flags... -Wall
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking location of HTSlib source tree... htslib-1.9
checking shared library type... plain .so
checking for library containing dlopen... -ldl
checking if the compiler accepts -rdynamic... yes
checking for zlib.h... yes
checking for inflate in -lz... no
configure: error: zlib development files not found

BCFtools uses compression routines from the zlib library <http://zlib.net>.
Building bcftools requires zlib development files to be installed on the build
machine; you may need to ensure a package such as zlib1g-dev (on Debian or
Ubuntu Linux) or zlib-devel (on RPM-based Linux distributions) is installed.

FAILED.  This error must be resolved in order to build bcftools successfully.

What is "inflate"? A library? A command? What is "lz"?

bcftools zlib

An easy workaround would be to install bcftools via a package manager such as conda.

Yes, I tried installing the GNU Scientific Library, then bcftools with conda. Both installations worked, but the GSL is not integrated/linked and thus I cannot get polysomy.

I found that adding the following to your bashrc solved most of these issues. I would install zlib (but not bcftools) with conda, then add the flags below to bashrc and then see if you can compile bcftools with that.

export LDFLAGS="-L$HOME/anaconda3/lib"
export CFLAGS="-I$HOME/anaconda3/include"
export CPATH="$HOME/anaconda3/include"

Try adding /include to your configure command and also adding LDFLAGS, maybe that would help

./configure --enable-libgsl CPPFLAGS="-I/my_home/lib/zlib-1.2.11/include" LDFLAGS="-L/my_home/lib/zlib-1.2.11/lib"

It's all very well being an advocate for conda, but the OP specifically said they want the polysomy subcommand. That subcommand is deactivated in the conda build, so recommending it is no help at all. It would be great if conda advocates would actually read the question before their just-use-conda reflexes kick in.

Does it state anywhere in the documentation that the subcommand is deactivated in the conda build? If not, ATpoint could never have known, and suggesting conda is perfectly valid in 99.99% of other cases, especially for novice users.

Edit fyi (by ATpoint): We removed this entire chain as it does not help others. !Constructive! discussions are always welcome on our slack ( biostar.slack.com: Chat for the biostars community ).

That would obviously be a question for the maintainers of the conda package for bcftools. But I would expect a 21k (or even a 13k) user to be able to run the condaised bcftools they already have installed and check. Effective helping requires research and tailoring your answer to the specific circumstances, y'see…

Reputation score is fairly arbitrary and as far as I'm concerned, measures very little of meaning.

FWIW, I don't have bcftools installed, but it doesn't seem unreasonable that, knowing that it is available in conda, the default assumption would be that it has parity with other releases. I'm more than happy to be corrected, as I'm sure ATpoint is, but your tone is not very helpful, nor have you provided an answer yourself, and seem to just be nitpicking at someone else's sincere attempt to help the OP. This is all the more so for someone who themselves has moderator status...

The OP cross-posted this elsewhere, where you will find myself and others providing advice.

John, seeing as to how you're a moderator, you're welcome to join our Slack group where we can internally discuss these issues. The forum would benefit from scientific debate, but targeting users harms the entire community.

1 answer

Devon Ryan was (as usual) very helpful and updated the conda recipe for bcftools to include the polysomy subcommand. You should now be able to pull a bcftools version from conda that includes that subcommand. Be sure that your ~/.condarc lists the channels in this order:

channels:
  - conda-forge
  - bioconda

to make sure that the correct versions of e.g. openssl is pulled. Works fine on my machine:

$ bcftools polysomy

About:   Detect number of chromosomal copies from Illumina's B-allele frequency (BAF)
Usage:   bcftools polysomy [OPTIONS] <file.vcf>

General options:
    -o, --output-dir <path>        
    -r, --regions <region>         restrict to comma-separated list of regions
    -R, --regions-file <file>      restrict to regions listed in a file
    -s, --sample <name>            sample to analyze
    -t, --targets <region>         similar to -r but streams rather than index-jumps
    -T, --targets-file <file>      similar to -R but streams rather than index-jumps
    -v, --verbose                  

Algorithm options:
    -b, --peak-size <float>        minimum peak size (0-1, larger is stricter) [0.1]
    -c, --cn-penalty <float>       penalty for increasing CN (0-1, larger is stricter) [0.7]
    -f, --fit-th <float>           goodness of fit threshold (>0, smaller is stricter) [3.3]
    -i, --include-aa               include the AA peak in CN2 and CN3 evaluation
    -m, --min-fraction <float>     minimum distinguishable fraction of aberrant cells [0.1]
    -p, --peak-symmetry <float>    peak symmetry threshold (0-1, larger is stricter) [0.5]

Hi, do you happen to know which version contains this subcommand? The current version (or most up to date) doesn't recognize the polysomy command.

$ bcftools polysomy [E::main] unrecognized command 'polysomy'

thank you!

oh, so are you suggesting to locally install bcftools instead of going through conda? i have attempted local installation but i was having some issues with the makefile

Hilariously @GenoMax you are doing much the same thing that other moderators five years ago did in their comments on this question. As the answer you are commenting on states, for over five years the Bioconda build of bcftools has indeed been built to include the GNU Scientific Library and the bcftools subcommands that that enables.

I was not sure if @nitya had already tried to install using conda since they were saying that the command was not recognized. So I was just pointing out that GSL was required in case they were trying to build locally.

Use bcftools --version or conda list bcftools to find out what version of bcftools you have actually installed. Also use which bcftools to check that the copy of bcftools that you are running is the one you think you are.

Any version of the bioconda bcftools package that depends on the gsl package will include the polysomy command. In particular, all bioconda builds of the current version, 1.21, have been built this way (as have the preceding versions for several years).

If yours does not include polysomy probably you will find that it is a much older version. The usual way people get such old versions via bioconda is that they do not have the conda-forge channel activated. Set up your conda installation according to the Bioconda instructions.

thank you! although I had the current version of bcftools, I don't think my conda installation was fully set up.

What did which bcftools and bcftools --version say?

Log in to answer this question.