Skip to content

MHCnuggets container with Jupyter Notebook interface

aellini edited this page Nov 7, 2019 · 1 revision
  1. Create a new and empty directory on your workstation, and change into that directory. From inside of the empty directory clone the repository to your workstation:

git clone https://github.com/KarchinLab/mhcnuggets

  1. Create file called Dockerfile, and contents of the file should be:
FROM python:3

COPY mhcnuggets mhcnuggets

WORKDIR mhcnuggets

RUN python3 setup.py sdist bdist_wheel

RUN pip install dist/mhcnuggets-2.3.2.tar.gz

RUN pip install jupyter

WORKDIR /mhcnuggets/mhcnuggets

CMD jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root
  1. Run the following command from within the same directory as the Dockerfile to build the docker image:

sudo docker build -t mhcnuggets_jupyter .

  1. Create a file called docker-compose.yml, with the following contents:
version: '3'
services: 
  mhcnuggets:
    image: mhcnuggets_jupyter
    container_name: mhcnuggets_jupyter
    ports:
        - "8888:8888"
  1. While still in the same directory that docker-compose.yml resides in, run the following command to start the docker container:

sudo docker-compose up

  1. After a minute or so, you should see log files outputting to your terminal, there will be a link with a unique token in the logs similar to this:

http://127.0.0.1:8888/?token=examplecharacters

  1. Copy the link seen in your logs (with the unique token included) and enter it into your browser. You should now see Jupyter notebook with mhcnuggets already installed. You are now able to upload files, and run predict and train modules.

For example, from the Jupyter Notebook home screen, you can click "New" > "Python 3", enter the following code and click "Run":

from mhcnuggets.src.predict import predict

predict(class_='I', peptides_path='data/test/test_peptides.peps', mhc='HLA-A02:01')