#NEWLINE# def gene_panel( self , ax , feature ) : #NEWLINE# #INDENT# '\n        Plots gene models on an Axes.\n\n        Queries the database\n\n        :param ax: matplotlib.Axes object\n        :param feature: pybedtools.Interval\n\n        ' #NEWLINE# from gffutils.contrib.plotting import Gene #NEWLINE# extent = [ feature . start , feature . stop ] #NEWLINE# nearby_genes = self . db . region ( ( feature . chrom , feature . start , feature . stop ) , featuretype = 'gene' ) #NEWLINE# ybase = 0 #NEWLINE# ngenes = 0 #NEWLINE# for nearby_gene in nearby_genes : #NEWLINE# #INDENT# ngenes += 1 #NEWLINE# extent . extend ( [ nearby_gene . start , nearby_gene . stop ] ) #NEWLINE# gene_collection = Gene ( self . db , nearby_gene , transcripts = [ 'mRNA' ] , cds = [ 'CDS' ] , utrs = [ 'exon' ] , ybase = ybase , color = '0.5' , picker = 5 ) #NEWLINE# gene_collection . name = nearby_gene . id #NEWLINE# gene_collection . add_to_ax ( ax ) #NEWLINE# ybase += gene_collection . max_y #NEWLINE# #UNINDENT# xmin = min ( extent ) #NEWLINE# xmax = max ( extent ) #NEWLINE# ymax = ngenes #NEWLINE# padding = ( ( xmax - xmin ) * 0.01 ) #NEWLINE# ax . axis ( 'tight' ) #NEWLINE# vline_kwargs = dict ( color = 'k' , linestyle = '--' ) #NEWLINE# ax . axvline ( feature . start , ** vline_kwargs ) #NEWLINE# ax . axvline ( feature . stop , ** vline_kwargs ) #NEWLINE# interval = pybedtools . create_interval_from_list ( feature . fields ) #NEWLINE# interval . start = ( xmin - padding ) #NEWLINE# interval . stop = ( xmax + padding ) #NEWLINE# interval . strand = '.' #NEWLINE# return interval