This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bcftools command not found

I've read quite a few posts about this, and tried what they suggest, but still encounter this problem.

I want to variant call using bcftools, so I installed it according to these instructions: https://samtools.github.io/bcftools/howtos/install.html it now sits here: /Users/michaelflower/bin/bcftools

I've made the bam file ch2ot_pairaln.sorted.bam with bwa, and I've got a reference file chr2.fa. I've put both these files in a folder within bcftools here: /Users/michaelflower/bin/bcftools/tempbcftools

I then try and variant call using the advice here: https://samtools.github.io/bcftools/howtos/variant-calling.html

bcftools mpileup -f tempbcftools/chr2.fa tempbcftools/ch2ot_pairaln.sorted.bam | bcftools call -mv -Ob -o tempbcftools/chr2ot_calls.bcf

But I get this error:

-bash: bcftools: command not found

I've read that others have had the same problem, and that it's due to a PATH problem: https://www.biostars.org/p/417504/ http://seqanswers.com/forums/showthread.php?t=31212

So I read about PATH here (https://astrobiomike.github.io/unix/modifying_your_path) and added bcftools to it:

export PATH="$PATH:/usr/bin/bcftools

Now my path looks like this:

$ echo $PATH | tr ":" "\n"
/Users/michaelflower/bin
/Users/michaelflower/bin
/Users/michaelflower/opt/anaconda3/bin
/Users/michaelflower/opt/anaconda3/condabin
/Users/michaelflower/bin
/Users/michaelflower/bin
/Library/Frameworks/Python.framework/Versions/3.7/bin
/Library/Frameworks/Python.framework/Versions/2.7/bin
/Library/Frameworks/Python.framework/Versions/3.5/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/X11/bin
/usr/bin/bcftools
/usr/bin/samtools
/usr/bin/htslib

But still I get the same error when I try and run bcftools:

-bash: bcftools: command not found

What am I doing wrong?? I'm still suspicious it has something to do with the way I've set up the PATH, as the response to the 'which' command is different for samtools (which works) and bcftools (which doesn't):

$ which samtools
/usr/local/bin/samtools

$ which bcftools
samtools bcftools vcf bam

1 answer

export PATH=/Users/michaelflower/bin/:$PATH

Just the folder with the executable, not the executable itself must be in PATH. This must a) be in .bash_profile and then b) you have to open a new terminal to make it work once you added the export command to .bash_profile.

Thanks, I've done that, closed terminal, reopened, but still get the same error:

I ran this:

export PATH=/Users/michaelflower/bin/:$PATH

Closed terminal and reopened.

$ echo $PATH | tr ":" "\n"
/Users/michaelflower/bin
/Users/michaelflower/bin
/Users/michaelflower/opt/anaconda3/bin
/Users/michaelflower/opt/anaconda3/condabin
/Users/michaelflower/bin
/Users/michaelflower/bin
/Library/Frameworks/Python.framework/Versions/3.7/bin
/Library/Frameworks/Python.framework/Versions/2.7/bin
/Library/Frameworks/Python.framework/Versions/3.5/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/X11/bin

cd to /Users/michaelflower/bin/bcftools And still get this error:

bcftools mpileup -f tempbcftools/chr2.fa tempbcftools/ch2ot_pairaln.sorted.bam | bcftools call -mv -Ob -o tempbcftools/chr2ot_calls.bcf

-bash: bcftools: command not found
-bash: bcftools: command not found

Is /Users/michaelflower/bin/bcftools a folder or the executable? You must PATH the folder in which the executable sits.

But given that you already have anaconda installed, just type conda install -c bioconda bcftools and be done with it :)

Log in to answer this question.