Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ease and modernise installation a bit #119

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions INSTALL.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,16 @@ caveman depends on:
Compilation
===========

If you have a local install of htslib:
```
cd CaVEMan
./setup.sh <install_dir>
```

Type 'make' if you have the following environmental variables $HTSLIB set
to be the directory of your local install of each.

Otherwise the command below will hopefully help you.

make HTSLOC="/full/path/to/htslib" TEST_REF="/path/to/GRCh37/genome.fa.fai"

If you wish to temporarily install htslib purely for building caveman:

Type './setup.sh <install_directory>' within the CaVEMan directory. Caveman executables
will be installed to 'install_directory/bin/'.
Caveman executables will be installed to `<install_dir>/bin/`.

Installation
============

Copy 'bin/caveman', and other executables in bin/ to a location you want
(e.g. a directory in your $PATH).
`<install_dir>/lib/` must be appended to LD_LIBRARY_PATH.
This ensures shared libraries are available to executables.
Add `<install_dir>/bin/` to path if system-wide availbility of executables is desired.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ HTSTMP?=./caveman_tmp
prefix=?/usr/local/

#Define locations of header files
OPTINC?=-I$(HTSLOC)/
OPTINC?=-I$(HTSLOC)/ -I$(LINASM_INC)
INCLUDES= -Isrc $(OPTINC) -rdynamic

JOIN_INCLUDES= -I$(prefix)/include
Expand All @@ -28,7 +28,7 @@ CAT_LFLAGS= -L$(prefix)/lib
# define library paths in addition to /usr/lib
# if I wanted to include libraries not in /usr/lib I'd specify
# their path using -Lpath, something like:
LFLAGS?=-L$(HTSTMP)
LFLAGS?=-L$(HTSTMP) -L$(LINASM_LIB)

# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
Expand Down Expand Up @@ -85,7 +85,7 @@ test: $(TESTS)
#Unit tests with coverage
coverage: CFLAGS += --coverage
coverage: test

make_bin:
$(MD) ./bin

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CaVEMan

