def Run2( flist ): aps = AllPossStrings( 'ACGT',7) NF = len( flist ) # the number of files for i in range( NF ): print 'Working on ',flist[i] # get the data dna = fasta.Fasta( 'bacteria/' + flist[i] ) # count the number of genes NG = len( dna ) # if there are multiple genes then combine if NG >1: t = [] for j in range( NG ): t.append( dna[j][1] ) st = ''.join(t) del t else: st = dna[0][1] del dna # for every million bases make a plot NP = int(len( st )/1000000) #if NP > 3: #NP = 3 for j in range( NP ): print '\tPortion',j,'of',NP ctr = Counter( aps, st[j*1000000:j*1000000+1000000] ) akando.a2i( ctr ).save('work/chaos'+str(i)+'c'+str(j)+'.gif' )
def Run2(flist): aps = AllPossStrings('ACGT', 7) NF = len(flist) # the number of files for i in range(NF): print 'Working on ', flist[i] # get the data dna = fasta.Fasta('bacteria/' + flist[i]) # count the number of genes NG = len(dna) # if there are multiple genes then combine if NG > 1: t = [] for j in range(NG): t.append(dna[j][1]) st = ''.join(t) del t else: st = dna[0][1] del dna # for every million bases make a plot NP = int(len(st) / 1000000) #if NP > 3: #NP = 3 for j in range(NP): print '\tPortion', j, 'of', NP ctr = Counter(aps, st[j * 1000000:j * 1000000 + 1000000]) akando.a2i(ctr).save('work/chaos' + str(i) + 'c' + str(j) + '.gif')
def MakeColorPic(mmb, data): pic = zeros((512, 512, 3), int) NC = len(mmb) # number of clusters = number of colors for i in range(NC): # for each color for j in mmb[i]: x, y = (data[j] + 1) * 240 x, y = int(x), int(y) pic[x, y, 0] = 250 - 250 / NC * i # red if i > 150: pic[x, y, 1] = (i - 150) * 20 # green pic[x, y, 2] = i * 250 # blue r = akando.a2i(pic[:, :, 0]) g = akando.a2i(pic[:, :, 1]) b = akando.a2i(pic[:, :, 2]) mg = Image.merge('RGB', (r, g, b)) return mg
def Color4( net ): # net from Make SOM # convert 4 channels to 3colors V,H,N = net.shape red = zeros( (V,H), float ) green = zeros( (V,H), float ) # first channel blue = net[:,:,0] + 0.67*net[:,:,1] + 0.33*net[:,:,2] green = 0.1*net[:,:,0] + 0.4*net[:,:,1] + 0.4*net[:,:,2]+0.1*net[:,:,3] red = net[:,:,3] + 0.67*net[:,:,2] + 0.33*net[:,:,1] # r = akando.a2i( red ) g = akando.a2i( green ) b = akando.a2i( blue ) mg = Image.merge( 'RGB', (r,g,b) ) return mg
def MakeColorPic( mmb, data ): pic = zeros( (512,512,3), int ) NC = len( mmb ) # number of clusters = number of colors for i in range( NC ): # for each color for j in mmb[i]: x,y = (data[j]+1)*240 x,y = int(x), int(y) pic[x,y,0] = 250 - 250/NC*i # red if i>150: pic[x,y,1] = (i-150) *20 # green pic[x,y,2] = i*250 # blue r = akando.a2i( pic[:,:,0] ) g = akando.a2i( pic[:,:,1] ) b = akando.a2i( pic[:,:,2] ) mg = Image.merge( 'RGB', (r,g,b) ) return mg
def MakePic(data): # assume that the maximum radius of the data is 1 pic = zeros((512, 512), int) for i in data: x, y = (i + 1) * 240 pic[int(x), int(y)] += 1 mg = akando.a2i(pic) return mg
def MakePic( data ): # assume that the maximum radius of the data is 1 pic = zeros( (512,512), int ) for i in data: x,y = (i+1)*240 pic[ int(x), int(y)] +=1 mg = akando.a2i( pic ) return mg
def Color4(net): # net from Make SOM # convert 4 channels to 3colors V, H, N = net.shape red = zeros((V, H), float) green = zeros((V, H), float) # first channel blue = net[:, :, 0] + 0.67 * net[:, :, 1] + 0.33 * net[:, :, 2] green = 0.1 * net[:, :, 0] + 0.4 * net[:, :, 1] + 0.4 * net[:, :, 2] + 0.1 * net[:, :, 3] red = net[:, :, 3] + 0.67 * net[:, :, 2] + 0.33 * net[:, :, 1] # r = akando.a2i(red) g = akando.a2i(green) b = akando.a2i(blue) mg = Image.merge('RGB', (r, g, b)) return mg
def Run1(): data = genbank.ReadGenbank( '/science/bartlett/genbank/nc_00918.gb.txt') dna = genbank.ParseDNA( data ) aps = AllPossStrings( 'cgat' ) ctr = Counter( aps, dna ) akando.a2i( ctr ).save('dud.gif')
def Run1(): data = genbank.ReadGenbank('/science/bartlett/genbank/nc_00918.gb.txt') dna = genbank.ParseDNA(data) aps = AllPossStrings('cgat') ctr = Counter(aps, dna) akando.a2i(ctr).save('dud.gif')
def SOMmg( som ): r = akando.a2i( som[:,:,0] ) g = akando.a2i( som[:,:,1] ) b = akando.a2i( som[:,:,2] ) mg = Image.merge( 'RGB', (r,g,b) ) return mg
def SOMmg(som): r = akando.a2i(som[:, :, 0]) g = akando.a2i(som[:, :, 1]) b = akando.a2i(som[:, :, 2]) mg = Image.merge('RGB', (r, g, b)) return mg