Tuesday, September 29, 2015

Docker for Bioinformatics and Genetics - Part 3

Docker Tutorial Part 3: Build a docker image which contains Birdsuite for CNV analysis

The installation of Birdsuite is quite tricky. The software package is a mix of Java, Python, R, and Matlab programs. Several programs are already obsoleted and need extra tweaking. Here I created a docker image which has the Birdsuite installed. The procedure to build the image is available at this github repo.
To get a copy of this image, simple by typing
docker pull psytky03/birdsuite
To use it, first create a container and get inside:
docker run -ti psytky03/birdsuite /bin/bash
Run with the test data:
cd /test_data
/birdsuite/birdsuite.sh --basename=test \
--chipType=GenomeWideSNP_6 \
--outputDir=output \
--genderFile=test.gender \
--celFiles=test.cels \
--noLsf \
--apt_probeset_summarize.force
Wait the program to finish ;-)
That is all, if without docker, It will take me probably a whole afternoon to install the package on another linux PC. I need to care and worry about all dependencies and enviroment, now if I have the docker image I can simplily run it everywhere. I think docker is really powerful and clears a big problem for reproducible research.

Additional:
The Dockerfile used to build the image
FROM ubuntu:14.04

MAINTAINER psytky03 <psytky03@gmail.com>

USER root
ENV bs /birdsuite

RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
python \
build-essential \
make \
gcc \
openjdk-6-jre \
r-base-core \
r-base-dev \
python-numpy \ 
python-setuptools \
bc \
libxp6 \
&& apt-get clean \
&& apt-get autoremove 

# Download birdsuite_executable files
RUN mkdir $bs \
&& wget http://www.broadinstitute.org/ftp/pub/mpg/birdsuite/birdsuite_executables_1.5.5.tgz \
&& tar -zxvf birdsuite_executables_1.5.5.tgz -C $bs \
&& rm birdsuite_executables_1.5.5.tgz \
&& rm $bs/birdsuite.sh $bs/run_birdseye.sh


