當前位置: 首頁>>代碼示例>>Python>>正文


Python ScreedDB.loadRecordByIndex方法代碼示例

本文整理匯總了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
開發者ID:anotherthomas,項目名稱:screed,代碼行數:27,代碼來源:pygr_api.py

示例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
開發者ID:lgautier,項目名稱:screed,代碼行數:21,代碼來源:pygr_api.py

示例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
        """
#.........這裏部分代碼省略.........
開發者ID:ahaerpfer,項目名稱:screed,代碼行數:103,代碼來源:__init__.py


注:本文中的screed.ScreedDB.loadRecordByIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。