本文整理汇总了Python中screed.ScreedDB.keys方法的典型用法代码示例。如果您正苦于以下问题:Python ScreedDB.keys方法的具体用法?Python ScreedDB.keys怎么用?Python ScreedDB.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类screed.ScreedDB
的用法示例。
在下文中一共展示了ScreedDB.keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _ScreedSeqInfoDict_ByName
# 需要导入模块: from screed import ScreedDB [as 别名]
# 或者: from screed.ScreedDB import keys [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: setup
# 需要导入模块: from screed import ScreedDB [as 别名]
# 或者: from screed.ScreedDB import keys [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
"""
#.........这里部分代码省略.........
示例3: myFirstUI
# 需要导入模块: from screed import ScreedDB [as 别名]
# 或者: from screed.ScreedDB import keys [as 别名]
class myFirstUI(Directory):
_q_exports = ['','firstkMer','kmerNeighborhood']
theK=17
def __init__(self):
# the 12 is the size of K which can be set here:
#self.ktable=khmer.new_ktable(12)
self.ktable=khmer.new_hashbits(self.theK,1e9,4)
#specify the files you want to load, they have to be screed files
names=('chr01.fsa','chr02.fsa','chr03.fsa','chr04.fsa','chr05.fsa','chr06.fsa','chr07.fsa',
'chr08.fsa','chr09.fsa','chr10.fsa','chr11.fsa','chr12.fsa','chr13.fsa','chr14.fsa','chr15.fsa','chr16.fsa')
for name in names:
self.fadb=ScreedDB(name)
print name
keys=self.fadb.keys()
for key in keys:
s=self.fadb[key]['sequence']
self.ktable.consume(str(s))
print "done consuming"
def _q_index(self):
return "kmer browser database"
def firstkMer(self):
i=0
while self.ktable.get(i)==0:
i+=1
return self.ktable.reverse_hash(i)
def addAllKmers(self,currentKmer,depth,maxDepth):
if depth<maxDepth:
L=['A','C','G','T']
rawStringLead=currentKmer[0:(self.theK-1)]
rawStringTrail=currentKmer[1:self.theK]
for l in L:
s=rawStringTrail+l
if self.ktable.get(s)!=0:
self.lines[currentKmer+' '+s]=1
if not s in self.liste:
self.liste[s]=depth+1
self.addAllKmers(s,depth+1,maxDepth)
s=l+rawStringLead
if self.ktable.get(s)!=0:
self.lines[currentKmer+' '+s]=1
if not s in self.liste:
self.liste[s]=depth+1
self.addAllKmers(s,depth+1,maxDepth)
def kmerNeighborhood(self):
request=quixote.get_request()
form=request.form
n=int(form['n'])
print n
self.liste=dict()
self.lines=dict()
self.liste.clear()
self.lines.clear()
self.liste[str(form['kmer'])]=0
self.addAllKmers(str(form['kmer']),0,n)
S=str(len(self.liste))+'\n'
for l in self.liste.keys():
S=S+l+' '+str(self.liste[l])+'\n'
for l in self.lines.keys():
S=S+l+'\n'
return S
def interface(self):
myVariable=templatesdir
template = env.get_template('kMerBrowserInterface.html')
return template.render(locals())
示例4: records
# 需要导入模块: from screed import ScreedDB [as 别名]
# 或者: from screed.ScreedDB import keys [as 别名]
#typing: $ records
# PRODUCES: [{'description': 'Drosophila melanogaster birnavirus SW-2009a strain DBV segment A, complete sequence', 'id': 0, 'name': 'gi|262225302|gb|GQ342962.1|', 'sequence': <_screed_attr 'sequence'>}, {'description': 'Drosophila melanogaster birnavirus SW-2009a strain DBV segment B, complete sequence', 'id': 1, 'name': 'gi|262225305|gb|GQ342963.1|', 'sequence': <_screed_attr 'sequence'>}]
#len(record['sequence'])
# 3014
#record['sequence']
# <_screed_attr 'sequence'>
print "\n\n\n"
#print "Printing a count: all birna records (should equal to 2)...\n"
#print len(birnarecords)
print "\n\n\n"
#print "\nPrinting sequence of last record.\n\t"
#print record['sequence']
print "\nPrinting first record\n\t"
segmentA = birna_x_virusdb[birna_x_virusdb.keys()[0]]
#print segmentA
#segment
# {'description': 'Drosophila melanogaster birnavirus SW-2009a strain DBV segment A, complete sequence', 'id': 0, 'name': 'gi|262225302|gb|GQ342962.1|', 'sequence': <_screed_attr 'sequence'>}
print "\nPrinting second record...\n\t"
segmentB = birna_x_virusdb[birna_x_virusdb.keys()[1]]
#print segmentB
print "\nPrinting third record\n\t"
segmentXA = birna_x_virusdb[birna_x_virusdb.keys()[2]]
#print segmentXA
print "\nPrinting fourth record...\n\t"
segmentXB = birna_x_virusdb[birna_x_virusdb.keys()[3]]