comparison smalt/README.md @ 9:81f36745bc9d draft

Uploaded
author triasteran
date Tue, 08 Mar 2022 11:43:08 +0000
parents
children
comparison
equal deleted inserted replaced
8:7e70e7a0f4bb 9:81f36745bc9d
1 Integration of SMALT into Galaxy and Docker
2 ===========================================
3
4 This describes a way to construct a docker image and modify a tool within Galaxy to work with Docker. The tool I use is SMALT from https://toolshed.g2.bx.psu.edu/repository/find_tools?sort=Repository.name&operation=view_or_manage_repository&id=61631a13f8a13237.
5
6 1. Building a Docker Image
7 ==========================
8
9 There are two different methods to construct a docker image for a tool:
10
11 1. Interactively
12 2. Using a `Dockerfile`
13
14 1. Building a Docker Image Interactively
15 ----------------------------------------
16
17 The interactive method of constructing a docker image is a good method for installing all the dependencies for a tool if you're not quite sure exactly what commands you need to run to get the tool working. This method involves starting up a docker container, and running commands within this container to get your tool working. Then, you can **commit** this container to an image and save to dockerhub for re-use.
18
19 ### Step 1: Starting up a Docker base Image
20
21 To build a docker image we need a starting point. The base image we will use is **debian/wheezy** since it contains `apt-get` for installing more software. To start up this image in an interactive mode please run:
22
23 ```bash
24 $ sudo docker run -i -t debian:wheezy
25 ```
26
27 This should bring up a prompt that looks like:
28
29 ```
30 root@2c1077a38bce:/#
31 ```
32
33 Note that the id `2c1077a38bce` can be used later for saving this container to an image.
34
35 ### Step 2: Installing Basic Dependencies
36
37 A few dependencies are required to install SMALT. These can be installed with:
38
39 ```bash
40 $ apt-get update
41 $ apt-get install python
42 $ apt-get install wget
43 $ apt-get install mercurial
44 ```
45
46 ### Step 3: Installing SMALT
47
48 We will install SMALT by downloading the necessary software and copying to `/usr/bin`. This can be accomplished with:
49
50 ```bash
51 $ mkdir tool
52 $ cd tool
53
54 $ wget ftp://ftp.sanger.ac.uk/pub4/resources/software/smalt/smalt-0.7.3.tgz
55 $ tar -xvvzf smalt-0.7.3.tgz
56
57 # because the smalt_wrapper.py finds the binary name based on `uname -i` which is unknown in docker
58 $ mv smalt-0.7.3/smalt_x86_64 smalt_unknown
59
60 $ hg clone https://toolshed.g2.bx.psu.edu/repos/cjav/smalt smalt_deps
61 $ cp smalt_deps/smalt_wrapper.py .
62
63 # add smalt tools to /usr/bin so they're on the PATH
64 $ ln -s /tool/smalt_unknown /usr/bin
65 $ ln -s /tool/smalt_wrapper.py /usr/bin
66
67 # make smalt_wrapper executable
68 $ chmod a+x /tool/smalt_wrapper.py
69 ```
70
71 You can test out SMALT by trying to run `smalt_unknown` and `smalt_wrapper.py` in the docker container.
72
73 ### Step 4: Building an Image
74
75 To build the docker image from the container, please exit the container and run the following:
76
77 ```bash
78 $ sudo docker commit -m "make smalt image" -a "Aaron Petkau" 2c1077a38bce apetkau/smalt-galaxy
79 ```
80
81 Please fill in the appropriate information for your image. In particular, make sure the container id `2c1077a38bce` is correct.
82
83 To push this image to dockerhub you can run:
84
85 ```bash
86 $ sudo docker push apetkau/smalt-galaxy
87 ```
88
89 2. Building an image using a `Dockerfile`
90 -----------------------------------------
91
92 Alternatively, instead of building an image interactively, you can build an image with a `Dockerfile`. An example Dockerfile can be found in this repository at [Dockerfile](Dockerfile). To build an image please run:
93
94 ```bash
95 $ sudo docker build -t apetkau/smalt-galaxy .
96 ```
97
98 More information on Dockerfiles can be found at https://docs.docker.com/reference/builder/.
99
100 2. Installing Tool configuration
101 ================================
102
103 ### Installing Example file
104
105 Once a Docker image has been built, it can be integrated into a tool by modifying the tool configuration XML file. For SMALT, the configuration file is [smalt_wrapper.xml](smalt_wrapper.xml). This is based on https://toolshed.g2.bx.psu.edu/repos/cjav/smalt/file/54855bd8d107/smalt_wrapper.xml. And can be installed by running:
106
107 ```bash
108 $ cp smalt_wrapper.xml galaxy-central/tools/docker/smalt_wrapper.xml
109 ```
110
111 Then, please add this tool to the `tool_conf.xml` by adding:
112
113 ```xml
114 <tool file="docker/smalt_wrapper.xml"/>
115 ```
116
117 ### List of Changes
118
119 The exact changes you I needed to make are:
120
121 1. I added the specific docker image name to the requirements by changing:
122
123 ```xml
124 <requirements>
125 <requirement type="package" version="0.7.3">smalt</requirement>
126 </requirements>
127 ```
128
129 To
130
131 ```xml
132 <requirements>
133 <container type="docker">apetkau/smalt-galaxy</container>
134 </requirements>
135 ```
136
137 2. I had to remove `interpreter` from the command attribute by changing
138
139 ```xml
140 <command interpreter="python">
141 smalt_wrapper.py
142 ```
143
144 To
145
146 ```xml
147 <command>
148 smalt_wrapper.py
149 ```
150
151 3. Running Galaxy
152 =================
153
154 Once the tool is installed, please run Galaxy. And test out the tool. Some example files (reference.fasta and reads.fastq) are included. To make sure it's running in docker you can look for the following `sudo docker run` in the logs:
155
156 ```
157 galaxy.jobs.runners DEBUG 2014-06-28 16:50:00,930 (18) command is: sudo docker run -e "GALAXY_SLOTS=$GALAXY_SLOTS" -v /home/aaron/Projects/galaxy-central:/home/aaron/Proj
158 ects/galaxy-central:ro -v /home/aaron/Projects/galaxy-central/tools/docker:/home/aaron/Projects/galaxy-central/tools/docker:ro -v /home/aaron/Projects/galaxy-central/data
159 base/job_working_directory/000/18:/home/aaron/Projects/galaxy-central/database/job_working_directory/000/18:rw -v /home/aaron/Projects/galaxy-central/database/files:/home
160 /aaron/Projects/galaxy-central/database/files:rw -w /home/aaron/Projects/galaxy-central/database/job_working_directory/000/18 --net none apetkau/smalt:v3 /home/aaron/Proj
161 ects/galaxy-central/database/job_working_directory/000/18/container.sh
162 ```