<p>我用python编写脚本,现在我必须创建一个非常大的列表,精确地包含248956422个整数。关键是,这个表中的“0”中的一些将被改为1、2或3,因为我有8个列表,4个是基因的起始位置,4个是它们的结尾。
关键是我必须重复“anno”几次,因为替换0的数字可能会随着其他迭代而改变。
“Anno”必须写入文件才能创建注释文件。
这是我的问题,我如何划分,或者动态地进行划分,以避免得到内存错误,包括为其他人替换“0”,为其他人替换1,2,3。
Mabye重写文件?我在等你的建议,请问我是否不清楚我写了什么:P。在</p>
<pre><code>whole_st_gen = [] #to make these lists more clear for example
whole_end_gen = [] # whole_st_gen has element "177"
whole_st_ex = [] # and whole_end_gen has "200" so from position 177to200
whole_end_ex = [] # i need to put "1"
whole_st_mr = [] # of course these list can have even 1kk+ elements
whole_end_mr = [] # note that every st/end of same kind have equal length
whole_st_nc = []
whole_end_nc = [] #these lists are including some values of course
length = 248956422
anno = ['0' for i in range(0,length)] # here i get the memoryerror
#then i wanted to do something like..
for j in range(0, len(whole_st_gen)):
for y in range(whole_st_gen[j],whole_end_gen[j]):
anno[y]='1'
</code></pre>