Skip to content

Commit

Permalink
added Dockerfile + custom init script
Browse files Browse the repository at this point in the history
  • Loading branch information
bbowles1 committed May 13, 2024
1 parent c272595 commit 8573b4d
Show file tree
Hide file tree
Showing 4 changed files with 1,229 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# using ubuntu LTS version
# from https://luis-sena.medium.com/creating-the-perfect-python-dockerfile-51bdec41f1c8

# using ubuntu LTS version
FROM ubuntu:20.04

RUN apt-get update && apt-get install --no-install-recommends -y python3.8-dev \
python3.8-venv python3-pip python3-wheel build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# create and activate virtual environment
RUN python3.8 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Install Poetry
RUN python3 -m pip install pipx && \
python3 -m pipx ensurepath && \
pipx install poetry && \
pipx ensurepath

# Set up environment variables for Poetry
ENV PATH="$PATH:/root/.local/bin"
ENV POETRY_HOME="/root/.poetry"

# export path
ENV PATH="$PATH:/root/.local/share/pipx/venvs/poetry/bin/"

# Install Pandas and Keras in a virtual environment using Poetry
WORKDIR /app

# Copy only the pyproject.toml and poetry.lock files initially to leverage Docker cache
COPY pyproject.toml ./

# upgrade pip
RUN pip install --upgrade pip setuptools wheel

# Install dependencies
#RUN poetry install --no-root -vvv

# Copy the rest of the application code
COPY . .

# append Python module dir to Path
RUN PATH="${PATH}:/app/modules"

# Set the default command to run the application
CMD ["python", "framepool_annotate.py"]
42 changes: 42 additions & 0 deletions framepool_annotate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 8 07:26:34 2023
Script to invoke FramePool annotation provided an input dataframe path
@author: bbowles
"""

import sys
sys.path.append('/app/modules/')
from kipoi_functions import framepool_caller

def main():
# Create an argument parser
parser = argparse.ArgumentParser(description="Annotate an ORFA file with FramePool ribosome load prediction.")

# Add the "--input" argument
parser.add_argument("--input", help="Input, tab-delimited ORFA file.", required=True)

# Parse the command line arguments
args = parser.parse_args()

# Get and print the full path
path = args.input

if path.endswith(".tsv"):

# run FramePool
scored_df = framepool_caller(path)

# save output
outpath = path.replace(".tsv",".framepool.tsv")
scored_df.to_csv(outpath, index=False, sep='\t')
print(f"Saved FramePool-annotated output to {outpath}.")

else:
raise Exception("Input file must end with .tsv!")

if __name__ == "__main__":
main()
Loading

0 comments on commit 8573b4d

Please sign in to comment.