Using docker for application development

I found Docker super useful, but going through a manual is quite time consuming. Here, very stripped manual to create your first image and push it online 🙂

[bash]
# install docker
wget -qO- https://get.docker.com/ | sh

# add your user to docker group
sudo usermod -aG docker $USER

# check if it’s working
docker run docker/whalesay cowsay "hello world!"

# create an account on https://hub.docker.com
# and login
docker login -u $USER –email=EMAIL

# run image
docker run -it ubuntu

# make some changes ie. create user, install needed software etc

# finally open new terminal & commit changes (SESSIONID=HOSTNAME)
docker commit SESSIONID $USER/image:version

# mount local directory `pwd`/test as /test in read/write mode
docker run -it -v `pwd`/test:/test:rw $USER/image:version some command with arguments

# push image
docker push $USER/image:version
[/bash]

From now, you can get your image from any other machine connected to Internet by executing:
[bash]
docker run -it $USER/image:version
# ie. redundans image
docker run -it -w /root/src/redundans lpryszcz/redundans:v0.11b ./redundans.py -v -i test/{600,5000}_{1,2}.fq.gz -f test/contigs.fa -o test/run1

# you can create alias latest, then version can be skipped on running
docker tag lpryszcz/redundans:v0.11b lpryszcz/redundans:latest
docker push lpryszcz/redundans:latest

docker run -it lpryszcz/redundans
[/bash]

You can add info about your repository at https://hub.docker.com/r/$USER/image/

Advertisements

Conflicting config for htop on machines sharing same /home directory

My friend spotted a problem with htop configuration. Simply when htop was executed on two different Ubuntu distros (10.04 and 14.04) the config was reset.
After some interrogation, we have spotted that 10.04 stores htop config to ~/.htoprc, while 14.04 to ~/.config/htop/htoprc. It was enough to remove one of them and link another one as below:
[bash]
rm .htoprc
ln -s .config/htop/htoprc .htoprc
[/bash]

Easy citation in LibreOffice / OpenOffice with Mendeley

Creating reference list is always a nightmare. Mendeley and its handy LibreOffice / OpenOffice plugin may be of great help to many. It was for me. Below, I’ll describe how to make it working.
[bash]
# get & install mendeley from https://www.mendeley.com/download-mendeley-desktop/

# check version of your mendeley
# Help > About Mendeley Desktop

# clone repo and build plugin
git clone git@github.com:Mendeley/openoffice-plugin.git
cd openoffice-plugin/
python build.py 1.15.2 false

# add to LibreOffice
# Tools > Extension Manager > Add…
# and look for `Mendeley-1.15.2.oxt`
[/bash]

After OpenOffice / LibreOffice restart, you should see new bar. Note, in order for the plugin to work, Mendeley has to be running.

What’s great about this plugin, you can adjust citation style by just a few clicks by clicking on `Choose Citation Style`. There is quite extensive database of predefined citation styles, so adjusting the reference style to your favourite journal will take just a few seconds 🙂
More info about the plugin on github.

Download youtube videos

More weekend oriented tip today;)
I have found downloading videos from youtube super easy with youtube-dl.
[bash]
# install it
sudo apt-get install youtube-dl

# you can fetch many videos at once
youtube-dl LINK1 [LINK2 LINK3]
[/bash]

This tool provide many useful options, like changing the audio/video compression format and quality. You can read more here.

Installing Gene Cluster on Ubuntu

Gene Cluster is a program for clustering. I wanted to use it to analyse gene expression data. However, I had problems during installation under Ubuntu 14.04. This is how I solved it:
[bash]
# install dependencies: Motif libraries
sudo apt-get install libxext-dev libmotif-dev
[/bash]

Get GeneCluster3.0 source code and unpack it.
[bash]
# configure to install in local dir
./configure –prefix=`pwd` –program-prefix=gene_ && make && make install

# add install dir to ~/.bashrc
[/bash]

pysam installation error on Ubuntu 14.04

If you encounter error during pysam installation:
[bash]
sudo easy_install -U pysam

pysam/csamtools.c:8:22: fatal error: pyconfig.h: No such file or directory
#include "pyconfig.h"
^
compilation terminated.
error: Setup script exited with error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
[/bash]

try installing python-dev first.
[bash]
sudo apt-get install python-dev
[/bash]

Solution found on github.

Encrypted swapfile

Sometimes, it’s worth to encrypt swap space, especially if you process some privacy-sensitive data.
[bash]
# install cryptsetup
sudo apt-get install cryptsetup

# generate swap
sudo truncate -s 1GB /cryptswap
sudo mkswap /cryptswap

# add to /etc/crypttab
cryptswap /cryptswap /dev/urandom swap

# add to /etc/fstab
/dev/mapper/cryptswap none swap sw 0 0

# activate encryption and swap
sudo /etc/init.d/cryptdisks reload && sudo swapon -a
[/bash]

Inspired by AskUbuntu.