RUN wget https://dl.dropboxusercontent.com/u/964493/additional.tar.gz \
&& tar -zxvf additional.tar.gz \
&& rm additional.tar.gz \
&& mv METADATADIR.tar.gz $bs/ \
&& tar -zxvf $bs/METADATADIR.tar.gz -C $bs \
&& rm $bs/METADATADIR.tar.gz \
&& mv addon/* $bs/ \
&& chmod 755 $bs/MCRInstaller.75.glnxa64.bin \
$bs/apt-probeset-summarize.64 \
$bs/birdsuite.sh \
$bs/run_birdseye.sh \
&& $bs/MCRInstaller.75.glnxa64.bin -P bean421.installLocation="/birdsuite/MCR75_glnxa64" -silent \
&& rm $bs/MCRInstaller.75.glnxa64.bin \
&& mkdir test_data data \
&& tar -zxvf birdsuite_inputs_1.5.5.tgz -C test_data \
&& rm birdsuite_inputs_1.5.5.tgz


# Install Python tools
WORKDIR $bs 

RUN sudo python install.py -e /usr/bin/easy_install 
RUN sudo easy_install birdsuite-1.0-py2.5.egg ; exit 0 
RUN sudo easy_install mpgutils-0.7-py2.5.egg ; exit 0 
RUN sudo ln -s /usr/local/bin/* . \
&& rm *.egg \
&& rm *.py


# Install R packages 
#
RUN wget --no-check-certificate https://cran.r-project.org/src/contrib/mclust_5.0.2.tar.gz \
&& sudo R CMD INSTALL mclust_5.0.2.tar.gz \
&& rm mclust_5.0.2.tar.gz 

RUN tar -xvf broadgap.utils_1.0.tar.gz \
\
# Fix broadgap.utils
&& cd broadgap.utils \
&& rm -r man \
&& cd .. \
&& R CMD build broadgap.utils \
\
# Fix broadgap.cnputils
&& tar -xvf broadgap.cnputils_1.0.tar.gz \
&& cd broadgap.cnputils/ \
&& echo 'exportPattern( "." )' > NAMESPACE \
&& cd .. \
&& R CMD build broadgap.cnputils \
\
# Fix broadgap.canary
&& tar -xvf broadgap.canary_1.0.tar.gz \
&& cd broadgap.canary/ \
&& echo 'exportPattern( "." )' > NAMESPACE \
&& cd .. \
&& R CMD build broadgap.canary \
&& rm -r broadgap.utils broadgap.cnputils broadgap.canary \
&& R CMD INSTALL -l $bs  broadgap.utils_1.0.tar.gz \
&& R CMD INSTALL -l $bs  broadgap.cnputils_1.0.tar.gz \
&& R CMD INSTALL -l $bs  broadgap.canary_1.0.tar.gz \
&& rm -f broadgap.utils_1.0.tar.gz broadgap.cnputils_1.0.tar.gz broadgap.canary_1.0.tar.gz

WORKDIR /

Monday, September 28, 2015

Docker for Bioinformatics and Genetics - Part 2

Docker Tutorial Part 2: Basci Commands and Running Rstudio Server with Docker

1. Basic docker commands

  • docker ps shows curretently running container
  • docker ps -a
    This command will show all containers available in the system. You will see there are quite a number of containers accuumlated. 
psytky03@ubuntu:~$ docker ps -a 
CONTAINER ID        IMAGE                   COMMAND                 
73af7edafa08        psytky03/eigandplink    "plink --file data/to"  
5d37644676f5        psytky03/eigandplink    "plink --file data/to"  
f85336ec937f        psytky03/eigandplink    "eigenstrat"            
0bd8bff7af23        psytky03/eigandplink    "bash"                  
08f6a6f41583        psytky03/eigandplink    "bash"                  
c3e1e1645e1a        psytky03/eigandplink    "plink --help"          
cc592b883668        psytky03/eigandplink    "plink -v"              
f9873e947389        ubuntu                  "bash"                  
43c5be566760        hello-world             "/hello"               
*docker rm CONTAINER_ID to delete unused constainer
psytky03@ubuntu:~$ docker rm 73af7edafa08 
73af7edafa08
  • docker run -rm to automatically delete the container after it exited 
psytky03@ubuntu:~$ docker run -ti --rm psytky03/eigandplink /bin/bash
root@44914cfcfd57:/# exit
exit

#Now let's try to delete this container with id 44914cfcfd57

psytky03@ubuntu:~$ docker rm 44914cfcfd57
Error response from daemon: no such id: 44914cfcfd57
Error: failed to remove containers: [44914cfcfd57]
  • docker images to show all images in the system
psytky03@ubuntu:~$ docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
psytky03/eigandplink   latest              6fd94c3b6e6e        38 hours ago        392.7 MB
ubuntu                 latest              91e54dfb1179        5 weeks ago         188.4 MB
hello-world            latest              af340544ed62        7 weeks ago         960 B
  • docker rmi IMAGE_ID to delete the image. Noticed that if a container is created fromt the image, need to either delete the container or force delete.
psytky03@ubuntu:~$ docker rmi af340544ed62
Error response from daemon: Conflict, cannot delete af340544ed62 because the container 43c5be566760 is using it, use -f to force
Error: failed to remove images: [af340544ed62]


psytky03@ubuntu:~$ docker rm 43c5be566760
43c5be566760

psytky03@ubuntu:~$ docker rmi af340544ed62
Untagged: hello-world:latest
Deleted: af340544ed62de0680f441c71fa1a80cb084678fed42bae393e543faea3a572c
Deleted: 535020c3e8add9d6bb06e5ac15a261e73d9b213d62fb2c14d752b8e189b2b912
  • docker pull to fetch the image from the dockerhub. 

2. Pull Rstudio Server image from DockerHub

The Rstudio server image can be fetched from Dockerhub at this link rocker/rstudio.

Since rocker/rstudio is not avilable in this linux system now, if we use docker run rocker/rstudio, docker will by default look for this image in dockerhub and download it this image can be found. 
Here we use docker pull to fetch it first
docker pull rocker/rstudio
psytky03@ubuntu:~$ docker pull rocker/rstudio
Using default tag: latest
latest: Pulling from rocker/rstudio

acdec9ec413b: Pull complete 
37cbf6c3413f: Pull complete 
7fc523e9982e: Pull complete 
359b980a72ed: Pull complete 
01c4f8f74e82: Pull complete 
46ac2c9f1a72: Pull complete 
2c218622f9d2: Pull complete 
a01f119d835b: Pull complete 
a5688ed074d1: Pull complete 
1e631da06610: Pull complete 
27866ec542bc: Pull complete 
ac88bcc53e01: Pull complete 
061029545a15: Pull complete 
be5e2022c62b: Pull complete 
776ce8e1ace5: Pull complete 
5608458f8ff4: Pull complete 
0948d1536ce1: Pull complete 
88b0e66f47b7: Pull complete 
62c92c006919: Pull complete 
20c2eeb79e8b: Pull complete 
7b226db5341a: Pull complete 
88c331104d7a: Pull complete 
eafb6b5866c1: Pull complete 
e19a7c84d5f1: Pull complete 
Digest: sha256:488f7c427a970b1d11424e8c8a01269e132d41ee1913a6bfadb97c4105fc2719
Status: Downloaded newer image for rocker/rstudio:latest
Confirm it with docker images
psytky03@ubuntu:~$ docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
psytky03/eigandplink   latest              6fd94c3b6e6e        39 hours ago        392.7 MB
rocker/rstudio         latest              e19a7c84d5f1        4 days ago          1.343 GB
ubuntu                 latest              91e54dfb1179        5 weeks ago         188.4 MB

3. Run Rstudio Server

Here we use docker run -d -p 8888:8787 rocker/rstudio to create a container and execute it.
The -d indicate we run it in background mode like a web application.

The -p tells docker how we are going to map port between the host and container. Rstudio Server use 8787 as its default port and here we map it to 8888 in the host. 
psytky03@ubuntu:~$ docker run -d -p 8888:8787 rocker/rstudio
0d1a38402d5ecd68e18276e5e2cd979e21f255e3c2b3525b9388c9a20501fd6e
Have a check of the host Ip address at eth0, my IP is 172.16.118.129
Type the address 172.16.118.129:8888 in the web browser of the Mac and you will see this login window
Rstudio
log in the system
The username and password are both rstudio
Now let's install ggplot2 package
install.packages("ggplot2")
library("ggplot2")
ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
awesome, seems everything is running great.
Now let's stop this container using docker stopcommand, but first we need to get the container ID with docker ps
psytky03@ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             
0d1a38402d5e        rocker/rstudio      "/usr/bin/supervisord"   20 minutes ago      

psytky03@ubuntu:~$ docker stop 0d1a38402d5e
0d1a38402d5e
Start it again
psytky03@ubuntu:~$ docker start 0d1a38402d5e
0d1a38402d5e
Everything is back again. If we want have the ggplot2 library installed in the image file. we need to use the commit command. 
To add the container into the image with docker commit command
psytky03@ubuntu:~$ docker commit -m "add ggplot2" 0d1a38402d5e rocker/rstudio
28024380329aa1f8fa23499fce8ea3f56233d19eb48a711111584cd4ecff7285
It is also possible to show all the intermediate layer information of this image. Similar to snapshot of virtual machine, we can run container from any state by telling docker the image ID. 
psytky03@ubuntu:~$  docker history rocker/rstudio
IMAGE               CREATED             CREATED BY                                    
28024380329a        2 minutes ago       /usr/bin/supervisord -c /etc/supervisor/conf. 
e19a7c84d5f1        4 days ago          /bin/sh -c #(nop) CMD ["/usr/bin/supervisord" 
eafb6b5866c1        4 days ago          /bin/sh -c #(nop) EXPOSE 8787/tcp             
88c331104d7a        4 days ago          /bin/sh -c mkdir -p /var/log/supervisor   &&  
7b226db5341a        4 days ago          /bin/sh -c #(nop) COPY file:8294dfdc8c50662db 
20c2eeb79e8b        4 days ago          /bin/sh -c #(nop) COPY file:df4e748b71577b0ec 
62c92c006919        4 days ago          /bin/sh -c #(nop) COPY file:674055700f4c6fbee 
88b0e66f47b7        4 days ago          /bin/sh -c usermod -l rstudio docker   && use 
0948d1536ce1        4 days ago          /bin/sh -c echo '\n\n# Configure httr to perf 
5608458f8ff4        4 days ago          /bin/sh -c rm -rf /var/lib/apt/lists/   && ap 
776ce8e1ace5        4 days ago          /bin/sh -c #(nop) ENV LANG=en_US.UTF-8        
be5e2022c62b        4 days ago          /bin/sh -c #(nop) ENV PATH=/usr/lib/rstudio-s 
061029545a15        4 days ago          /bin/sh -c #(nop) MAINTAINER "Carl Boettiger  
ac88bcc53e01        2 weeks ago         /bin/sh -c #(nop) CMD ["R"]                   
27866ec542bc        2 weeks ago         /bin/sh -c apt-get update                          
1e631da06610        2 weeks ago         /bin/sh -c #(nop) ENV R_BASE_VERSION=3.2.2    
a5688ed074d1        2 weeks ago         /bin/sh -c echo "deb http://http.debian.net/d 
a01f119d835b        2 weeks ago         /bin/sh -c #(nop) ENV LANG=en_US.UTF-8        
2c218622f9d2        2 weeks ago         /bin/sh -c #(nop) ENV LC_ALL=en_US.UTF-8      
46ac2c9f1a72        2 weeks ago         /bin/sh -c echo "en_US.UTF-8 UTF-8" >> /etc/l 
01c4f8f74e82        2 weeks ago         /bin/sh -c apt-get update                          
359b980a72ed        2 weeks ago         /bin/sh -c useradd docker                          
7fc523e9982e        2 weeks ago         /bin/sh -c #(nop) MAINTAINER "Carl Boettiger  
37cbf6c3413f        2 weeks ago         /bin/sh -c #(nop) CMD ["/bin/bash"]           
acdec9ec413b        2 weeks ago         /bin/sh -c #(nop) ADD file:9101a1e6d928e77435     

Saturday, September 26, 2015

Docker for Bioinformatics and Genetics - Part 1

Docker Tutorial 1: Palying with Docker to deploy genetics software

This is a tutorial of using docker to set up bioinforamatics and genetics analysis tools. 

1. First let's install the docker

The installation procedures can be found in Docker's offical userguide for Ubuntu
I am running the Ubuntu 14.04.03 LTS server version in VMware Fusion Pro. First confirm the Linux Kernel version with uname -r and my return is 3.19.0-25-generic. Which will be fine since the prerequirement is version higher than 3.10
The curl is preinstalled in the system, otherwise use 
sudo apt-get install curl
 to get one. 
The installation of Docker is done in one step
curl -sSL https://get.docker.com/ | sh
Verify the installation from the log message
...
cgroup-lite start/running
Setting up docker-engine (1.8.2-0~trusty) ...
docker start/running, process 3512
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for ureadahead (0.100.0-16) ...
+ sudo -E sh -c docker version
Client:
 Version:      1.8.2
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   0a8c2e3
 Built:        Thu Sep 10 19:19:00 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.2
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   0a8c2e3
 Built:        Thu Sep 10 19:19:00 UTC 2015
 OS/Arch:      linux/amd64

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker psytky03

Remember that you will have to log out and back in for this to take effect!
Create a user groud named docker and add the user to this group.
sudo usermod -aG docker psytky03
Logout and back again.
Run a HelloWorld test image
docker run hello-world
Here is the output 
Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/
docker run -it ubuntu bash

2. Sign up a DockerHub account

Dockerhub is similar to the concept of github for pushing and pulling docker images
https://hub.docker.com/login/
Here I got a username as "psytky03"

3. Make the first Dockerfile

Dockerfile is the blueprint to tell docker how to create an image. It contains the basic information such as which platform the image is based on, a full collection of the commands for installation of the software, the system path et.c 
Here I am going to install two tools: the latest Eigensoft ver 6.01 for pricinple component analysis (PCA) and Plink ver 1.9. 
The contents of this dockerfile looks like this
FROM ubuntu

MAINTAINER Psytky03
RUN sudo apt-get update
RUN sudo apt-get -y install wget git unzip
RUN sudo apt-get -y install libgsl0ldbl gfortran-4.4
RUN git clone https://github.com/DReichLab/EIG.git

RUN sudo apt-get -y install wget unzip python
RUN wget https://www.cog-genomics.org/static/bin/plink150903/plink_linux_x86_64.zip
RUN unzip plink_linux_x86_64.zip -d plinkbin


ENV PATH $PATH:/EIG/bin:/plinkbin
RUN mkdir data

4. Build the Docker image

mkdir my_first_docker_image
cd my_first_docker_image/

nano Dockerfile   
#Copy and Paste contents list in section 3

docker build -t psytky03/eigandplink .
It will take for a while, finally the log report shows the image is built without error
Successfully built 87f7aefa7968
Check the built image with docker images command
docker images 
------------------------------------------------------------------------------------------
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
psytky03/eigandplink   latest              6fd94c3b6e6e        3 minutes ago       392.7 MB
ubuntu                 latest              91e54dfb1179        5 weeks ago         188.4 MB
hello-world            latest              af340544ed62        7 weeks ago         960 B
The size of this image is 392 MB
Verify the Eigensoft and Plink
docker run psytky03/eigandplink plink --help
docker run psytky03/eigandplink eigenstrat

# To get into the image file
docker run -it psytky03/eigandplink bash

# To check all docker image/container info
docker ps -a
Run Plink with data in the host machine
#First let's grab some test files shipped with Plink

wget https://www.cog-genomics.org/static/bin/plink150903/plink_linux_x86_64.zip
unzip plink_linux_x86_64.zip -d plink1.9
Now we use docker run -v to bridge the folder in the host machine to the data folder in the container:
docker run -v /home/psytky03/plink1.9:/data psytky03/eigandplink \
plink --file data/toy --make-bed --out data/test 
Check the plink1.9 folder and you should be able to see the test.bed test.bim test.fam files. 

5. Push the image to DockerHub

docker login
#Login Succeeded

docker push psytky03/eigandplink

6. Pull back the image at another Linux machine

docker pull psytky03/eigandplink

Where to Sell English Book In Japan

Some while ago I finally decided to sell some of textbook/non-ficition/technical books to save space for my tiny apartment.

The books are mostly English and I am not sure whether the local Japanese secondhand bookstore will accept them or not. I first visited a nearby BookOff - a popular secondhand dealer in Japan specializing in book, CD, movie, and game software. I was immediately turned down and the staff told me only the large store in Ikebukuro can accept those non-Japanese books. Since I was almost near the station and I make my way to Ikebukuro, this store did accept those books but only offer tiny amount of money for each book (10 - 500 JPY) which is ridiculous.

At this situation, I searched whether I can sell them online and eventually put all my book in Amazon.co.jp. The whole process is super easy and another good thing is I can set the price. After 3 months, I finally sold more than half of my books and got nearly 30K.

Thursday, September 17, 2015

Installation of Gbrowse Syn on CentOS 6.6 for Human Mouse synteny mapping

Instsllation of Gbrowse-Syn on a CentOS system

Last updated: 2015-09-16

Prerequisite

  • A Physical/Virtual machine running on CentOS release 6.6
#To confirm the version of CentOS 
cat /etc/*release*
  • Internet connection

Referenes

  1. http://gmod.org/wiki/GBrowse2.0HOWTO
  2. http://gmod.org/wiki/GBrowsesynTutorial2013#InstallingGBrowse_syn
  3. http://nix-bio.blogspot.jp/2013/10/installing-gbrowse2-on-centos-6-and-mac.html
  4. http://gmod.org/wiki/GBrowseNGSTutorial

Installation

0. add user to sudoers

su
visudo

...
# Allow root to run any commands anywhere

#(add this line)
username ALL=(ALL) ALL

exit
1. Apache
sudo yum -y install httpd httpd-devel
save a copy of original configuation file
sudo cp -i /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.org
sudo cp -i /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org

sudo /etc/init.d/httpd start
check the ip address of the machine and try access at the 80 port
ifconfig
Additional tweak if a static IP is disrired
## Configure eth0
# add the static IP

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

# change 
BOOTPROTO="dhcp"
# to
BOOTPROTO="static"


# add following lines
IPADDR=192.168.1.2
NETMASK=255.255.255.0
Configure Default Gateway
sudo nano /etc/sysconfig/network

# replace or add following lines
NETWORKING=yes
HOSTNAME=CentOS_6.6
GATEWAY=192.168.1.1
Restart Network
/etc/init.d/network restart
2. MySQL
sudo yum -y install mysql mysql-server
Start MySQL
sudo /etc/init.d/mysqld start
Setup the root password and other stuff
mysql_secure_installation

#memo the root password 
Log message
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
Enable MySQL and Apache service to run at bootup
sudo chkconfig --levels 235 mysqld on
sudo chkconfig --levels 235 httpd on
3. PHP
sudo yum -y install php
sudo yum -y install php-mbstring
sudo yum -y install php-mysql
sudo yum -y install php-devel
Additional: PhPMyAdmin
sudo rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
sudo yum -y install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
sudo yum -y install phpmyadmin
Edit the configuation file
sudo nano /etc/httpd/conf.d/phpmyadmin.conf
change the following lines
#Deny from all
#Allow from 127.0.0.1
Allow from 0.0.0.0
Add secret passphrease
sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
sudo chmod 660 /usr/share/phpmyadmin/config.inc.php

sudo yum -y install expect
mkpasswd -l 20

--> Example: Scxjbwdbrftbx83[bHhq

sudo vi /usr/share/phpmyadmin/config.inc.php
$cfg['blowfish_secret'] = 'Scxjbwdbrftbx83[bHhq'; 
$cfg['Servers'][$i]['auth_type']     = 'cookie'; 

/*
 * End of servers configuration
 */