A C implementation of the CaVEMan program. Uses an expectation maximisation
approach to calling single base substitutions in paired data.
Designed for use with a compute farm/cluster most steps in the program make
Designed for use with a compute farm/cluster; most steps in the program make
use of an index parameter. The split step is designed to divide the genome into
chunks of adjustable size to optimise for runtime/memory usage requirements.
For simple execution of CaVEMan please see [cgpCaVEManWrapper](https://github.com/cancerit/cgpCaVEManWrapper)
Expand Down
91 changes: 38 additions & 53 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##########LICENCE##########

SOURCE_HTSLIB="https://github.com/samtools/htslib/releases/download/1.10.2/htslib-1.10.2.tar.bz2"

REQUIRED_MIN_LIBZ="1.2.3.4"

function version_eq_gt() {
Expand All @@ -32,28 +30,7 @@ function version_eq_gt() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
}

get_distro () {
EXT=""
DECOMP="gunzip -f"
echo "$1"
if [[ $2 == *.tar.bz2* ]] ; then
EXT="tar.bz2"
DECOMP="bzip2 -fd"
elif [[ $2 == *.tar.gz* ]] ; then
EXT="tar.gz"
else
echo "I don't understand the file type for $1"
exit 1
fi
if hash curl 2>/dev/null; then
curl -sS -o $1.$EXT -L $2
else
wget -nv -O $1.$EXT $2
fi
mkdir -p $1
`$DECOMP $1.$EXT`
tar --strip-components 1 -C $1 -xf $1.tar
}
set -euo pipefail

if [ "$#" -ne "1" ] ; then
echo "Please provide an installation path such as /opt/pancan"
Expand All @@ -75,18 +52,10 @@ echo "Max compilation CPUs set to $CPU"
# get current directory
INIT_DIR=`pwd`

# log information about this system
echo '============== System information ===='
set -x
lsb_release -a
uname -a
sw_vers
system_profiler
grep MemTotal /proc/meminfo
set +x
echo; echo
LIBZ_VER=`echo '#include <zlib.h>' | cpp -H -o /dev/null |& head -1 | cut -d' ' -f 2 | xargs grep -e '#define ZLIB_VERSION' | cut -d ' ' -f 3 | perl -pe 's/["\n]//g'`
echo $LIBZ_VER
set +o pipefail
LIBZ_VER=$(echo '#include <zlib.h>' | cpp -H -o /dev/null |& head -1 | cut -d' ' -f 2 | xargs grep -e '#define ZLIB_VERSION' | cut -d ' ' -f 3 | perl -pe 's/["\n]//g')
set -o pipefail

if version_eq_gt $LIBZ_VER $REQUIRED_MIN_LIBZ ; then
echo "Found acceptable libz version $LIBZ_VER."
echo "Continuing install"
Expand All @@ -97,8 +66,6 @@ else
exit 1
fi

set -ue

# cleanup inst_path
mkdir -p $INST_PATH/bin
cd $INST_PATH
Expand All @@ -110,41 +77,59 @@ SETUP_DIR=$INIT_DIR/install_tmp
mkdir -p $SETUP_DIR

cd $SETUP_DIR
echo -n "Building linasm..."
if [ -e $SETUP_DIR/linasm.success ]; then
echo -n "previously installed..."
else
wget https://github.com/rurban/linasm/archive/e33b4a083f8bbdcbd58018c9abc65047d20fd431.zip &&
unzip -o e33b4a083f8bbdcbd58018c9abc65047d20fd431.zip && mv linasm-e33b4a083f8bbdcbd58018c9abc65047d20fd431 linasm && cd linasm &&
mkdir -p linasm_inst &&
make &&
make install prefix=${SETUP_DIR}/linasm/linasm_inst/ &&
make clean &&
touch $SETUP_DIR/linasm.success
fi

export LINASM_INC=$SETUP_DIR/linasm/linasm_inst/include/
export LINASM_LIB=$SETUP_DIR/linasm/linasm_inst/lib/

cd $SETUP_DIR
echo -n "Building htslib ..."
if [ -e $SETUP_DIR/htslib.success ]; then
echo -n " previously installed ...";
echo -n "previously installed ...";
else
cd $SETUP_DIR
if [ ! -e htslib ]; then
get_distro "htslib" $SOURCE_HTSLIB
fi
make -C htslib -j$CPU
wget https://github.com/samtools/htslib/releases/download/1.10.2/htslib-1.10.2.tar.bz2 &&
bzip2 -fd htslib-1.10.2.tar.bz2 &&
mkdir -p htslib &&
tar --strip-components 1 -C htslib -xf htslib-1.10.2.tar &&
cd htslib &&
make -j$CPU &&
touch $SETUP_DIR/htslib.success
fi

export HTSLIB="$SETUP_DIR/htslib"

set -e
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HTSLIB}:${LINASM_LIB}"

echo -n "Building CaVEMan ..."
if [ -e "$SETUP_DIR/caveman.success" ]; then
echo -n " previously installed ...";
else
cd $INIT_DIR
mkdir -p $INIT_DIR/c/bin &&
make clean &&
make -j$CPU &&
cp $INIT_DIR/bin/caveman $INST_PATH/bin/. &&
cp $INIT_DIR/bin/mergeCavemanResults $INST_PATH/bin/. &&
mv $INIT_DIR/bin/* $INST_PATH/bin/ &&
mkdir -p $INST_PATH/lib/ &&
cp $LINASM_LIB/liblinasm.so $INST_PATH/lib/. &&
touch $SETUP_DIR/caveman.success
fi

cd $INIT_DIR
exit

# cleanup all junk
rm -rf $SETUP_DIR
rm -rf $SETUP_DIR
make clean

echo
echo "Please add the following to beginning of path:"
echo " $INST_PATH/bin"
echo "Installation succesful"
echo "Binaries available at $INST_PATH/bin/"
echo "linasm.so available at $INST_PATH/lib/ - directory must be on LD_LIBRARY_PATH"