给云服务器配置blast

151

blast+(已放弃)

cd
wget https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.13.0+-x64-linux.tar.gz
tar -zxvf ncbi-blast-2.13.0+-x64-linux.tar.gz
sudo ln -sf  /home/caigui/ncbi-blast-2.13.0+/bin/* /usr/bin/

# 建立小翠云的cds和protein的blast数据库
sudo makeblastdb -in xiaocuiyun_protein_represent.fa -dbtype prot -parse_seqids -out sk.p
sudo makeblastdb -in xiaocuiyun_cds_represent.fa -dbtype nucl -parse_seqids -out sk.n

# 测试
blastp -query test.p.blast -db sk.p -outfmt 6
blastn -query test.n.blast -db sk.n -outfmt 6

放弃安装blast+,这需要用到php知识。 地钱网站用的是sequenceserver,效果很好,我试试。

安装SequenceServer

# 安装ruby
sudo apt-get install ruby-full

# 安装SequenceServer
su caigui
sudo gem install sequenceserver

# 运行sequenceserver
sequenceserver
配置完成后会生成/root/.sequenceserver.conf文件

# 修改网页样式
# gem environment
# /var/lib/gems/2.5.0/gems/sequenceserver-2.0.0/views/layout.erb
# 这里修改完得重启(服务/计算机)才能生效
# 修改前先备份,我把原来页面的页眉和页脚删了,准备直接插入到现有网站的页面中

# 配置自动启动
# sudo useradd -s /sbin/nologin seqservuser # 添加一个用户专门搞这个(不添加的话就修改User行)
sudo vim /etc/systemd/system/sequenceserver.service # 主要修改ExecStart这一行
------------------------------------------------------------------------------------------
[Unit]
Description=SequenceServer server daemon
Documentation="file://sequenceserver --help" "http://sequenceserver.com/doc"
After=network.target

[Service]
Type=simple
User=caigui
ExecStart=/usr/local/bin/sequenceserver -c /var/www/lab.ccgg.fun/public/blastdata/sequenceserver.conf
KillMode=process
Restart=on-failure
RestartSec=42s
RestartPreventExitStatus=255

[Install]
WantedBy=multi-user.target
------------------------------------------------------------------------------------------
sudo systemctl daemon-reload
sudo systemctl enable sequenceserver.service
sudo systemctl start sequenceserver.service
# 现在可以打开http://show.caigui.fun:4567/,来使用这个blast了。当然要提前在服务器网页管理的地方,开放4567这个端口。

# 查看一下配置文件
cat /var/www/lab.ccgg.fun/public/blastdata/sequenceserver.conf
# ---
# :host: 0.0.0.0
# :port: 4567
# :databases_widget: classic
# :options:
#   :blastn:
#   - "-task blastn"
#   - "-evalue 1e-5"
#   :blastp:
#   - "-evalue 1e-5"
#   :blastx:
#   - "-evalue 1e-5"
#   :tblastx:
#   - "-evalue 1e-5"
#   :tblastn:
#   - "-evalue 1e-5"
# :num_threads: 1
# :num_jobs: 1
# :job_lifetime: 43200
# :database_dir: "/var/www/lab.ccgg.fun/public/blastdata"

# 配置nginx的反向代理
sudo vim /etc/nginx/sites-enabled/show.caigui.fun.conf
# 在server中添加
------------------------------------------------------------------------------------------
    location /sequenceserver/ {
        proxy_pass http://127.0.0.1:4567/;
        proxy_intercept_errors on;
        proxy_connect_timeout 8;
        proxy_read_timeout 180;
    }
------------------------------------------------------------------------------------------
# 现在可以通过访问https://show.caigui.fun/sequenceserver/来使用这个blast了

# 更新数据库
# 在/var/www/lab.ccgg.fun/public/blastdata目录下运行
sequenceserver -m #不需要root权限
# 根据提示添加新数据库即可,添加完毕后重启(服务/计算机)
# 水蕨蛋白不知道为什么识别数据类型不成功,手动弄一下
touch Crichardii.taxid_map.txt
sudo makeblastdb -dbtype prot -title '[Ceratopteris richardii_v2.1] Protein' -in Crichardii.fa -parse_seqids -hash_index -taxid 0
sequenceserver -m

# 删除现有数据库
# 直接在/var/www/lab.ccgg.fun/public/blastdata文件夹下删除想删除的数据库文件,然后重启服务
sudo systemctl restart sequenceserver.service



# 配置完重启后显示端口被占用
netstat -ntlp
# 发现sequenceserver进程独占了一个端口,其它程序都没有正确连接到端口上
# kill上面这个pid
# 再重启,解决了

20240906:更新SequenceServer,失败

参考文档:

https://sequenceserver.com/doc/
https://github.com/wurmlab/sequenceserver
https://www.ruby-lang.org/en/documentation/installation/ https://www.runoob.com/ruby/ruby-installation-unix.html

更新SequenceServer。地钱网站当前还用的v1版本,我们网站目前用的是v2版本,20240214更新到了最新的v3版本,v3.0.1

sequenceserver -v #2.0.0

sudo gem install sequenceserver 
# 以上命令安装不了,可能是被屏蔽了?更换镜像源

# 更换镜像源
sudo gem sources
sudo gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

# 重新安装
sudo gem install sequenceserver 
# 总算有信息了,不过还是报错。
# Fetching: webrick-1.8.1.gem (100%)
# Successfully installed webrick-1.8.1
# Fetching: rack-3.1.7.gem (100%)
# Successfully installed rack-3.1.7
# Fetching: base64-0.2.0.gem (100%)
# Successfully installed base64-0.2.0
# Fetching: rack-protection-4.0.0.gem (100%)
# ERROR:  Error installing sequenceserver:
# 	There are no versions of rack-protection (= 4.0.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?
# 	rack-protection requires Ruby version >= 2.7.8. The current ruby version is 2.5.0.



# 更新ruby.
# 当前版本
ruby -v #ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
# upgrade试试
sudo apt-get update
sudo apt-get upgrade ruby-full #一直404,失败
# 卸载再安装试试,
sudo apt-get remove ruby-full
sudo apt-get install ruby-full
# 可以成功卸载再安装,但还是2.5.5版本
# 根据文档:https://www.ruby-lang.org/en/documentation/installation/。据说打包的ruby很可能不是最新版本。

# 🌟可能需要通过rvm来管理版本,算了,以后有空再折腾吧。
# 未完待续


20241011:更新SequenceServer,成功

https://github.com/rvm/rvm

  • rvm安装新版本ruby,失败
sudo apt-get install gnupg2
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

# \curl -sSL https://get.rvm.io | bash -s stable
# 保存到本地后再运行
bash rvm.sh stable

# source或者重启shell
source /home/caigui/.rvm/scripts/rvm

# 安装最新版本ruby,装不上
rvm install 3.3.5

# 试试安装满足要求的最低版本
rvm install 2.7.8

  • 源代码编译新版ruby,成功
# 从源代码编译ruby

# github install step1
./configure
# github install step2
make
# 报错缺少libyaml-dev,重新安装
sudo apt-get install libyaml-dev
# 重新安装后需要make clean,否则还报错
make clean

# github完整安装步骤走一遍即可
# github install step1
./configure
# github install step2
make
# github install step3
sudo make install

# 重新进入shell
ruby -v
# ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]
# 总算更新成功了

# 直接安装sequenceserver,覆盖安装时选y
sudo gem install sequenceserver 

# 打开网页发现还是旧版
# 服务器运行一下试试
sequenceserver
# 提示需要更新blast+,回车安装新版blast+
# Your BLAST+ version 2.13.0+ is incompatible.
# SequenceServer needs NCBI BLAST+ version 2.16.0+.
# 回车安装的有问题,我还是自己安装吧

#安装新版blast
cd 
wget https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.16.0+-x64-linux.tar.gz
tar -zxvf ncbi-blast-2.16.0+-x64-linux.tar.gz
sudo ln -sf  /home/caigui/ncbi-blast-2.16.0+/bin/* /usr/bin/

# 重启服务
sudo systemctl restart sequenceserver.service

# 更新成功,但是之前的数据库都没了

# 可能是我重启了一下?也可能是又等了几分钟?总之数据库又都回来了。测试成功,更新成功!
sudo systemctl daemon-reload
sudo systemctl enable sequenceserver.service
sudo systemctl start sequenceserver.service



  • 修改网页样式,失败。按之前的方法修改后,网页的形式没有任何变化,怪了,先不改了
# 修改网页样式
gem environment #查看存储路径
#INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/3.3.0
# 找layout.erb
# 修改前先备份,我把原来页面的页眉和页脚删了,直接插入到现有网站的页面中
sudo vim /usr/local/lib/ruby/gems/3.3.0/gems/sequenceserver-3.1.3/views/layout.erb #和之前路径不一样了,之前安装在/var/lib/gems/2.5.0/gems/sequenceserver-2.0.0/views下
# 这里修改完得重启(服务/计算机)才能生效
sudo systemctl restart sequenceserver.service