使用脚本解析大型 XML 文件还是使用 BioPython API?
嘿伙计们,这是我的第一个问题。我正在尝试用 SQL 制作 UniprotKB 的本地副本。
UniprotKB 为 2.1GB,采用 XML 和 SwissProt 使用的特殊文本格式
以下是我的选择:
1) 使用 SAX 解析器 (XML) - 我选择 Ruby 和 Nokogiri。我开始编写解析器,但我最初的反应是:如何将 XML 模式映射到 SAX 解析器?
2) BioPython - 我已经安装了 BioSQL/Biopython,它确实为我创建了 SQL 模式,并且我能够成功地将一个 SwissProt/Uniprot txt 文件插入数据库。
我现在正在整个 2.1gb 上运行它(交叉手指)。这是我正在运行的代码:
from Bio import SeqIO
from BioSQL import BioSeqDatabase
from Bio import SwissProt
server = BioSeqDatabase.open_database(driver = "MySQLdb", user = "root", passwd = "", host="localhost", db = "bioseqdb")
db = server["uniprot"]
iterator = SeqIO.parse(open("/path/to/uniprot_sprot.dat", "r"), "swiss")
db.load(iterator)
server.commit()
编辑:它现在崩溃了,因为事务被锁定(因为表是 Innodb) 错误号:1205 超过锁等待超时;尝试重新启动事务。我正在使用 MySQL 版本:5.1.43
我应该将数据库切换到 Postgrelsql 吗?
Hey guys this is my first question on here. I'm trying to make a local copy of the UniprotKB in SQL.
The UniprotKB is 2.1GB, and it comes in XML and a special text format used by SwissProt
Here are my options:
1) Use a SAX parser (XML) - I chose Ruby, and Nokogiri. I started writing the parser, but my initial reaction: how would I map the XML schema to the SAX parser?
2) BioPython - I already have BioSQL/Biopython installed, which literally created my SQL schema for me, and I was able to successfully insert one SwissProt/Uniprot txt file into the database.
I'm running it right now (crosses fingers) on the entire 2.1gb. Here is the code I'm running:
from Bio import SeqIO
from BioSQL import BioSeqDatabase
from Bio import SwissProt
server = BioSeqDatabase.open_database(driver = "MySQLdb", user = "root", passwd = "", host="localhost", db = "bioseqdb")
db = server["uniprot"]
iterator = SeqIO.parse(open("/path/to/uniprot_sprot.dat", "r"), "swiss")
db.load(iterator)
server.commit()
Edit: it's now crashing because the transactions are getting locked (since the tables are Innodb)
Error Number: 1205
Lock wait timeout exceeded; try restarting transaction. I'm using
MySQL version: 5.1.43
Should I switch my database to Postgrelsql ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了方便起见,切换到 PostgrelSQL。有些问题是通过下载 NCBI 分类信息解决的(我不知道这是必要的,应该在文档中更清楚),所以我最终使用 BioPython 的 Swiss 解析器,因为它非常适合 BioSQL。
Switched to PostgrelSQL for convenience purposes. Some of the issues were resolved by downloading the NCBI taxonomy information (which I did not know was necessary, should have been more clear in the documentation), so I ended up using the Swiss parser from BioPython because it fits so nicely with BioSQL.