我有一個文件(FILEA)與以下列格式的基因組區域的n個:獲取隨機區域從單個站點
Chromosome Start End Length Number
chr1 100 400 300 6...
我有另一個(大得多)FILEB(控制數據)包含在單個位點格式如下:
Chromosome Site
chr1 105
chr1 110...
從中我想根據第一個數據集選擇隨機條目。 因此,對於第一個文件中的每個區域,我將從第二個數據集中獲得具有相同長度和數量但隨機位置的隨機區域。
例如:
Chromosome Start End Length Number
chr5 350 650 300 6...
到目前爲止,我所擁有的是:
List = []
NewList = []
LineCount = 0
for Line in FileB:
if LineCount == 0:
OutFile.write(Line)
else:
List.append(Line)
LineCount +=1
for Line in FileA:
Chr, Start, End, Len, Entries = Line.strip("\n").split("\t")[:5]
RandomStart = random.sample(List, 1)
## here I need to find a way to keep adding sequential lines to a NewList till the last site minus the first site is near the Len
## then I need to convert this new list into the format Chr, Start, End, Lenght, Number and write out and then clear NewList
你可以發佈你試過這樣的代碼遠? – mdml
如果第二個數據集僅包含網站(沒有長度和數量),如何在第二個數據集中找到長度和編號相同的區域?或者你想從第一組中選取一個區域,然後從第二組中選取一個隨機區域,並將其轉換爲從第二個區域開始的區域,長度和第一個區域的數量? – Hyperboreus
什麼是「位置」,數據集中的信息在哪裏? – duhaime