Restart Apache
sudo /etc/init.d/httpd restart
Confirm the installation
http://localhost/phpmyadmin/
4. Install neccessary Perl modules
sudo yum -y install make gcc gmp-devel wget git 

##mod_fcgid fcgi-perl (Need to be installed later for fastCGI)

sudo yum -y install perl-GD 
sudo yum -y install perl-Module-Build
sudo yum -y install perl-CPAN 
sudo yum -y install perl-IO-String perl-Capture-Tiny perl-CGI-Session             
sudo yum -y install perl-JSON perl-JSON-Any 
sudo yum -y install perl-libwww-perl perl-DBD-SQLite 
sudo yum -y install perl-File-NFSLock perl-Net-SMTP-SSL             
sudo yum -y install perl-Crypt-SSLeay perl-Net-SSLeay perl-Template-Toolkit
Final Installation
sudo yum -y install inkscape
sudo yum -y install perl-YAML
git clone https://github.com/bioperl/bioperl-live.git
cd bioperl-live
git checkout bioperl-release-1-6-901
perl Build.PL 
./Build test
sudo ./Build install
sudo perl -MCPAN -e 'install Bio::Graphics::Browser2'
Configuation step
Directory for GBrowse's config and support files? [/etc/gbrowse2]
Directory for GBrowse's static images & HTML files? [/var/www/html/gbrowse2]
Directory for GBrowse's temporary data [/var/tmp/gbrowse2]
Directory for GBrowse's sessions, uploaded tracks and other persistent data [/var/lib/gbrowse2]
Directory for GBrowse's example databases [/var/lib/gbrowse2/databases]
Directory for GBrowse's CGI script executables? [/var/www/cgi-bin] -->> [/var/www/cgi-bin/gb2]
Internet port to run demo web site on (for demo)? [8000]
Apache loadable module directory (for demo)? [/etc/modules] --> [/etc/httpd/modules]
User account under which Apache daemon runs? [apache]
Automatically update Apache config files to run GBrowse? [y]
        
