code refactoring to rename oligo to word
This commit is contained in:
@ -3,7 +3,36 @@ from itertools import imap
|
||||
|
||||
_dna='acgt'
|
||||
|
||||
def wordIterator(size,_prefix=''):
|
||||
def wordCount(liste):
|
||||
count = {}
|
||||
|
||||
for e in liste:
|
||||
count[e]=count.get(e,0) + 1
|
||||
|
||||
return count
|
||||
|
||||
|
||||
def wordIterator(sequence,lword,step=1,endIncluded=False,circular=False):
|
||||
assert not (endIncluded and circular), \
|
||||
"endIncluded and circular cannot not be set to True at the same time"
|
||||
|
||||
L = len(sequence)
|
||||
sequence = str(sequence)
|
||||
if circular:
|
||||
sequence += sequence[0:lword]
|
||||
pmax=L
|
||||
elif endIncluded:
|
||||
pmax=L
|
||||
else:
|
||||
pmax = L - lword + 1
|
||||
|
||||
pos = xrange(0,pmax,step)
|
||||
|
||||
for x in pos:
|
||||
yield sequence[x:x+lword]
|
||||
|
||||
|
||||
def allWordIterator(size,_prefix=''):
|
||||
'''
|
||||
Iterate thought the list of all DNA word of
|
||||
size `size`.
|
||||
@ -18,7 +47,7 @@ def wordIterator(size,_prefix=''):
|
||||
'''
|
||||
if size:
|
||||
for l in _dna:
|
||||
for w in wordIterator(size-1,_prefix+l):
|
||||
for w in allWordIterator(size-1,_prefix+l):
|
||||
yield w
|
||||
else:
|
||||
yield _prefix
|
||||
|
@ -2,8 +2,8 @@ from logging import debug,root,DEBUG
|
||||
|
||||
|
||||
|
||||
from obitools.oligo import wordSelector,wordIterator
|
||||
from obitools.oligo import predicat
|
||||
from obitools.word import wordSelector,wordIterator
|
||||
from obitools.word import predicat
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import re
|
||||
from obitools.oligo import wordDist
|
||||
from obitools.word import wordDist
|
||||
|
||||
def rePredicatGenerator(regex):
|
||||
regex = re.compile(regex,re.I)
|
||||
|
Reference in New Issue
Block a user