Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert isinstance(context.get_matrix(), Matrix)
assert context.get_matrix().as_tuple() == (1, 0, 0, 1, 0, 0)
context.translate(6, 5)
assert context.get_matrix().as_tuple() == (1, 0, 0, 1, 6, 5)
context.scale(1, 6)
assert context.get_matrix().as_tuple() == (1, 0, 0, 6, 6, 5)
context.scale(.5)
assert context.get_matrix().as_tuple() == (.5, 0, 0, 3, 6, 5)
context.rotate(math.pi / 2)
assert round_tuple(context.get_matrix().as_tuple()) == (0, 3, -.5, 0, 6, 5)
context.identity_matrix()
assert context.get_matrix().as_tuple() == (1, 0, 0, 1, 0, 0)
context.set_matrix(Matrix(2, 1, 3, 7, 8, 2))
assert context.get_matrix().as_tuple() == (2, 1, 3, 7, 8, 2)
context.transform(Matrix(2, 0, 0, .5, 0, 0))
assert context.get_matrix().as_tuple() == (4, 2, 1.5, 3.5, 8, 2)
context.set_matrix(Matrix(2, 0, 0, 3, 12, 4))
assert context.user_to_device_distance(1, 2) == (2, 6)
assert context.user_to_device(1, 2) == (14, 10)
assert context.device_to_user_distance(2, 6) == (1, 2)
assert round_tuple(context.device_to_user(14, 10)) == (1, 2)
cr.line_to(width*0.1, y_center-120)
cr.set_line_width(2)
cr.stroke()
cr.move_to(width*0.1, y_center-60)
cr.line_to(width*0.08, y_center-60)
cr.set_line_width(2)
cr.stroke()
cr.move_to(width*0.075, y_center-60+4*10)
cr.rotate(-90*math.pi/180.0)
#cr.set_line_width(2)
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,cairo.FONT_WEIGHT_NORMAL)
font_mat=cairo.Matrix(xx=32.0,yx=0.0,xy=0.0,yy=32,x0=0.0,y0=0.0)
cr.set_font_matrix(font_mat)
cr.show_text("2 bit")
cr.rotate(90*math.pi/180.0)
font_mat=cairo.Matrix(xx=12.0,yx=0.0,xy=0.0,yy=12,x0=0.0,y0=0.0)
cr.move_to(width*0.5, hight)
cr.show_text("k"+str(k))
#print y_center
AGCT={}
#values=[]
#print reconstruct[k]
#reconstruct[k]=reconstruct[k]*50
#mean=np.mean(reconstruct[k])
#stdv=np.std(reconstruct[k])
#reconstruct[k]=(reconstruct[k]-mean)/stdv
#print kernels[:,:,k]
xkernel=kernels[:,:,k]
xkernel=np.exp(xkernel*100.0)
"""
# "Transforms apply to block-level and atomic inline-level elements,
# but do not apply to elements which may be split into
# multiple inline-level boxes."
# http://www.w3.org/TR/css3-2d-transforms/#introduction
if box.style['transform'] and not isinstance(box, boxes.InlineBox):
border_width = box.border_width()
border_height = box.border_height()
origin_x, origin_y = box.style['transform_origin']
offset_x = percentage(origin_x, border_width)
offset_y = percentage(origin_y, border_height)
origin_x = box.border_box_x() + offset_x
origin_y = box.border_box_y() + offset_y
matrix = cairo.Matrix()
matrix.translate(origin_x, origin_y)
for name, args in box.style['transform']:
if name == 'scale':
matrix.scale(*args)
elif name == 'rotate':
matrix.rotate(args)
elif name == 'translate':
translate_x, translate_y = args
matrix.translate(
percentage(translate_x, border_width),
percentage(translate_y, border_height),
)
else:
if name == 'skewx':
args = (1, 0, math.tan(args), 1, 0, 0)
elif name == 'skewy':
pos=filter(lambda x:x[1]>=0,values)
#neg=filter(lambda x:x[1]<0,values)
pos.sort(key=lambda x:x[1])
#neg.sort(key=lambda x:x[1], reverse=True)
Nucpos=0
#Nucneg=0
x_pos=k%(DNA_len/line_num)
for l in range(len(pos)):
Nuc=pos[l][0]
Nucsize=abs(pos[l][1])+0.1
cr.move_to(100+x_pos*40*0.75, y_center-Nucpos*0.75)
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,cairo.FONT_WEIGHT_NORMAL)
_select_color(cr, Nuc)
font_mat=cairo.Matrix(xx=40.0,yx=0.0,xy=0.0,yy=Nucsize,x0=0.0,y0=0.0)
cr.set_font_matrix(font_mat)
cr.show_text(str(Nuc))
Nucpos+=abs(pos[l][1])
"""
l=0
for l in range(len(neg)):
Nuc=neg[l][0]
Nucsize=abs(neg[l][1])
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,cairo.FONT_WEIGHT_NORMAL)
_select_color(cr, Nuc)
font_mat=cairo.Matrix(xx=40.0,yx=0.0,xy=0.0,yy=-Nucsize,x0=0.0,y0=0.0)
cr.set_font_matrix(font_mat)
cr.move_to(100+x_pos*40*0.75, y_center+(Nucneg)*0.75)
cr.show_text(str(Nuc))
map_ = {}
for arg in dir(obj):
if arg.startswith("_"):
continue
c_name = "_".join(filter(None, ["cairo", prefix, arg]))
if hasattr(lib, c_name):
map_[c_name] = ["cairo." + obj.__name__ + "." + arg]
type_name = "_".join(filter(None, ["cairo", prefix, "t"]))
map_[type_name] = ["cairo." + obj.__name__]
return map_
types = {}
types.update(get_mapping(cairo.Context, ""))
types.update(get_mapping(cairo.Surface, "surface"))
types.update(get_mapping(cairo.Pattern, "pattern"))
types.update(get_mapping(cairo.Matrix, "matrix"))
types.update(get_mapping(cairo.FontFace, "font_face"))
return types
cr.line_to(width*0.1, y_center-120)
cr.set_line_width(2)
cr.stroke()
cr.move_to(width*0.1, y_center-60)
cr.line_to(width*0.08, y_center-60)
cr.set_line_width(2)
cr.stroke()
cr.move_to(width*0.075, y_center-60+4*10)
cr.rotate(-90*math.pi/180.0)
#cr.set_line_width(2)
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,cairo.FONT_WEIGHT_NORMAL)
font_mat=cairo.Matrix(xx=32.0,yx=0.0,xy=0.0,yy=32,x0=0.0,y0=0.0)
cr.set_font_matrix(font_mat)
cr.show_text("2 bit")
cr.rotate(90*math.pi/180.0)
font_mat=cairo.Matrix(xx=12.0,yx=0.0,xy=0.0,yy=12,x0=0.0,y0=0.0)
cr.move_to(width*0.5, hight)
cr.show_text("k"+str(k))
#print y_center
AGCT={}
#values=[]
#print reconstruct[k]
#reconstruct[k]=reconstruct[k]*50
#mean=np.mean(reconstruct[k])
#stdv=np.std(reconstruct[k])
#reconstruct[k]=(reconstruct[k]-mean)/stdv
#print kernels[:,:,k]
xkernel=kernels[:,:,k]
xkernel=np.exp(xkernel*100.0)
pattern.set_filter(cairocffi.FILTER_BEST)
matrix = cairocffi.Matrix()
tr_width, tr_height = 1.0, 1.0
surf_width, surf_height = surface.get_width(), surface.get_height()
if (width is not None) and (width != surf_width):
tr_width = surf_width / width
if (height is not None) and (height != surf_height):
tr_height = surf_height / height
matrix.scale(tr_width, tr_height)
epsilon = 1.0e-6
pi = 3.141592653589793
if abs(theta) > epsilon:
theta_rad = pi / 180.0 * theta
mat_rot = cairocffi.Matrix()
# https://cairographics.org/cookbook/transform_about_point/
xt = surf_width * tr_width * 0.5
yt = surf_height * tr_height * 0.5
mat_rot.translate(xt, yt)
mat_rot.rotate(theta_rad)
mat_rot.translate(-xt, -yt)
matrix = mat_rot.multiply(matrix)
pattern.set_matrix(matrix)
return pattern
cr.rectangle(x, y,nodew, nodeh)
coordinates["hidden"+str(i+2)].append([x,y])
cr.fill()
last_conv_y=y+0.0018*height-upper_lim
last_conv_shape=conv_shape[1]
"""drawing nodes as bars in fully-connected layers"""
for i, fc in enumerate(fc_kernels):
x+=x_interval
cr.move_to(x, upper_lim-0.0018*height)
cr.set_source_rgba(0.0,0.0,0.0,1.0)
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,cairo.FONT_WEIGHT_NORMAL)
font_mat=cairo.Matrix(xx=12.0,yx=0.0,xy=0.0,yy=12,x0=0.0,y0=0.0)
cr.set_font_matrix(font_mat)
cr.show_text("fc"+str(i+1))
coordinates["fc"+str(i+1)]=[]
fc_shape=fc.shape
print(fc_shape)
y=upper_lim
#cr.move_to(width*0.1, height*0.1+0.0008*height*j)
#cr.arc(x, y, 0.001*height, 0, 2*math.pi)
cr.set_source_rgba(0.5,0.5,0.5,0.5)
cr.rectangle(x, y,width*0.015, fc_shape[0]*last_conv_y/(float(last_seq_length)*last_conv_shape))
coordinates["fc"+str(i+1)].append([x,y])
cr.fill()
fc2_hight=fc_shape[0]*last_conv_y/(float(last_seq_length)*last_conv_shape)
"""drawing nodes in the last prediction layer"""
pos=filter(lambda x:x[1]>=0,values)
#neg=filter(lambda x:x[1]<0,values)
pos.sort(key=lambda x:x[1])
#neg.sort(key=lambda x:x[1], reverse=True)
Nucpos=0.01
#Nucneg=0
x_pos=width*0.1+pind*30
for l in range(len(pos)):
Nuc=pos[l][0]
Nucsize=pos[l][1]+0.01
cr.move_to(x_pos, y_center-Nucpos*0.75)
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,cairo.FONT_WEIGHT_NORMAL)
_select_color(cr, Nuc)
font_mat=cairo.Matrix(xx=40.0,yx=0.0,xy=0.0,yy=Nucsize,x0=0.0,y0=0.0)
cr.set_font_matrix(font_mat)
cr.show_text(str(Nuc))
Nucpos+=abs(pos[l][1])
ims1.write_to_png(prefix+"kernel_"+str(k)+'.png')
png_list.append(prefix+"kernel_"+str(k)+'.png')
kernel_shape_ic_list.append(ic_sum)
cr.show_page()
meme_fileout.close()
return png_list, kernel_shape_ic_list