This guide addresses common installation issues with pHapCompass, particularly related to compiling the extractHAIRS dependency.
pHapCompass uses a modified version of extractHAIRS (from HAPCUT2) to extract fragment information from BAM files. This tool must be compiled from C source code, which requires:
- A C compiler (gcc, clang, or cc)
- The make build tool
- Git (for downloading required submodules: htslib and samtools)
Cause: Required build tools are not installed on your system.
Solution:
On Ubuntu/Debian:
sudo apt-get update
sudo apt-get install build-essential gitOn macOS:
# Install Xcode Command Line Tools
xcode-select --install
# Verify installation
gcc --version
make --versionOn Fedora/RHEL/CentOS:
sudo dnf install gcc gcc-c++ make gitOn Arch Linux:
sudo pacman -S base-devel gitSymptoms:
- "fatal: No url found for submodule path"
- "Makefile:XX: sub/htslib/Makefile: No such file or directory"
Cause: The git submodules (htslib and samtools) were not downloaded.
Solution:
If you cloned the repository:
cd pHapCompass
git submodule update --init --recursiveIf you installed via pip:
# Uninstall first
pip uninstall phapcompass
# Clone properly with submodules
git clone --recursive https://github.com/bayesomicslab/pHapCompass.git
cd pHapCompass
pip install -e .Symptoms:
- Errors mentioning "htslib.h" or "sam.h" not found
- Linker errors with "-lhts" or "-lbam"
Cause: The htslib/samtools libraries failed to compile.
Solution:
cd pHapCompass/third_party/extract_poly
# Check if submodules exist
ls -la sub/
# If they don't exist, initialize them
git submodule update --init --recursive
# Clean and rebuild everything
make clean
make
# If successful, the binary should exist at:
ls -lh build/extractHAIRSSymptoms:
FileNotFoundError: extractHAIRS binary not found
Cause: The binary was not compiled or not copied to the correct location.
Solution:
Check if binary exists:
# From pHapCompass root directory
ls -lh src/phapcompass/bin/extractHAIRSIf not found, manually compile and copy:
cd third_party/extract_poly
make clean
make
# Verify binary was created
ls -lh build/extractHAIRS
# Copy to package bin directory
mkdir -p ../../src/phapcompass/bin
cp build/extractHAIRS ../../src/phapcompass/bin/
chmod +x ../../src/phapcompass/bin/extractHAIRSSymptoms:
- "Permission denied" when running make
- Cannot create build directory
Solution:
Check directory permissions:
ls -ld third_party/extract_polyFix permissions if needed:
chmod -R u+w third_party/extract_polyIf installed in system Python:
# Try installing in user mode instead
pip install --user -e .Cause: zlib development headers are missing. This is commonly seen on Fedora and RHEL/Rocky Linux.
Solution:
On Ubuntu/Debian:
sudo apt-get install zlib1g-dev libbz2-dev liblzma-devOn Fedora/RHEL/Rocky Linux:
sudo dnf install zlib-devel bzip2-devel xz-develThen retry the installation:
pip install -e .Cause: RHEL and Rocky Linux ship with Python 3.9 by default, but pHapCompass requires Python 3.10+.
Solution:
# Install epel-release first to get access to more packages
sudo dnf install -y epel-release
# Install Python 3.11
sudo dnf install -y python3.11 python3.11-pip
# Verify version
python3.11 --version
# Install pHapCompass using Python 3.11 explicitly
python3.11 -m pip install -e .Alternatively, use conda to manage the Python version:
# Create a conda environment with Python 3.10
conda create -n phapcompass python=3.10 -y
conda activate phapcompass
pip install -e .If compilation continues to fail and you have fragment files (.frag), you can skip extractHAIRS:
# Install without extractHAIRS
pip install git+https://github.com/bayesomicslab/pHapCompass.git
# Use with fragment files
phapcompass --data-type short \
--frag-path precomputed.frag \
--vcf-path sample.vcf.gz \
--result-path output.vcf.gzYou can also install the original HAPCUT2 separately:
# Clone HAPCUT2
git clone --recursive https://github.com/vibansal/HapCUT2.git
cd HapCUT2
make
# Add to PATH
export PATH=$PATH:$(pwd)/build
# Now pHapCompass will use the system extractHAIRSAfter resolving issues, verify everything works:
# Test pHapCompass installation
phapcompass --help
# Test extractHAIRS specifically
which extractHAIRS
# OR
python -c "from phapcompass.utils import find_extracthairs; print(find_extracthairs())"
# Run a test with example data
phapcompass --data-type short \
--bam-path test_data/short_data_example/0.bam \
--vcf-path test_data/ref_example/Chr1_unphased.vcf \
--result-path test_output.vcf.gzIf none of these solutions work:
- Collect diagnostic information:
# System information
uname -a
gcc --version
make --version
git --version
python --version
# Package information
pip show phapcompass
ls -lh src/phapcompass/bin/-
Open a GitHub issue with:
- Your operating system and version
- The complete error message
- Output from the diagnostic commands above
- Steps you've already tried
-
Ask on the GitHub Discussions page for community support