9
9
from figeno .utils import KnownException , split_box , draw_bounding_box , interpolate_polar_vertices , compute_rotation_text , polar2cartesian , cartesian2polar
10
10
11
11
class chr_track :
12
- def __init__ (self ,style = "default" ,unit = "kb" ,ticklabels_pos = "below" ,ticks_interval = "auto" ,ticks_angle = 0 ,lw_scale = 1.0 ,no_margin = False ,reference = "custom" ,cytobands_file = "" ,
12
+ def __init__ (self ,style = "default" ,unit = "kb" ,ticklabels_pos = "below" ,ticks_interval = "auto" ,ticks_angle = 0 ,lw_scale = 1.0 ,chr_prefix = "chr" , no_margin = False ,reference = "custom" ,cytobands_file = "" ,
13
13
fontscale = 1 ,bounding_box = False ,height = 12 ,margin_above = 1.5 ,label = "" ,label_rotate = False ,** kwargs ):
14
14
self .style = style
15
15
self .unit = unit
@@ -19,6 +19,7 @@ def __init__(self,style="default",unit="kb",ticklabels_pos="below",ticks_interva
19
19
self .lw_scale = float (lw_scale )
20
20
while self .ticks_angle < - 180 : self .ticks_angle += 360
21
21
while self .ticks_angle > 180 : self .ticks_angle -= 360
22
+ self .chr_prefix = chr_prefix
22
23
self .no_margin = no_margin
23
24
self .reference = reference
24
25
self .fontscale = float (fontscale )
@@ -149,9 +150,9 @@ def draw_region(self,region,box,single_region=False):
149
150
# Chr label
150
151
if self .ticklabels_pos != "none" :
151
152
if self .ticklabels_pos == "below" and (not "upside_down" in box ):
152
- box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 ,box ["bottom" ],"chr" + region .chr ,horizontalalignment = "center" ,verticalalignment = "bottom" ,fontsize = 9 * self .fontscale )
153
+ box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 ,box ["bottom" ],self . chr_prefix + region .chr ,horizontalalignment = "center" ,verticalalignment = "bottom" ,fontsize = 9 * self .fontscale )
153
154
else :
154
- box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 ,box ["top" ],"chr" + region .chr ,horizontalalignment = "center" ,verticalalignment = "top" ,fontsize = 9 * self .fontscale )
155
+ box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 ,box ["top" ],self . chr_prefix + region .chr ,horizontalalignment = "center" ,verticalalignment = "top" ,fontsize = 9 * self .fontscale )
155
156
156
157
def draw_region_arrow (self ,region ,box ):
157
158
arrow_height = (box ["top" ]- box ['bottom' ]) * 0.5 * self .lw_scale
@@ -193,23 +194,23 @@ def draw_region_arrow(self,region,box):
193
194
fontsize = 8 * self .fontscale )
194
195
195
196
if self .ticklabels_pos == "below" and (not "upside_down" in box ):
196
- box ["ax" ].text ((box ["right" ]+ box ["left" ])/ 2 ,box ["top" ]- arrow_height * 1.55 ,"chr" + region .chr .lstrip ("chr" ),horizontalalignment = "center" ,verticalalignment = "top" ,
197
+ box ["ax" ].text ((box ["right" ]+ box ["left" ])/ 2 ,box ["top" ]- arrow_height * 1.55 ,self . chr_prefix + region .chr .lstrip ("chr" ),horizontalalignment = "center" ,verticalalignment = "top" ,
197
198
fontsize = 10 * self .fontscale )
198
199
else :
199
- box ["ax" ].text ((box ["right" ]+ box ["left" ])/ 2 ,box ["bottom" ]+ arrow_height * 1.55 ,"chr" + region .chr .lstrip ("chr" ),horizontalalignment = "center" ,verticalalignment = "bottom" ,
200
+ box ["ax" ].text ((box ["right" ]+ box ["left" ])/ 2 ,box ["bottom" ]+ arrow_height * 1.55 ,self . chr_prefix + region .chr .lstrip ("chr" ),horizontalalignment = "center" ,verticalalignment = "bottom" ,
200
201
fontsize = 10 * self .fontscale )
201
202
202
203
def draw_region_ideogram (self ,region ,box ):
203
204
height = (box ["top" ]- box ["bottom" ]) * 0.5 * self .lw_scale
204
205
if self .ticklabels_pos == "below" and (not "upside_down" in box ):
205
206
y = box ["bottom" ] + (box ["top" ]- box ["bottom" ]) * 0.75
206
207
if self .fontscale > 0 :
207
- box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 , box ["top" ]- height - 1 , "chr" + region .chr ,
208
+ box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 , box ["top" ]- height - 1 , self . chr_prefix + region .chr ,
208
209
horizontalalignment = "center" , verticalalignment = "top" ,fontsize = 10 * self .fontscale )
209
210
elif self .ticklabels_pos == "above" :
210
211
y = box ["bottom" ] + (box ["top" ]- box ["bottom" ]) * 0.25
211
212
if self .fontscale > 0 :
212
- box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 , box ["bottom" ] + height + 1 , "chr" + region .chr ,
213
+ box ["ax" ].text ((box ["left" ]+ box ["right" ])/ 2 , box ["bottom" ] + height + 1 , self . chr_prefix + region .chr ,
213
214
horizontalalignment = "center" , verticalalignment = "bottom" ,fontsize = 10 * self .fontscale )
214
215
else :
215
216
y = (box ["bottom" ]+ box ["top" ]) / 2
0 commit comments