1. 程式人生 > 其它 >Linux系統建立可執行檔案軟連結

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的原始碼下載和安裝使用的基本方法,編譯成一個可執行檔案後,可以建立一個軟連結,在系統各處都可以使用,是一個比較基礎的操作。

版權宣告

本文首發連結為:https://www.cnblogs.com/dechinphy/p/ln.html

作者ID:DechinPhy

更多原著文章請參考:https://www.cnblogs.com/dechinphy/

打賞專用連結:https://www.cnblogs.com/dechinphy/gallery/image/379634.html

騰訊雲專欄同步:https://cloud.tencent.com/developer/column/91958

CSDN同步連結:https://blog.csdn.net/baidu_37157624?spm=1008.2028.3001.5343

51CTO同步連結:https://blog.51cto.com/u_15561675

參考連結

  1. https://blog.csdn.net/jialibang/article/details/108247033