diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..675165d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +# Docker ignore file for pager +.git +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env +pip-log.txt +pip-delete-this-directory.txt +.ipynb_checkpoints +.DS_Store \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..be00779 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,83 @@ +# Dockerfile for pager - PAGE algorithm and data curation container +FROM ubuntu:22.04 + +# Set environment variables to avoid interactive prompts +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=UTC + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + perl \ + wget \ + curl \ + git \ + build-essential \ + unzip \ + gzip \ + && rm -rf /var/lib/apt/lists/* + +# Install Miniconda +RUN wget --no-check-certificate https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p /opt/conda && \ + rm miniconda.sh + +# Add conda to PATH +ENV PATH="/opt/conda/bin:$PATH" + +# Initialize conda and create pager environment as described in README +RUN conda init bash && \ + conda config --set ssl_verify false && \ + conda tos accept --override-channels --channel defaults && \ + conda create -n pager -y && \ + echo "conda activate pager" >> ~/.bashrc + +# Install Python dependencies in the pager environment +RUN /bin/bash -c "source /opt/conda/etc/profile.d/conda.sh && \ + conda activate pager && \ + conda install -y pandas numpy matplotlib" + +# Create working directory +WORKDIR /opt/pager + +# Copy pager code +COPY . . + +# Set up environment variables for iPAGE and TEISER using conda env config vars +# This follows the README conda setup instructions +RUN /bin/bash -c "source /opt/conda/etc/profile.d/conda.sh && \ + conda activate pager && \ + conda env config vars set PAGEDIR=/opt/PAGE && \ + conda env config vars set TEISERDIR=/opt/TEISER" + +# Create directories for external tools +RUN mkdir -p /opt/PAGE /opt/TEISER + +# Make shell scripts executable +RUN find . -name "*.sh" -exec chmod +x {} \; + +# Create a script to help users set up external dependencies +RUN echo '#!/bin/bash' > /opt/setup_tools.sh && \ + echo 'echo "To use pager fully, you need to install iPAGE and TEISER:"' >> /opt/setup_tools.sh && \ + echo 'echo "1. iPAGE: https://github.com/hanig/PAGE"' >> /opt/setup_tools.sh && \ + echo 'echo "2. TEISER: https://github.com/hanig/TEISER"' >> /opt/setup_tools.sh && \ + echo 'echo ""' >> /opt/setup_tools.sh && \ + echo 'echo "Mount these tools into the container at:"' >> /opt/setup_tools.sh && \ + echo 'echo " - iPAGE: /opt/PAGE"' >> /opt/setup_tools.sh && \ + echo 'echo " - TEISER: /opt/TEISER"' >> /opt/setup_tools.sh && \ + echo 'echo ""' >> /opt/setup_tools.sh && \ + echo 'echo "Example run command:"' >> /opt/setup_tools.sh && \ + echo 'echo "docker run -v /path/to/PAGE:/opt/PAGE -v /path/to/TEISER:/opt/TEISER -v /path/to/data:/data pager"' >> /opt/setup_tools.sh && \ + chmod +x /opt/setup_tools.sh + +# Create entrypoint script that activates conda environment +RUN echo '#!/bin/bash' > /opt/entrypoint.sh && \ + echo 'source /opt/conda/etc/profile.d/conda.sh' >> /opt/entrypoint.sh && \ + echo 'conda activate pager' >> /opt/entrypoint.sh && \ + echo 'exec "$@"' >> /opt/entrypoint.sh && \ + chmod +x /opt/entrypoint.sh + +# Set the entrypoint to activate conda environment +ENTRYPOINT ["/opt/entrypoint.sh"] + +# Default command shows setup instructions +CMD ["/opt/setup_tools.sh"] \ No newline at end of file diff --git a/README.md b/README.md index e5f3cf0..6d0a270 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,57 @@ Container of codes and data to run PAGE algorithm and enable further data curati ## Installation +**Option 1: Docker (Recommended)** + +The easiest way to use pager is with Docker. Build and run the container: + +```bash +# Build the Docker image +docker build -t pager . + +# Run with setup instructions +docker run pager + +# Run with your data mounted (interactive shell) +docker run -v /path/to/your/data:/data -it pager /bin/bash + +# If you have iPAGE and TEISER installed locally +docker run -v /path/to/PAGE:/opt/PAGE -v /path/to/TEISER:/opt/TEISER -v /path/to/data:/data -it pager /bin/bash + +# Test the container functionality +docker run pager /opt/pager/docker_test.sh +``` + +Or use docker-compose for easier management: + +```bash +# Edit docker-compose.yml to mount your local directories +docker compose build +docker compose run pager + +# Or run specific commands +docker compose run pager python -c "import pager; help(pager)" +``` + +**Docker Examples:** + +```bash +# Run iPAGE analysis (assuming you have the tools mounted) +docker run -v /local/data:/data -v /local/PAGE:/opt/PAGE pager \ + bash /opt/pager/iPAGE_loop.sh /data/input.txt + +# Run Python pager functions +docker run -v /local/data:/data pager \ + python -c " +import sys; sys.path.append('/opt/pager') +import pager +df = pager.read_pvmatrix('/data/pvmatrix.txt') +print(df.head()) +" +``` + +**Option 2: Manual Installation** + **Requirements:** Follw the instructions to install iPAGE and TEISER from the following links: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..07c3a3b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +services: + pager: + build: . + image: pager:latest + container_name: pager + volumes: + # Mount your local data directory + - ./data:/data + # Mount iPAGE and TEISER tools if available locally + # - /path/to/your/PAGE:/opt/PAGE + # - /path/to/your/TEISER:/opt/TEISER + working_dir: /data + environment: + - PAGEDIR=/opt/PAGE + - TEISERDIR=/opt/TEISER + # Override default command to start interactive shell + command: /bin/bash \ No newline at end of file diff --git a/docker_test.sh b/docker_test.sh new file mode 100755 index 0000000..af9dc20 --- /dev/null +++ b/docker_test.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Example script to test pager functionality in Docker container +# This script demonstrates basic pager module functionality + +echo "=== Pager Docker Container Test ===" +echo "" + +# Test Python import +echo "Testing Python environment..." +python -c " +import sys +sys.path.append('/opt/pager') +import pager +import pandas as pd +import os + +print('✓ Python available via conda') +print('✓ pager module imported successfully') +print('✓ pandas available:', pd.__version__) +print('✓ Working directory:', os.getcwd()) +" + +echo "" +echo "=== Environment Variables ===" +echo "PAGEDIR: $PAGEDIR" +echo "TEISERDIR: $TEISERDIR" + +echo "" +echo "=== Available Scripts ===" +ls -la /opt/pager/*.sh + +echo "" +echo "=== Test Data ===" +if [ -f "/opt/pager/test/input.txt" ]; then + echo "Test input data found:" + head -n 5 /opt/pager/test/input.txt + echo "... (showing first 5 lines)" +else + echo "No test data found in /opt/pager/test/" +fi + +echo "" +echo "=== Docker Container Ready ===" +echo "To get started:" +echo "1. Mount your data: docker run -v /path/to/data:/data pager" +echo "2. Mount iPAGE/TEISER tools for full functionality" +echo "3. Use 'python -c \"import pager; help(pager)\"' to explore the module" \ No newline at end of file