
BioSQL----搭建分子生物學(xué)數(shù)據(jù)庫
最近在做一個網(wǎng)站,網(wǎng)站必不可少的當(dāng)然是數(shù)據(jù)庫。現(xiàn)在可能生物領(lǐng)域的數(shù)據(jù)庫還比較少。。。所以我在CSDN找了很多的資料結(jié)果還是不盡如人意。于是乎,我就想到了python里極為強大的一個分子生物學(xué)庫:biopython。嘿,真別說,官方中文文檔里還真出現(xiàn)了這么一個東西----BioSQL。
?
因為BioSQL是需要基于其他數(shù)據(jù)庫來運行,這里我們以MySQL為例
?
首先,傳統(tǒng)藝能,打開終端,輸入以下命令行創(chuàng)建數(shù)據(jù)庫:
mysqladmin -u root -p create 數(shù)據(jù)庫名稱
?
然后,我們可以告訴MySQL加載上面下載的BioSQL,從解壓縮的BioSQL下載更改到腳本子目錄:
mysql -u root -p bioseqdb < 數(shù)據(jù)庫名稱-mysql.sql
?
接下來,到Tests/setup_BioSQL.py路徑下的這個文件中來,開始配置數(shù)據(jù)庫參數(shù)~
DBDRIVER = "mysql.connector"? ??? # 數(shù)據(jù)庫驅(qū)動器名稱
DBTYPE = "mysql"? ? ? ? ? ?# 數(shù)據(jù)庫類型
DBHOST = "localhost"? ? ? ? # 數(shù)據(jù)庫主機
DBUSER = "root"? ? ? ? ? ? ? # 數(shù)據(jù)庫用戶名
DBPASSWD = "your-password"? ? ? # 數(shù)據(jù)庫密碼
TESTDB = "biosql_test"? ? ? ? # 測試數(shù)據(jù)庫
?
之后,你就可以先測試一下~
python run_tests.py test_BioSQL test_BioSQL_SeqIO
?
子數(shù)據(jù)庫的創(chuàng)建;
from BioSQL import BioSeqDatabase
server = BioSeqDatabase.open_database(
? ? driver="mysql.connector",
? ? user="root",
? ? passwd="your-password",
? ? host="localhost",
? ? db="bioseqdb",
)
db = server.new_database("orchids", description="Just for testing")
?
數(shù)據(jù)庫的加載:
from BioSQL import BioSeqDatabase
server = BioSeqDatabase.open_database(
? ? driver="mysql.connector",
? ? user="root",
? ? passwd="your-password",
? ? host="localhost",
? ? db="bioseqdb",
)
db = server[子庫名稱]
db.load
server.commit()
?
這個教程大概是國內(nèi)網(wǎng)上能找到為數(shù)不多的之一,因為中文官方文檔里沒有,我又用神秘的方法找遍了各種英文資料,才找到的然后翻譯過來。因為BioSQL支持所有的biopython類型,而biopython幾乎包下了python屆分子生物學(xué)半邊天的感覺??所以直接用BioSQL真的挺方便的,而且biopython里還有重復(fù)計數(shù)這么一說~還能順便降低服務(wù)器存儲成本~
?
因為BioSQL是需要基于其他數(shù)據(jù)庫來運行,這里我們以MySQL為例
?
首先,傳統(tǒng)藝能,打開終端,輸入以下命令行創(chuàng)建數(shù)據(jù)庫:
mysqladmin -u root -p create 數(shù)據(jù)庫名稱
?
然后,我們可以告訴MySQL加載上面下載的BioSQL,從解壓縮的BioSQL下載更改到腳本子目錄:
mysql -u root -p bioseqdb < 數(shù)據(jù)庫名稱-mysql.sql
?
接下來,到Tests/setup_BioSQL.py路徑下的這個文件中來,開始配置數(shù)據(jù)庫參數(shù)~
DBDRIVER = "mysql.connector"? ??? # 數(shù)據(jù)庫驅(qū)動器名稱
DBTYPE = "mysql"? ? ? ? ? ?# 數(shù)據(jù)庫類型
DBHOST = "localhost"? ? ? ? # 數(shù)據(jù)庫主機
DBUSER = "root"? ? ? ? ? ? ? # 數(shù)據(jù)庫用戶名
DBPASSWD = "your-password"? ? ? # 數(shù)據(jù)庫密碼
TESTDB = "biosql_test"? ? ? ? # 測試數(shù)據(jù)庫
?
之后,你就可以先測試一下~
python run_tests.py test_BioSQL test_BioSQL_SeqIO
?
子數(shù)據(jù)庫的創(chuàng)建;
from BioSQL import BioSeqDatabase
server = BioSeqDatabase.open_database(
? ? driver="mysql.connector",
? ? user="root",
? ? passwd="your-password",
? ? host="localhost",
? ? db="bioseqdb",
)
db = server.new_database("orchids", description="Just for testing")
?
數(shù)據(jù)庫的加載:
from BioSQL import BioSeqDatabase
server = BioSeqDatabase.open_database(
? ? driver="mysql.connector",
? ? user="root",
? ? passwd="your-password",
? ? host="localhost",
? ? db="bioseqdb",
)
db = server[子庫名稱]
db.load
server.commit()
?
這個教程大概是國內(nèi)網(wǎng)上能找到為數(shù)不多的之一,因為中文官方文檔里沒有,我又用神秘的方法找遍了各種英文資料,才找到的然后翻譯過來。因為BioSQL支持所有的biopython類型,而biopython幾乎包下了python屆分子生物學(xué)半邊天的感覺??所以直接用BioSQL真的挺方便的,而且biopython里還有重復(fù)計數(shù)這么一說~還能順便降低服務(wù)器存儲成本~
3 個回復(fù)
贊同來自: 大灰狼
贊同來自:
贊同來自:
要回復(fù)問題請先登錄或注冊