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