生物信息学与算法NCBI&Ensembl&UCSC&EBI&Genecode生信情报站

本地安装UCSC基因组浏览器

2019-02-25  本文已影响66人  生信宝典

UCSC基因组浏览器在大规模高通量数据的可视化和比较分析研究中发挥着重要的作用。拥有了本地浏览器,就可以对自己的测序数据进行更深入的分析和共享使用。本文详细介绍了如何一步步在本地安装、配置、高级使用UCSC浏览器。

安装UCSC浏览器

1. 安装mysql+apache

#For Ubuntu usersudo 
apt-get install taskselsudo apt-get install lamp-server

#For readhat or centos user
yum install httpd mariadb-server mariadb

2. 新建mysql用户

# 用户名:gw
# 密码  :qazplm_gw
create user 'gw'@'localhost' identified by 'qazplm_gw';

3. 同步UCSC所需html文件和运行程序

# 设置UCSC的安装目录为 /var/www/gw
mkdir /var/www/gw

# 同步相应的html文件
rsync -avzP --exclude 'ENCODE' rsync://hgdownload.cse.ucsc.edu/htdocs/ /var/www/gw

# 同步可执行程序到cgi-bin目录下mkdir /var/www/gw/cgi-bin

# For 64-bit
rsync -avzP rsync://hgdownload.cse.ucsc.edu/cgi-bin/ /var/www/gw/cgi-bin/  #64 bit

# 更改cgi-bin目录的所有者
chown -R www-data.www-data /var/www/gw/cgi-bin/

4. 把以下内容写入/etc/apahce2/httpd.conf

# XBitHack on 是必须的
# 其它参数的意思参见apache文档
XBitHack on
<Directory /var/www/gw>   
    AllowOverride AuthConfig
    Options +Includes
</Directory>

 # the ScriptAlias directive is crucial

ScriptAlias /gw/cgi-bin /var/www/gw/cgi-bin
<Directory "/var/www/gw/cgi-bin">

    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

    Order allow,deny
    Allow from all
    AddHandler cgi-script cgi pl

</Directory>

5. 设置Apache解析有执行权限的文件中的SSI指令,然后重启apache

ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled//etc/init.d/apache2 restart

6. 设置数据库配置文件

进入/var/www/gw/cgi-bin/目录,建立hg.conf文件并写入下列内容

db.host=localhost
db.user=gw
db.password=qazplm_gw
db.trackDb=trackDb

central.db=hgcentral
central.host=localhost
central.user=gw
central.password=qazplm_gw
central.domain=

backupcentral.db=hgcentral
backupcentral.host=localhost
backupcentral.user=gw
backupcentral.password=qazplm_gw
backupcentral.domain=

同时运行如下命令sudo chown www-data /var/www/gw/cgi-bin/hg.conf更改文件的所有权。

更多功能的conf文件见http://genome-test.cse.ucsc.edu/~kent/src/unzipped/product/ex.hg.conf.

7. 建立缓存文件夹

rm /var/www/gw/trash
mkdir /var/www/gw/trash
chown www-data.www-data /var/www/gw/trash

8. 提供Javascript文件

mkdir -p /usr/local/apache/htdocs/ln -s /var/www/gw/js/ /usr/local/apache/htdocs/jsln -s /var/www/gw/style/ /usr/local/apache/htdocs/style
# 每次重启服务器后,可能要重复上述操作。

9. 这时就应该能够访问了,成功的标志就是访问http://localhost/gw会看到UCSC常见的页面。


加载UCSC浏览器所需数据库内容

1. 安装hgcentral数据库内容

wget http://hgdownload.cse.ucsc.edu/admin/hgcentral.sql
mysql -uroot -proot_passwd -e 'create database hgcentral'
mysql -uroot -proot_passwd -e 'grant all privileges on hgcentral.* to 'gw'@'localhost''
# 加载下载的hgcentral数据库
mysql -ugw -p qazplm_gw hgcentral <hgcentral.sql
mysql -uroot -proot_passwd -e 'create database hgFixed'
mysql -uroot -proot_passwd -e 'grant select on hgFixed.* to 'gw'@'localhost'
#如果不存在就安装,如果存在就直接建立软连接
sudo apt-get install libssl0.9.8
# Use `locate libssl.so.0.9.8` to find the path of this file. 

# For 32 bit  
sudo ln -s /lib/i386-linux-gnu/libssl.so.0.9.8 /usr/lib/libssl.so.6  
sudo ln -s /lib/i386-linux-gnu/libcrypto.so.0.9.8 /usr/lib/libcrypto.so.

