Skip to content

Commit d32f178

Browse files
committed
add Singularity container
1 parent e24d53c commit d32f178

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ ENV/
9090
IGV_Snapshots*
9191
bin*
9292
test.py
93+
target.bed

README.md

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# IGV Snapshot Automator
2-
A script to automatically create and run [IGV snapshot batchscripts](http://software.broadinstitute.org/software/igv/batch). This script will first write an IGV batch script for the supplied input files, then load all supplied files for visualization (.bam, etc) in a headless IGV session and take snapshots at the locations defined in the `regions.bed` file.
2+
A script to automatically create and run [IGV snapshot batchscripts](http://software.broadinstitute.org/software/igv/batch). This script will first write an IGV batch script for the supplied input files, then load all supplied files for visualization (.bam, etc) in a headless IGV session and take snapshots at the locations defined in the `regions.bed` file.
33

4-
Designed for use on Linux systems, and intended to be used as a component of sequencing analysis pipelines.
4+
Designed for use on Linux systems, and intended to be used as a component of sequencing analysis pipelines.
55

66
# Usage
77

@@ -54,11 +54,11 @@ $ python make_IGV_snapshots.py /path/to/alignments1.bam /path/to/alignments2.bam
5454
- `-g`: Genome to use, e.g. `hg19`
5555
- `-ht`: Height of the snapshot, default is 500
5656
- `-o`: Name of the output directory to save the snapshots in.
57-
- `-bin`: Path to the IGV jar binary to run
57+
- `-bin`: Path to the IGV jar binary to run
5858
- `-mem`: Memory to allocate to IGV (MB)
5959
- `-suffix`: Filename suffix to place before '.png' in the snapshots
6060
- `-onlysnap`: Skip batchscript creation and only run IGV using the supplied batchscript file
61-
- `-nf4`: "Name field 4" mode, uses values saved in 4th field of the `regions.bed` file as the output filename of the PNG snapshot. Use this when you have pre-made filenames you wish to use for each snapshot.
61+
- `-nf4`: "Name field 4" mode, uses values saved in 4th field of the `regions.bed` file as the output filename of the PNG snapshot. Use this when you have pre-made filenames you wish to use for each snapshot.
6262
- `-s` or `-group_by_strand`: Group alignment(s) by read strand with forward on top and reverse on the bottom.
6363

6464

@@ -69,9 +69,23 @@ $ python make_IGV_snapshots.py /path/to/alignments1.bam /path/to/alignments2.bam
6969

7070
# Notes
7171

72-
Default memory allotment is set at 4GB; this can be changed with the `-mem` argument (e.g. `-mem 1000` sets memory to 1GB).
72+
Default memory allotment is set at 4GB; this can be changed with the `-mem` argument (e.g. `-mem 1000` sets memory to 1GB).
7373

74-
IGV may take several minutes to run, depending on the number of input files and regions to snapshot. Stdout messages from the program may not appear immediately in the console.
74+
IGV may take several minutes to run, depending on the number of input files and regions to snapshot. Stdout messages from the program may not appear immediately in the console.
75+
76+
# Singularity Container
77+
78+
An example Singularity container recipe file to run the IGV Snapshot Automator script is included (`Singularity`). If you have Singularity installed, it can be built with a command such as:
79+
80+
```
81+
sudo singularity build IGV.simg Singularity
82+
```
83+
84+
If you do not have root access or do not have Singularity installed on your system, you can refer to the repo [here](https://github.com/NYU-Molecular-Pathology/containers) for some examples of how to build Singularity containers using Vagrant or Docker.
85+
86+
An example wrapper script that can be used to launch the Singularity container and run the IGV Snapshot Automator can be found in `run.Singularity.sh`. You should update this with the commands you wish to use and make necessary changes to it in order to run on your system.
87+
88+
Tested with Singularity 2.4 and 2.5.2.
7589

7690
# Software Requirements
7791
- Python 2.7 or 3+

Singularity

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BootStrap: docker
2+
From: ubuntu:16.04
3+
4+
%post
5+
apt-get update && \
6+
apt-get install -y wget \
7+
unzip \
8+
default-jdk \
9+
xvfb \
10+
xorg \
11+
python
12+
13+
wget http://data.broadinstitute.org/igv/projects/downloads/2.4/IGV_2.4.10.zip && \
14+
unzip IGV_2.4.10.zip && \
15+
rm -f unzip IGV_2.4.10.zip
16+
17+
export PATH="/IGV_2.4.10/:${PATH}"
18+
19+
# make a dummy batch script in order to load the hg19 genome into the container
20+
# https://software.broadinstitute.org/software/igv/PortCommands
21+
printf 'new\ngenome hg19\nexit\n' > /genome.bat
22+
xvfb-run --auto-servernum --server-num=1 igv.sh -b /genome.bat
23+
24+
%test
25+
which igv.sh
26+
27+
%environment
28+
export PATH="/IGV_2.4.10/:${PATH}"

run.Singularity.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# example wrapper script to launch the snapshot script inside a Singularity container (needed if xvfb is not installed)
4+
5+
# default path to Singularity container file
6+
container="${1:-IGV.simg}"
7+
8+
# need to load Singularity if running on Big Purple HPC
9+
if [ "$(hostname | grep -q 'bigpurple' ; echo $?)" -eq 0 ]; then
10+
module load singularity/2.5.2
11+
12+
# command to launch Singularity container and run commands inside the container
13+
# NOTE: you may need to make sure that the directory filesystem root and the current dir are bound to the container with `-B`
14+
singularity exec \
15+
-B /gpfs \
16+
-B "${PWD}" \
17+
"${container}" \
18+
/bin/bash -c " \
19+
cd ${PWD}
20+
python make_IGV_snapshots.py test_data/test_alignments.bam test_data/test_alignments2.bam
21+
"
22+
fi

0 commit comments

Comments
 (0)