2018 Hakyung August Lab note
From Crop Genomics Lab.
svg 만드는 코드
- format을 써봤음 ㅎㅎ
print ("<svg width = ""4000"" height = ""50000"">") #도화지? 사이즈 x = 100 f = open ("chromosomesize.txt", "r").readlines() # chr01 /n size 로 정렬되어 있음 i = 2 while i < 41 : # chromosome size 에 대하여 height = float(f[i].strip())/25000 # 25000 비율로 줄이기 rec = ' <rect x = \"{0}\" y =\"100\" rx= \"50\" ry = \"20\" width = \"25\" height= \"{1}\" style="fill:white;stroke:black;stroke-width:5"/>'.format(x, height) # 0 자리에 x 변수, 1 자리에 height 변수에 해당하는 값 넣기. (100,100)에서 시작하여 넓이 25에, chr size에 맞는 height 가짐 print (rec) x += 190 #figure? 사이의 거리 = 190-25 i += 2 x = 105 #이건 그때그때 알아서 k = 1 while k <21 : text = ' <text x = \"{0}\" y = \"80\" fill=\"black\" font-size=\"28\">Chr'.format(x) chromosome 이름 넣어주기 text2 = k text3 = '</text>' print text, print text2, print text3 k = k +1 x +=190 #figure 간격대로 file = open("/data2/haggui/SNPpos.txt",'r').readlines() i = 1 x1 = 80 x2 = 145 while i < 21 : for SNP in file : if int(SNP.split()[0].split('Chr')[1])== i : y = 100 + int(SNP.split()[1])/25000
결과로 나오는 code
<svg width = 4000 height = 50000> <rect x = "100" y ="100" rx= "50" ry = "20" width = "25" height= "2273.26496" style="fill:white;stroke:black;stroke-width:5"/> <rect x = "290" y ="100" rx= "50" ry = "20" width = "25" height= "1943.1002" style="fill:white;stroke:black;stroke-width:5"/> *쭉쭉쭉 <text x = "105" y = "80" fill="black" font-size="28">Chr 1 </text> <text x = "295" y = "80" fill="black" font-size="28">Chr 2 </text> *쭉쭉쭉 <line x1= "80" y1 = "101" x2 = "145" y2 = "101" stroke="black" stroke-width= "1" /> <line x1= "80" y1 = "102" x2 = "145" y2 = "102" stroke="black" stroke-width= "1" /> *쭉쭉쭉 </sgv>