11import sys
2- import os
32import numpy as np
43from flask import Flask , render_template , request , send_file
54
65import os
7- from os .path import basename , exists
6+ from os .path import exists
87
98import json
109
1817hicexplorer .trackPlot .DEFAULT_WIDTH_RATIOS = (0.89 , 0.11 )
1918hicexplorer .trackPlot .DEFAULT_MARGINS = {'left' : 0.02 , 'right' : 0.98 , 'bottom' : 0 , 'top' : 1 }
2019
20+
2121def get_TAD_for_gene (gene_name ):
2222 """
2323 Returs the TAD position of a given gene name
@@ -34,8 +34,7 @@ def get_TAD_for_gene(gene_name):
3434 chrom_ = chrom_ [3 :]
3535 else :
3636 chrom_ = 'chr' + chrom_
37- tad_pos = tads_intval_tree [chrom_ ].find (start_ , end_ )[0 ]
38-
37+ tad_pos = sorted (tads_intval_tree [chrom_ ][start_ , end_ ])[0 ]
3938 return chrom_ , tad_pos .start , tad_pos .end
4039 else :
4140 return None
@@ -147,8 +146,8 @@ def main(config_file, port, numProc, template_folder=None, debug=False):
147146
148147 # register an static path for images using Blueprint
149148 images_static = Blueprint ('site' , __name__ ,
150- static_url_path = '/images' ,
151- static_folder = img_path )
149+ static_url_path = '/images' ,
150+ static_folder = img_path )
152151 app .register_blueprint (images_static )
153152
154153 # setup up the tracks. It works as follows
@@ -188,8 +187,6 @@ def main(config_file, port, numProc, template_folder=None, debug=False):
188187 track_file = config .get ('general' , 'tracks' )
189188 tads = hicbrowser .tracks2json .SetTracks (track_file , fig_width = 40 )
190189
191- #tads = hicexplorer.trackPlot.PlotTracks(track_file, fig_width=40, dpi=70)
192-
193190 from hicexplorer .trackPlot import opener
194191 with opener (genes ) as fh :
195192 for line in fh .readlines ():
@@ -221,9 +218,9 @@ def get_tad(gene_name):
221218
222219 # plot
223220 outfile = "{}/{}_{}_{}.json" .format (tad_img_root ,
224- chromosome ,
225- start ,
226- end )
221+ chromosome ,
222+ start ,
223+ end )
227224 if not exists (outfile ):
228225 with open (outfile , 'w' ) as fh :
229226 sys .stderr .write ("Saving json file: {}\n " .format (outfile ))
0 commit comments