5. check the Demo
http://localhost/gbrowse2/
Repair the permission
sudo chown -R *user_name* /var/lib/gbrowse2/databases
sudo chown -R *user_name* /etc/gbrowse2

cd /var/www/html/gbrowse2/tutorial/data_files
cp tutorial/data_files/volvox_remarks.gff3 /var/lib/gbrowse2/databases/volvox
6. Install GBrowse_syn
cd ..
git clone https://github.com/GMOD/GBrowse.git
cd GBrowse/
perl Build.PL
./Build test
./Build install  
Confirm the installation
http://localhost/cgi-bin/gb2/gbrowse_syn
7. Prepare the Human-Mouse pairwise alignment data
This directory contains alignments of the following assemblies:
- target/reference: Human (hg19, Feb. 2009 (GRCh37/hg19), GRCh37 Genome Reference Consortium Human Reference 37 (GCA_000001405.1))
- query: Mouse (mm10, Dec. 2011 (GRCm38/mm10), Genome Reference Consortium Mouse Build 38 (GCA_000001635.2))
  
http://hgdownload.cse.ucsc.edu/goldenPath/hg19/vsMm10/axtNet/
use rsync to fetch a copy
mkdir hg19vsMm10_alignment
cd hg19vsMm10_alignment
rsync -a -P rsync://hgdownload.cse.ucsc.edu/goldenPath/hg19/vsMm10/axtNet/* ./


