Linux系統創建可執行文件軟鏈接
技術背景
由於創建軟鏈接這個事情,在演算法開發的日常中使用到的並不是很多,因此本文也是做一個簡單的回顧。這裡我們使用的案例是通過TMalign這個蛋白質打分文件,在編譯好可執行文件之後,可以使用建立軟鏈接的方法快捷的使用該可執行文件。
TMalign的下載與安裝
TMalign可以給兩個給定的蛋白質pdb文件進行評分:
$ TMalign out.pdb origin.pdb
*********************************************************************
* TM-align (Version 20220412): protein structure alignment *
* References: Y Zhang, J Skolnick. Nucl Acids Res 33, 2302-9 (2005) *
* Please email comments and suggestions to [email protected] *
*********************************************************************
Name of Chain_1: out.pdb (to be superimposed onto Chain_2)
Name of Chain_2: origin.pdb
Length of Chain_1: 207 residues
Length of Chain_2: 207 residues
Aligned length= 207, RMSD= 0.00, Seq_ID=n_identical/n_aligned= 1.000
TM-score= 1.00000 (if normalized by length of Chain_1, i.e., LN=207, d0=5.35)
TM-score= 1.00000 (if normalized by length of Chain_2, i.e., LN=207, d0=5.35)
那麼如果要使用該評分軟體,需要從該鏈接中下載相關的文件,比如cpp文件和readme文件。下載到本地目錄下之後,可以執行如下指令進行編譯(如果是Mac可能需要去掉static):
$ g++ -static -O3 -ffast-math -lm -o TMalign TMalign.cpp
編譯之後就會在當前路徑下生成一個名為TMalign
的可執行文件:
$ ll
總用量 3036
drwxrwxr-x 2 dechin dechin 4096 5月 6 13:58 ./
drwxrwxr-x 11 dechin dechin 4096 5月 6 13:57 ../
-rw-rw-r-- 1 dechin dechin 7387 5月 6 13:58 readme.c++.txt
-rwxrwxr-x 1 dechin dechin 2904224 5月 6 13:59 TMalign*
-rw-rw-r-- 1 dechin dechin 182097 5月 6 13:57 TMalign.cpp
建立軟鏈接
雖然這條指令很簡單,但是需要注意的是一定要使用絕對路徑,如果使用相對路徑,會出現符號連接的層數過多
的報錯資訊。另外如果要創建的軟鏈接在/usr/bin
之類的目錄下的話,需要使用到sudo
許可權。具體執行指令如下:
$ sudo ln -s /home/dechin/tools/TMalign/TMalign /usr/bin/TMalign
一般/usr/bin
是用戶的系統路徑,相比於不斷的補充系統路徑,這種建立軟鏈接的方式會顯得更加簡潔。建立完軟鏈接之後,就可以在系統的任一位置直接執行TMalign
的指令了:
$ TMalign
*********************************************************************
* TM-align (Version 20220412): protein structure alignment *
* References: Y Zhang, J Skolnick. Nucl Acids Res 33, 2302-9 (2005) *
* Please email comments and suggestions to [email protected] *
*********************************************************************
Usage: TMalign PDB1.pdb PDB2.pdb [Options]
Options:
-u TM-score normalized by user assigned length (the same as -L)
warning: it should be >= minimum length of the two structures
otherwise, TM-score may be >1
-a TM-score normalized by the average length of two structures
T or F, (default F)
-i Start with an alignment specified in fasta file 'align.txt'
-I Stick to the alignment specified in 'align.txt'
-m Output TM-align rotation matrix
-d TM-score scaled by an assigned d0, e.g. 5 Angstroms
-o Output the superposition to 'TM_sup*'
$ TMalign PDB1.pdb PDB2.pdb -o TM_sup
View superposed C-alpha traces of aligned regions by RasMol or PyMOL:
$ rasmol -script TM_sup
$ pymol -d @TM_sup.pml
View superposed C-alpha traces of all regions:
$ rasmol -script TM_sup_all
$ pymol -d @TM_sup_all.pml
View superposed full-atom structures of aligned regions:
$ rasmol -script TM_sup_atm
$ pymol -d @TM_sup_atm.pml
View superposed full-atom structures of all regions:
$ rasmol -script TM_sup_all_atm
$ pymol -d @TM_sup_all_atm.pml
View superposed full-atom structures and ligands of all regions
$ rasmol -script TM_sup_all_atm_lig
$ pymol -d @TM_sup_all_atm_lig.pml
-fast Fast but slightly inaccurate alignment by fTM-align algorithm
-cp Alignment with circular permutation
-v Print the version of TM-align
-h Print the full help message, including additional options
(Options -u, -a, -d, -o will not change the final structure alignment)
Example usages:
TMalign PDB1.pdb PDB2.pdb
TMalign PDB1.pdb PDB2.pdb -u 100 -d 5.0
TMalign PDB1.pdb PDB2.pdb -a T -o PDB1.sup
TMalign PDB1.pdb PDB2.pdb -i align.txt
TMalign PDB1.pdb PDB2.pdb -m matrix.txt
TMalign PDB1.pdb PDB2.pdb -fast
TMalign PDB1.pdb PDB2.pdb -cp
總結概要
編譯安裝源程式碼為可執行文件時,有時候會遇到想把可執行文件放在特定的路徑下的問題,比如放到/usr/bin
目錄下,這樣可以全局可調用,又不需要手動添加各種亂七八糟的系統路徑。這就需要使用到Linux中的軟鏈接的功能,通常使用ln -s
的指令即可。本文順帶介紹了蛋白質結構評分軟體TMalign的源碼下載和安裝使用的基本方法,編譯成一個可執行文件後,可以建立一個軟鏈接,在系統各處都可以使用,是一個比較基礎的操作。
版權聲明
本文首發鏈接為://www.cnblogs.com/dechinphy/p/ln.html
作者ID:DechinPhy
更多原著文章請參考://www.cnblogs.com/dechinphy/
打賞專用鏈接://www.cnblogs.com/dechinphy/gallery/image/379634.html
騰訊雲專欄同步://cloud.tencent.com/developer/column/91958
CSDN同步鏈接://blog.csdn.net/baidu_37157624?spm=1008.2028.3001.5343
51CTO同步鏈接://blog.51cto.com/u_15561675