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/

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]

Connecting to MySQL without passwd prompt

If you are (like me) annoyed by providing password at every mysql login, you can skip it. Also it makes easier programmatic access to any MySQL db, as not passwd prompting is necessary 🙂
Create `~/.my.cnf` file:

[bash]
[client]
user=username
password="pass"

[mysql]
user=username
password="pass"
[/bash]

And login without `-p` parameter:
[bash]
mysql -h host -u username dbname
[/bash]

If you want to use `~/.my.cnf` file in MySQLdb, just connect using this:
[python]
import MySQLdb
cnx = MySQLdb.connect(host=host, port=port, read_default_file="~/.my.cnf")
[/python]

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]