cd .. 
8. Convert the format
The AxtNet format looks like as below
1 chrY 150918 150993 chr5 110101042 110101117 + 4971
GACTGGATGTCGGCACTGTGTCCCCGGCTCTGGGATGTGCCCCTCCACCACCTCTCCATCCCAGGTGAGGTTGGGG
GACTGGATGTCGCAGCTGTGCCCTCAGCTGTGGGATGTCCCCCTGCACCACCTGTCCATCCCAGGTGAGTACGGGG
The desired format that can be handled by load_alignment_database.pl is
#species1       seqid1  start1   end1   strand1  reserved  species2      seqid2        start2   end2  strand2 reserved pos1-1  pos1-2  ...  posn-1  posn-2  |  pos1-2  pos1-1  ...  posn-2  posn-1
c_briggsae      chrI    1583997 1590364 +       .       c_remanei       Crem_Contig24   631879  634679  -       .       1584000 634676  1584100 634584  (truncated...)  |     631900  1590333 632000  1590233  (truncated ...)
9. The GFF3 annotation file for Hg19 and Mm10
Basic information about the annotation
Human GFF3: Release 19 (GRCh37.p13)
http://www.gencodegenes.org/releases/19.html

Mouse GFF3: Release M6 (GRCm38.p4)
http://www.gencodegenes.org/mouse_releases/current.html
Fetch the data
mkdir GFF3
cd GFF3
wget ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_19/gencode.v19.annotation.gff3.gz -O hg19.gff3.gz
wget ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_mouse/release_M6/gencode.vM6.annotation.gff3.gz  -O mm10.gff3.gz

