Installing Bio::DB::Sam perl module
Asked Answered
A

4

6

I am trying to install a perl module Bio::DB::Sam on my home directory on a remote server.

I downloaded the module, extracted the files, and ran:

perl Build.pl prefix=~/local

this is what happens next:

This module requires samtools 0.1.10 or higher (samtools.sourceforge.net).
Please enter the location of the bam.h and compiled libbam.a files: **/some_places/samtools-0.1.19**

Found /some_places/samtools-0.1.19/bam.h and /some_places/samtools-0.1.19/libbam.a.
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Bio-SamTools' version '1.39'

Next when I try to run:

./Build

this is what I get:

  Building Bio-SamTools
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -o blib/arch/auto/Bio/DB/Sam/Sam.so lib/Bio/DB/Sam.o c_bin/bam2bedgraph.o -L/some_places/samtools-0.1.19 -lbam -lpthread -lz
/usr/bin/ld: /some_places/samtools-0.1.19/libbam.a(bgzf.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/some_places/samtools-0.1.19/libbam.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error building blib/arch/auto/Bio/DB/Sam/Sam.so from lib/Bio/DB/Sam.o c_bin/bam2bedgraph.o at ~/perl5/lib/perl5/ExtUtils/CBuilder/Base.pm line 323.

I did google the possible solutions and tried a couple, but they didn't work, e.g. --enable-shared OR export CXXFLAGS="$CXXFLAGS -fPIC".

I have already have Bioperl installed on my home directory.

Any help would be appreciated.

Cheers

Albumin answered 28/8, 2014 at 19:3 Comment(4)
Have you emailed the author of samtools to ask for assistance?Trickster
No, I haven't yet. At the moment, I'm trying to re-compile the version of samtools on our side using -fPIC to see if I still see the same problem while installing Bio::DB::Sam.Albumin
This is pretty common, in my experience. You need to make clean in the samtools directory, then edit the Makefile in the samtools dist to add "-fPIC" to the CFLAGS. After that, you can try to build Bio-SamTools.Roehm
I did so, but I started getting different errors which apaprently come from the different in the samtools and Bio::DB::Sam versions. I had downloaded the newest version of samtools which apparently the Bio::DB::Sam doesn't supoprt anymore. There were some functions which were commented out in the new samtools bam.h library. I am gonig to download and install an older version of samtools and try to link Bio::DB::Sam to the old version of samtools and will keep here posted on the results.Albumin
R
7

Here is a script that will fetch the SAMtools source and compile it, then fetch and compile the Perl bindings.

wget http://sourceforge.net/projects/samtools/files/samtools/0.1.18/samtools-0.1.18.tar.bz2
tar xjf samtools-0.1.18.tar.bz2 && cd samtools-0.1.18
make CFLAGS=-fPIC
export SAMTOOLS=`pwd`
cpanm Bio::DB::Sam

Part of the problem you were likely seeing is that the SAMtools project has recently undergone some major code reorganization (and this has naturally made it difficult to work with external language bindings).

Roehm answered 1/9, 2014 at 19:5 Comment(6)
Thanks SES, I will give this a try and will keep you posted on how it worked. One last question though, if I want to install it on my home directory, do I need to do anything other than defining the prefix=~/someplaces while installing samtools?Albumin
@Nikleotide, you will also need to make sure the SAMTOOLS env variable points to the correct location of the samtools directory before building Bio-SamTools (if not building interactively and specifying it explicitly). Hope that helps.Roehm
Thanks SES. I have to put this on hold for a couple of days as something urgent has come up. I will pick this up and let you know about my progres.. Thanks for all the help and taking your time.Albumin
@Nikleotide, the above commands will only take a few seconds, so you will know instantly if it works (i.e., you'll see "PASS" at the end of the tests). From there, you can use the Perl library in place, or run ./Build install, then you can use Bio-SamTools anywhere.Roehm
Thanks SES. I got the PASS at the end. And then I did ./Build install. I('m going to try the installation. Will keep you posted on that.Albumin
@Nikleotide, if the tests passed and you did ./Build install successfully, then Bio-SamTools is installed. You can use the command perl -MBio::DB::Sam -e 1 to test the installation. If it prints nothing, everything is installed.Roehm
S
1

I fixed this issue by remaking samtools with the -fPIC parameter

make clean
make CXXFLAGS=-fPIC CFLAGS=-fPIC CPPFLAGS=-fPIC

then installed using cpan.

cpan[2]> install Bio::DB::Sam 
Sibylle answered 3/11, 2014 at 1:12 Comment(0)
V
1

[Solved]

wget http://sourceforge.net/projects/samtools/files/samtools/0.1.18/samtools-0.1.18.tar.bz2

tar xjf samtools-0.1.18.tar.bz2 && cd samtools-0.1.18

make CFLAGS=-fPIC

enter cpan in terminal and enter

install Bio::DB::Sam

Be carefully:

You can not use the following command:

perl -MCPAN -Mlocal::lib -e 'CPAN::install(Bio::DB::Sam)'

You can only use cpan and then use

install Bio::DB::Sam
Vouge answered 27/5, 2016 at 3:11 Comment(0)
C
0

I followed instructions from README file below of Bio-SamTools-1.43 to edit the Makefile in samtools 0.1.17. Then, to install, I used

perl -MCPAN -e shell install Bio::DB::Sam

README:

This is a Perl interface to the SAMtools sequence alignment interface. It ONLY works on versions of Samtools up to 0.1.17. It does not work on version 1.0 or higher due to major changes in the library structure.

See http://samtools.sourceforge.net/ for samtools documentation.

  • ONE-STEP INSTALLATION

In the root directory of this distribution you will find the script INSTALL.pl. Running this will download the latest versions of this module and SamTools into a temporary directory, compile them, test and install. Simply run:

perl INSTALL.pl

  • MULTI-STEP INSTALLATION

The more traditional install requires you to separately download, unpack and compile SAMtools 0.1.10 through 0.1.17 in some accessible directory. Typing "make" in the samtools directory will usually work. SAMtools versions 0.1.18 and higher do not work with this library.

Then set the environment variable SAMTOOLS to point to this directory.

You will also need to install Bio::Perl from CPAN.

Now run:

perl Build.PL ./Build ./Build test (sudo) ./Build install

TROUBLESHOOTING:

If you encounter problems during compiling, you may need to edit Build.PL so that extra_compiler_flags matches the CFLAGS and DFLAGS settings in the Samtools Makefile. Here are some common problems:

  1. When building this module, you get an error like the following: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

To fix this, edit the Makefile in the Samtools distribution by adding "-fPIC" to the CFLAGS line. While you're at it, you may also wish to get rid of a bunch of unused variable warnings that appears under recent versions of gcc. The modified CFLAGS will look like this

CFLAGS= -g -Wall -Wno-unused -Wno-unused-result -O2 -fPIC #-m64 #-arch ppc

Then do "make clean; make" in the Samtools directory to recompile the library. After this you should be able to build this module without errors.

  1. When building this module, you get an error about a missing math library.

To fix this, follow the recipe in (1) except add -m64 to CFLAGS so it looks like this:

CFLAGS= -g -Wall -O2 -fPIC #-m64 #-arch ppc

TESTING AND CONTRIBUTING:

You can obtain the most recent development version of this module via its GitHub site at https://github.com/GMOD/GBrowse-Adaptors. Please feel free to submit bug reports, patches, etc. via GitHub.

AUTHOR:

Lincoln D. Stein

Copyright (c) 2009-2015 Ontario Institute for Cancer Research

This package and its accompanying libraries are free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0, the Apache 2.0 License, or the GNU General Public License (version 1 or higher). Refer to LICENSE for the full license text.

Clarkclarke answered 28/2, 2017 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.