2. 获取相关物种信息数据库

# 鉴于物种信息数据库比较大,可以在数据盘新建目录用于存储
#change datadir to /home/mysql
/etc/init.d/mysql stop
vim /etc/mysql/my.cnf

#下载数据库
rsync -avzP  rsync://hgdownload.cse.ucsc.edu/mysql/mm9/chromInfo.MYD /home/mysql/mm9rsync -avzP 
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/chromInfo.MYI /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/chromInfo.frm /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/cytoBandIdeo.MYD /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/cytoBandIdeo.MYI /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/cytoBandIdeo.frm /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/grp.MYD /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/grp.MYI /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/grp.frm /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/hgFindSpec.MYD /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/hgFindSpec.MYI /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/hgFindSpec.frm /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/trackDb.MYD /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/trackDb.MYI /home/mysql/mm9rsync -avzP  
rsync://hgdownload.cse.ucsc.edu/mysql/mm9/trackDb.frm /home/mysql/mm9
##赋予权限
chown -R mysql.mysql /home/mysql/mm9

3. 下载gbdb数据

#bbi 为encode数据
mkdir -p /home/user/gbdb/mm9
rsync -avzP --delete --max-delete=20 --exclude=bbi \    
rsync://hgdownload.cse.ucsc.edu/gbdb/mm9/ ~/gbdb/mm9/
#---mappability data---------------rsync -avzp 
rsync://hgdownload.cse.ucsc.edu/gbdb/mm9/bbi/*.bw ~/gbdb/mm9/bbi
ln -s /home/user/gbdb /gbdb

4. 访问链接http://localhost/gw/cgi-bin/hgGateway?db=mm9

UCSC Track Hub使用

UCSC Track Hub可以方便加载多组高通量分析结果文件,并且可以使用Track overlay, 即不同的Track叠加到一起显示,方便比较。具体见测序数据可视化 (三) - UCSC genomebrowser

1. 构建UCSC hub track


#首先看目录结构
/var/www/hub$ tree
.
├── genomes.txt
├── hub.txt
└── mm9
    ├── ctcf1.bw
    ├── P3001.bw
    ├── ctcf2.bw
    ├── P3002.bw
    └── trackDb.txt

#再看每个文件的内容
$cat genomes.txt
genome    mm9
trackDb    mm9/trackDb.txt

$cat hub.txt
hub    myhub
shortLabel    Testhub
longLabel    Testhubsdsdsdsd
genomesFile    genomes.txt
email    my@my.com

$cat mm9/trackDb.txt
# access http://localhost/cgi-bin/hgTracks?db=mm9&amp;hubUrl=https://localhost/hub.txt
# help : http://genome.ucsc.edu/goldenPath/help/hgTrackHubHelp.html
# trackDb.txt syntax http://genome.ucsc.edu/goldenPath/help/trackDb/trackDbHub.html#bigBed_-_Item_or_Region_Track_Settings
#http://davetang.org/muse/2012/03/15/ucsc-genome-browser-custom-overlap-tracks/
track One
container multiWig
shortLabel One
longLabel One
type bigWig
#viewLimits 0:160
visibility full
aggregate transparentOverlay
showSubtrackColorOnUi on
priority 1.2
configurable on
autoScale on
dragAndDrop subtracks
windowingFunction mean+whiskers
maxHeightPixels 100:60:8

track One_ctcf
bigDataUrl ctcf1.bw
shortLabel ctcf1.bw
longLabel ctcf1.bw
parent one
type bigWig
color 0,102,255

track P300
bigDataUrl P3001.bw
shortLabel P3001.bw
longLabel P3001.bw
parent one
type bigWig
color 136,102,255

track Two
container multiWig
shortLabel Two
longLabel Two
type bigWig
#viewLimits 0:160
visibility full
aggregate transparentOverlay
showSubtrackColorOnUi on
windowingFunction maximum
priority 1.2
configurable on
autoScale on
dragAndDrop subtracks

track ctcf2
bigDataUrl ctcf2.bw
shortLabel ctcf2.bw
longLabel ctcf2.bw
parent Two
type bigWig
color 0,102,255

2. 定时清理

#!/bin/bash
#10080 means 10080 minutes which is 14 days.
find /var/www/gw/trash/ \! \( -regex "/var/www/gw/trash/ct/.*" -or \
    -regex "/var/www/gw/trash/hgSs/.*" \) -type f -amin +10080 -exec rm -f {} \;
上一篇下一篇

猜你喜欢

热点阅读