gunzip hg19.gff3.gz
gunzip mm10.gff3.gz
10. Load to the MySQL database
mysql -uroot -p
Create database
create database hg19;
create database mm10;
create database hg19mm10synteny;
quit;
Parse and upload to the MySQL database
bp_seqfeature_load.pl -u root -p ****** -d hg19 -c -f hg19.gff3
bp_seqfeature_load.pl -u root -p ****** -d mm10 -c -f mm10.gff3
Part of the log output
loading hg19.gff3...
Building object tree...62.91s02.94s                                                                                                          
Loading bulk data into database.../tmp/feature.44907
/tmp/name.44907
/tmp/attribute.44907
/tmp/parent2child.44907
338.07s
load time: 2003.95s
Building summary statistics for coverage graphs...
2612000 features processed
coverage graph build time: 723.74s
total load time: 2727.69s

----------------------------------------------------------------------
loading mm9.gff3...
Building object tree...24.78s2.97s                                                                                                          
Loading bulk data into database.../tmp/feature.45166
/tmp/name.45166
/tmp/attribute.45166
/tmp/parent2child.45166
206.92s
load time: 1124.70s
Building summary statistics for coverage graphs...
1537000 features processed
coverage graph build time: 469.13s
total load time: 1593.83s
Prepare hg19.conf
[GENERAL]
description   = Home sapiens
db_adaptor    = Bio::DB::SeqFeature::Store
db_args       = -dsn dbi:mysql:hg19

