我正在从同一个组装体的染色体(大约10s的Mb)内寻找支架(大约10s的Kb)。两者都包含IUPAC歧义。到目前为止,我一直在使用
from Bio.SeqUtils import *
nt_search(chromosome, scaffold)
但是,有一种情况是,前向串搜索很好,但对其反向补码的搜索会产生正则表达式重载错误。你知道吗
from Bio.Seq import Seq
from Bio.SeqUtils import *
def findCoordinates (self):
''' Performs scaffold string search within chromosomes. Returns scaffold coordinates within said chromosome. '''
for chromosome in self.chromosomes.keys():
for scaffold in self.scaffolds.keys():
# search forward strand.
nt_forward = nt_search(self.chromosomes[chromosome], self.scaffolds[scaffold])
if len(nt_forward) > 1:
startCoord = nt_forward[1] + 1
endCoord = (startCoord + len(self.scaffolds[scaffold]))
# save coordinates
else: # search reverse strand
scaffold_seq = Seq(self.scaffolds[scaffold])
reverse_seq = scaffold_seq.reverse_complement()
nt_reverse = nt_search(self.chromosomes[chromosome], str(reverse_seq))
if len(nt_reverse) > 1:
startCoord = nt_reverse[1] + 1
endCoord = (startCoord + len(self.scaffolds[scaffold]))
# save coordinates
self.scaffolds[scaffold] = str(scaffold_seq.reverse_complement())
我得到以下错误:
Traceback (most recent call last):
File "scaffoldPlacer.py", line 98, in <module>
z.findCoordinates()
File "scaffoldPlacer.py", line 60, in findCoordinates
nt_reverse = nt_search(self.chromosomes[chromosome], str(reverse_seq))
File "/usr/local/lib/python2.7/site-packages/Bio/SeqUtils/__init__.py", line 191, in nt_search
m = re.search(pattern, s)
File "/usr/local/lib/python2.7/re.py", line 142, in search
return _compile(pattern, flags).search(string)
File "/usr/local/lib/python2.7/re.py", line 243, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/local/lib/python2.7/sre_compile.py", line 523, in compile
groupindex, indexgroup
OverflowError: regular expression code size limit exceeded
如前所述,只有在搜索反向补码正则表达式时才会发生此错误,因此前向搜索不会出错。你知道吗
有没有一种方法可以避免这个错误,或者有没有更好的方法来执行有关IUPAC歧义的DNA字符串搜索。你知道吗
谢谢
在这之后(Python's Regular Expression Source String Length),似乎巨大的模式打破了重新编译. 我使用的是x64linux,即使使用
re.compile
,我也无法“破坏”这个re.compile("x"*5000000)
,而链接问题上的comenters声称它使用65536破坏,这与您的10Ks查询一致。你知道吗你能尝试使用另一台计算机或操作系统吗?你知道吗
或者您可以将查询一分为二(或者用上面的代码检查您的最大查询大小),然后检查匹配的坐标是否“连续”,在代码中添加一些行。你知道吗
编辑。我发现了一个错误重现的系统。在文件
python2.7/sre_compile.py
的开头,您将看到以下行(python2.7.0):其中
_sre
是一个内置的(C文件)。如果您的python版本是用一个_sre.c
编译的,这个CODESIZE == 2
将regex的大小限制为65535,那么您必须升级python解释器。你知道吗相关问题 更多 >
编程相关推荐