本文整理汇总了Python中screed.ScreedDB.loadRecordByIndex方法的典型用法代码示例。如果您正苦于以下问题:Python ScreedDB.loadRecordByIndex方法的具体用法?Python ScreedDB.loadRecordByIndex怎么用?Python ScreedDB.loadRecordByIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类screed.ScreedDB
的用法示例。
在下文中一共展示了ScreedDB.loadRecordByIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _ScreedSeqInfoDict_ByName
# 需要导入模块: from screed import ScreedDB [as 别名]
# 或者: from screed.ScreedDB import loadRecordByIndex [as 别名]
class _ScreedSeqInfoDict_ByName(object, UserDict.DictMixin):
"""seqInfoDict implementation that uses names to retrieve records."""
def __init__(self, filepath):
self.sdb = ScreedDB(filepath)
def __getitem__(self, k):
v = self.sdb[k]
return _ScreedSequenceInfo(k, v)
def keys(self):
return self.sdb.keys()
def itervalues(self):
i = 0
max_index = len(self.sdb)
while i < max_index:
v = self.sdb.loadRecordByIndex(i)
yield _ScreedSequenceInfo(v.name, v)
i += 1
def iteritems(self):
for v in self.itervalues():
yield v.record.name, v
示例2: _ScreedSeqInfoDict_ByIndex
# 需要导入模块: from screed import ScreedDB [as 别名]
# 或者: from screed.ScreedDB import loadRecordByIndex [as 别名]
class _ScreedSeqInfoDict_ByIndex(object, UserDict.DictMixin):
"""seqInfoDict implementation that uses indices to retrieve records."""
def __init__(self, filepath):
self.sdb = ScreedDB(filepath)
def __getitem__(self, k):
n = int(k)
v = self.sdb.loadRecordByIndex(n)
return _ScreedSequenceInfo(k, v)
def keys(self):
return xrange(0, len(self.sdb))
def iterkeys(self):
i = 0
max_index = len(self.sdb)
while i < max_index:
yield i
i += 1
示例3: setup
# 需要导入模块: from screed import ScreedDB [as 别名]
# 或者: from screed.ScreedDB import loadRecordByIndex [as 别名]
class Test_xeno_fasta:
"""
Test screed methods on the xeno fasta file
"""
def setup(self):
self.db = ScreedDB(xeno + '_screed')
def tearDown(self):
del self.db
gc.collect()
def test_iteration(self):
"""
Runs through the database, accessing each element by index and then by
name
"""
for idx in xrange(0, len(self.db)):
rcrd = self.db.loadRecordByIndex(idx)
nameRcrd = self.db[rcrd.name]
assert rcrd == nameRcrd
def test_dict_stuff(self):
"""
Tests some dictionary methods on the database
"""
keys = self.db.keys()
ikeys = list(self.db.iterkeys())
assert sorted(keys) == sorted(ikeys)
del keys
del ikeys
gc.collect()
def test_contains(self):
for k in self.db:
assert k in self.db
assert not 'FOO' in self.db
def test_get(self):
for k in self.db:
record = self.db.get(k)
assert record.name == k
record = self.db[k]
assert record.name == k
assert self.db.get('FOO') == None
try:
self.db['FOO']
assert False, "the previous line should raise a KeyError"
except KeyError:
pass
def test_missing(self):
"""
Make sure that unsupported dict attributes are actually missing.
"""
db = self.db
try:
db.clear()
assert 0
except AttributeError:
pass
try:
db.update({})
assert 0
except AttributeError:
pass
try:
db.clear()
assert 0
except AttributeError:
pass
try:
db.setdefault(None)
assert 0
except AttributeError:
pass
try:
db.pop()
assert 0
except AttributeError:
pass
try:
db.popitem()
assert 0
except AttributeError:
pass
def test_certain_records(self):
"""
Pulls first, last, middle and few other records out of database and
compares them to known quantities
"""
#.........这里部分代码省略.........