tmpimages   = /tmp/gbrowse2

[CG]
label        = 1
description  = 1
feature      = mRNA
category     = Genes
glyph        = processed_transcript
font2color   = blue
height       = 6
key          = Gene Models
bgcolor      = sub {
  my $flip = pop->panel->flip;
  my $strand = shift->strand;
  return $strand < 0 ? 'violet' : 'turquoise' if $flip;
  return $strand > 0 ? 'violet' : 'turquoise';
 }

# draw genes differently for segments > 100Kb
[CG:100001]
label        = 0
description  = 0
glyph        = generic
strand_arrow = 1
Prepare mm10.conf
[GENERAL]
description   =  Mus musculus
db_adaptor    = Bio::DB::SeqFeature::Store
db_args       = -dsn dbi:mysql:mm10

tmpimages   = /tmp/gbrowse2

[CG]
label        = 1
description  = 1
feature      = mRNA
category     = Genes
glyph        = processed_transcript
font2color   = blue
height       = 6
key          = Gene Models
bgcolor      = sub {
  my $flip = pop->panel->flip;
  my $strand = shift->strand;
  return $strand < 0 ? 'violet' : 'turquoise' if $flip;
  return $strand > 0 ? 'violet' : 'turquoise';
 }

# draw genes differently for segments > 100Kb
[CG:100001]
label        = 0
description  = 0
glyph        = generic
strand_arrow = 1
Prepare the alignment configuation file hg19mm10aln.synconf
[GENERAL]
description =  Hg19 - Mm10 Synteny mapping 

