If anyone else has recently stumbled onto this thread due to the Tophat2 "checking for bamlib... configure: error" then my advice is, at this point in time, don't try and compile Tophat2 with the newest versions of samtools.
Here is my story. I hope this saves some other soul from hours of frustration.
So, I was trying to compile from source due to this error message when I run the binary:
Error: TopHat requires Samtools 0.1.7 or later
When I, in fact, have this version installed:
Using htslib 0.2.0-rc9-4-gc8c5b31
So I try to compile from source and run into dramas with the
configure script which is a bit brain damaged and has incorrect documentation.
The documentation states:
Notes on compiling the package from source:
TopHat requires the Samtools package (http://samtools.sourceforge.net/)
in order to generate and handle the compressed, binary alignment files (BAM).
The --with-bam=<bam_prefix> option of the configure script expects the
following subdirectories and files:
<bam_prefix>/include/bam/*.h (all the header files from Samtools)
<bam_prefix>/lib/libbam.a (obtained by compiling Samtools)
At the time of this writing the Samtools package does not have an
install routine the user will have to explicitly create the above
directory structure (./include/bam/ and ./lib) and copy the required
Samtools files as indicated (the header files and libbam.a)
However, after much trouble shooting and pain I finally realise I;m not at fault so I start reading the configure shell script. Somewhere around line 4000 I see these lines:
for i in `ls -d $ac_bam_path/include/bam-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$ac_bam_path##" | sed 's/\/include\/bam-//' | sed 's/_/./'`
So, the script looks for directory names under the relative path
include/bam-* and not
include/bam as the documentation states. Then, it carves the bam version out of this user created directory name using sed. Why? This is so fragile! Using a user created directory name to work out the version is a recipe for disaster, plus telling the user to create a directory with no version name in the docs really obscures things?! Why not parse the output of
samtools --version from the
$ac_bam_path folder to get the version number! :/
Okay, so I rename the folder and now I can run
configure without errors. So I type make and now I get compilation errors because the new versions of samtools have separate htslib libraries. So I copy the htslib header files into
/usr/local/include/bam-0.2.0-rc9-1-g1ff7535/htslib and try again. This time I get a new error.
common.h: In member function 'void GBamRecord::add_aux(const char*, char, int, uint8_t*)':
common.h:372:10: error: 'struct bam1_t' has no member named 'l_aux'
common.h: In member function 'void GBamWriter::write(bam1_t*, int64_t)':
common.h:598:35: error: 'BAM_CORE_SIZE' was not declared in this scope
It's taken two days to get to this point and now I'm giving up. Time to remove samtools 0.2.0 from the path and try with version 0.1.8 and the Tophat2 binary. Failing that, I will convert my workflow to STAR, which happily compiled and is aligning reads nicely.