# The synteny database
join        = dbi:mysql:hg19mm10synteny

#                 symbolic src   config file (".conf")    Description
source_map =      hg19              hg19                      "Homo Sapine" 
                  mm10              mm10                      "Mus musculus"
          

# web site configuration info
tmpimages     = /tmp/gbrowse2 
imagewidth    = 800
stylesheet    = /gbrowse2/css/gbrowse_transparent.css


# The extension of species config files
# can also use .syn (the default)
config_extension = conf

# sparse data, use all coordinates
grid coordinates  = exact

# example searches to display
examples = hg19 chrX:402000..426999
           mm10 chrX:255000..275000

zoom levels = 5000 10000 25000 50000 100000 200000 400000 1000000

# species-specific databases
[hg19]
tracks    = CG 
color     = green

[mm10]
tracks    = CG
color     = blue
make a test alignment file: testaln.txt
hg19    chrX    70345   70614   +   .   mm10    chr8    35873813    35874094    -   .
Drop to the hg19mm10synteny database
gbrowse_syn_load_alignment_database.pl -u root -p ******* -d hg19mm10synteny -c -v testaln.txt

nano hg19.conf
nano mm10.conf
nano hg19mm10aln.synconf

sudo cp *conf /etc/gbrowse2/synteny
sudo mkdir /var/www/html/tmp/
sudo mkdir /var/www/html/tmp/gbrowse2
sudo chmod 777 /var/www/html/tmp/gbrowse2
 
 
mysql -uroot -p 

CREATE USER 'liuxiaoxi'@'localhost' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'liuxiaoxi'@'localhost'
quit;


/var/www/html/gbrowse2/tutorial/data_files